:root {
    --bg: #0b1019;
    --sidebar: #111827;
    --surface: rgba(20, 28, 43, .88);
    --surface-solid: #141c2b;
    --surface-raised: #182235;
    --surface-hover: #202c41;
    --surface-input: #0e1624;
    --border: #29374e;
    --border-strong: #3a4a66;
    --primary: #6d8cff;
    --primary-strong: #5578f6;
    --primary-soft: rgba(109, 140, 255, .13);
    --info: #38bdf8;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #fb7185;
    --text: #f1f5fb;
    --text-secondary: #b8c3d4;
    --text-muted: #7f8da3;
    --radius: 8px;
    --sidebar-w: 226px;
    --topbar-h: 64px;
    --shadow: 0 18px 50px rgba(1, 5, 12, .36);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background-color: var(--bg);
    background-image:
        linear-gradient(180deg, rgba(55, 82, 140, .16), transparent 280px),
        repeating-linear-gradient(90deg, transparent 0 79px, rgba(139, 163, 205, .018) 80px),
        repeating-linear-gradient(0deg, transparent 0 79px, rgba(139, 163, 205, .018) 80px);
    font: 14px/1.55 "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}
button, input, select, textarea { font: inherit; }
a { color: #8fa7ff; text-decoration: none; }
a:hover { color: #b9c6ff; }
code { padding: 2px 6px; color: #d5deec; background: #0b1320; border: 1px solid #27364b; border-radius: 4px; font-family: Consolas, monospace; font-size: 12px; }
.muted { color: var(--text-muted); }

.admin-layout { min-height: 100vh; }
.admin-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 100; display: flex; width: var(--sidebar-w); flex-direction: column; background: rgba(17, 24, 39, .96); border-right: 1px solid rgba(91, 113, 150, .28); box-shadow: 10px 0 32px rgba(0, 0, 0, .12); backdrop-filter: blur(16px); }
.admin-main { min-width: 0; min-height: 100vh; margin-left: var(--sidebar-w); }
.sidebar-brand { display: flex; min-height: var(--topbar-h); align-items: center; gap: 11px; padding: 10px 16px; border-bottom: 1px solid rgba(91, 113, 150, .22); }
.brand-mark { display: grid; width: 36px; height: 36px; place-items: center; flex: 0 0 36px; color: #dce4ff; background: rgba(109, 140, 255, .16); border: 1px solid rgba(109, 140, 255, .34); border-radius: 8px; }
.brand-mark svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-brand strong, .sidebar-brand small { display: block; letter-spacing: 0; }
.sidebar-brand strong { font-size: 15px; font-weight: 650; }
.sidebar-brand small { margin-top: 1px; color: #718096; font-size: 10px; font-weight: 400; }
.admin-sidebar nav { flex: 1; overflow-y: auto; padding: 9px 10px 14px; scrollbar-width: thin; scrollbar-color: #34445e transparent; }
.nav-group-label { padding: 15px 10px 5px; color: #627087; font-size: 10px; font-weight: 600; }
.admin-sidebar nav a { position: relative; display: flex; min-height: 40px; align-items: center; gap: 11px; margin: 2px 0; padding: 8px 11px; color: #9eabc0; border-radius: 7px; transition: background .16s ease, color .16s ease; }
.admin-sidebar nav a:hover { color: #edf2ff; background: rgba(139, 157, 190, .08); }
.admin-sidebar nav a.active { color: #f3f6ff; background: linear-gradient(90deg, rgba(109, 140, 255, .18), rgba(109, 140, 255, .07)); }
.admin-sidebar nav a.active::before { content: ""; position: absolute; left: 0; width: 3px; height: 20px; background: #8ca4ff; border-radius: 0 3px 3px 0; }
.nav-icon { width: 18px; height: 18px; flex: 0 0 18px; color: #738198; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.admin-sidebar nav a:hover .nav-icon { color: #aebce0; }
.admin-sidebar nav a.active .nav-icon { color: #9eb2ff; }
.sidebar-footer { display: flex; align-items: center; gap: 8px; min-height: 60px; padding: 9px 12px; border-top: 1px solid rgba(91, 113, 150, .22); }
.sidebar-footer > span { min-width: 0; display: grid; grid-template-columns: 8px 1fr; column-gap: 8px; flex: 1; color: var(--text-secondary); font-size: 12px; }
.sidebar-footer small { grid-column: 2; color: var(--text-muted); font-size: 10px; }
.user-dot { width: 8px; height: 8px; margin-top: 5px; background: var(--success); border-radius: 50%; }
.logout-form { display: inline-flex; margin: 0; }
.logout-link,.account-link { display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center; padding: 0; color: var(--text-muted); background: transparent; border: 0; border-radius: 7px; cursor: pointer; }
.logout-link svg,.account-link svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.logout-link span,.account-link span { display: none; }
.account-link:hover,.account-link.active { color: var(--primary-light); background: rgba(79, 125, 243, .1); }
.logout-link:hover { color: var(--danger); background: rgba(251, 113, 133, .08); }

.admin-topbar { position: sticky; top: 0; z-index: 50; display: flex; height: var(--topbar-h); align-items: center; gap: 12px; padding: 0 24px; background: rgba(11, 16, 25, .78); border-bottom: 1px solid rgba(91, 113, 150, .22); backdrop-filter: blur(18px); }
.page-heading { min-width: 0; flex: 1; }
.page-heading > span { display: block; margin-bottom: 0; color: #748198; font-size: 10px; }
.page-heading h1 { margin: 0; overflow: hidden; color: var(--text); font-size: 19px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.topbar-role { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; color: #aeb9ca; background: rgba(20, 28, 43, .72); border: 1px solid rgba(91, 113, 150, .28); border-radius: 7px; font-size: 11px; }
.topbar-role svg { width: 14px; height: 14px; color: var(--success); fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-toggle { display: none; width: 38px; height: 38px; padding: 9px; color: var(--text-secondary); background: var(--surface); border: 1px solid var(--border); border-radius: 7px; }
.sidebar-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.sidebar-scrim { display: none; }
.admin-content { position: relative; width: 100%; max-width: 1560px; margin: 0 auto; padding: 20px 24px 40px; }

.dashboard-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(152px, 1fr)); gap: 10px; margin-bottom: 16px; }
.card { position: relative; min-height: 92px; overflow: hidden; padding: 16px; text-align: left; background: linear-gradient(145deg, rgba(27, 38, 58, .92), rgba(17, 25, 39, .88)); border: 1px solid rgba(79, 99, 133, .42); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .08); }
.card::after { content: ""; position: absolute; top: 0; right: 0; width: 68px; height: 68px; border-top: 1px solid rgba(109, 140, 255, .14); border-right: 1px solid rgba(109, 140, 255, .14); transform: translate(24px, -24px) rotate(45deg); }
.card-num { position: relative; z-index: 1; color: #f6f8fd; font-size: 24px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.card-label { position: relative; z-index: 1; margin-top: 8px; color: #8795aa; font-size: 11px; }

.panel { margin-bottom: 16px; overflow: hidden; background: var(--surface); border: 1px solid rgba(79, 99, 133, .4); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .07); backdrop-filter: blur(10px); }
.panel > p, .panel > form, .panel > .bar-chart { margin-left: 18px; margin-right: 18px; }
.panel-header { display: flex; min-height: 46px; align-items: center; padding: 11px 15px; color: #e9eef8; background: rgba(29, 40, 60, .72); border-bottom: 1px solid rgba(79, 99, 133, .35); font-size: 13px; font-weight: 650; }
.table-shell { width: 100%; overflow-x: auto; border: 1px solid rgba(79, 99, 133, .4); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 24px rgba(0, 0, 0, .06); scrollbar-width: thin; scrollbar-color: #40506c transparent; }
.panel > .table-shell { border: 0; border-radius: 0; }
table { width: 100%; min-width: 680px; border-collapse: collapse; }
thead { background: #182235; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid rgba(55, 72, 99, .52); font-size: 12px; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; color: #8f9db2; background: #182235; font-size: 11px; font-weight: 600; white-space: nowrap; }
tbody tr { transition: background .14s ease; }
tbody tr:nth-child(even) { background: rgba(255, 255, 255, .012); }
tbody tr:hover { background: rgba(109, 140, 255, .055); }
tbody tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; }
td.actions form { display: inline-flex !important; }
td.empty { padding: 34px !important; color: var(--text-muted); text-align: center; }
.url-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toolbar { display: flex; min-height: 50px; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; padding: 7px 9px; background: rgba(20, 28, 43, .7); border: 1px solid rgba(79, 99, 133, .36); border-radius: var(--radius); backdrop-filter: blur(10px); }
.toolbar > div { display: flex; flex-wrap: wrap; gap: 5px; }
.toolbar a { padding: 6px 10px; color: var(--text-secondary); border: 1px solid transparent; border-radius: 5px; font-size: 12px; }
.toolbar a:hover { color: var(--text); background: rgba(109, 140, 255, .09); border-color: rgba(109, 140, 255, .22); }
.page-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-actions p { margin: 0; color: var(--text-muted); }
.filter-bar { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; padding: 9px 11px; background: rgba(20, 28, 43, .7); border: 1px solid rgba(79, 99, 133, .36); border-radius: var(--radius); }
.filter-bar label { color: var(--text-secondary); font-size: 12px; white-space: nowrap; }
.filter-bar select { width: auto; min-width: 180px; }
.filter-clear { color: var(--danger); font-size: 12px; }
.split-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.section-stack { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); }
.section-intro { margin: -2px 0 12px; color: var(--text-muted); font-size: 12px; }
.section-description { padding: 11px 15px; color: var(--text-muted); border-bottom: 1px solid rgba(55, 72, 99, .4); font-size: 12px; }
.settings-copy-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.settings-form { padding: 15px 16px 17px; }
.settings-form .form-actions { margin-top: 12px; }
.nav-emoji-cell { font-size: 17px; }
.note-panel { margin-bottom: 14px; padding: 12px 14px; color: var(--text-secondary); background: rgba(56, 189, 248, .06); border: 1px solid rgba(56, 189, 248, .2); border-radius: var(--radius); }
.note-panel p { margin: 0; }
.danger-zone { margin: 18px; padding: 20px; color: #fecdd3; background: rgba(251, 113, 133, .07); border: 1px solid rgba(251, 113, 133, .28); border-radius: var(--radius); }
.danger-zone h3 { margin: 0 0 10px; color: #fda4af; font-size: 15px; }
.danger-zone p { margin: 0 0 16px; }
.media-preview { display: flex; align-items: center; gap: 10px; margin: 7px 0; }
.media-preview img { max-width: 100%; max-height: 110px; object-fit: contain; background: var(--surface-input); border: 1px solid var(--border); border-radius: 5px; }
.media-preview small { color: var(--success); }
.check-row { display: flex !important; align-items: flex-start; gap: 9px; cursor: pointer; }
.check-row input { width: 18px !important; height: 18px; margin-top: 1px; accent-color: var(--primary); }

.form-panel { max-width: 720px; padding: 18px; background: var(--surface); border: 1px solid rgba(79, 99, 133, .4); border-radius: var(--radius); }
.form-group, .form-row { margin-bottom: 14px; }
.form-row:has(> .form-group) { display: flex; gap: 12px; }
.form-row > .form-group { min-width: 0; flex: 1; margin-bottom: 0; }
.form-group label, .form-row > label { display: block; margin-bottom: 5px; color: var(--text-secondary); font-size: 12px; font-weight: 600; }
.form-group small, .form-row small { display: block; margin-top: 5px; color: var(--text-muted); font-size: 11px; }
input[type="text"], input[type="url"], input[type="password"], input[type="number"], input[type="date"], input[type="file"], select, textarea { width: 100%; min-height: 40px; padding: 8px 10px; color: var(--text); background: var(--surface-input); border: 1px solid #30405a; border-radius: 6px; outline: none; transition: border-color .15s ease, box-shadow .15s ease, background .15s ease; }
textarea { min-height: 88px; resize: vertical; }
input[type="color"] { width: 100%; height: 40px; padding: 4px; background: var(--surface-input); border: 1px solid var(--border); border-radius: 5px; }
input:focus, select:focus, textarea:focus { background: #111b2b; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(109, 140, 255, .13); }
input:disabled { cursor: not-allowed; opacity: .48; }
.inline-form { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 14px; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.inline-form textarea { flex: 1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.btn { min-height: 38px; padding: 8px 14px; color: var(--text); background: #202c41; border: 1px solid #3b4b66; border-radius: 6px; cursor: pointer; font-weight: 600; transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease; }
.btn:hover { background: #28364f; border-color: #536685; }
.btn:active { transform: translateY(1px); }
.btn-primary { color: #fff; background: var(--primary-strong); border-color: #6f8eff; box-shadow: 0 6px 18px rgba(73, 105, 226, .2); }
.btn-primary:hover { color: #fff; background: #6686ff; border-color: #88a0ff; }
.btn-block { width: 100%; }
.btn-sm { min-width: 30px; min-height: 30px; padding: 4px 8px; color: var(--text-secondary); background: #1a2537; border: 1px solid #31415b; border-radius: 5px; cursor: pointer; transition: all .14s ease; }
.btn-sm:hover { color: var(--text); background: #25334b; border-color: #526684; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { color: #fecdd3; background: rgba(251, 113, 133, .09); border-color: rgba(251, 113, 133, .45); }
.btn-cancel { width: 100%; min-height: 38px; margin-top: 8px; color: var(--text-muted); background: transparent; border: 1px solid var(--border); border-radius: 5px; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 2px solid #8fa7ff; outline-offset: 2px; }

.alert { margin-bottom: 12px; padding: 10px 12px; border: 1px solid; border-radius: 7px; font-size: 12px; backdrop-filter: blur(8px); }
.alert-ok { color: #a7f3d0; background: rgba(52, 211, 153, .08); border-color: rgba(52, 211, 153, .28); }
.alert-error, .alert-err { color: #fecdd3; background: rgba(251, 113, 133, .08); border-color: rgba(251, 113, 133, .28); }
.alert-warning { color: #fde68a; background: rgba(251, 191, 36, .07); border-color: rgba(251, 191, 36, .24); }
.badge { display: inline-flex; align-items: center; min-height: 22px; padding: 2px 7px; color: var(--text-secondary); background: #192129; border: 1px solid var(--border); border-radius: 4px; font-size: 10px; }
.badge-success { color: #a7f3d0; background: rgba(52, 211, 153, .08); border-color: rgba(52, 211, 153, .28); }
.badge-danger { color: #fecdd3; background: rgba(251, 113, 133, .08); border-color: rgba(251, 113, 133, .3); }
.after-sales-grid { margin-bottom: 16px; }
.after-sales-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 18px; }
.after-sales-summary > div { display: flex; min-height: 92px; align-items: flex-start; justify-content: center; flex-direction: column; padding: 14px; background: rgba(18, 27, 42, .82); border: 1px solid var(--border); border-radius: 6px; }
.after-sales-summary strong { color: var(--text); font-size: 25px; line-height: 1; }
.after-sales-summary span { margin-top: 9px; color: var(--text-muted); font-size: 11px; }
.after-sales-summary .is-active strong { color: var(--success); }
.after-sales-summary .is-expired strong { color: var(--danger); }
.after-sales-records table { min-width: 900px; }

.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, .72); backdrop-filter: blur(4px); }
.modal-box, .modal-content { position: relative; z-index: 1; width: min(620px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 22px; background: #182235; border: 1px solid #3b4b66; border-radius: 8px; box-shadow: var(--shadow); }
.modal-box h2, .modal-content h2 { margin: 0 0 18px; color: var(--text); font-size: 17px; }

.bar-chart { padding: 14px 0 18px; }
.bar-row { display: grid; grid-template-columns: 82px minmax(80px, 1fr) 38px; align-items: center; gap: 10px; min-height: 28px; font-size: 11px; }
.bar-label { color: var(--text-muted); text-align: right; }
.bar-fill { height: 8px; min-width: 2px; background: linear-gradient(90deg, #5578f6, #38bdf8); border-radius: 3px; }
.bar-val { color: var(--text-secondary); font-weight: 600; }

.login-page { display: grid; min-height: 100vh; min-height: 100dvh; place-items: center; padding: 20px; background-color: var(--bg); background-image: linear-gradient(135deg, rgba(64, 91, 153, .18), transparent 50%), repeating-linear-gradient(90deg, transparent 0 79px, rgba(139, 163, 205, .02) 80px), repeating-linear-gradient(0deg, transparent 0 79px, rgba(139, 163, 205, .02) 80px); }
.login-box { width: min(380px, 100%); padding: 30px; text-align: left; background: rgba(20, 28, 43, .94); border: 1px solid rgba(79, 99, 133, .5); border-radius: 8px; box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.login-box h1 { display:flex; align-items:center; gap:9px; margin: 0; color: var(--text); font-size: 22px; }
.login-box h1 svg { width:24px; height:24px; fill:none; stroke:var(--primary); stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.login-box .subtitle { margin: 5px 0 22px; color: var(--text-muted); font-size: 12px; }
.login-box input,.login-box .btn { min-height:44px; }

.install-page { min-height:100vh; min-height:100dvh; padding:32px 16px; }
.install-shell { width:min(800px, 100%); margin:0 auto; }
.install-panel { padding:24px; background:var(--surface); border:1px solid rgba(79, 99, 133, .5); border-radius:var(--radius); box-shadow:var(--shadow); }
.install-heading { display:flex; align-items:center; gap:12px; margin-bottom:20px; padding-bottom:16px; border-bottom:1px solid var(--border); }
.install-heading svg { width:28px; height:28px; flex:0 0 28px; fill:none; stroke:var(--primary); stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.install-page h1 { margin:0 0 16px; font-size:22px; line-height:1.3; }
.install-heading h1 { margin:0; }
.install-heading p { margin:3px 0 0; color:var(--text-muted); font-size:12px; }
.install-page p { color:var(--text-secondary); }
.install-page pre { overflow:auto; padding:12px; color:var(--text); background:var(--surface-input); border:1px solid var(--border); border-radius:6px; white-space:pre-wrap; overflow-wrap:anywhere; }
.install-page .ok { color:var(--success); }
.install-page .err { color:var(--danger); }
.install-page ol { padding-left:22px; color:var(--text-secondary); }
.install-page li + li { margin-top:8px; }
.install-form { display:grid; gap:12px; margin-top:18px; }
.install-form label { color:var(--text-secondary); font-size:12px; font-weight:600; }
.install-form .btn { min-height:44px; }

@media (max-width: 1100px) { .admin-content { padding-left: 18px; padding-right: 18px; } }
@media (max-width: 600px) { .login-box input { font-size:16px; } }
@media (max-width: 900px) {
    .admin-sidebar { transform: translateX(-100%); box-shadow: var(--shadow); transition: transform .2s ease; }
    .admin-main { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .sidebar-open .admin-sidebar { transform: translateX(0); }
    .sidebar-scrim { position: fixed; inset: 0; z-index: 90; width: 100%; height: 100%; padding: 0; background: rgba(0, 0, 0, .55); border: 0; }
    .sidebar-open .sidebar-scrim { display: block; }
}
@media (max-width: 640px) {
    .admin-topbar { height: 60px; padding: 0 12px; }
    .topbar-role { display: none; }
    .admin-content { padding: 14px 12px 30px; }
    .dashboard-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .card { min-height: 96px; padding: 14px; }
    .card-num { font-size: 21px; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .page-actions, .filter-bar { align-items: stretch; flex-direction: column; }
    .page-actions .btn, .filter-bar select { width: 100%; }
    .split-grid { grid-template-columns: 1fr; }
    .settings-copy-grid { grid-template-columns: 1fr; }
    .after-sales-summary { grid-template-columns: 1fr; }
    .toolbar .btn { width: 100%; }
    .form-row, .inline-form { flex-direction: column; }
    .modal { align-items: flex-end; padding: 0; }
    .modal-box, .modal-content { width: 100%; max-height: 92vh; padding: 18px 14px; border-radius: 8px 8px 0 0; }
    .form-actions { position: sticky; bottom: -18px; margin: 18px -14px -18px; padding: 12px 14px; background: var(--surface-raised); border-top: 1px solid var(--border); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; } }
