:root {
    --canvas: #f5f7f5;
    --surface: #ffffff;
    --surface-muted: #f8faf8;
    --ink: #15231d;
    --ink-soft: #5f6d66;
    --line: #dfe6e1;
    --brand: #176b4d;
    --brand-strong: #11543c;
    --brand-soft: #e7f3ec;
    --warning: #a86608;
    --warning-soft: #fff4df;
    --danger: #ba3b3b;
    --danger-soft: #fdf0f0;
    --success: #18734d;
    --success-soft: #e9f7ef;
    --shadow: 0 18px 45px rgba(27, 47, 36, .08);
    --radius-lg: 22px;
    --radius-md: 15px;
    --sidebar-width: 264px;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font-family: "Manrope", sans-serif;
    font-size: 14px;
    line-height: 1.5;
}
body.has-open-nav { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
small, .muted { color: var(--ink-soft); }

.layout { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding: 24px 16px 16px;
    background: #123529;
    color: #eaf3ee;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 24px; }
.brand-mark {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    border: 1px solid rgba(214, 240, 223, .8);
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-copy { display: grid; gap: 1px; }
.brand-copy strong { font-size: 14px; }
.brand-copy small { color: #a9c5b6; font-size: 11px; }
.nav { display: grid; gap: 4px; }
.nav-label { margin: 17px 10px 6px; color: #89aa99; font-family: "DM Mono", monospace; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.nav-label:first-child { margin-top: 0; }
.nav-link { display: flex; align-items: center; gap: 11px; min-height: 40px; padding: 9px 11px; border-radius: 10px; color: #bfd2c6; font-weight: 600; transition: background .18s ease, color .18s ease; }
.nav-link i { width: 18px; color: #95b7a5; text-align: center; }
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.is-active { background: #d9eee1; color: #123529; }
.nav-link.is-active i { color: #176b4d; }
.account-card { display: flex; align-items: center; gap: 9px; margin-top: auto; padding: 12px 10px; border: 1px solid rgba(221, 242, 229, .13); border-radius: 13px; background: rgba(255,255,255,.05); }
.account-avatar { display: grid; flex: 0 0 auto; width: 29px; height: 29px; place-items: center; border-radius: 50%; background: #89b59c; color: #103225; font-size: 12px; font-weight: 800; }
.account-copy { display: grid; min-width: 0; flex: 1; }
.account-copy small { color: #a9c5b6; font-size: 10px; }
.account-copy strong { overflow: hidden; color: #fff; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.account-logout { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 8px; color: #b9d4c4; }
.account-logout:hover { color: #fff; background: rgba(255,255,255,.11); }

.overlay { display: none; }
.content { width: 100%; min-width: 0; max-width: 1580px; padding: 30px 38px 48px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.topbar-heading { display: grid; gap: 0; }
.eyebrow { margin: 0 0 3px; color: var(--brand); font-family: "DM Mono", monospace; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.topbar h1 { margin: 0; font-size: clamp(24px, 3vw, 31px); letter-spacing: -.045em; line-height: 1.18; }
.page-description { max-width: 670px; margin: 7px 0 0; color: var(--ink-soft); }
.topbar-actions { display: flex; flex-shrink: 0; gap: 8px; flex-wrap: wrap; }

.section { min-width: 0; }
.panel, .status-card, .stat { border: 1px solid var(--line); background: var(--surface); box-shadow: 0 1px 0 rgba(21,35,29,.02); }
.panel { border-radius: var(--radius-lg); padding: 20px; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-size: 16px; letter-spacing: -.02em; }
.panel-head p { max-width: 620px; margin: 4px 0 0; }
.panel-head a { color: var(--brand); font-size: 13px; font-weight: 800; }
.panel-head > .muted { white-space: nowrap; }

.status-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; padding: 15px 18px; border-radius: var(--radius-md); }
.status-card.is-ok { border-color: #bce2ca; background: var(--success-soft); }
.status-card.is-bad { border-color: #efcaca; background: var(--danger-soft); }
.status-card strong { display: block; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { position: relative; min-height: 132px; padding: 18px; border-radius: var(--radius-md); overflow: hidden; }
.stat::after { position: absolute; right: -16px; bottom: -28px; width: 92px; height: 92px; border-radius: 50%; background: var(--brand-soft); content: ""; }
.stat:nth-child(2)::after { background: #e7edf9; }
.stat:nth-child(3)::after { background: var(--warning-soft); }
.stat:nth-child(4)::after { background: #f5eafa; }
.stat span { display: block; max-width: 140px; color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.stat strong { position: absolute; bottom: 15px; font-family: "DM Mono", monospace; font-size: 31px; font-weight: 500; letter-spacing: -.06em; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.analytics-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 16px; margin-bottom: 16px; }
.chart-panel { min-height: 302px; }
.event-chart { display: flex; align-items: flex-end; gap: 8px; min-height: 208px; padding: 15px 4px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.event-chart > .empty { width: 100%; align-self: center; }
.event-bar { display: grid; flex: 1 0 34px; grid-template-rows: 20px 1fr 20px; align-items: end; gap: 6px; min-width: 34px; height: 205px; text-align: center; }
.event-bar-value { overflow: hidden; color: var(--ink-soft); font-family: "DM Mono", monospace; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.event-bar i { display: block; width: 100%; min-height: 5px; border-radius: 7px 7px 2px 2px; background: linear-gradient(180deg, #52a97e, var(--brand)); }
.event-bar small { color: var(--ink-soft); font-family: "DM Mono", monospace; font-size: 9px; }
.rank-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.rank-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.rank-list li:last-child { border-bottom: 0; }
.rank-list span { display: grid; min-width: 0; gap: 2px; }
.rank-list strong, .rank-list small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list b { color: var(--brand); font-family: "DM Mono", monospace; font-size: 16px; font-weight: 500; }
.list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.list li { display: grid; gap: 3px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { padding-bottom: 0; border-bottom: 0; }
.empty { padding: 28px !important; color: var(--ink-soft); text-align: center; }

.table-tools { display: flex; justify-content: flex-end; margin: 0 0 12px; }
.table-tools .input { max-width: 340px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); -webkit-overflow-scrolling: touch; }
.table { width: 100%; min-width: 760px; border-collapse: collapse; }
.table th, .table td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { background: var(--surface-muted); color: var(--ink-soft); font-family: "DM Mono", monospace; font-size: 10px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfdfb; }
.table td strong { font-size: 13px; }
.table td small { display: block; margin-top: 2px; line-height: 1.45; }
.actions, .inline-form { white-space: nowrap; }
.inline-form { display: inline-block; margin: 0 4px 0 0; }
.actions .btn + .btn { margin-left: 4px; }
.table tr[hidden] { display: none; }
.registration-table .registration-person { width: 33%; }
.registration-table .registration-business { width: 31%; }
.registration-table .registration-status { width: 18%; }
.registration-table .registration-action { width: 18%; }
.registration-table td:nth-child(3), .registration-table td:nth-child(4) { white-space: nowrap; }

.btn, .icon-btn { min-height: 38px; border: 1px solid transparent; border-radius: 10px; cursor: pointer; font-weight: 800; transition: transform .16s ease, background .16s ease, border-color .16s ease; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 13px; }
.btn:hover, .icon-btn:hover { transform: translateY(-1px); }
.btn:focus-visible, .icon-btn:focus-visible, .input:focus-visible { outline: 3px solid rgba(23,107,77,.18); outline-offset: 2px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); }
.btn-ghost { border-color: var(--line); background: #fff; color: var(--ink); }
.btn-ghost:hover { border-color: #c5d2ca; background: var(--surface-muted); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #9e2f2f; }
.btn-sm { min-height: 32px; padding: 6px 10px; border-radius: 8px; font-size: 12px; }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; width: 38px; place-items: center; background: #fff; border-color: var(--line); color: var(--ink); }

.input { width: 100%; min-height: 42px; border: 1px solid #cfdad3; border-radius: 10px; background: #fff; color: var(--ink); padding: 10px 12px; outline: none; transition: border-color .16s ease, box-shadow .16s ease; }
.input:hover { border-color: #b6c6bc; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(23,107,77,.11); }
textarea.input { min-height: 96px; resize: vertical; }
.field { display: grid; gap: 6px; }
.field > span { color: #38473e; font-size: 12px; font-weight: 800; }
.field-help { margin-top: -1px; color: var(--ink-soft); font-size: 11px; line-height: 1.4; }
.field-full { grid-column: 1 / -1; }
.advanced-options { margin-top: 3px; color: var(--ink-soft); }
.advanced-options summary { cursor: pointer; font-weight: 800; }
.advanced-grid { margin-top: 14px; }
.code-value { font-family: "DM Mono", monospace; font-size: 12px; }
.pill { display: inline-flex; align-items: center; width: fit-content; min-height: 26px; padding: 4px 9px; border-radius: 999px; background: #eef2ef; color: #526057; font-size: 11px; font-weight: 800; text-transform: capitalize; }
.pill-ok { background: var(--success-soft); color: var(--success); }
.pill-warn { background: var(--warning-soft); color: var(--warning); }
.pill-bad { background: var(--danger-soft); color: var(--danger); }

.flash-stack { display: grid; gap: 8px; margin: 0 0 16px; }
.flash { display: flex; align-items: flex-start; gap: 9px; padding: 12px 14px; border: 1px solid; border-radius: 12px; font-weight: 700; }
.flash-success { border-color: #bee4cb; background: var(--success-soft); color: var(--success); }
.flash-error { border-color: #f0caca; background: var(--danger-soft); color: var(--danger); }

.modal { width: min(920px, calc(100vw - 24px)); max-height: min(760px, calc(100dvh - 24px)); border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow-y: auto; }
.modal::backdrop { background: rgba(11, 30, 21, .58); backdrop-filter: blur(2px); }
.modal-form { padding: 22px; }
.modal-head, .modal-actions { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.modal-head { margin-bottom: 18px; }
.modal-head h3 { margin: 0; font-size: 18px; letter-spacing: -.025em; }
.modal-head p { margin: 4px 0 0; }
.modal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.modal-actions { justify-content: flex-end; margin-top: 20px; }
.modal-small { width: min(540px, calc(100vw - 24px)); }
.android-release-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr); gap: 16px; }
.android-release-card { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 18px; padding: 24px; border: 1px solid #bce2ca; border-radius: var(--radius-lg); background: linear-gradient(135deg, #e9f7ef, #f8fcf9); }
.android-release-card h2 { margin: 2px 0 5px; font-size: 25px; letter-spacing: -.04em; }
.android-release-card p:not(.eyebrow) { margin: 0; color: var(--ink-soft); }
.android-release-card .btn, .android-release-card .pill { grid-column: 2; justify-self: start; }
.android-release-icon { display: grid; grid-row: span 2; width: 56px; height: 56px; place-items: center; border-radius: 18px; background: var(--brand); color: #fff; font-size: 28px; }
.android-release-note { align-self: stretch; }
.release-steps { display: grid; gap: 12px; margin: 0; padding-left: 21px; color: var(--ink-soft); }

.page-auth { background: #103327; }
.auth-shell { display: grid; min-height: 100vh; place-items: center; padding: 22px; background: radial-gradient(circle at 80% 18%, rgba(142, 207, 164, .19), transparent 24rem), radial-gradient(circle at 20% 80%, rgba(58, 142, 105, .22), transparent 26rem), #103327; }
.auth-card { width: min(100%, 432px); padding: 30px; border: 1px solid rgba(235,248,240,.18); border-radius: 24px; background: rgba(255,255,255,.97); box-shadow: 0 28px 80px rgba(0,0,0,.24); }
.auth-head { display: flex; align-items: center; gap: 12px; }
.auth-head h1 { margin: 0; font-size: 17px; letter-spacing: -.025em; }
.auth-head p { margin: 3px 0 0; color: var(--ink-soft); font-size: 12px; }
.auth-copy { margin: 27px 0 20px; }
.auth-copy h2 { margin: 0; font-size: 23px; letter-spacing: -.035em; }
.auth-copy p { margin: 6px 0 0; color: var(--ink-soft); }
.auth-form { display: grid; gap: 14px; }
.error-shell { display: grid; min-height: 100vh; place-items: center; padding: 22px; background: radial-gradient(circle at 75% 16%, rgba(142, 207, 164, .19), transparent 24rem), #103327; }
.error-card { width: min(100%, 440px); padding: 32px; border: 1px solid rgba(235,248,240,.18); border-radius: 24px; background: rgba(255,255,255,.98); box-shadow: 0 28px 80px rgba(0,0,0,.24); }
.error-card strong { display: block; margin: 8px 0 2px; color: var(--brand); font-family: "DM Mono", monospace; font-size: 42px; letter-spacing: -.08em; }
.error-card h1 { margin: 0; font-size: 24px; letter-spacing: -.035em; }
.error-card p:not(.eyebrow) { margin: 8px 0 22px; color: var(--ink-soft); }

.mobile-only { display: none; }
@media (max-width: 1080px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { position: fixed; z-index: 30; width: min(82vw, 300px); transform: translateX(-104%); transition: transform .22s ease; box-shadow: 18px 0 40px rgba(0,0,0,.18); }
    .sidebar.is-open { transform: translateX(0); }
    .overlay { position: fixed; z-index: 20; inset: 0; display: block; background: rgba(9,25,18,.5); opacity: 0; pointer-events: none; transition: opacity .22s ease; }
    .overlay.is-open { opacity: 1; pointer-events: auto; }
    .mobile-only { display: inline-grid; }
    .content { max-width: none; }
}
@media (max-width: 900px) {
    .content { padding: 24px; }
    .topbar { flex-wrap: wrap; }
    .topbar-heading { flex: 1 1 360px; }
    .topbar-actions { margin-left: auto; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2, .modal-grid, .analytics-grid { grid-template-columns: 1fr; }
    .android-release-grid { grid-template-columns: 1fr; }
    .field-full { grid-column: auto; }
}
@media (max-width: 640px) {
    .content { padding: 16px 14px 30px; }
    .topbar { flex-direction: column; align-items: stretch; gap: 14px; margin-bottom: 18px; }
    .topbar-heading { flex: auto; width: 100%; }
    .topbar h1 { font-size: 24px; }
    .topbar-actions { width: 100%; margin-left: 0; }
    .topbar-actions .btn { flex: 1 1 0; }
    .panel { padding: 15px; border-radius: 17px; }
    .panel-head { align-items: flex-start; }
    .stats-grid { grid-template-columns: 1fr; gap: 10px; }
    .stat { min-height: 104px; }
    .table-tools .input { max-width: none; }
    .table { min-width: 560px; }
    .table th, .table td { padding: 11px 12px; }
    .table td { font-size: 13px; }
    .status-card { align-items: flex-start; flex-direction: column; }
    .modal { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); border-radius: 18px; }
    .modal-form { padding: 17px; }
    .modal-actions .btn { flex: 1; }
    .auth-card { padding: 24px 20px; }
    .android-release-card { grid-template-columns: 1fr; padding: 19px; }
    .android-release-icon { grid-row: auto; }
    .android-release-card .btn, .android-release-card .pill { grid-column: auto; width: 100%; }
}

@media (max-width: 420px) {
    .content { padding-inline: 12px; }
    .topbar h1 { font-size: 22px; }
    .page-description { font-size: 13px; }
    .panel { padding: 13px; }
    .panel-head { flex-direction: column; gap: 5px; }
    .panel-head > .muted { white-space: normal; }
    .topbar-actions { display: grid; grid-template-columns: 1fr; }
    .topbar-actions .btn { width: 100%; }
    .modal-actions { flex-direction: column-reverse; }
    .modal-actions .btn { width: 100%; }
}
