:root {
    --bg: #f4f7f6;
    --surface: #ffffff;
    --surface-soft: #f8faf9;
    --sidebar: #11291f;
    --sidebar-soft: #193b2d;
    --text: #17231e;
    --muted: #68766f;
    --border: #dfe7e3;
    --primary: #0d8b5f;
    --primary-dark: color-mix(in srgb, var(--primary), #000 20%);
    --primary-soft: color-mix(in srgb, var(--primary), #fff 89%);
    --secondary: #2878d0;
    --blue: var(--secondary);
    --blue-soft: color-mix(in srgb, var(--secondary), #fff 89%);
    --amber: #c57a12;
    --amber-soft: #fff5df;
    --red: #c43d45;
    --red-soft: #feedef;
    --violet: #7654c6;
    --violet-soft: #f1edfb;
    --shadow-sm: 0 1px 2px rgba(18, 41, 31, .04), 0 5px 18px rgba(18, 41, 31, .04);
    --shadow-lg: 0 24px 70px rgba(11, 34, 24, .19);
    --radius: 16px;
    --radius-sm: 10px;
    --sidebar-width: 258px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--text); background: var(--bg); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--primary-dark); text-decoration: none; }
a:hover { color: var(--primary); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(26px, 3vw, 36px); line-height: 1.12; letter-spacing: -.035em; }
h2 { margin-bottom: 4px; font-size: 18px; line-height: 1.25; letter-spacing: -.015em; }
h3 { margin-bottom: 4px; }
p { margin-bottom: 0; }
small { font-size: 12px; }
svg { display: block; }
[hidden] { display: none !important; }
.block { display: block; }
.muted { color: var(--muted); }
.text-green { color: var(--primary-dark) !important; }
.text-amber { color: var(--amber) !important; }
.text-red { color: var(--red) !important; }
.skip-link { position: fixed; z-index: 1000; top: -100px; left: 16px; padding: 10px 14px; border-radius: 8px; color: #fff; background: var(--primary); }
.skip-link:focus { top: 12px; }

/* Application frame */
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; z-index: 50; inset: 0 auto 0 0; display: flex; width: var(--sidebar-width); flex-direction: column; color: #e9f3ee; background: linear-gradient(180deg, #102a1f 0%, #0d2119 100%); box-shadow: 10px 0 32px rgba(12, 34, 24, .08); }
.brand { display: flex; align-items: center; gap: 12px; min-height: 78px; padding: 16px 20px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand:hover { color: #fff; }
.brand-mark { display: grid; width: 42px; height: 42px; place-items: center; flex: 0 0 auto; border-radius: 13px; color: #fff; background: linear-gradient(145deg, var(--primary), var(--primary-dark)); box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 8px 18px rgba(0,0,0,.16); }
.brand-mark svg { width: 25px; height: 25px; fill: currentColor; }
.brand-mark .brand-flame { fill: #bff2dd; }
.brand strong { display: block; font-size: 16px; line-height: 1.1; letter-spacing: -.01em; }
.brand small { display: block; margin-top: 4px; color: #9cc6b3; font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px 20px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
.nav-label { margin: 18px 10px 7px; color: #719785; font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.nav-label:first-child { margin-top: 3px; }
.nav-item { display: flex; align-items: center; gap: 11px; min-height: 42px; margin: 3px 0; padding: 7px 10px; color: #bad2c6; border: 1px solid transparent; border-radius: 10px; font-weight: 600; transition: .16s ease; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.055); }
.nav-item.is-active { color: #fff; border-color: color-mix(in srgb, var(--primary), transparent 70%); background: linear-gradient(90deg, color-mix(in srgb, var(--primary), transparent 62%), color-mix(in srgb, var(--primary), transparent 82%)); }
.nav-icon { display: grid; width: 28px; height: 28px; place-items: center; flex: 0 0 auto; color: #a8cfbd; border-radius: 8px; background: rgba(255,255,255,.07); font-size: 9px; font-weight: 900; letter-spacing: .04em; }
.is-active .nav-icon { color: #d9f8ea; background: rgba(49, 205, 137, .2); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 14px 15px; border-top: 1px solid rgba(255,255,255,.09); background: rgba(0,0,0,.08); }
.sidebar-user-copy { min-width: 0; flex: 1; }
.sidebar-user-copy strong, .sidebar-user-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-copy strong { color: #f2faf6; font-size: 12px; }
.sidebar-user-copy small { color: #85aa98; }
.sidebar-user .icon-button { color: #a8c5b7; border-color: rgba(255,255,255,.1); }
.app-main { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar { position: sticky; z-index: 30; top: 0; display: flex; align-items: center; gap: 14px; height: 72px; padding: 0 clamp(18px, 3vw, 36px); border-bottom: 1px solid rgba(218, 228, 223, .86); background: rgba(255,255,255,.88); backdrop-filter: blur(14px); }
.topbar-title { min-width: 0; flex: 1; }
.topbar-title small, .topbar-title strong { display: block; }
.topbar-title small { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.topbar-title strong { overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.menu-button { display: none; width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: #fff; cursor: pointer; }
.content { width: min(1600px, 100%); min-height: calc(100vh - 72px); margin: 0 auto; padding: 30px clamp(18px, 3vw, 38px) 54px; }
.sidebar-backdrop { display: none; }

/* Common controls */
.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border: 1px solid transparent; border-radius: 10px; font-weight: 750; line-height: 1.2; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, background .12s ease; }
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button:focus-visible, .icon-button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary), transparent 82%); outline-offset: 2px; }
.button-primary { color: #fff; background: linear-gradient(180deg, var(--primary), var(--primary-dark)); box-shadow: 0 7px 18px color-mix(in srgb, var(--primary), transparent 78%); }
.button-primary:hover { color: #fff; background: var(--primary-dark); box-shadow: 0 9px 24px color-mix(in srgb, var(--primary), transparent 72%); }
.button-secondary { color: #275044; border-color: #cfded7; background: #fff; }
.button-secondary:hover { color: var(--primary-dark); border-color: #a8cbbd; background: #fbfdfc; }
.button-ghost { color: var(--muted); background: transparent; }
.button-ghost:hover { color: var(--text); background: #edf2ef; }
.button-danger { color: #fff; background: var(--red); }
.button-danger:hover { color: #fff; background: #ad3038; }
.button-full { width: 100%; }
.button-compact { min-height: 36px; padding: 7px 13px; }
.button-small { min-height: 32px; padding: 6px 10px; border-radius: 8px; font-size: 12px; }
.button-large { min-height: 48px; }
.icon-button { display: inline-grid; width: 34px; height: 34px; place-items: center; padding: 0; border: 1px solid var(--border); border-radius: 9px; color: #53665d; background: transparent; cursor: pointer; }
.icon-button:hover { color: var(--primary-dark); background: var(--primary-soft); }
.icon-button.danger:hover { color: var(--red); border-color: #efc5c8; background: var(--red-soft); }
.heading-actions, .form-actions, .table-actions { display: flex; align-items: center; gap: 8px; }
.table-actions form { display: inline-flex; }
.form-actions { justify-content: flex-end; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; margin-bottom: 24px; }
.page-heading > div:first-child { max-width: 760px; }
.page-heading p:not(.eyebrow) { color: var(--muted); font-size: 15px; }
.eyebrow { margin-bottom: 7px; color: var(--primary); font-size: 10px; font-weight: 850; letter-spacing: .15em; text-transform: uppercase; }
.card { margin-bottom: 20px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.card-header { display: flex; min-height: 70px; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid #e7ece9; }
.card-header p { color: var(--muted); }
.card-header > a { font-size: 12px; font-weight: 750; }
.card-body { padding: 20px; }
.filter-card { padding: 14px; }
.filters { display: flex; align-items: flex-end; gap: 10px; }
.filters-wrap { flex-wrap: wrap; }
.filters-wrap .search-field { min-width: 260px; }
.search-field { display: flex; min-width: 240px; min-height: 40px; align-items: center; gap: 8px; flex: 1; padding: 0 12px; border: 1px solid #cedbd5; border-radius: 10px; background: #fff; }
.search-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary), transparent 90%); }
.search-field span { color: #7d9187; font-size: 18px; }
.search-field input { width: 100%; padding: 0; border: 0; outline: 0; background: transparent; }
.field { display: flex; min-width: 0; flex-direction: column; gap: 6px; }
.field > span, fieldset > legend { color: #3f5048; font-size: 12px; font-weight: 750; }
.field > small { color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #cedbd5; border-radius: 9px; color: var(--text); background: #fff; outline: 0; transition: border .12s, box-shadow .12s; }
.field textarea { min-height: 70px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary), transparent 90%); }
.field input::placeholder, .field textarea::placeholder { color: #9aa8a1; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 76px; }
.password-field button { position: absolute; inset: 50% 9px auto auto; padding: 4px 7px; transform: translateY(-50%); border: 0; border-radius: 6px; color: var(--primary-dark); background: var(--primary-soft); font-size: 10px; font-weight: 800; cursor: pointer; }
.inline-field { min-width: 150px; }
.inline-field > span { display: none; }
.input-prefix { display: flex; overflow: hidden; border: 1px solid #cedbd5; border-radius: 9px; background: #fff; }
.input-prefix:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary), transparent 90%); }
.input-prefix > span { display: grid; min-width: 43px; place-items: center; color: #4b6156; border-right: 1px solid var(--border); background: #f2f6f4; font-weight: 750; }
.input-prefix input { border: 0; border-radius: 0; box-shadow: none !important; }
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.segmented-field { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; border: 0; }
.segmented-field legend { width: 100%; margin-bottom: 1px; }
.segmented-field label { cursor: pointer; }
.segmented-field input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-field label span { display: block; padding: 9px 15px; border: 1px solid var(--border); border-radius: 9px; color: var(--muted); background: #fff; font-weight: 700; }
.segmented-field input:checked + span { color: var(--primary-dark); border-color: color-mix(in srgb, var(--primary), #fff 60%); background: var(--primary-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary), transparent 92%); }
.check-card { display: flex; align-items: flex-start; gap: 11px; padding: 13px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--surface-soft); }
.check-card input { width: 17px; height: 17px; margin-top: 2px; accent-color: var(--primary); }
.check-card span { display: block; }
.check-card strong, .check-card small { display: block; }
.check-card small { margin-top: 2px; color: var(--muted); }
.conditional-panel { padding: 14px; border: 1px dashed #bed3c9; border-radius: 10px; background: #f6faf8; }
.details-panel { border: 1px solid var(--border); border-radius: 10px; background: #fbfcfc; }
.details-panel summary { padding: 13px 15px; cursor: pointer; font-weight: 750; }
.details-panel summary small { margin-left: 5px; color: var(--muted); font-weight: 500; }
.details-content { padding: 0 15px 15px; }
.server-note { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid #cae5d9; border-radius: 10px; color: #416057; background: #f1faf6; font-size: 12px; }
.server-note > span { display: grid; width: 22px; height: 22px; place-items: center; flex: 0 0 auto; border-radius: 50%; color: #fff; background: var(--primary); font-weight: 800; }
.warning-box { padding: 13px; border: 1px solid #f0d399; border-radius: 10px; color: #704c18; background: var(--amber-soft); }
.warning-box p { margin-top: 3px; font-size: 12px; }
.context-box { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); }
.context-box > span { min-width: 110px; flex: 1; }
.context-box small, .context-box strong { display: block; }
.context-box small { color: var(--muted); }

/* Alerts and states */
.alert { display: flex; min-height: 48px; align-items: center; gap: 11px; margin-bottom: 18px; padding: 10px 13px; border: 1px solid; border-radius: 11px; }
.alert > span:first-child { display: grid; width: 25px; height: 25px; place-items: center; flex: 0 0 auto; border-radius: 50%; color: #fff; font-weight: 850; }
.alert p { flex: 1; }
.alert button { border: 0; color: inherit; background: transparent; font-size: 20px; cursor: pointer; }
.alert a { font-weight: 750; white-space: nowrap; }
.alert-success { color: #205b43; border-color: #b9e2ce; background: #ecfaf3; }
.alert-success > span:first-child { background: var(--primary); }
.alert-error { color: #7c2d33; border-color: #efc3c7; background: var(--red-soft); }
.alert-error > span:first-child { background: var(--red); }
.alert-warning { color: #72501b; border-color: #eed39d; background: var(--amber-soft); }
.alert-warning > span:first-child { background: var(--amber); }
.empty-state { display: grid; min-height: 250px; place-items: center; align-content: center; padding: 30px; text-align: center; }
.empty-state.compact { min-height: 190px; }
.empty-state > span { display: grid; width: 42px; height: 42px; place-items: center; margin-bottom: 10px; border-radius: 12px; color: var(--primary); background: var(--primary-soft); font-weight: 850; }
.empty-state p, .empty-table { color: var(--muted); }
.empty-table { padding: 28px 12px; text-align: center; }
.empty-inline { padding: 14px; color: var(--muted); text-align: center; }

/* Tables and badges */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 13px; color: #687870; background: #f7f9f8; font-size: 10px; font-weight: 850; letter-spacing: .055em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 13px; border-top: 1px solid #e8edea; vertical-align: middle; }
.density-compact td { padding-top: 8px; padding-bottom: 8px; }
.density-compact .card-header { min-height: 60px; padding-top: 13px; padding-bottom: 13px; }
.density-compact .content { padding-top: 22px; }
tbody tr:hover { background: #fbfdfc; }
.row-muted { opacity: .62; background: #fafafa; }
.money-cell { font-variant-numeric: tabular-nums; white-space: nowrap; }
.actions-column { width: 1%; text-align: right; }
.table-actions { justify-content: flex-end; white-space: nowrap; }
.badge { display: inline-flex; min-height: 23px; align-items: center; justify-content: center; padding: 3px 8px; border: 1px solid transparent; border-radius: 999px; font-size: 10px; font-weight: 820; letter-spacing: .025em; white-space: nowrap; }
.badge-green { color: var(--primary-dark); border-color: color-mix(in srgb, var(--primary), #fff 72%); background: var(--primary-soft); }
.badge-blue { color: #2865a7; border-color: #cbdff5; background: var(--blue-soft); }
.badge-amber { color: #9a5c08; border-color: #efd69f; background: var(--amber-soft); }
.badge-red { color: #a63138; border-color: #efc6ca; background: var(--red-soft); }
.badge-violet { color: #6544ac; border-color: #d9cdf2; background: var(--violet-soft); }
.badge-neutral { color: #5d6d65; border-color: #dce4e0; background: #f3f6f4; }
code { padding: 3px 6px; border-radius: 6px; color: #33584a; background: #edf3f0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.movement { font-weight: 850; font-variant-numeric: tabular-nums; }
.movement.positive { color: var(--primary-dark); }
.movement.negative { color: var(--red); }
.person-cell { display: flex; min-width: 170px; align-items: center; gap: 9px; }
.person-cell span:not(.avatar) { min-width: 0; }
.person-cell strong, .person-cell small { display: block; }
.person-cell small { max-width: 220px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.avatar { display: grid; width: 38px; height: 38px; place-items: center; flex: 0 0 auto; border-radius: 12px; color: #e8f7f0; background: #2b5b47; font-weight: 850; }
.avatar.small { width: 32px; height: 32px; border-radius: 9px; color: var(--primary-dark); background: var(--primary-soft); font-size: 12px; }

/* Dashboard */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 20px; }
.kpi-card { position: relative; min-width: 0; padding: 18px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.kpi-card::before { position: absolute; inset: 0 auto 0 0; width: 3px; content: ""; }
.kpi-card.accent-green::before { background: var(--primary); }
.kpi-card.accent-blue::before { background: var(--blue); }
.kpi-card.accent-amber::before { background: var(--amber); }
.kpi-card.accent-violet::before { background: var(--violet); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; font-weight: 700; }
.kpi-icon { display: grid; width: 31px; height: 31px; place-items: center; border-radius: 9px; color: var(--primary-dark); background: var(--primary-soft); font-size: 9px; font-weight: 900; }
.accent-blue .kpi-icon { color: var(--blue); background: var(--blue-soft); }
.accent-amber .kpi-icon { color: var(--amber); background: var(--amber-soft); }
.accent-violet .kpi-icon { color: var(--violet); background: var(--violet-soft); }
.kpi-card > strong { display: block; margin: 12px 0 3px; overflow: hidden; font-size: clamp(22px, 2.3vw, 29px); line-height: 1; letter-spacing: -.035em; text-overflow: ellipsis; white-space: nowrap; }
.kpi-card > p { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, .8fr); gap: 20px; }
.bar-chart { display: flex; height: 270px; align-items: flex-end; gap: 7px; padding: 35px 20px 20px; }
.bar-column { display: flex; height: 100%; min-width: 17px; flex: 1; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; }
.bar-fill { width: min(30px, 82%); min-height: 5px; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, var(--primary), var(--primary-dark)); transition: height .3s ease; }
.bar-value { color: var(--muted); font-size: 9px; }
.bar-column small { color: #7b8982; font-size: 9px; white-space: nowrap; }
.pending-card { align-self: start; }
.pending-row { display: flex; align-items: center; gap: 11px; padding: 15px 18px; color: var(--text); border-top: 1px solid #edf0ee; }
.pending-row:first-of-type { border-top: 0; }
.pending-row:hover { color: var(--text); background: #fbfdfc; }
.pending-row > span:nth-child(2) { min-width: 0; flex: 1; }
.pending-row strong, .pending-row small { display: block; }
.pending-row small { color: var(--muted); }
.pending-row b { font-size: 18px; }
.pending-icon { display: grid; width: 37px; height: 37px; place-items: center; flex: 0 0 auto; border-radius: 10px; font-size: 10px; font-weight: 900; }
.pending-icon.amber { color: var(--amber); background: var(--amber-soft); }
.pending-icon.green { color: var(--primary); background: var(--primary-soft); }
.pending-icon.blue { color: var(--blue); background: var(--blue-soft); }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.status-dot.online { background: #12a870; box-shadow: 0 0 0 3px #d5f3e6; }
.status-dot.offline { background: #a5aea9; box-shadow: 0 0 0 3px #edf0ee; }
.quick-actions { display: flex; gap: 9px; margin: -6px 0 20px; overflow-x: auto; scrollbar-width: none; }
.quick-actions::-webkit-scrollbar { display: none; }
.quick-actions a { display: inline-flex; min-width: 140px; align-items: center; gap: 9px; padding: 10px 12px; color: var(--text); border: 1px solid var(--border); border-radius: 11px; background: #fff; box-shadow: var(--shadow-sm); white-space: nowrap; }
.quick-actions a:hover { color: var(--primary-dark); border-color: #acd1c1; }
.quick-actions span { display: grid; width: 29px; height: 29px; place-items: center; border-radius: 8px; color: var(--primary); background: var(--primary-soft); font-size: 9px; font-weight: 900; }
.quick-actions strong { font-size: 12px; }
.operations-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 20px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow-sm); }
.operations-strip > div { padding: 14px 16px; border-left: 1px solid var(--border); }
.operations-strip > div:first-child { border-left: 0; }
.operations-strip small, .operations-strip strong { display: block; }
.operations-strip small { margin-bottom: 4px; color: var(--muted); }
.operations-strip strong { font-size: 17px; }
.operations-strip strong span { color: var(--muted); font-size: 12px; font-weight: 600; }
.rank-list { padding: 5px 18px 15px; }
.rank-list > a { display: flex; align-items: center; gap: 10px; padding: 11px 3px; color: var(--text); border-bottom: 1px solid #edf1ef; }
.rank-list > a:last-child { border-bottom: 0; }
.rank-list > a:hover strong { color: var(--primary-dark); }
.rank-list > a > span:nth-child(2) { min-width: 0; flex: 1; }
.rank-list strong, .rank-list small { display: block; }
.rank-list small { color: var(--muted); }
.rank-list b { font-size: 12px; white-space: nowrap; }
.rank-number { display: grid; width: 31px; height: 31px; place-items: center; flex: 0 0 auto; border-radius: 9px; color: var(--primary-dark); background: var(--primary-soft); font-weight: 850; }
.birthday-list .rank-number { color: var(--amber); background: var(--amber-soft); }
.horizontal-bars { display: flex; flex-direction: column; gap: 15px; padding: 20px; }
.horizontal-bars > div > span { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.horizontal-bars small { color: var(--muted); }
.horizontal-bars i { display: block; height: 8px; overflow: hidden; border-radius: 999px; background: #edf2ef; }
.horizontal-bars i b { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #32b585); }
.hour-bars { display: flex; height: 210px; align-items: flex-end; gap: 5px; padding: 22px 18px 15px; }
.hour-bars > div { display: flex; height: 100%; min-width: 12px; flex: 1; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px; }
.hour-bars > div > span { width: min(24px, 82%); min-height: 5px; border-radius: 5px 5px 2px 2px; background: linear-gradient(180deg, #5e9edf, var(--blue)); }
.hour-bars small { color: var(--muted); font-size: 9px; }

/* Sales */
.sale-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; gap: 20px; }
.sale-main { min-width: 0; }
.form-card { margin-bottom: 0; }
.card-header.numbered { justify-content: flex-start; }
.card-header.numbered > span { display: grid; width: 31px; height: 31px; place-items: center; flex: 0 0 auto; border-radius: 9px; color: var(--primary-dark); background: var(--primary-soft); font-weight: 850; }
.card-header.numbered.green > span { color: #fff; background: var(--primary); }
.sale-summary { position: sticky; top: 92px; margin: 0; }
.summary-sticky { padding: 21px; }
.summary-stock { display: flex; align-items: center; justify-content: space-between; margin: 18px 0; padding: 11px 12px; border: 1px solid var(--border); border-radius: 9px; color: var(--muted); background: var(--surface-soft); }
.summary-stock strong { color: var(--text); }
.totals { margin: 0 0 17px; }
.totals > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed #dfe6e2; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; font-weight: 750; font-variant-numeric: tabular-nums; }
.totals .discount dd { color: var(--primary); }
.totals .total { margin-top: 5px; padding: 14px 0; border-bottom: 0; }
.totals .total dt { color: var(--text); font-size: 16px; font-weight: 800; }
.totals .total dd { font-size: 24px; letter-spacing: -.03em; }
.sale-summary .button { margin-top: 10px; }
.voucher-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.voucher-option { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: #fff; }
.voucher-option:has(input:checked) { border-color: #92cfb5; background: var(--primary-soft); }
.voucher-option input { accent-color: var(--primary); }
.voucher-option strong, .voucher-option small { display: block; }
.voucher-option small { color: var(--muted); }

/* Inventory, cash, reports */
.inventory-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 15px; margin-bottom: 20px; }
.stock-card { padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow-sm); }
.stock-product { display: flex; align-items: center; gap: 12px; }
.stock-product h2 { margin: 0; }
.stock-product p { color: var(--muted); font-size: 12px; }
.stock-cylinder { display: grid; width: 45px; height: 52px; place-items: center; border: 3px solid #2c755a; border-radius: 12px 12px 8px 8px; color: #2c755a; background: var(--primary-soft); font-size: 9px; font-weight: 900; }
.stock-values { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0; }
.stock-values > div { padding: 12px; border-radius: 10px; background: #f3f7f5; }
.stock-values small, .stock-values strong { display: block; }
.stock-values small { color: var(--muted); }
.stock-values strong { margin-top: 4px; font-size: 25px; }
.commitment-strip, .empty-hero { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; padding: 15px 18px; border: 1px solid #eed49f; border-radius: var(--radius); background: var(--amber-soft); }
.commitment-strip > div, .empty-hero > div { flex: 1; }
.commitment-strip p, .empty-hero p { color: #775d36; }
.commitment-strip > a { font-weight: 800; }
.cash-hero { display: flex; min-height: 190px; align-items: center; justify-content: space-between; gap: 30px; margin-bottom: 20px; padding: clamp(22px, 4vw, 36px); border-radius: var(--radius); color: #eaf8f2; background: radial-gradient(circle at 80% 20%, rgba(45,180,127,.25), transparent 38%), linear-gradient(135deg, #123c2c, #0d2a20); box-shadow: 0 14px 35px rgba(15,51,38,.16); }
.cash-hero > div:first-child > p { margin: 19px 0 2px; color: #a6c8b8; }
.cash-hero > div:first-child > strong { display: block; font-size: clamp(34px, 5vw, 54px); line-height: 1; letter-spacing: -.04em; }
.cash-hero > div:first-child > small { display: block; margin-top: 12px; color: #92b8a7; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status-pill.open { color: #bdf2da; background: rgba(45,188,127,.16); }
.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: #39dc9a; box-shadow: 0 0 0 3px rgba(57,220,154,.13); }
.cash-hero-note { display: flex; max-width: 380px; align-items: flex-start; gap: 10px; padding: 15px; border: 1px solid rgba(255,255,255,.11); border-radius: 12px; color: #bad1c6; background: rgba(255,255,255,.055); }
.cash-hero-note > span { color: #5be0a7; }
.empty-hero { border-color: var(--border); background: #fff; box-shadow: var(--shadow-sm); }
.empty-hero p { color: var(--muted); }
.empty-hero-icon { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 13px; color: var(--primary); background: var(--primary-soft); font-size: 11px; font-weight: 900; }
.purchase-total { display: flex; align-items: center; justify-content: space-between; padding: 13px; border-radius: 10px; color: #315649; background: var(--primary-soft); }
.purchase-total strong { font-size: 20px; }
.report-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fise-report { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 20px; }
.fise-report > div { padding: 15px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-soft); }
.fise-report small, .fise-report strong { display: block; }
.fise-report small { color: var(--muted); }
.fise-report strong { margin-top: 5px; font-size: 22px; }
.report-note { margin: 0 20px 20px; }
.method-dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--primary); }

/* Settings and audit */
.section-tabs { position: sticky; z-index: 20; top: 82px; display: flex; gap: 5px; margin-bottom: 18px; padding: 6px; overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,.92); backdrop-filter: blur(10px); box-shadow: var(--shadow-sm); }
.section-tabs a { padding: 8px 13px; border-radius: 8px; color: var(--muted); font-size: 12px; font-weight: 750; white-space: nowrap; }
.section-tabs a:hover { color: var(--primary-dark); background: var(--primary-soft); }
.settings-section { scroll-margin-top: 145px; }
.settings-rule-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.rule-field { display: flex; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--border); border-radius: 10px; }
.rule-field > span { min-width: 0; flex: 1; }
.rule-field strong, .rule-field small { display: block; }
.rule-field small { margin-top: 3px; color: var(--muted); }
.rule-field select, .rule-field input { width: 130px; min-height: 38px; padding: 7px 9px; border: 1px solid #cedbd5; border-radius: 8px; background: #fff; }
.permission-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.permission-option { display: flex; align-items: flex-start; gap: 9px; padding: 11px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--surface-soft); }
.permission-option:has(input:checked) { border-color: #a8d7c3; background: var(--primary-soft); }
.permission-option input { margin-top: 3px; accent-color: var(--primary); }
.permission-option span { min-width: 0; }
.permission-option strong, .permission-option code { display: block; }
.permission-option strong { margin-bottom: 4px; font-size: 12px; }
.permission-option code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-list { padding: 4px 20px 20px; }
.audit-row { position: relative; display: flex; gap: 14px; padding: 18px 0; border-bottom: 1px solid #e8edea; }
.audit-row:last-child { border-bottom: 0; }
.audit-marker { width: 10px; height: 10px; margin-top: 6px; flex: 0 0 auto; border: 2px solid #fff; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.audit-main { min-width: 0; flex: 1; }
.audit-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.audit-title > span { color: var(--muted); font-size: 11px; white-space: nowrap; }
.audit-main > p { margin: 7px 0; }
.audit-meta { display: flex; flex-wrap: wrap; gap: 7px 18px; color: var(--muted); font-size: 11px; }
.audit-details { margin-top: 10px; }
.audit-details summary { color: var(--primary-dark); font-size: 11px; font-weight: 750; cursor: pointer; }
.audit-json { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 9px; }
.audit-json > div { min-width: 0; }
.audit-json small { color: var(--muted); font-weight: 750; }
.audit-json pre { max-height: 260px; margin: 5px 0 0; padding: 11px; overflow: auto; border-radius: 8px; color: #d9eee4; background: #173026; font-size: 10px; }

/* Profiles and printable sale detail */
.customer-profile-grid { grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr); }
.profile-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 0; padding: 8px 20px 20px; }
.profile-list > div { padding: 12px 0; border-bottom: 1px solid #edf1ef; }
.profile-list > div:nth-child(odd) { padding-right: 15px; }
.profile-list .wide { grid-column: 1 / -1; padding-right: 0 !important; }
.profile-list dt { color: var(--muted); font-size: 11px; }
.profile-list dd { margin: 3px 0 0; font-weight: 650; }
.profile-obligations { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 20px; }
.profile-obligations > div { padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); }
.profile-obligations span, .profile-obligations strong { display: block; }
.profile-obligations span { color: var(--muted); font-size: 11px; }
.profile-obligations strong { margin-top: 5px; font-size: 22px; }
.profile-obligations + .button { width: calc(100% - 40px); margin: 0 20px 20px; }
.sale-document { max-width: 1100px; margin-right: auto; margin-left: auto; }
.sale-document-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 25px; border-bottom: 1px solid var(--border); }
.sale-document-header h2 { font-size: 26px; }
.sale-document-header > div:first-child > span { color: var(--muted); }
.document-status { display: flex; align-items: flex-end; flex-direction: column; gap: 7px; }
.document-status small { color: var(--muted); font-weight: 800; letter-spacing: .12em; }
.void-banner { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 11px 25px; color: #8e3037; border-bottom: 1px solid #efc3c7; background: var(--red-soft); }
.document-parties { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; padding: 22px 25px; border-bottom: 1px solid var(--border); }
.document-parties small, .document-parties strong, .document-parties span { display: block; }
.document-parties small { margin-bottom: 5px; color: var(--muted); text-transform: uppercase; }
.document-parties span { margin-top: 3px; color: var(--muted); }
.document-table th:first-child, .document-table td:first-child { padding-left: 25px; }
.document-table th:last-child, .document-table td:last-child { padding-right: 25px; }
.document-summary { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 30px; padding: 25px; }
.document-notes > small { display: block; margin: 0 0 6px; color: var(--muted); font-weight: 800; text-transform: uppercase; }
.document-notes > p { margin-bottom: 20px; }
.document-totals { margin: 0; }
.movement-line { display: flex; align-items: center; gap: 10px; }
.movement-line > div { min-width: 0; }
.movement-line strong, .movement-line small { display: block; }
.movement-line small { color: var(--muted); }

/* Dialogs */
.modal { width: min(720px, calc(100% - 28px)); max-height: min(90vh, 900px); padding: 0; overflow: hidden; border: 0; border-radius: 17px; color: var(--text); background: #fff; box-shadow: var(--shadow-lg); }
.modal.modal-small { width: min(500px, calc(100% - 28px)); }
.modal::backdrop { background: rgba(9, 25, 18, .62); backdrop-filter: blur(3px); }
.modal-card { display: flex; max-height: min(90vh, 900px); flex-direction: column; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; padding: 20px 22px 17px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 21px; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: #fafbfa; }

/* Authentication and setup */
.auth-page, .setup-page, .error-page { min-height: 100vh; background: #edf3f0; }
.auth-layout { display: grid; min-height: 100vh; grid-template-columns: minmax(420px, 1.05fr) minmax(430px, .95fr); }
.auth-showcase { position: relative; display: grid; place-items: center; overflow: hidden; padding: 60px; color: #eaf7f1; background: radial-gradient(circle at 20% 15%, rgba(51,202,140,.28), transparent 28%), radial-gradient(circle at 85% 80%, rgba(55,139,103,.2), transparent 35%), linear-gradient(145deg, #0e3728, #0a2219); }
.auth-showcase::after { position: absolute; width: 500px; height: 500px; right: -220px; bottom: -250px; border: 1px solid rgba(255,255,255,.09); border-radius: 50%; box-shadow: 0 0 0 70px rgba(255,255,255,.025), 0 0 0 140px rgba(255,255,255,.018); content: ""; }
.auth-showcase-inner { position: relative; z-index: 1; width: min(570px, 100%); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: clamp(55px, 10vh, 110px); }
.auth-brand strong { font-size: 18px; }
.auth-showcase .eyebrow { color: #62d7a8; }
.auth-showcase h1 { max-width: 560px; margin-bottom: 18px; font-size: clamp(42px, 5vw, 66px); letter-spacing: -.05em; }
.auth-showcase h1 + p { max-width: 560px; color: #aecabd; font-size: 17px; }
.auth-features { display: flex; flex-wrap: wrap; gap: 9px 18px; margin-top: 35px; color: #cae3d7; font-size: 12px; font-weight: 700; }
.auth-panel { display: grid; place-items: center; padding: 40px; background: #f7faf8; }
.auth-card { width: min(430px, 100%); padding: 35px; border: 1px solid var(--border); border-radius: 20px; background: #fff; box-shadow: 0 20px 60px rgba(19,51,37,.09); }
.auth-card h2 { margin-bottom: 8px; font-size: 29px; }
.auth-card > .muted { margin-bottom: 24px; }
.auth-card .alert { margin-top: 18px; }
.auth-note { margin-top: 21px; color: var(--muted); font-size: 11px; text-align: center; }
.setup-wrap { display: grid; width: min(1180px, calc(100% - 34px)); min-height: 100vh; grid-template-columns: .8fr 1.2fr; align-items: center; gap: clamp(30px, 6vw, 80px); margin: auto; padding: 45px 0; }
.setup-intro { padding: 20px; }
.setup-intro .auth-brand { margin-bottom: 52px; }
.setup-intro h1 { max-width: 480px; }
.setup-intro > p:not(.eyebrow) { max-width: 480px; color: var(--muted); font-size: 16px; }
.setup-steps { margin: 35px 0 0; padding: 0; list-style: none; counter-reset: setup; }
.setup-steps li { position: relative; display: flex; flex-direction: column; min-height: 60px; margin-left: 17px; padding: 2px 0 20px 37px; border-left: 1px solid #bfd2c9; counter-increment: setup; }
.setup-steps li:last-child { border-left-color: transparent; }
.setup-steps li::before { position: absolute; left: -16px; top: -2px; display: grid; width: 31px; height: 31px; place-items: center; border-radius: 50%; color: #fff; background: var(--primary); content: counter(setup); font-size: 11px; font-weight: 850; }
.setup-steps span { color: var(--muted); }
.setup-card { padding: clamp(25px, 4vw, 40px); border: 1px solid var(--border); border-radius: 22px; background: #fff; box-shadow: 0 22px 70px rgba(18,52,37,.1); }
.setup-card h2 { margin-bottom: 23px; font-size: 28px; }
.error-page { display: grid; place-items: center; padding: 20px; }
.error-card { width: min(560px, 100%); padding: 45px; border: 1px solid var(--border); border-radius: 20px; background: #fff; box-shadow: var(--shadow-lg); text-align: center; }
.error-code { display: inline-grid; min-width: 72px; height: 45px; place-items: center; margin-bottom: 19px; border-radius: 12px; color: var(--red); background: var(--red-soft); font-size: 20px; font-weight: 900; }
.error-card p { margin: 12px 0 24px; color: var(--muted); }

@media (max-width: 1180px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sale-layout { grid-template-columns: minmax(0, 1fr) 290px; }
    .report-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .permission-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .operations-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .operations-strip > div:nth-child(3) { border-top: 1px solid var(--border); border-left: 0; }
    .operations-strip > div:nth-child(4) { border-top: 1px solid var(--border); }
}

@media (max-width: 940px) {
    .sidebar { transform: translateX(-105%); transition: transform .2s ease; }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open { overflow: hidden; }
    .sidebar-backdrop { position: fixed; z-index: 45; inset: 0; background: rgba(8,25,17,.55); }
    body.sidebar-open .sidebar-backdrop { display: block; }
    .app-main { margin-left: 0; }
    .menu-button { display: inline-grid; place-items: center; }
    .dashboard-grid, .report-grid { grid-template-columns: 1fr; }
    .sale-layout { grid-template-columns: 1fr; }
    .sale-summary { position: static; }
    .auth-layout { grid-template-columns: 1fr; }
    .auth-showcase { display: none; }
    .auth-panel { min-height: 100vh; }
    .setup-wrap { grid-template-columns: 1fr; }
    .setup-intro { padding-bottom: 0; }
    .setup-intro .auth-brand { margin-bottom: 30px; }
    .setup-steps { display: none; }
}

@media (max-width: 680px) {
    body { font-size: 13px; }
    .topbar { height: 64px; padding: 0 14px; }
    .topbar-action { display: none; }
    .content { padding: 20px 12px 38px; }
    .page-heading { align-items: stretch; flex-direction: column; margin-bottom: 18px; }
    .heading-actions { flex-wrap: wrap; }
    .page-heading > .button, .page-heading > button { width: 100%; }
    .kpi-grid, .report-kpis { grid-template-columns: 1fr; gap: 10px; }
    .kpi-card > strong { font-size: 27px; }
    .filters { align-items: stretch; flex-direction: column; }
    .filters > * { width: 100%; }
    .search-field { min-width: 0; }
    .form-grid.two, .form-grid.three, .settings-rule-grid, .audit-json, .permission-grid { grid-template-columns: 1fr; }
    .voucher-picker { grid-template-columns: 1fr; }
    .card-header { align-items: flex-start; padding: 15px; }
    .card-body { padding: 15px; }
    .modal-body { padding: 17px; }
    .modal-header, .modal-footer { padding-left: 17px; padding-right: 17px; }
    .modal-footer { flex-wrap: wrap; }
    .modal-footer .button { flex: 1; }
    .cash-hero { align-items: flex-start; flex-direction: column; }
    .cash-hero-note { max-width: none; }
    .commitment-strip, .empty-hero { align-items: flex-start; flex-wrap: wrap; }
    .commitment-strip > a, .empty-hero > .button { width: 100%; }
    .rule-field { align-items: flex-start; flex-direction: column; }
    .rule-field select, .rule-field input { width: 100%; }
    .bar-chart { gap: 3px; padding-right: 9px; padding-left: 9px; }
    .bar-column small { writing-mode: vertical-rl; }
    .auth-panel { padding: 18px; }
    .auth-card { padding: 25px 20px; }
    .setup-wrap { width: min(100% - 22px, 700px); padding: 20px 0; }
    .setup-intro { padding: 10px; }
    .setup-card { padding: 22px 16px; }
    .operations-strip { grid-template-columns: 1fr; }
    .operations-strip > div { border-top: 1px solid var(--border); border-left: 0; }
    .operations-strip > div:first-child { border-top: 0; }
    .customer-profile-grid { grid-template-columns: 1fr; }
    .profile-list, .document-parties, .document-summary { grid-template-columns: 1fr; }
    .profile-list > div { padding-right: 0 !important; }
    .document-summary { gap: 10px; }
    .hour-bars { overflow-x: auto; }
    .hour-bars > div { min-width: 24px; }
}

@media print {
    .sidebar, .topbar, .page-heading .button, .filter-card, .section-tabs, .alert, .no-print { display: none !important; }
    .app-main { margin: 0; }
    .content { padding: 0; }
    .card, .kpi-card { break-inside: avoid; box-shadow: none; }
    .sale-document { max-width: none; border: 0; }
}
