:root {
    --bg: #f4f7fb;
    --panel: #fff;
    --text: #172033;
    --muted: #6f7b91;
    --line: #e5eaf2;
    --blue: #3974f6;
    --blue-soft: #edf3ff;
    --purple: #7a5af8;
    --green: #19a974;
    --orange: #f39a37;
    --red: #dc4c64;
    --sidebar: #111a2e;
    --shadow: 0 8px 30px rgba(24, 41, 75, .07);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 "Segoe UI", "Microsoft YaHei", sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.sidebar { position: fixed; inset: 0 auto 0 0; width: 244px; z-index: 20; display: flex; flex-direction: column; padding: 22px 16px; background: linear-gradient(180deg, #121d34 0%, #0d1527 100%); color: #dbe4f5; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 25px; color: #fff; }
.brand-mark { display: grid; place-items: center; width: 39px; height: 39px; flex: 0 0 39px; border-radius: 12px; background: linear-gradient(145deg, #5487ff, #7058e8); color: #fff; font-size: 13px; font-weight: 800; box-shadow: 0 8px 22px rgba(70, 106, 244, .32); }
.brand strong, .brand small, .account-chip strong, .account-chip small { display: block; }
.brand strong { font-size: 14px; letter-spacing: .1px; }
.brand small { margin-top: 2px; color: #8493ad; font-size: 11px; }
.nav-list { flex: 1; }
.nav-list p { margin: 20px 12px 8px; color: #64738e; font-size: 11px; font-weight: 700; letter-spacing: 1.2px; }
.nav-list a { display: flex; align-items: center; gap: 12px; margin: 3px 0; padding: 11px 13px; border-radius: 9px; color: #9fadc4; transition: .15s ease; }
.nav-list a span { width: 18px; text-align: center; font-size: 16px; }
.nav-list a:hover { background: rgba(255,255,255,.055); color: #fff; }
.nav-list a.active { background: linear-gradient(90deg, rgba(67,117,244,.28), rgba(67,117,244,.08)); color: #fff; box-shadow: inset 3px 0 #5c88ff; }
.sidebar-footer { padding: 15px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.account-chip { display: flex; align-items: center; gap: 10px; }
.account-chip .avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #263653; color: #fff; font-weight: 700; }
.account-chip strong { font-size: 13px; }
.account-chip small { color: #7787a2; font-size: 11px; }
.link-button { padding: 9px 0 0; border: 0; background: none; color: #7f8da4; cursor: pointer; }
.link-button:hover { color: #fff; }

.page-shell { min-height: 100vh; margin-left: 244px; }
.topbar { height: 67px; display: flex; align-items: center; gap: 13px; padding: 0 30px; background: rgba(255,255,255,.9); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.topbar strong, .topbar small { display: block; }
.topbar strong { font-size: 14px; }
.topbar small { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; }
.topbar .status-dot { margin-left: auto; color: var(--green); font-size: 12px; }
.menu-toggle { display: none; border: 0; background: transparent; font-size: 20px; }
.page-content { max-width: 1540px; margin: auto; padding: 28px 30px 48px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-heading h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.4px; }
.page-heading p, .panel-title p { margin: 0; color: var(--muted); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.metric-card { position: relative; min-height: 136px; overflow: hidden; padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); }
.metric-card::after { content: ""; position: absolute; width: 90px; height: 90px; right: -28px; top: -30px; border-radius: 50%; background: currentColor; opacity: .08; }
.metric-card span, .metric-card small { display: block; color: var(--muted); }
.metric-card strong { display: block; margin: 9px 0 2px; color: var(--text); font-size: 30px; line-height: 1.1; letter-spacing: -.8px; }
.accent-blue { color: var(--blue); border-top: 3px solid var(--blue); }
.accent-purple { color: var(--purple); border-top: 3px solid var(--purple); }
.accent-green { color: var(--green); border-top: 3px solid var(--green); }
.accent-orange { color: var(--orange); border-top: 3px solid var(--orange); }

.content-grid { display: grid; gap: 18px; }
.two-one { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.panel, .table-panel { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); }
.panel { padding: 22px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; }
.panel h2, .panel-title h2 { margin: 0 0 3px; font-size: 16px; }
.bar-chart { height: 260px; display: flex; align-items: stretch; gap: 12px; padding: 34px 10px 0; border-bottom: 1px solid var(--line); background: repeating-linear-gradient(to bottom, transparent 0, transparent 53px, #eef1f6 54px); }
.bar-day { flex: 1; min-width: 36px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.bar-day .bars { height: 190px; display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.bar-day i { display: block; width: 12px; min-height: 2px; border-radius: 5px 5px 2px 2px; }
.level-bar { background: linear-gradient(#6994ff, #3974f6); }
.ad-bar { background: linear-gradient(#a08bff, #7659ef); }
.bar-day span { padding-top: 7px; color: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 18px; margin-top: 14px; color: var(--muted); font-size: 12px; }
.legend i { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; }
.legend-level { background: var(--blue); }.legend-ad { background: var(--purple); }
.snapshot { display: flex; flex-direction: column; }
.snapshot-number { display: block; margin-top: 34px; font-size: 46px; letter-spacing: -1.8px; }
.snapshot > span { color: var(--muted); }
.snapshot hr { width: 100%; margin: 25px 0; border: 0; border-top: 1px solid var(--line); }
.snapshot > div:not(.panel-title) { display: flex; justify-content: space-between; }
.snapshot > a { margin-top: auto; padding-top: 26px; color: var(--blue); font-weight: 600; }
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 18px; }
.quick-grid > a { display: flex; align-items: center; gap: 13px; padding: 17px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.quick-grid > a:hover { transform: translateY(-1px); border-color: #ccd8ef; }
.quick-grid strong, .quick-grid small { display: block; }.quick-grid small { color: var(--muted); }.quick-grid b { margin-left: auto; color: #a4aec0; }
.quick-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; font-size: 17px; }
.quick-icon.blue { color: var(--blue); background: var(--blue-soft); }.quick-icon.orange { color: var(--orange); background: #fff3e7; }.quick-icon.purple { color: var(--purple); background: #f1edff; }
.quick-icon.green { color: var(--green); background: #eaf8f2; }

.button { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; padding: 8px 15px; border: 1px solid transparent; border-radius: 8px; cursor: pointer; font-weight: 600; }
.button.primary { background: var(--blue); color: #fff; box-shadow: 0 5px 14px rgba(57,116,246,.2); }
.button.secondary { border-color: #ccd7ea; background: #fff; color: #40506b; }
.button.ghost { color: var(--muted); }
.button.wide { width: 100%; }
.filter-panel { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 16px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.filter-panel label, .form-panel label { display: flex; flex-direction: column; gap: 5px; color: #526079; font-size: 12px; font-weight: 600; }
input, select { height: 38px; min-width: 154px; padding: 7px 10px; border: 1px solid #d8dfeb; border-radius: 7px; outline: none; background: #fff; color: var(--text); }
input:focus, select:focus { border-color: #779bf5; box-shadow: 0 0 0 3px rgba(57,116,246,.1); }
.wide-filters label:nth-child(5), .wide-filters label:nth-child(6) { flex: 1; min-width: 180px; }

.table-panel { overflow: hidden; }
.table-meta { padding: 15px 18px; border-bottom: 1px solid var(--line); color: var(--muted); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 15px; border-bottom: 1px solid #edf0f5; text-align: left; white-space: nowrap; }
th { background: #fafbfd; color: #66738a; font-size: 11px; font-weight: 700; letter-spacing: .2px; }
th small, td small { color: #9aa4b5; font-weight: 400; }
tbody tr:hover { background: #fafcff; }
tbody tr:last-child td { border-bottom: 0; }
.no-data { height: 150px; color: #97a2b4; text-align: center; }
.compact-top { margin-top: 16px; }
.rate { display: inline-flex; min-width: 52px; justify-content: center; padding: 3px 8px; border-radius: 12px; background: #f2f4f8; color: #536077; font-size: 12px; }
.rate.good { background: #eaf8f2; color: #13835b; }.rate.bad { background: #fff0f2; color: #c63d55; }
.event-pill, .role-pill { display: inline-flex; padding: 3px 8px; border-radius: 12px; background: #eef3fc; color: #476898; font-size: 11px; font-weight: 600; }
.event-pill.level { background: #eaf2ff; color: #356ddf; }.event-pill.ad { background: #fff2e4; color: #d17c1f; }
code, .mono { font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; }
.events-table { min-width: 1250px; }.truncate { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }.nowrap { white-space: nowrap; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 14px; padding: 14px 18px; border-top: 1px solid var(--line); }
.pagination a { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; }.pagination a.disabled { opacity: .4; pointer-events: none; }

.accounts-grid { grid-template-columns: minmax(0, 2.2fr) minmax(290px, .8fr); align-items: start; }.stack-panels { display: grid; gap: 16px; }.form-panel form { display: grid; gap: 13px; margin-top: 16px; }.form-panel input, .form-panel select { width: 100%; }.mini-button { min-height: 31px; padding: 5px 10px; border: 1px solid #d5ddeb; border-radius: 6px; background: #fff; color: #59677f; cursor: pointer; }.mini-button.danger { border-color: #f0cbd2; color: #bd3e54; }.mini-button.danger:hover { background: #fff0f2; }.state-on { color: var(--green); }.state-off { color: var(--red); }
.gm-help { margin: 8px 0 0; }.gm-note p { margin: 10px 0 0; color: var(--muted); }
.alert { margin-bottom: 16px; padding: 12px 15px; border-radius: 8px; }.alert.success { background: #eaf8f2; color: #147651; }.alert.error { background: #fff0f2; color: #b6354b; }
.device-note { border: 1px solid #dbe5f6; background: #f4f8ff; color: #50617d; }
.device-report-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(340px, .8fr); gap: 18px; align-items: start; }

.login-body { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 10%, rgba(81,125,255,.18), transparent 30%), radial-gradient(circle at 85% 90%, rgba(122,90,248,.14), transparent 28%), #edf2f9; }
.login-card { width: min(420px, 100%); padding: 38px 42px; border: 1px solid rgba(255,255,255,.7); border-radius: 18px; background: rgba(255,255,255,.94); box-shadow: 0 25px 70px rgba(33,51,84,.14); }
.login-brand { display: flex; justify-content: center; }.login-card .brand-mark { width: 52px; height: 52px; border-radius: 15px; }.eyebrow { margin: 19px 0 4px; color: var(--blue); text-align: center; font-size: 10px; font-weight: 800; letter-spacing: 2px; }.login-card h1 { margin: 0; text-align: center; font-size: 27px; }.muted { color: var(--muted); }.login-card > .muted { margin: 7px 0 24px; text-align: center; }.login-form { display: grid; gap: 8px; }.login-form label:not(.checkbox) { margin-top: 5px; color: #4e5c73; font-size: 12px; font-weight: 600; }.login-form input:not([type=checkbox]) { width: 100%; height: 43px; }.checkbox { display: flex; align-items: center; gap: 7px; margin: 5px 0 8px; color: var(--muted); }.checkbox input { width: 15px; height: 15px; min-width: 0; }.validation { color: var(--red); font-size: 12px; }.validation:empty { display: none; }.validation ul { margin: 0; padding-left: 18px; }.login-note { margin: 20px 0 0; color: #9aa4b5; text-align: center; font-size: 11px; }
.empty-state { max-width: 580px; margin: 90px auto; padding: 50px; text-align: center; }.empty-icon { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 15px; border-radius: 50%; background: #fff0f2; color: var(--red); font-size: 25px; font-weight: 800; }.empty-state p { color: var(--muted); }

@media (max-width: 1050px) {
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .two-one, .accounts-grid, .device-report-grid { grid-template-columns: 1fr; }
    .quick-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    body.nav-open .sidebar { transform: translateX(0); }
    .page-shell { margin-left: 0; }.menu-toggle { display: block; }.topbar { padding: 0 16px; }.page-content { padding: 20px 15px 40px; }
    .metric-grid, .quick-grid { grid-template-columns: 1fr; }.page-heading { align-items: flex-start; flex-direction: column; }.bar-chart { gap: 4px; padding-left: 2px; padding-right: 2px; }.bar-day i { width: 8px; }.filter-panel > label { width: calc(50% - 6px); }.filter-panel input, .filter-panel select { width: 100%; min-width: 0; }.login-card { padding: 30px 24px; }
}
