@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("../fonts/plus-jakarta-sans.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  --navy-900: #0d2149;
  --navy-800: #122c63;
  --blue-700: #123a8c;
  --blue-600: #1d4fd8;
  --blue-500: #2f6bf0;
  --blue-100: #dfe9fd;
  --blue-50: #eef4ff;
  --grey-50: #f4f6fa;
  --grey-100: #eaeef5;
  --grey-200: #dde3ed;
  --grey-300: #c5cedc;
  --ink: #15233b;
  --ink-2: #47566e;
  --ink-3: #66748b;
  --white: #fff;
  --working: #166534;
  --working-bg: #dcfce7;
  --working-mark: #22a55a;
  --idle: #b42318;
  --idle-bg: #fee4e2;
  --idle-mark: #c5cedc;
  --warn-bg: #fff7e6;
  --warn: #92590a;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgb(13 33 73 / 6%);
  --shadow: 0 1px 2px rgb(13 33 73 / 5%), 0 6px 18px rgb(13 33 73 / 6%);
  --shadow-lg: 0 20px 50px rgb(13 33 73 / 25%);
  --ease: cubic-bezier(.2, .7, .3, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--grey-50);
  color: var(--ink);
  font: 400 15px/1.5 "Plus Jakarta Sans", "Noto Sans Gujarati", "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  word-spacing: .12em;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
a { color: var(--blue-600); }
small { font-size: 12.5px; }
code { font-size: .9em; background: rgb(13 33 73 / 7%); padding: 1px 5px; border-radius: 4px; }
mark { background: #ffe58a; color: inherit; border-radius: 3px; padding: 0 1px; }

:focus-visible { outline: 2px solid var(--blue-500); outline-offset: 2px; border-radius: 4px; }

.icon { width: 18px; height: 18px; flex: none; display: inline-block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

.container { width: min(1240px, 100%); margin-inline: auto; padding-inline: 24px; }

/* Wing identity colours — validated for colour-vision deficiency; always paired with an icon and name. */
.w-mahila { --wing: #7c3aed; --wing-tint: #f1eafe; }
.w-yuvati { --wing: #e0447c; --wing-tint: #fdeaf1; }
.w-yuvak  { --wing: #2563eb; --wing-tint: #e6eefd; }
.w-bal    { --wing: #d97706; --wing-tint: #fdf1de; }
.w-balika { --wing: #0d9488; --wing-tint: #dff5f2; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--grey-200); border-radius: var(--radius-sm);
  background: var(--white); color: var(--ink);
  font: 600 14px/1.2 inherit; font-family: inherit; text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .15s var(--ease);
}
.btn:hover { background: var(--grey-50); border-color: var(--grey-300); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn-primary { background: var(--blue-600); border-color: var(--blue-600); color: var(--white); box-shadow: 0 1px 2px rgb(29 79 216 / 30%); }
.btn-primary:hover { background: var(--blue-700); border-color: var(--blue-700); }
.btn-danger { background: #c4281c; border-color: #c4281c; color: var(--white); }
.btn-danger:hover { background: #a31f15; border-color: #a31f15; }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn-hero { background: rgb(255 255 255 / 12%); border-color: rgb(255 255 255 / 25%); color: var(--white); }
.btn-hero:hover { background: rgb(255 255 255 / 22%); border-color: rgb(255 255 255 / 40%); }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--ink-2); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--grey-100); color: var(--ink); }
.icon-btn.danger:hover { background: var(--idle-bg); color: var(--idle); }
.icon-btn-dark { color: #b8c6e3; }
.icon-btn-dark:hover { background: rgb(255 255 255 / 12%); color: var(--white); }

.brand-mark {
  display: inline-grid; place-items: center; width: 42px; height: 42px; flex: none;
  border-radius: 11px; background: linear-gradient(145deg, #3d7bf7, #1d4fd8); color: var(--white);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 25%), 0 3px 8px rgb(13 33 73 / 25%);
}
.brand-mark .icon { width: 22px; height: 22px; }

/* Forms */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > label, .field > .field-label { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.field .req { color: var(--idle); margin-left: 2px; }
input[type=text], input[type=search], input[type=number], input[type=password], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px;
  border: 1px solid var(--grey-300); border-radius: var(--radius-sm); background: var(--white); color: var(--ink);
  font: inherit; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 88px; }
input:hover, select:hover, textarea:hover { border-color: #a7b3c6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px rgb(47 107 240 / 18%); }
select {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2347566e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input-icon { position: relative; display: block; }
.input-icon > .icon { position: absolute; left: 12px; top: 12px; color: var(--ink-3); pointer-events: none; }
.input-icon > input { padding-left: 38px; }
.input-action {
  position: absolute; right: 4px; top: 4px; width: 34px; height: 34px;
  display: grid; place-items: center; border: 0; background: none; color: var(--ink-3); border-radius: 6px; cursor: pointer;
}
.input-action:hover { color: var(--ink); background: var(--grey-100); }
.input-icon:has(.input-action) > input { padding-right: 42px; }
.field-help { font-size: 12.5px; color: var(--ink-3); }
.field-error { font-size: 12.5px; color: var(--idle); font-weight: 500; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--idle); }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented label {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px;
  border: 1px solid var(--grey-300); border-radius: var(--radius-sm); font-weight: 600; font-size: 14px; color: var(--ink-2); cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:hover { background: var(--grey-50); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--blue-500); outline-offset: 2px; }
.segmented label.opt-working:has(input:checked) { background: var(--working-bg); border-color: var(--working-mark); color: var(--working); }
.segmented label.opt-non_working:has(input:checked) { background: var(--idle-bg); border-color: #e0776c; color: var(--idle); }

.alert { display: flex; gap: 10px; padding: 11px 13px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.alert .icon { margin-top: 1px; }
.alert-error { background: var(--idle-bg); color: #8f1c13; }
.alert-info { background: var(--blue-50); color: var(--blue-700); }

/* Login and setup */
.auth-page {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(900px 500px at 85% -10%, rgb(61 123 247 / 55%), transparent 60%),
    radial-gradient(700px 500px at -10% 110%, rgb(29 79 216 / 45%), transparent 60%),
    var(--navy-900);
}
.auth-card { width: min(420px, 100%); padding: 32px; background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: rise .35s var(--ease); }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .brand-mark { width: 52px; height: 52px; border-radius: 14px; margin-bottom: 14px; }
.auth-brand .brand-mark .icon { width: 26px; height: 26px; }
.auth-brand h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.auth-brand p { color: var(--ink-2); font-size: 14px; margin-top: 4px; }
.auth-back { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 18px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); text-decoration: none; }
.auth-back:hover { color: var(--blue-600); }
.auth-back .icon { width: 15px; height: 15px; }

/* Public header */
.hero {
  padding: 22px 0 92px;
  background:
    radial-gradient(800px 300px at 90% -40%, rgb(95 150 255 / 55%), transparent 70%),
    linear-gradient(120deg, var(--navy-900), var(--blue-700) 70%, #1b4fc4);
  color: var(--white);
}
.hero-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.hero-brand { display: flex; align-items: center; gap: 13px; color: inherit; text-decoration: none; min-width: 0; }
.hero-brand span:last-child { display: grid; min-width: 0; }
.hero-brand strong { font-size: 22px; font-weight: 700; letter-spacing: -.015em; line-height: 1.2; }
.hero-brand small { color: #c0d2f5; font-size: 13px; }
.public-main { margin-top: -68px; padding-bottom: 32px; }
.public-footer { padding-block: 0 28px; color: var(--ink-3); font-size: 13px; text-align: center; }

/* Summary cards */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-grid.five { grid-template-columns: repeat(5, 1fr); }
.stat-card {
  display: flex; align-items: flex-start; gap: 14px; padding: 18px;
  background: var(--white); border: 1px solid var(--grey-100); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgb(13 33 73 / 6%), 0 12px 26px rgb(13 33 73 / 9%); }
.stat-icon { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 11px; background: var(--blue-50); color: var(--blue-600); }
.stat-icon .icon { width: 22px; height: 22px; }
.stat-card.tone-good .stat-icon { background: var(--working-bg); color: var(--working); }
.stat-card.tone-bad .stat-icon { background: var(--idle-bg); color: var(--idle); }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13.5px; font-weight: 500; color: var(--ink-2); margin-top: 3px; }
.stat-note { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.skeleton { min-height: 92px; background: linear-gradient(100deg, var(--white) 30%, var(--grey-100) 50%, var(--white) 70%) 0 0 / 300% 100%; animation: shimmer 1.4s linear infinite; border-radius: var(--radius); box-shadow: var(--shadow-sm); }

/* Toolbar */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px;
  background: var(--white); border: 1px solid var(--grey-100); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 12px;
}
.toolbar .search { flex: 1 1 260px; }
.toolbar select { width: auto; flex: 0 1 190px; min-width: 150px; }
.toolbar .btn-group { display: flex; gap: 8px; margin-left: auto; }
.result-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 0 4px; margin-bottom: 12px; font-size: 13px; color: var(--ink-2); min-height: 24px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--blue-600); font: inherit; font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* Hierarchy tree */
.tree { display: grid; gap: 12px; }
.xetra-node { background: var(--white); border: 1px solid var(--grey-100); border-radius: var(--radius); box-shadow: var(--shadow-sm); transition: box-shadow .2s; }
.xetra-node:hover, .xetra-node.is-open { box-shadow: var(--shadow); }
.node-head { display: flex; align-items: center; gap: 4px; padding-right: 8px; }
.node-toggle {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 13px; padding: 14px;
  border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: var(--radius);
}
.node-actions { display: flex; gap: 2px; flex: none; }
.node-chevron { color: var(--ink-3); transition: transform .25s var(--ease); flex: none; }
.is-open > .node-head .node-chevron { transform: rotate(180deg); }

.xetra-head .node-icon { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 11px; background: var(--blue-600); color: var(--white); }
.xetra-head .node-icon .icon { width: 21px; height: 21px; }
.node-title { display: grid; min-width: 0; flex: 1; }
.node-title strong { overflow-wrap: anywhere; }
.xetra-head .node-title strong { font-size: 16.5px; font-weight: 700; letter-spacing: -.01em; }
.node-sub { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.node-sub .icon { width: 14px; height: 14px; color: var(--ink-3); }

.xetra-metrics { display: flex; align-items: center; gap: 22px; flex: none; margin-right: 8px; }
.metric { display: grid; text-align: right; }
.metric b { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; }
.metric span { font-size: 11.5px; color: var(--ink-3); }

.collapse { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .28s var(--ease); }
.is-open > .collapse { grid-template-rows: 1fr; }
.collapse-inner { overflow: hidden; min-height: 0; }

.village-list { padding: 2px 14px 14px 34px; display: grid; gap: 8px; position: relative; }
.village-list::before { content: ""; position: absolute; left: 34px; top: 0; bottom: 37px; width: 2px; background: var(--grey-200); border-radius: 2px; }
.village-empty { padding: 2px 14px 16px 69px; color: var(--ink-3); font-size: 14px; }
.village-node { position: relative; margin-left: 20px; border: 1px solid var(--grey-100); border-radius: var(--radius-sm); background: #fbfcfe; transition: border-color .15s, background .15s; }
.village-node::before { content: ""; position: absolute; left: -20px; top: 24px; width: 20px; height: 2px; background: var(--grey-200); }
.village-node:hover { border-color: var(--grey-200); }
.village-node.is-open { background: var(--white); border-color: var(--grey-200); }
.village-head .node-toggle { padding: 10px 12px; gap: 11px; }
.village-head .node-icon { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 8px; background: var(--blue-50); color: var(--blue-600); }
.village-head .node-icon .icon { width: 16px; height: 16px; }
.village-head .node-title strong { font-size: 14.5px; font-weight: 600; }

.wing-dots { display: flex; gap: 4px; flex: none; }
.wing-dot { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: var(--wing-tint); color: var(--wing); }
.wing-dot .icon { width: 13px; height: 13px; }
.wing-dot.off { background: var(--grey-100); color: #8a97ab; }
.village-count { flex: none; min-width: 66px; text-align: right; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.village-count b { color: var(--ink); font-weight: 700; }

.wing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(186px, 1fr)); gap: 10px; padding: 2px 12px 12px; }
.wing-card {
  position: relative; display: flex; flex-direction: column; gap: 10px; padding: 12px;
  border: 1px solid var(--grey-100); border-radius: var(--radius-sm); background: var(--white);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s;
}
.wing-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--grey-200); }
.wing-card.off { background: var(--grey-50); }
.wing-top { display: flex; align-items: center; gap: 9px; }
.wing-chip { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 9px; background: var(--wing-tint); color: var(--wing); }
.wing-chip .icon { width: 17px; height: 17px; }
.wing-name { font-size: 13.5px; font-weight: 700; line-height: 1.25; }
.wing-card .icon-btn { width: 30px; height: 30px; margin: -4px -4px -4px auto; }
.wing-card .icon-btn .icon { width: 15px; height: 15px; }
.wing-rows { display: grid; gap: 5px; font-size: 13px; }
.wing-row { display: flex; align-items: flex-start; gap: 6px; color: var(--ink-2); overflow-wrap: anywhere; min-width: 0; }
.wing-row .icon { width: 14px; height: 14px; margin-top: 3px; color: var(--ink-3); }
.wing-row b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.wing-row em { font-style: normal; color: var(--ink-3); }
.wing-remark { font-size: 12.5px; padding: 6px 8px; background: var(--warn-bg); color: var(--warn); border-radius: 6px; overflow-wrap: anywhere; }

.status-pill {
  display: inline-flex; align-items: center; gap: 4px; align-self: flex-start;
  padding: 2px 8px 2px 6px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.status-pill .icon { width: 13px; height: 13px; }
.status-working { background: var(--working-bg); color: var(--working); }
.status-non_working { background: var(--idle-bg); color: var(--idle); }

.empty-state { display: grid; justify-items: center; gap: 6px; padding: 48px 20px; text-align: center; background: var(--white); border: 1px dashed var(--grey-300); border-radius: var(--radius); color: var(--ink-2); }
.empty-state .empty-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--blue-50); color: var(--blue-600); margin-bottom: 6px; }
.empty-state .empty-icon .icon { width: 24px; height: 24px; }
.empty-state h3 { font-size: 16px; font-weight: 700; color: var(--ink); }
.empty-state .btn { margin-top: 10px; }

/* Dialogs */
dialog.modal {
  width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: var(--radius-lg);
  background: var(--white); color: var(--ink); box-shadow: var(--shadow-lg); overflow: auto;
}
dialog.modal[open] { animation: rise .24s var(--ease); }
dialog.modal::backdrop { background: rgb(13 33 73 / 50%); backdrop-filter: blur(3px); animation: fade .2s; }
.modal-head { display: flex; align-items: flex-start; gap: 13px; padding: 20px 20px 0; }
.modal-head .stat-icon { width: 42px; height: 42px; }
.modal-head.danger .stat-icon { background: var(--idle-bg); color: var(--idle); }
.modal-head > div { flex: 1; min-width: 0; }
.modal-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.modal-head p { font-size: 13.5px; color: var(--ink-2); margin-top: 2px; overflow-wrap: anywhere; }
.modal-body { padding: 18px 20px 4px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 8px 20px 20px; position: sticky; bottom: 0; background: var(--white); }

/* Toasts */
.toast-stack { position: fixed; z-index: 1000; top: 16px; right: 16px; display: grid; gap: 8px; width: min(360px, calc(100vw - 32px)); pointer-events: none; }
dialog .toast-stack { position: fixed; }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 13px; background: var(--white); color: var(--ink);
  border-radius: var(--radius-sm); box-shadow: 0 10px 30px rgb(13 33 73 / 18%); border: 1px solid var(--grey-100);
  font-size: 14px; font-weight: 500; pointer-events: auto; animation: slide-in .28s var(--ease); overflow-wrap: anywhere;
}
.toast.leaving { opacity: 0; transform: translateX(16px); transition: opacity .2s, transform .2s; }
.toast.success .icon { color: var(--working-mark); }
.toast.error .icon { color: var(--idle); }

/* Admin shell */
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40; width: 248px; display: flex; flex-direction: column; padding: 16px 12px;
  background: linear-gradient(180deg, var(--navy-900), var(--navy-800)); color: #d9e3f7; overflow-y: auto;
  transition: transform .26s var(--ease);
}
.side-brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; color: var(--white); text-decoration: none; }
.side-brand span:last-child { display: grid; }
.side-brand strong { font-size: 15.5px; font-weight: 700; line-height: 1.25; }
.side-brand small { color: #9fb3da; font-size: 12px; }
.sidebar nav { display: grid; gap: 2px; flex: 1; align-content: start; }
.nav-link {
  display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 8px 11px; border-radius: var(--radius-sm);
  color: #c3d1ec; text-decoration: none; font-size: 14px; font-weight: 500; transition: background .15s, color .15s;
}
.nav-link:hover { background: rgb(255 255 255 / 8%); color: var(--white); }
.nav-link[aria-current=page] { background: var(--blue-600); color: var(--white); font-weight: 600; box-shadow: 0 3px 10px rgb(0 0 0 / 22%); }
.nav-divider { height: 1px; background: rgb(255 255 255 / 12%); margin: 10px 4px; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 12px 8px 2px; margin-top: 12px; border-top: 1px solid rgb(255 255 255 / 12%); }
.side-user form { margin: 0; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 50%; background: rgb(255 255 255 / 12%); color: var(--white); }
.side-user-name { flex: 1; min-width: 0; display: grid; }
.side-user-name strong, .side-user-name small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user-name strong { font-size: 13.5px; color: var(--white); font-weight: 600; }
.side-user-name small { color: #9fb3da; font-size: 12px; }
.sidebar-backdrop { position: fixed; inset: 0; z-index: 35; background: rgb(13 33 73 / 50%); opacity: 0; pointer-events: none; transition: opacity .2s; }

.admin-shell { margin-left: 248px; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 10px 24px;
  background: rgb(255 255 255 / 92%); backdrop-filter: blur(8px); border-bottom: 1px solid var(--grey-100);
}
.topbar h1 { font-size: 19px; font-weight: 700; letter-spacing: -.01em; flex: 1; min-width: 0; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.menu-btn { display: none; }
.admin-main { padding: 20px 24px 40px; flex: 1; outline: none; animation: fade .2s; }

.panel { background: var(--white); border: 1px solid var(--grey-100); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 16px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 15px 16px 0; }
.panel-head h2 { font-size: 15.5px; font-weight: 700; }
.panel-head-table { padding-bottom: 13px; }
.panel-body { padding: 14px 16px 16px; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .k-working { background: var(--working-mark); }
.legend .k-idle { background: var(--idle-mark); }

.breakdown { display: grid; gap: 14px; }
.breakdown-row { display: grid; grid-template-columns: 172px minmax(80px, 1fr) 210px; align-items: center; gap: 14px; }
.breakdown-name { display: flex; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 600; min-width: 0; }
.breakdown-values { font-size: 13px; color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }
.breakdown-values b { color: var(--ink); font-weight: 700; }
.bar { display: flex; gap: 2px; height: 10px; width: 100%; border-radius: 4px; }
.bar-empty { background: var(--grey-100); border-radius: 4px; }
.seg { position: relative; min-width: 3px; height: 100%; transition: filter .15s; }
.seg:first-child { border-radius: 4px 0 0 4px; }
.seg:last-child { border-radius: 0 4px 4px 0; }
.seg:only-child { border-radius: 4px; }
.seg:hover { filter: brightness(.9); }
.seg.working { background: var(--working-mark); }
.seg.idle { background: var(--idle-mark); }
.seg::before { content: ""; position: absolute; inset: -8px 0; }
.seg::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  padding: 4px 8px; border-radius: 6px; background: var(--navy-900); color: var(--white); font-size: 12px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 2;
}
.seg:hover::after { opacity: 1; }
.rate { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.rate .bar { height: 8px; flex: 1; background: var(--grey-100); border-radius: 4px; }
.rate .fill { background: var(--working-mark); border-radius: 4px; height: 100%; }
.rate span { font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--ink-2); min-width: 34px; text-align: right; }

/* Tables */
.table-wrap { background: var(--white); border: 1px solid var(--grey-100); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow-x: auto; }
.panel .table-wrap { border: 0; box-shadow: none; border-radius: 0 0 var(--radius) var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { padding: 11px 14px; text-align: left; font-size: 12.5px; font-weight: 600; color: var(--ink-2); background: var(--grey-50); border-bottom: 1px solid var(--grey-100); white-space: nowrap; }
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--grey-100); vertical-align: middle; overflow-wrap: anywhere; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: #f8fafe; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.cell-actions { text-align: right; white-space: nowrap; width: 1%; }
.cell-strong { font-weight: 600; }
.cell-muted { color: var(--ink-3); }
.cell-name { display: flex; align-items: center; gap: 9px; }
.cell-sub { font-size: 12.5px; color: var(--ink-3); }
.row-remark { display: block; margin-top: 3px; font-size: 12.5px; color: var(--warn); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; font-size: 13px; color: var(--ink-2); border-top: 1px solid var(--grey-100); }
.pager > div { display: flex; gap: 8px; }

.switch { display: inline-flex; align-items: center; gap: 9px; border: 0; background: none; padding: 4px 0; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; color: var(--idle); white-space: nowrap; }
.switch .track { position: relative; width: 36px; height: 20px; flex: none; border-radius: 99px; background: var(--grey-300); transition: background .18s; }
.switch .track::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--white); box-shadow: 0 1px 2px rgb(0 0 0 / 25%); transition: transform .18s var(--ease); }
.switch[aria-checked=true] { color: var(--working); }
.switch[aria-checked=true] .track { background: var(--working-mark); }
.switch[aria-checked=true] .track::after { transform: translateX(16px); }
.switch[disabled] { opacity: .6; cursor: progress; }

.account-grid { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; font-size: 14px; margin-bottom: 16px; }
.account-grid dt { color: var(--ink-3); }
.account-grid dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.985); } }
@keyframes fade { from { opacity: 0; } }
@keyframes slide-in { from { opacity: 0; transform: translateX(20px); } }
@keyframes shimmer { to { background-position: -300% 0; } }

@media (max-width: 1180px) {
  .stat-grid.five { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .admin-shell { margin-left: 0; }
  .menu-btn { display: inline-grid; margin-left: -6px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .breakdown-row { grid-template-columns: 1fr auto; gap: 6px 12px; }
  .breakdown-row .bar { grid-column: 1 / -1; grid-row: 2; }
}

@media (max-width: 720px) {
  .container { padding-inline: 16px; }
  .hero { padding-bottom: 84px; }
  .hero-brand strong { font-size: 18px; }
  .hero-brand small { font-size: 12px; }
  .btn-hero { width: 42px; padding: 0; min-height: 42px; }
  .btn-hero span { display: none; }
  .topbar { padding: 10px 16px; min-height: 58px; }
  .topbar h1 { font-size: 17px; }
  .topbar .btn span { display: none; }
  .topbar .btn { width: 40px; padding: 0; }
  .admin-main { padding: 16px 16px 32px; }

  .stat-card { padding: 14px; gap: 11px; }
  .stat-icon { width: 38px; height: 38px; }
  .stat-icon .icon { width: 19px; height: 19px; }
  .stat-value { font-size: 23px; }
  .stat-label { font-size: 12.5px; }
  .stat-grid, .stat-grid.five { gap: 10px; }

  .toolbar select { flex: 1 1 140px; min-width: 0; }
  .toolbar .search { flex-basis: 100%; }
  .toolbar .btn-group { width: 100%; margin-left: 0; }
  .toolbar .btn-group .btn { flex: 1; }

  .xetra-head .node-toggle { flex-wrap: wrap; padding: 12px; gap: 10px; }
  .xetra-head .node-title { flex: 1 1 calc(100% - 90px); order: 1; }
  .xetra-head .node-icon { order: 0; width: 38px; height: 38px; }
  .xetra-head .node-chevron { order: 2; }
  .xetra-metrics { order: 3; width: 100%; justify-content: flex-start; margin: 0; padding-left: 48px; gap: 18px; }
  .metric { text-align: left; }

  .village-empty { padding: 0 14px 14px; }
  .village-list { padding: 0 10px 12px 18px; }
  .village-list::before { left: 18px; }
  .village-node { margin-left: 12px; }
  .village-node::before { left: -12px; width: 12px; }
  .village-head .node-toggle { flex-wrap: wrap; padding: 9px; }
  .village-head .node-title { flex: 1 1 calc(100% - 75px); order: 1; }
  .village-head .node-icon { order: 0; }
  .village-head .node-chevron { order: 2; }
  .wing-dots { order: 3; margin-left: 41px; }
  .village-count { order: 4; margin-left: auto; min-width: 0; }
  .node-head { padding-right: 4px; align-items: flex-start; }
  .node-actions { padding-top: 6px; }
  .node-actions .icon-btn { width: 32px; height: 32px; }

  .wing-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 2px 8px 8px; gap: 8px; }
  .wing-card { padding: 10px; }

  /* Tables become stacked cards */
  table.data thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr { padding: 8px 14px; border-bottom: 1px solid var(--grey-100); }
  table.data tbody tr:last-child { border-bottom: 0; }
  table.data td { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 5px 0; border: 0; text-align: right; }
  table.data td::before { content: attr(data-label); flex: none; font-size: 12.5px; font-weight: 500; color: var(--ink-3); text-align: left; }
  table.data td.cell-title { font-size: 15px; justify-content: flex-start; text-align: left; }
  table.data td.cell-title::before { display: none; }
  table.data td.cell-actions { width: 100%; justify-content: flex-end; }
  table.data td.cell-actions::before { display: none; }
  .row-remark { text-align: right; }
  .rate { flex: 1; max-width: 180px; }

  .auth-card { padding: 24px 20px; }
}

@media (max-width: 340px) {
  .wing-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
