:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --slate-900: #0f172a;
    --slate-800: #1e293b;
    --slate-700: #334155;
    --slate-600: #475569;
    --slate-500: #64748b;
    --slate-400: #94a3b8;
    --slate-200: #e2e8f0;
    --slate-100: #f1f5f9;
    --slate-50: #f8fafc;
    --emerald-600: #059669;
    --emerald-50: #ecfdf5;
    --amber-600: #d97706;
    --amber-50: #fffbeb;
    --rose-600: #e11d48;
    --rose-50: #fff1f2;
    --radius: 12px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow: 0 4px 16px rgba(15, 23, 42, .06);
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--slate-50);
    color: var(--slate-900);
    line-height: 1.5;
    font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--slate-100); padding: 2px 6px; border-radius: 5px; font-size: .85em; }

/* Shell Layout */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 260px;
    background: var(--slate-900);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 40;
    transition: transform .25s ease;
}
.sidebar-brand {
    padding: 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex; align-items: center; justify-content: space-between;
}
.sidebar-brand a { color: #fff; font-weight: 700; font-size: 1.15rem; text-decoration: none; display: flex; align-items: center; gap: .6rem; }
.brand-dot { width: 10px; height: 10px; border-radius: 999px; background: #818cf8; display: inline-block; }
.sidebar-nav { flex: 1; padding: 1rem .75rem; overflow-y: auto; }
.nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: .75rem .75rem .35rem; font-weight: 700; }
.nav-link {
    display: flex; align-items: center; gap: .65rem;
    padding: .62rem .85rem; border-radius: 9px;
    color: #cbd5e1; font-weight: 500; margin-bottom: 2px;
    text-decoration: none !important; transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-link.active { background: var(--primary); color: #fff; }
.sidebar-footer { padding: 1rem; border-top: 1px solid rgba(255,255,255,.08); font-size: .82rem; }

.main-area { flex: 1; margin-left: 260px; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    height: 64px; background: #fff; border-bottom: 1px solid var(--slate-200);
    padding: 0 1.5rem; display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 30;
}
.topbar-left { display: flex; align-items: center; gap: .85rem; }
.topbar-title { margin: 0; font-size: 1.08rem; font-weight: 700; }
.mobile-toggle { display: none; background: var(--slate-100); border: 1px solid var(--slate-200); border-radius: 8px; padding: .45rem .65rem; cursor: pointer; font-size: 1rem; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.content { padding: 1.5rem; max-width: 1400px; width: 100%; margin: 0 auto; }

/* Cards & Grids */
.card {
    background: #fff; border: 1px solid var(--slate-200);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 1.25rem; margin-bottom: 1.25rem;
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-title { margin: 0; font-size: 1rem; font-weight: 700; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }

.stat-card { background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius); padding: 1.15rem; box-shadow: var(--shadow-sm); }
.stat-label { font-size: .8rem; color: var(--slate-500); font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 800; margin-top: .3rem; color: var(--slate-900); }
.stat-sub { font-size: .78rem; color: var(--slate-500); margin-top: .25rem; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .55rem 1rem; border-radius: 8px; font-weight: 600; font-size: .86rem;
    border: 1px solid transparent; cursor: pointer; text-decoration: none !important;
    transition: all .15s ease; white-space: nowrap;
}
.btn-sm { padding: .35rem .7rem; font-size: .78rem; border-radius: 6px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--slate-100); color: var(--slate-800); border-color: var(--slate-200); }
.btn-secondary:hover { background: var(--slate-200); }
.btn-success { background: var(--emerald-600); color: #fff; }
.btn-danger { background: var(--rose-600); color: #fff; }
.btn-outline { background: #fff; color: var(--slate-700); border-color: var(--slate-200); }
.btn-outline:hover { background: var(--slate-50); }
.btn-block { width: 100%; }

/* Forms */
.form-group { margin-bottom: .95rem; }
.form-label { display: block; font-size: .83rem; font-weight: 600; color: var(--slate-700); margin-bottom: .32rem; }
.form-control {
    width: 100%; padding: .58rem .8rem; border: 1px solid var(--slate-200);
    border-radius: 8px; font-size: .9rem; color: var(--slate-900); background: #fff;
    font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.form-check { display: flex; align-items: center; gap: .5rem; font-size: .88rem; cursor: pointer; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .87rem; }
.table th {
    text-align: left; padding: .7rem .85rem; background: var(--slate-50);
    color: var(--slate-600); font-weight: 700; font-size: .76rem; text-transform: uppercase;
    letter-spacing: .04em; border-bottom: 1px solid var(--slate-200);
}
.table td { padding: .75rem .85rem; border-bottom: 1px solid var(--slate-100); vertical-align: middle; }
.table tr:hover td { background: #fafbff; }

/* Badges & Alerts */
.badge { display: inline-flex; align-items: center; padding: .2rem .6rem; border-radius: 999px; font-size: .74rem; font-weight: 700; }
.badge-success { background: var(--emerald-50); color: var(--emerald-600); }
.badge-warning { background: var(--amber-50); color: var(--amber-600); }
.badge-danger { background: var(--rose-50); color: var(--rose-600); }
.badge-info { background: var(--primary-soft); color: var(--primary); }
.badge-muted { background: var(--slate-100); color: var(--slate-600); }

.alert { padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: .9rem; border: 1px solid transparent; }
.alert-success { background: var(--emerald-50); color: #065f46; border-color: #a7f3d0; }
.alert-error { background: var(--rose-50); color: #9f1239; border-color: #fecdd3; }
.alert-info { background: var(--primary-soft); color: #3730a3; border-color: #c7d2fe; }

/* Auth Layout */
.auth-bg {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem;
    background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 50%, #ecfeff 100%);
}
.auth-card { width: 100%; max-width: 440px; background: #fff; border: 1px solid var(--slate-200); border-radius: 16px; padding: 2rem; box-shadow: var(--shadow); }
.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-logo h1 { margin: 0; font-size: 1.45rem; color: var(--slate-900); }
.auth-logo p { margin: .25rem 0 0; color: var(--slate-500); font-size: .88rem; }

/* Plan & Template Cards */
.plan-card { border: 1px solid var(--slate-200); border-radius: 14px; padding: 1.4rem; background: #fff; display: flex; flex-direction: column; position: relative; }
.plan-card.featured { border: 2px solid var(--primary); box-shadow: 0 12px 28px rgba(79,70,229,.12); }
.plan-price { font-size: 1.9rem; font-weight: 800; margin: .5rem 0; }
.plan-list { list-style: none; padding: 0; margin: 1rem 0 1.25rem; flex: 1; }
.plan-list li { padding: .3rem 0; font-size: .87rem; color: var(--slate-700); }
.tpl-card { border: 1px solid var(--slate-200); border-radius: 12px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.tpl-thumb { height: 165px; background: var(--slate-100); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.tpl-thumb img { width: 100%; height: 100%; object-fit: cover; }
.tpl-body { padding: 1rem; flex: 1; display: flex; flex-direction: column; }

/* Search Bar & Pagination */
.toolbar { display: flex; gap: .65rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.pagination { display: flex; gap: .35rem; margin-top: 1rem; flex-wrap: wrap; }
.page-link { padding: .4rem .75rem; border: 1px solid var(--slate-200); border-radius: 6px; background: #fff; color: var(--slate-700); font-size: .83rem; }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Two-Column Website Editor */
.editor-shell { display: flex; flex-direction: column; height: 100vh; overflow: hidden; background: var(--slate-100); }
.editor-topbar {
    height: 56px; background: var(--slate-900); color: #fff;
    padding: 0 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-shrink: 0;
}
.editor-body { display: grid; grid-template-columns: 440px 1fr; flex: 1; min-height: 0; }
.editor-left { background: #fff; border-right: 1px solid var(--slate-200); display: flex; flex-direction: column; min-height: 0; }
.editor-tabs { display: flex; border-bottom: 1px solid var(--slate-200); background: var(--slate-50); }
.editor-tab {
    flex: 1; padding: .7rem .5rem; border: none; background: transparent; font-weight: 600;
    font-size: .82rem; color: var(--slate-600); cursor: pointer; border-bottom: 2px solid transparent;
}
.editor-tab.active { color: var(--primary); border-bottom-color: var(--primary); background: #fff; }
.editor-panel { flex: 1; overflow-y: auto; padding: 1rem; }
.editor-right { display: flex; flex-direction: column; padding: 1rem; min-height: 0; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; gap: .5rem; }
.preview-frame-wrap { flex: 1; background: #fff; border-radius: 12px; border: 1px solid var(--slate-200); overflow: hidden; display: flex; justify-content: center; box-shadow: var(--shadow); }
.preview-frame { width: 100%; height: 100%; border: none; transition: width .25s ease; background: #fff; }
.preview-frame.mobile { width: 390px; border-left: 1px solid var(--slate-200); border-right: 1px solid var(--slate-200); }
.sec-item { border: 1px solid var(--slate-200); border-radius: 10px; margin-bottom: .75rem; background: #fff; overflow: hidden; }
.sec-item-head { padding: .65rem .8rem; background: var(--slate-50); display: flex; align-items: center; justify-content: space-between; gap: .5rem; cursor: pointer; }
.sec-item-body { padding: .85rem; border-top: 1px solid var(--slate-200); display: none; }
.sec-item.open .sec-item-body { display: block; }
.repeater-box { border: 1px dashed var(--slate-300, #cbd5e1); border-radius: 8px; padding: .65rem; margin-bottom: .5rem; background: #fafbff; }

/* Utilities */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: .75rem; }
.mb-2 { margin-bottom: .5rem; }
.text-muted { color: var(--slate-500); font-size: .84rem; }
.text-right { text-align: right; }

@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .editor-body { grid-template-columns: 1fr; overflow-y: auto; }
    .editor-right { min-height: 500px; }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-area { margin-left: 0; }
    .mobile-toggle { display: inline-flex; }
    .grid-4, .grid-3, .grid-2, .form-row { grid-template-columns: 1fr; }
}
