:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e5e9f2;
    --text: #1a2238;
    --text-muted: #6b7280;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --success: #16a34a;
    --sidebar-bg: #0f172a;
    --sidebar-text: #cbd5e1;
    --sidebar-text-strong: #f8fafc;
    --sidebar-active: #1e293b;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow: 0 4px 16px rgba(15, 23, 42, .08);
    --radius: 12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* -------- LOGIN -------- */
.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at 20% 0%, rgba(79, 70, 229, .15), transparent 50%),
        radial-gradient(circle at 80% 100%, rgba(99, 102, 241, .15), transparent 50%),
        #0f172a;
    padding: 24px;
}

.login-shell {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 36px 32px 28px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}

.login-brand {
    text-align: center;
    margin-bottom: 24px;
}

.login-brand h1 {
    margin: 12px 0 4px;
    font-size: 20px;
    font-weight: 600;
}

.login-brand p {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    font-weight: 700;
    font-size: 22px;
    box-shadow: 0 8px 20px rgba(79, 70, 229, .35);
}

.login-form {
    display: grid;
    gap: 16px;
    margin-top: 8px;
}

.field {
    display: grid;
    gap: 6px;
}

.field span {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.field input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--surface-2);
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.field input:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, .12);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .05s;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: translateY(1px); }

.btn-block { width: 100%; }

.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 8px;
}

.alert-error {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(220, 38, 38, .2);
}

.login-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}

/* -------- APP LAYOUT -------- */
.app-body {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.sidebar-brand strong {
    display: block;
    color: var(--sidebar-text-strong);
    font-size: 14px;
}

.sidebar-brand span {
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.sidebar-nav {
    flex: 1;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13.5px;
    color: var(--sidebar-text);
    transition: background .15s, color .15s;
}

.sidebar-nav a svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-nav a:hover {
    background: var(--sidebar-active);
    color: var(--sidebar-text-strong);
}

.sidebar-nav a.is-active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-strong);
    box-shadow: inset 2px 0 0 var(--primary);
}

.sidebar-nav a.is-disabled {
    opacity: .45;
    pointer-events: none;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, .06);
}

.logout-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13.5px;
    color: var(--sidebar-text);
    transition: background .15s, color .15s;
}

.logout-link svg {
    width: 18px;
    height: 18px;
}

.logout-link:hover {
    background: rgba(220, 38, 38, .12);
    color: #fca5a5;
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 32px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.topbar-sub {
    margin: 2px 0 0;
    color: var(--text-muted);
    font-size: 13px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    font-weight: 600;
    display: grid;
    place-items: center;
}

.user-meta strong {
    display: block;
    font-size: 13.5px;
}

.user-meta span {
    font-size: 11.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.content {
    padding: 28px 32px 40px;
}

/* -------- STAT CARDS -------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    margin: 8px 0 4px;
}

.stat-trend {
    font-size: 12px;
    color: var(--text-muted);
}

/* -------- PANEL -------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.panel-body {
    padding: 22px;
}

.muted { color: var(--text-muted); font-size: 12px; }

.empty-state {
    text-align: center;
    padding: 56px 22px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 56px;
    height: 56px;
    color: #cbd5e1;
    margin-bottom: 12px;
}

.empty-state h3 {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.empty-state p {
    margin: 0;
    font-size: 13.5px;
}

/* -------- FLASH MESSAGES -------- */
.flash {
    margin: 16px 32px -8px;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    border: 1px solid transparent;
}

.flash-success {
    background: #ecfdf5;
    color: #047857;
    border-color: #a7f3d0;
}

.flash-error {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: rgba(220, 38, 38, .2);
}

/* -------- TOOLBAR -------- */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    gap: 12px;
}

.toolbar-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

/* -------- TABLE -------- */
.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.data-table thead th {
    text-align: left;
    padding: 12px 18px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.data-table tbody td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }

.data-table small {
    display: block;
    color: var(--text-muted);
    font-size: 11.5px;
    margin-top: 2px;
}

.t-right { text-align: right; }
.mono { font-family: 'SFMono-Regular', Consolas, Menlo, monospace; }

/* -------- BUTTONS EXTRA -------- */
.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); }

.btn-sm {
    padding: 6px 10px;
    font-size: 12.5px;
}

.btn-danger { color: var(--danger); border-color: rgba(220, 38, 38, .25); }
.btn-danger:hover { background: var(--danger-soft); }

/* -------- FORM CARD -------- */
.form-card {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-sm);
}

.form-section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.form-section-head h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.form-section-head p {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 12.5px;
    flex-basis: 100%;
}

.grid-2, .grid-3, .grid-4 {
    display: grid;
    gap: 14px;
    margin-bottom: 14px;
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.form-section > .grid-2:last-child,
.form-section > .grid-3:last-child,
.form-section > .grid-4:last-child { margin-bottom: 0; }

.field .span-2, .field.span-2 { grid-column: span 2; }
.field.flex-grow { flex: 1; }

.field select,
.field textarea,
.field input[type="file"] {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    background: var(--surface-2);
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.field textarea { resize: vertical; min-height: 64px; }

.field select:focus,
.field textarea:focus,
.field input:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, .12);
}

.input-strong { font-weight: 700; font-size: 15px !important; }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 4px;
}

/* -------- REPEATER -------- */
.repeater {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.repeater-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.repeater-row .field { margin: 0; }
.repeater-row .row-remove {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 18px;
    line-height: 1;
}

.item-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
}

.item-grid .field span {
    font-size: 10.5px;
    letter-spacing: .02em;
}

.item-grid .field input {
    padding: 7px 9px;
    font-size: 12.5px;
}

.item-grid .item-desc { grid-column: span 3; }

/* -------- LOGO UPLOADER -------- */
.logo-uploader {
    display: flex;
    gap: 22px;
    align-items: flex-start;
}

.logo-preview {
    width: 180px;
    height: 120px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    background: var(--surface-2);
    overflow: hidden;
}

.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

.logo-placeholder {
    color: var(--text-muted);
    font-size: 12.5px;
}

.logo-actions {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

@media (max-width: 1080px) {
    .item-grid { grid-template-columns: repeat(4, 1fr); }
    .item-grid .item-desc { grid-column: span 2; }
}

@media (max-width: 768px) {
    .sidebar { width: 64px; }
    .sidebar-brand strong, .sidebar-brand span { display: none; }
    .topbar { padding: 18px 20px; flex-direction: column; align-items: flex-start; gap: 10px; }
    .content { padding: 20px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .item-grid { grid-template-columns: repeat(2, 1fr); }
    .item-grid .item-desc { grid-column: span 2; }
}
