/* =====================================================================
   XCloudPhone Automation — Admin UI
   Dark polished theme · vanilla CSS · no build
   Sections: 1.tokens 2.reset 3.layout 4.sidebar/drawer 5.topbar
             6.cards/surfaces 7.metrics+charts 8.tables 9.forms
             10.buttons 11.toggles/switch 12.chips/pills/status
             13.toast 14.skeleton 15.notice 16.login 17.logs
             18.utilities 19.responsive 20.motion-prefs
   ===================================================================== */

/* 1. tokens ---------------------------------------------------------- */
:root {
    color-scheme: dark;

    /* surfaces */
    --bg: #0a0d12;
    --bg-grad: radial-gradient(1200px 600px at 80% -10%, rgba(38, 208, 124, .08), transparent 60%),
               radial-gradient(900px 500px at -10% 110%, rgba(97, 168, 255, .07), transparent 60%),
               #0a0d12;
    --panel: #11161d;
    --panel-2: #161d27;
    --panel-3: #1c2531;
    --glass: rgba(17, 22, 29, .72);
    --glass-strong: rgba(17, 22, 29, .9);

    /* lines */
    --line: rgba(255, 255, 255, .06);
    --line-strong: rgba(255, 255, 255, .12);

    /* text */
    --text: #f4f7fb;
    --text-2: #c7d0db;
    --muted: #8a96a4;
    --muted-2: #6b7682;

    /* brand / state */
    --accent: #26d07c;
    --accent-2: #57e5a0;
    --accent-soft: rgba(38, 208, 124, .14);
    --accent-line: rgba(38, 208, 124, .35);
    --blue: #61a8ff;
    --blue-soft: rgba(97, 168, 255, .14);
    --purple: #b388ff;
    --warn: #f2b84b;
    --warn-soft: rgba(242, 184, 75, .14);
    --danger: #ff5b63;
    --danger-soft: rgba(255, 91, 99, .14);

    /* gradients */
    --grad-accent: linear-gradient(135deg, #26d07c 0%, #61a8ff 100%);
    --grad-accent-soft: linear-gradient(135deg, rgba(38, 208, 124, .18), rgba(97, 168, 255, .14));
    --grad-warn: linear-gradient(135deg, #f2b84b, #ff8a5b);
    --grad-danger: linear-gradient(135deg, #ff5b63, #ff8a8e);

    /* radius */
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-xl: 20px;
    --r-pill: 999px;

    /* spacing scale */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 20px;
    --s-6: 24px;
    --s-7: 32px;
    --s-8: 48px;

    /* shadows */
    --sh-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --sh-md: 0 6px 18px rgba(0, 0, 0, .35);
    --sh-lg: 0 18px 48px rgba(0, 0, 0, .45);
    --sh-xl: 0 28px 80px rgba(0, 0, 0, .55);
    --glow-accent: 0 0 0 1px rgba(38, 208, 124, .35), 0 8px 32px rgba(38, 208, 124, .25);
    --glow-blue: 0 0 0 1px rgba(97, 168, 255, .3), 0 8px 32px rgba(97, 168, 255, .2);

    /* typography */
    --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", "Fira Code", Consolas, ui-monospace, monospace;
    --fs-xs: 11px;
    --fs-sm: 12px;
    --fs-md: 14px;
    --fs-lg: 16px;
    --fs-xl: 20px;
    --fs-2xl: 26px;
    --fs-3xl: 34px;

    /* easing */
    --ease-out: cubic-bezier(.2, .8, .2, 1);
    --ease-spring: cubic-bezier(.34, 1.56, .64, 1);

    /* layout */
    --sidebar-w: 248px;
    --topbar-h: 64px;
}

/* 2. reset ----------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    background: var(--bg-grad);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: var(--fs-md);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

img,
svg {
    display: block;
    max-width: 100%;
}

::selection {
    background: var(--accent-soft);
    color: var(--accent-2);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .08);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, .16);
}

.icon-sprite {
    display: none;
}

/* 3. layout ---------------------------------------------------------- */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
}

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

.page {
    padding: var(--s-6);
    display: grid;
    gap: var(--s-5);
    align-content: start;
    animation: pageIn .35s var(--ease-out) both;
}

.app-footer {
    margin-top: auto;
    padding: var(--s-5) var(--s-6);
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: var(--fs-sm);
    display: flex;
    justify-content: space-between;
    gap: var(--s-3);
    flex-wrap: wrap;
}

@keyframes pageIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 4. sidebar / drawer ------------------------------------------------ */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: linear-gradient(180deg, #0d1118 0%, #0a0d12 100%);
    border-right: 1px solid var(--line);
    padding: var(--s-5) var(--s-3);
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
    z-index: 40;
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-2) var(--s-2);
}

.brand-mark {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: var(--r-md);
    background: var(--grad-accent);
    color: #04120b;
    font-weight: 800;
    letter-spacing: -.02em;
    box-shadow: var(--glow-accent);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.brand-text strong {
    font-size: var(--fs-md);
    letter-spacing: -.01em;
}

.brand-text small {
    color: var(--muted);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: .12em;
}

.nav-group {
    display: grid;
    gap: var(--s-1);
}

.nav-group + .nav-group {
    margin-top: var(--s-2);
}

.nav-group-title {
    padding: 0 var(--s-3);
    margin: var(--s-2) 0 var(--s-1);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: var(--muted-2);
    font-weight: 700;
}

.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--s-3);
    min-height: 42px;
    padding: 0 var(--s-3);
    border-radius: var(--r-md);
    color: var(--text-2);
    font-weight: 500;
    transition: background .18s var(--ease-out), color .18s var(--ease-out), transform .18s var(--ease-out);
}

.nav-link svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: none;
}

.nav-link:hover {
    background: rgba(255, 255, 255, .04);
    color: var(--text);
}

.nav-link.active {
    background: var(--accent-soft);
    color: var(--accent-2);
}

.nav-link.active::before {
    content: "";
    position: absolute;
    left: -3px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 999px;
    background: var(--grad-accent);
    box-shadow: 0 0 12px rgba(38, 208, 124, .55);
}

.nav-link .nav-badge {
    margin-left: auto;
    font-size: var(--fs-xs);
    padding: 2px 7px;
    border-radius: var(--r-pill);
    background: rgba(255, 255, 255, .06);
    color: var(--muted);
}

.nav-link.active .nav-badge {
    background: var(--accent-soft);
    color: var(--accent-2);
}

.nav-divider {
    height: 1px;
    background: var(--line);
    margin: var(--s-2) 0;
}

.nav-footer {
    margin-top: auto;
    display: grid;
    gap: var(--s-1);
}

/* drawer overlay (mobile) */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s var(--ease-out);
    z-index: 39;
}

body.drawer-open .drawer-overlay {
    opacity: 1;
    pointer-events: auto;
}

/* 5. topbar ---------------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--topbar-h);
    padding: 0 var(--s-6);
    display: flex;
    align-items: center;
    gap: var(--s-4);
    background: var(--glass);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    border-bottom: 1px solid var(--line);
}

.topbar-leading {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    min-width: 0;
}

.hamburger {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-md);
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text);
    cursor: pointer;
    transition: background .18s var(--ease-out), border-color .18s var(--ease-out);
}

.hamburger:hover {
    background: rgba(255, 255, 255, .04);
    border-color: var(--line-strong);
}

.hamburger svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    color: var(--muted);
    font-size: var(--fs-sm);
    min-width: 0;
}

.breadcrumbs .sep {
    opacity: .5;
}

.breadcrumbs .current {
    color: var(--text);
    font-weight: 600;
}

.topbar h1 {
    margin: 0;
    font-size: var(--fs-xl);
    font-weight: 700;
    letter-spacing: -.01em;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-trailing {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--s-3);
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    padding: 6px 10px 6px 6px;
    border-radius: var(--r-pill);
    background: rgba(255, 255, 255, .04);
    border: 1px solid var(--line);
    color: var(--text-2);
    font-size: var(--fs-sm);
}

.user-chip .avatar {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: var(--grad-accent);
    color: #04120b;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 800;
}

.icon-btn {
    width: 38px;
    height: 38px;
    display: inline-grid;
    place-items: center;
    border-radius: var(--r-md);
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text-2);
    cursor: pointer;
    transition: background .18s var(--ease-out), color .18s var(--ease-out), border-color .18s var(--ease-out);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, .04);
    color: var(--text);
    border-color: var(--line-strong);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* 6. cards / surfaces ------------------------------------------------ */
.surface {
    position: relative;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: var(--s-5);
    box-shadow: var(--sh-sm);
}

.surface.narrow {
    max-width: 720px;
}

.surface.padded-lg {
    padding: var(--s-6);
}

.surface-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--s-4);
    margin-bottom: var(--s-4);
}

.surface-head h2,
.surface h2 {
    margin: 0 0 4px;
    font-size: var(--fs-lg);
    font-weight: 700;
    letter-spacing: -.01em;
}

.surface-head .muted,
.surface .muted {
    margin: 0;
    color: var(--muted);
    font-size: var(--fs-sm);
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    margin-bottom: var(--s-4);
    flex-wrap: wrap;
}

.hero-card {
    background: var(--grad-accent-soft), var(--panel);
    background-blend-mode: normal;
    border: 1px solid var(--accent-line);
    border-radius: var(--r-lg);
    padding: var(--s-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    flex-wrap: wrap;
    box-shadow: var(--sh-md);
    overflow: hidden;
    position: relative;
}

.hero-card::after {
    content: "";
    position: absolute;
    inset: -1px;
    pointer-events: none;
    background: radial-gradient(600px 220px at 100% 0%, rgba(97, 168, 255, .14), transparent 60%);
}

.hero-card .hero-text {
    position: relative;
    z-index: 1;
}

.hero-card h2 {
    margin: 0 0 4px;
    font-size: var(--fs-2xl);
    letter-spacing: -.02em;
}

.hero-card .hero-meta {
    display: flex;
    gap: var(--s-4);
    flex-wrap: wrap;
    color: var(--muted);
    font-size: var(--fs-sm);
}

.hero-card .hero-meta strong {
    color: var(--text);
}

.hero-actions {
    position: relative;
    z-index: 1;
    display: flex;
    gap: var(--s-2);
    flex-wrap: wrap;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--s-3);
}

.detail-grid > div {
    padding: var(--s-4);
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    display: grid;
    gap: var(--s-1);
    align-content: start;
}

.detail-grid span {
    color: var(--muted);
    font-size: var(--fs-sm);
}

.detail-grid strong,
.detail-grid code {
    font-size: var(--fs-md);
    word-break: break-word;
    line-height: 1.4;
}

.detail-grid code {
    font-family: var(--font-mono);
    color: var(--accent-2);
}

/* 7. metrics + charts ------------------------------------------------ */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--s-3);
}

.metric-card {
    position: relative;
    overflow: hidden;
    padding: var(--s-5);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    transition: transform .25s var(--ease-out), border-color .25s var(--ease-out), box-shadow .25s var(--ease-out);
}

.metric-card:hover {
    transform: translateY(-2px);
    border-color: var(--line-strong);
    box-shadow: var(--sh-md);
}

.metric-card .metric-head {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    color: var(--muted);
    font-size: var(--fs-sm);
    margin-bottom: var(--s-2);
}

.metric-card .metric-icon {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: var(--r-md);
    background: var(--accent-soft);
    color: var(--accent-2);
}

.metric-card.tone-blue .metric-icon { background: var(--blue-soft); color: var(--blue); }
.metric-card.tone-warn .metric-icon { background: var(--warn-soft); color: var(--warn); }
.metric-card.tone-danger .metric-icon { background: var(--danger-soft); color: var(--danger); }

.metric-card .metric-icon svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.metric-card strong {
    display: block;
    font-size: var(--fs-3xl);
    font-weight: 700;
    letter-spacing: -.02em;
    line-height: 1.1;
}

.metric-card .metric-foot {
    margin-top: var(--s-3);
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--s-2);
}

.metric-card .delta {
    font-size: var(--fs-xs);
    color: var(--muted);
}

.metric-card .delta.up { color: var(--accent-2); }
.metric-card .delta.down { color: var(--danger); }

.sparkline {
    width: 96px;
    height: 32px;
    overflow: visible;
}

.sparkline path.line {
    fill: none;
    stroke: var(--accent-2);
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sparkline path.area {
    fill: rgba(38, 208, 124, .18);
    stroke: none;
}

.metric-card.tone-blue .sparkline path.line { stroke: var(--blue); }
.metric-card.tone-blue .sparkline path.area { fill: rgba(97, 168, 255, .18); }
.metric-card.tone-warn .sparkline path.line { stroke: var(--warn); }
.metric-card.tone-warn .sparkline path.area { fill: rgba(242, 184, 75, .18); }
.metric-card.tone-danger .sparkline path.line { stroke: var(--danger); }
.metric-card.tone-danger .sparkline path.area { fill: rgba(255, 91, 99, .18); }

.charts-row {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: var(--s-3);
}

.chart-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: var(--s-5);
}

.chart-card h3 {
    margin: 0 0 var(--s-3);
    font-size: var(--fs-md);
    font-weight: 700;
}

.donut-wrap {
    display: flex;
    align-items: center;
    gap: var(--s-5);
    flex-wrap: wrap;
}

.donut {
    width: 168px;
    height: 168px;
    flex: none;
}

.donut .track {
    fill: none;
    stroke: rgba(255, 255, 255, .06);
    stroke-width: 14;
}

.donut .seg {
    fill: none;
    stroke-width: 14;
    stroke-linecap: butt;
    transition: stroke-dashoffset .6s var(--ease-out);
}

.donut-center {
    text-anchor: middle;
}

.donut-center .big {
    fill: var(--text);
    font-size: 24px;
    font-weight: 700;
}

.donut-center .small {
    fill: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .14em;
}

.legend {
    display: grid;
    gap: var(--s-2);
    flex: 1;
    min-width: 160px;
}

.legend-row {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    font-size: var(--fs-sm);
}

.legend-row .swatch {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex: none;
}

.legend-row .label {
    color: var(--muted);
}

.legend-row .val {
    margin-left: auto;
    font-weight: 700;
    color: var(--text);
}

.bars {
    display: grid;
    gap: var(--s-3);
}

.bar-row {
    display: grid;
    grid-template-columns: 110px 1fr auto;
    align-items: center;
    gap: var(--s-3);
    font-size: var(--fs-sm);
}

.bar-row .label {
    color: var(--muted);
}

.bar-track {
    position: relative;
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .05);
    overflow: hidden;
}

.bar-fill {
    position: absolute;
    inset: 0 auto 0 0;
    border-radius: inherit;
    background: var(--grad-accent);
    transition: width .8s var(--ease-out);
}

.bar-fill.warn { background: var(--grad-warn); }
.bar-fill.danger { background: var(--grad-danger); }

/* 8. tables ---------------------------------------------------------- */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--r-md);
    border: 1px solid var(--line);
    background: var(--panel-2);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

thead {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--panel-3);
}

th,
td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

tbody tr {
    transition: background .15s var(--ease-out);
}

tbody tr:hover {
    background: rgba(255, 255, 255, .02);
}

tbody tr:last-child td {
    border-bottom: 0;
}

th {
    color: var(--muted);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 700;
    user-select: none;
}

th[data-sortable] {
    cursor: pointer;
}

th[data-sortable]:hover {
    color: var(--text);
}

th[data-sortable] .sort-ind {
    display: inline-block;
    margin-left: 6px;
    opacity: .5;
    font-size: 10px;
    transition: transform .2s var(--ease-out);
}

th[data-sortable].sort-asc .sort-ind { opacity: 1; transform: rotate(180deg); }
th[data-sortable].sort-desc .sort-ind { opacity: 1; }

td code {
    font-family: var(--font-mono);
    background: rgba(255, 255, 255, .04);
    padding: 2px 7px;
    border-radius: 6px;
    font-size: var(--fs-sm);
    color: var(--text-2);
}

.copy-btn {
    background: transparent;
    border: 0;
    color: var(--muted);
    cursor: pointer;
    padding: 2px 4px;
    margin-left: 4px;
    border-radius: 4px;
    vertical-align: middle;
    transition: color .15s var(--ease-out), background .15s var(--ease-out);
}

.copy-btn:hover { color: var(--accent-2); background: rgba(255, 255, 255, .04); }
.copy-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; }

.empty-state {
    padding: var(--s-8) var(--s-5);
    text-align: center;
    color: var(--muted);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--s-3);
    opacity: .65;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
}

.empty-state h3 {
    margin: 0 0 4px;
    color: var(--text);
    font-size: var(--fs-md);
}

/* 9. forms ----------------------------------------------------------- */
label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: var(--fs-sm);
}

label > span {
    font-weight: 600;
    color: var(--text-2);
    letter-spacing: .01em;
}

label .help {
    font-size: var(--fs-xs);
    color: var(--muted-2);
    font-weight: 400;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    outline: none;
    transition: border-color .18s var(--ease-out), box-shadow .18s var(--ease-out), background .18s var(--ease-out);
}

input::placeholder,
textarea::placeholder {
    color: var(--muted-2);
}

input:hover,
select:hover,
textarea:hover {
    border-color: var(--line-strong);
}

input:focus,
select:focus,
textarea:focus,
.btn:focus-visible,
.icon-btn:focus-visible,
.nav-link:focus-visible,
.toggle:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(38, 208, 124, .2);
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a96a4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    padding-right: 36px;
}

.input-with-icon {
    position: relative;
}

.input-with-icon > svg.lead {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    stroke: var(--muted);
    fill: none;
    stroke-width: 2;
    pointer-events: none;
}

.input-with-icon > input {
    padding-left: 36px;
}

.input-with-icon .clear-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    border: 0;
    background: transparent;
    color: var(--muted);
    border-radius: 999px;
    cursor: pointer;
    display: none;
}

.input-with-icon.has-value .clear-btn {
    display: grid;
    place-items: center;
}

.input-with-icon .clear-btn:hover { color: var(--text); background: rgba(255, 255, 255, .05); }

.stack { display: grid; gap: var(--s-3); }
.stack-lg { display: grid; gap: var(--s-4); }

.row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s-4);
}

.filter-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--s-3);
    align-items: end;
}

.filter-bar > .actions {
    display: flex;
    gap: var(--s-2);
    align-items: end;
    justify-content: flex-end;
}

.inline-form {
    display: flex;
    align-items: center;
    gap: var(--s-2);
}

.inline-form input {
    min-width: 140px;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    flex-wrap: wrap;
    margin-bottom: var(--s-3);
}

.toolbar .grow { flex: 1; min-width: 220px; }
.toolbar .count { color: var(--muted); font-size: var(--fs-sm); }

.chip-input {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px;
    min-height: 42px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    align-items: center;
    transition: border-color .18s var(--ease-out), box-shadow .18s var(--ease-out);
}

.chip-input:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(38, 208, 124, .2);
}

.chip-input .chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px 3px 10px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-2);
    font-size: var(--fs-sm);
    border: 1px solid var(--accent-line);
}

.chip-input .chip button {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .2);
    color: inherit;
    border: 0;
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 11px;
    line-height: 1;
}

.chip-input input {
    flex: 1;
    min-width: 120px;
    border: 0;
    background: transparent;
    box-shadow: none;
    min-height: 30px;
    padding: 0 8px;
}

.chip-input input:focus {
    border: 0;
    box-shadow: none;
}

/* 10. buttons -------------------------------------------------------- */
.btn {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--panel-2);
    color: var(--text);
    cursor: pointer;
    font-weight: 600;
    letter-spacing: .01em;
    transition: transform .14s var(--ease-out), border-color .18s var(--ease-out), background .18s var(--ease-out), box-shadow .18s var(--ease-out), color .18s var(--ease-out);
}

.btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.btn:hover {
    border-color: var(--line-strong);
    background: var(--panel-3);
}

.btn:active {
    transform: translateY(1px);
}

.btn.primary {
    background: var(--grad-accent);
    color: #04120b;
    border-color: transparent;
    box-shadow: var(--glow-accent);
}

.btn.primary:hover {
    filter: brightness(1.05);
    border-color: transparent;
}

.btn.secondary {
    color: var(--accent-2);
    border-color: var(--accent-line);
    background: var(--accent-soft);
}

.btn.secondary:hover {
    background: rgba(38, 208, 124, .2);
    border-color: var(--accent);
}

.btn.ghost {
    background: transparent;
    border-color: var(--line);
    color: var(--text-2);
}

.btn.ghost:hover {
    color: var(--text);
}

.btn.danger {
    background: var(--grad-danger);
    color: #1a0506;
    border-color: transparent;
}

.btn.compact {
    min-height: 36px;
    padding: 6px 12px;
    font-size: var(--fs-sm);
}

.btn.block { width: 100%; }
.btn[disabled],
.btn.is-loading { opacity: .65; pointer-events: none; }

.btn .spinner {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* 11. toggles / switch ---------------------------------------------- */
.toggle-form { margin: 0; }

.switch {
    --w: 44px;
    --h: 24px;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    background: transparent;
    border: 0;
    color: var(--text-2);
    cursor: pointer;
    font-size: var(--fs-sm);
    font-weight: 700;
    letter-spacing: .04em;
}

.switch .track {
    width: var(--w);
    height: var(--h);
    border-radius: 999px;
    background: rgba(255, 91, 99, .25);
    border: 1px solid rgba(255, 91, 99, .4);
    position: relative;
    transition: background .2s var(--ease-out), border-color .2s var(--ease-out);
}

.switch .thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
    transition: left .22s var(--ease-spring), background .2s var(--ease-out);
}

.switch.on .track {
    background: rgba(38, 208, 124, .25);
    border-color: var(--accent-line);
}

.switch.on .thumb {
    left: 22px;
    background: var(--accent-2);
}

.switch .label-text {
    color: var(--muted);
}

.switch.on .label-text {
    color: var(--accent-2);
}

/* 12. chips / pills / status / status-dot --------------------------- */
.pill,
.status,
.chip-static {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 26px;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .04);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: var(--fs-sm);
    white-space: nowrap;
}

.pill.accent,
.status.active,
.status.ok {
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent-2);
}

.status.expired,
.status.error,
.status.offline {
    background: var(--danger-soft);
    border-color: rgba(255, 91, 99, .35);
    color: #ffb1b6;
}

.status.online {
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent-2);
}

.status.warn {
    background: var(--warn-soft);
    border-color: rgba(242, 184, 75, .35);
    color: #ffd584;
}

.status.unknown {
    background: rgba(255, 255, 255, .04);
    border-color: var(--line);
    color: var(--muted);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: currentColor;
    flex: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, .04);
}

.dot.pulse {
    position: relative;
}

.dot.pulse::after {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 999px;
    border: 2px solid currentColor;
    opacity: .6;
    animation: pulse 1.6s ease-out infinite;
}

@keyframes pulse {
    0%   { transform: scale(.8); opacity: .7; }
    80%  { transform: scale(2);  opacity: 0; }
    100% { opacity: 0; }
}

.ok { color: var(--accent-2); }
.bad { color: var(--danger); }

/* 13. toast --------------------------------------------------------- */
.toast-stack {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 80;
    display: grid;
    gap: 10px;
    width: min(360px, calc(100vw - 36px));
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    background: var(--glass-strong);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: var(--r-md);
    color: var(--text);
    box-shadow: var(--sh-lg);
    animation: toastIn .3s var(--ease-spring) both;
    overflow: hidden;
    position: relative;
}

.toast.leaving { animation: toastOut .25s var(--ease-out) forwards; }

.toast.success { border-left-color: var(--accent); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warn); }
.toast.info    { border-left-color: var(--blue); }

.toast .ic {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(255, 255, 255, .04);
    color: var(--accent-2);
    flex: none;
}

.toast.error .ic   { color: #ffb1b6; }
.toast.warning .ic { color: #ffd584; }
.toast.info .ic    { color: var(--blue); }

.toast .ic svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.2;
}

.toast .msg {
    font-size: var(--fs-sm);
    line-height: 1.45;
    word-break: break-word;
}

.toast .close {
    background: transparent;
    border: 0;
    color: var(--muted);
    cursor: pointer;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    display: grid;
    place-items: center;
}

.toast .close:hover { color: var(--text); background: rgba(255, 255, 255, .06); }

.toast .progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 100%;
    background: currentColor;
    opacity: .5;
    transform-origin: left center;
    animation: toastProgress var(--toast-dur, 4500ms) linear forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(8px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
    to { opacity: 0; transform: translateX(20px); }
}

@keyframes toastProgress {
    to { transform: scaleX(0); }
}

/* 14. skeleton ------------------------------------------------------- */
.skeleton {
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, .05);
    border-radius: 8px;
}

.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .07), transparent);
    transform: translateX(-100%);
    animation: shimmer 1.4s infinite;
}

@keyframes shimmer { to { transform: translateX(100%); } }

/* 15. notice (fallback no-JS) --------------------------------------- */
.notice {
    padding: 12px 14px;
    border-radius: var(--r-md);
    border: 1px solid var(--line);
    background: var(--panel-2);
    border-left: 3px solid var(--blue);
}

.notice.success { border-left-color: var(--accent); color: var(--accent-2); }
.notice.error   { border-left-color: var(--danger); color: #ffb1b6; }
.notice.warning { border-left-color: var(--warn); color: #ffd584; }

/* 16. login --------------------------------------------------------- */
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: var(--s-6);
    position: relative;
    overflow: hidden;
}

.auth-shell::before,
.auth-shell::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: .55;
    z-index: 0;
    pointer-events: none;
}

.auth-shell::before {
    width: 400px; height: 400px;
    top: -120px; left: -120px;
    background: radial-gradient(circle, rgba(38, 208, 124, .5), transparent 70%);
}

.auth-shell::after {
    width: 480px; height: 480px;
    bottom: -150px; right: -150px;
    background: radial-gradient(circle, rgba(97, 168, 255, .45), transparent 70%);
}

.login-card {
    position: relative;
    z-index: 1;
    width: min(440px, 100%);
    background: var(--glass-strong);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-xl);
    padding: 36px 32px;
    box-shadow: var(--sh-xl);
    display: grid;
    gap: var(--s-5);
    animation: pageIn .5s var(--ease-spring) both;
}

.login-card .login-brand {
    display: flex;
    align-items: center;
    gap: var(--s-3);
}

.login-card .login-brand .brand-mark {
    width: 48px;
    height: 48px;
    font-size: 18px;
}

.login-card h1 {
    margin: 0;
    font-size: var(--fs-2xl);
    letter-spacing: -.02em;
}

.caps-warning {
    display: none;
    margin-top: 6px;
    font-size: var(--fs-xs);
    color: var(--warn);
}

.caps-warning.show { display: block; }

/* 17. logs ----------------------------------------------------------- */
.log-toolbar {
    display: flex;
    gap: var(--s-2);
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: var(--s-3);
}

.log-toolbar .grow { flex: 1; min-width: 200px; }

.log-box {
    max-height: 620px;
    overflow: auto;
    padding: 0;
    background: #06090d;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: #c7d0db;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.55;
    margin: 0;
}

.log-box .log-line {
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 12px;
    padding: 2px 14px;
    border-left: 3px solid transparent;
}

.log-box .log-line:hover { background: rgba(255, 255, 255, .02); }
.log-box .log-line .ln { color: var(--muted-2); user-select: none; text-align: right; }
.log-box .log-line .txt { white-space: pre-wrap; word-break: break-word; }

.log-box .log-line.lvl-error   { border-left-color: var(--danger); color: #ffb1b6; }
.log-box .log-line.lvl-warn    { border-left-color: var(--warn); color: #ffd584; }
.log-box .log-line.lvl-info    { border-left-color: var(--blue); }
.log-box .log-line.lvl-success { border-left-color: var(--accent); color: var(--accent-2); }

.log-box .log-line.hidden { display: none; }

.log-empty {
    padding: var(--s-7);
    text-align: center;
    color: var(--muted);
}

/* 18. utilities ----------------------------------------------------- */
.eyebrow {
    margin: 0 0 4px;
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: var(--fs-xs);
    color: var(--muted);
    font-weight: 700;
}

.muted { color: var(--muted); }
.text-end { text-align: right; }
.row-actions { display: flex; gap: 6px; align-items: center; }
.divider { height: 1px; background: var(--line); margin: var(--s-3) 0; }
.flex-wrap { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
.hide { display: none !important; }

.kv-list {
    display: grid;
    gap: 8px;
}

.kv-list .kv {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 12px;
    padding: 8px 10px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    font-size: var(--fs-sm);
}

.kv-list .kv .k { color: var(--muted); }
.kv-list .kv .v { color: var(--text); word-break: break-word; font-family: var(--font-mono); font-size: 12.5px; }

.is-loading { opacity: .72; pointer-events: none; }

.summary-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--s-2);
    margin-bottom: var(--s-3);
}

.summary-row .stat {
    padding: 12px 14px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
}

.summary-row .stat span { color: var(--muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; }
.summary-row .stat strong { display: block; font-size: var(--fs-xl); margin-top: 2px; }

/* 19. responsive ---------------------------------------------------- */
@media (max-width: 1280px) {
    :root { --sidebar-w: 220px; }
}

@media (max-width: 1024px) {
    .app-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px;
        transform: translateX(-105%);
        transition: transform .26s var(--ease-out);
        box-shadow: var(--sh-xl);
    }

    body.drawer-open .sidebar {
        transform: translateX(0);
    }

    .hamburger {
        display: inline-flex;
    }

    .charts-row {
        grid-template-columns: 1fr;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .detail-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .summary-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .topbar {
        padding: 0 var(--s-4);
    }

    .topbar h1 {
        font-size: var(--fs-lg);
    }

    .breadcrumbs { display: none; }

    .page {
        padding: var(--s-4);
        gap: var(--s-4);
    }

    .hero-card {
        padding: var(--s-5);
    }

    .row {
        grid-template-columns: 1fr;
    }

    .user-chip span.name { display: none; }
}

@media (max-width: 480px) {
    .metrics-grid,
    .detail-grid,
    .summary-row {
        grid-template-columns: 1fr;
    }

    .surface {
        padding: var(--s-4);
    }

    .kv-list .kv {
        grid-template-columns: 1fr;
    }

    .filter-bar > .actions {
        justify-content: stretch;
    }

    .filter-bar > .actions .btn { flex: 1; }

    .toast-stack {
        right: 10px;
        left: 10px;
        bottom: 10px;
        width: auto;
    }
}

/* 20. motion prefs -------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}
