/* Twash admin design system: plain CSS, self-hosted assets only (CSP: style-src/font-src 'self'). */

@font-face {
  font-family: "Google Sans";
  src: url("fonts/GoogleSans.ttf") format("truetype");
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Google Sans";
  src: url("fonts/GoogleSans-Italic.ttf") format("truetype");
  font-weight: 100 900; font-style: italic; font-display: swap;
}

/* ---- Tokens ----------------------------------------------------------- */
:root {
  color-scheme: light;
  /* brand */
  --primary: #2C74B3; --navy: #1B3A86; --sky: #7CC4EE; --ink-brand: #0F1B2D;
  --brand: var(--primary); --brand-dark: var(--navy); --brand-soft: #E7F1FA;
  --on-primary: #FFFFFF;
  /* surfaces + text */
  --bg: #EEF2F7; --surface: #FFFFFF; --surface-2: #F6F8FB; --surface-3: #EEF2F6;
  --card: var(--surface);
  --ink: #0F1B2D; --ink-2: #33415C; --muted: #6B7A90; --faint: #98A4B5;
  --line: #E6EBF1; --line-strong: #D3DBE5;
  --input-bg: #FFFFFF; --input-line: #D8E0EA;
  --dark-btn: #14171C; --dark-btn-hover: #2A2F37; --on-dark-btn: #FFFFFF;
  /* semantic tints */
  --accent: #F2B12C; --accent-soft: #FFF4DB; --accent-ink: #8A5A00;
  --red: #D23B30; --red-soft: #FDECEA; --red-ink: #B42318;
  --green: #17914F; --green-soft: #E5F6EC; --green-ink: #0F7A40;
  --violet: #7A4FE0; --violet-soft: #F0EBFE; --violet-ink: #6436CF;
  --blue: #2367C9; --blue-soft: #E7F0FC; --blue-ink: #1D5DB8;
  --gray-soft: #EEF1F5; --gray-ink: #4A5872;
  --shadow-sm: 0 1px 2px rgba(15, 27, 45, .05);
  --shadow: 0 1px 2px rgba(15, 27, 45, .04), 0 8px 24px rgba(15, 27, 45, .05);
  --shadow-lg: 0 24px 60px rgba(15, 27, 45, .18);
  --radius: 16px; --radius-sm: 10px; --radius-lg: 22px;
  --sidebar-w: 256px;
  font-family: "Google Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand: #5AA2E2; --brand-dark: #9CCBF2; --brand-soft: rgba(90, 162, 226, .16);
  --on-primary: #FFFFFF;
  --bg: #0A111D; --surface: #111B2B; --surface-2: #162236; --surface-3: #1C2A41;
  --ink: #E7EEF8; --ink-2: #C3CFDF; --muted: #8E9DB4; --faint: #64748B;
  --line: #213049; --line-strong: #2C3D5A;
  --input-bg: #0E1726; --input-line: #2C3D5A;
  --dark-btn: #E7EEF8; --dark-btn-hover: #FFFFFF; --on-dark-btn: #0F1B2D;
  --accent-soft: rgba(242, 177, 44, .16); --accent-ink: #F6C760;
  --red: #F06A60; --red-soft: rgba(240, 106, 96, .15); --red-ink: #FF8F86;
  --green: #3CC27A; --green-soft: rgba(60, 194, 122, .15); --green-ink: #5BD594;
  --violet-soft: rgba(150, 118, 240, .18); --violet-ink: #B9A2FF;
  --blue-soft: rgba(90, 162, 226, .17); --blue-ink: #8CC2F2;
  --gray-soft: rgba(148, 163, 184, .14); --gray-ink: #B3C0D3;
  --shadow-sm: none;
  --shadow: 0 1px 0 rgba(255, 255, 255, .02), 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
}

/* ---- Base ------------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.25; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 26px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
strong { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.hidden { display: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.ico { width: 20px; height: 20px; flex: 0 0 auto; display: inline-block; vertical-align: middle; }
.ico-sm { width: 16px; height: 16px; }
.accent-text { color: var(--brand); }

/* ---- Shell ------------------------------------------------------------ */
.shell { display: flex; gap: 16px; min-height: 100vh; padding: 16px; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 20px 14px; position: sticky; top: 16px; height: calc(100vh - 32px); overflow-y: auto; display: flex; flex-direction: column; box-shadow: var(--shadow-sm);
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 10px 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; font-size: 18px; }
.brand:hover { text-decoration: none; }
.brand-logo-side { display: block; width: 88px; height: auto; }
:root[data-theme="dark"] .brand-logo-side { background: #fff; border-radius: 12px; padding: 4px 8px; }
.brand-icon { width: 30px; height: 30px; border-radius: 8px; background: #fff; padding: 2px; object-fit: contain; vertical-align: middle; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: #fff; font-weight: 800; }
.brand-dark { color: var(--ink); }
.side-nav { display: flex; flex-direction: column; flex: 1; }
.nav-group { margin-top: 18px; }
.nav-group:last-child { margin-top: auto; padding-top: 18px; }
.nav-head { text-transform: uppercase; font-size: 11.5px; letter-spacing: .06em; color: var(--faint); margin: 0 10px 6px; font-weight: 500; }
.nav-link {
  display: flex; align-items: center; gap: 12px; width: 100%; color: var(--muted); padding: 9px 10px; border-radius: 12px; margin-bottom: 2px;
  font: inherit; font-size: 14.5px; background: none; border: 0; cursor: pointer; text-align: left; transition: background .15s, color .15s;
}
.nav-link .ico { color: var(--faint); transition: color .15s; }
.nav-link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-link:hover .ico { color: var(--ink-2); }
.nav-link.active { color: var(--ink); font-weight: 600; background: var(--brand-soft); }
.nav-link.active .ico { color: var(--brand); }
.nav-link-danger, .nav-link-danger .ico { color: var(--red); }
.nav-link-danger:hover { background: var(--red-soft); color: var(--red); }
.nav-link-danger:hover .ico { color: var(--red); }
.nav-logout { margin: 0; }
.nav-close, .nav-toggle { display: none; }
.nav-backdrop { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px; }

.topbar {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px 12px 24px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); position: sticky; top: 16px; z-index: 20; box-shadow: var(--shadow-sm);
}
.topbar-title { font-size: 17px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.top-search { margin-left: auto; position: relative; width: min(380px, 34vw); }
.top-search .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 18px; height: 18px; pointer-events: none; }
.top-search input[type=search] { margin: 0; padding: 10px 14px 10px 40px; border-radius: 999px; background: var(--surface-2); border-color: transparent; font-size: 13.5px; }
.top-search input[type=search]:focus { background: var(--input-bg); }
.topbar-tools { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 999px; border: 1px solid transparent; background: transparent;
  color: var(--ink-2); cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.when-dark { display: none; }
:root[data-theme="dark"] .when-dark { display: inline-flex; }
:root[data-theme="dark"] .when-light { display: none; }
.when-light, .when-dark { line-height: 0; }

.user-menu { position: relative; margin-left: 6px; }
.user-menu > summary { list-style: none; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 999px; cursor: pointer; }
.user-chip:hover { background: var(--surface-2); }
.user-chip .ico { color: var(--muted); }
.avatar {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 999px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--navy), var(--primary) 60%, var(--sky)); color: #fff; font-weight: 600; font-size: 14px; letter-spacing: .02em;
}
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-name { font-weight: 600; font-size: 14px; white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 12px; color: var(--muted); }
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 30;
}
.user-dropdown-head { display: flex; flex-direction: column; padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.user-dropdown form { margin: 0; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 10px; border: 0; background: none; font: inherit; color: var(--ink); cursor: pointer; text-align: left; }
.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-item-danger { color: var(--red); }
.menu-item-danger:hover { background: var(--red-soft); }

.content { padding: 8px 8px 32px; min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 4px 0 20px; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 600; }
.page-sub { margin: 4px 0 0; color: var(--muted); font-size: 14.5px; }
.page-sub:empty { display: none; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.page-actions:empty { display: none; }

@media (max-width: 1024px) {
  .shell { padding: 10px; gap: 0; }
  .sidebar {
    position: fixed; top: 10px; left: 10px; bottom: 10px; height: auto; z-index: 60; transform: translateX(calc(-100% - 20px));
    transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  .nav-open .sidebar { transform: none; }
  .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(10, 17, 29, .45); z-index: 50; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  .nav-close, .nav-toggle { display: inline-grid; }
  .topbar { top: 10px; padding: 8px 10px; gap: 8px; }
  .main { gap: 12px; }
}
@media (max-width: 760px) {
  .top-search { display: none; }
  .topbar-tools { margin-left: auto; }
  .user-meta, .user-chip > .ico { display: none; }
  .content { padding: 4px 2px 24px; }
  .page-head h1 { font-size: 22px; }
}

/* ---- Cards / grid ----------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow-sm); min-width: 0; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grid { display: grid; gap: 18px; }
.grid > .card { margin-bottom: 0; }
.grid + .card, .grid + .grid, .card + .grid { margin-top: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* KPI cards */
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); margin-bottom: 18px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm);
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "label chip" "value value" "meta meta"; align-items: start; column-gap: 10px; min-height: 124px;
}
.kpi .label { grid-area: label; color: var(--ink); font-size: 14.5px; font-weight: 500; }
.kpi .value { grid-area: value; font-size: 28px; font-weight: 600; margin-top: 14px; letter-spacing: -.01em; line-height: 1.1; overflow-wrap: anywhere; }
.kpi .kpi-meta, .kpi > .muted { grid-area: meta; margin-top: 4px; font-size: 12px; color: var(--muted); }
.kpi-chip { grid-area: chip; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); }
.kpi-chip .ico { width: 18px; height: 18px; }
.chip-green { background: var(--green-soft); color: var(--green-ink); }
.chip-violet { background: var(--violet-soft); color: var(--violet-ink); }
.chip-amber { background: var(--accent-soft); color: var(--accent-ink); }
.chip-red { background: var(--red-soft); color: var(--red-ink); }
.chip-sky { background: var(--blue-soft); color: var(--blue-ink); }
.kpi.kpi-accent .kpi-chip { background: var(--accent-soft); color: var(--accent-ink); }
.kpi.kpi-red .kpi-chip { background: var(--red-soft); color: var(--red-ink); }
.kpi.kpi-red .value { color: var(--red-ink); }

/* Table card toolbar: segmented tabs + search + filter */
.table-card { padding: 18px 20px 14px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; align-items: center; gap: 2px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg-item {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 10px; color: var(--muted); font-size: 14px; white-space: nowrap;
  border: 0; background: none; font: inherit; cursor: pointer;
}
.seg-item:hover { color: var(--ink); text-decoration: none; }
.seg-item.active { background: var(--surface); color: var(--brand); font-weight: 600; box-shadow: 0 1px 3px rgba(15, 27, 45, .1); }
:root[data-theme="dark"] .seg-item.active { background: var(--surface-3); color: var(--brand-dark); }
.seg-count { font-size: 11.5px; padding: 0 7px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-weight: 500; }
.seg-item.active .seg-count { background: var(--brand-soft); color: var(--brand); }
.search-field { position: relative; width: min(300px, 100%); margin: 0; }
.search-field .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 18px; height: 18px; pointer-events: none; }
.search-field input[type=search] { margin: 0; padding: 9px 12px 9px 40px; border-radius: 12px; }
.filter-panel { border: 1px dashed var(--line-strong); border-radius: 14px; padding: 14px 14px 4px; margin-bottom: 16px; background: var(--surface-2); }

/* ---- Tables ----------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 0 -2px; padding: 0 2px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; background: transparent; }
th, td { text-align: left; padding: 12px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 13.5px; color: var(--ink-2); font-weight: 500; background: var(--surface-2); border-bottom: 0; white-space: nowrap; }
thead th:first-child { border-radius: 12px 0 0 12px; }
thead th:last-child { border-radius: 0 12px 12px 0; }
thead th:only-child { border-radius: 12px; }
tbody tr:last-child td, table > tr:last-child td { border-bottom: 0; }
tr:hover td { background: var(--surface-2); }
thead tr:hover th { background: var(--surface-2); }
tfoot td { font-weight: 600; }
tr.selected td { background: var(--brand-soft); }
td .muted.small, td .small.muted { margin-top: 2px; }
.data-table td { padding-top: 14px; padding-bottom: 14px; }
.data-table td.id-cell, .id-cell { font-weight: 600; color: var(--ink); white-space: nowrap; }
.id-cell a { color: var(--ink); }
.id-cell a:hover { color: var(--brand); }
.cell-main { color: var(--ink); }
.cell-sub { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.check-col { width: 44px; padding-right: 0; }
.row-check {
  appearance: none; -webkit-appearance: none; width: 20px; height: 20px; border: 1.5px solid var(--line-strong); border-radius: 6px; margin: 0;
  display: inline-grid; place-items: center; cursor: pointer; background: var(--input-bg); vertical-align: middle;
}
.row-check:checked { background: var(--brand); border-color: var(--brand); }
.row-check:checked::after { content: ""; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.row-actions { display: inline-flex; align-items: center; gap: 2px; }
.row-actions form { margin: 0; display: inline; }
.act {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--muted); background: none; border: 0; cursor: pointer; padding: 0;
}
.act:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.act-danger:hover { background: var(--red-soft); color: var(--red); }
.act .ico { width: 19px; height: 19px; }
.empty-row td { text-align: center; color: var(--muted); padding: 32px 12px; }

/* ---- Forms ------------------------------------------------------------ */
form.inline { display: inline; }
label { display: block; font-weight: 500; font-size: 13.5px; color: var(--ink-2); margin-bottom: 12px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; flex-wrap: wrap; }
.req { color: var(--red); margin-left: 2px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=time], input[type=search], input[type=tel], input[type=url], input[type=file], select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--input-line); border-radius: 12px; font: inherit; color: var(--ink);
  background: var(--input-bg); transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type=file] { padding: 8px 10px; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 16px; height: 16px; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.form-grid { display: grid; gap: 4px 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; margin-bottom: 16px; }
.filters label { margin: 0; min-width: 150px; flex: 0 1 auto; }
.filters input, .filters select { margin-top: 4px; }
.card-head .filters { margin-bottom: 0; }
.help { font-weight: 400; color: var(--muted); font-size: 12.5px; }
p.help { margin-top: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 4px; margin: 0 0 12px; min-width: 0; }
legend { font-weight: 500; font-size: 13.5px; color: var(--ink-2); padding: 0 6px; }
details summary { cursor: pointer; color: var(--brand); margin: 6px 0; }
.form-foot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---- Buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s; line-height: 1.3;
}
.btn .ico { width: 18px; height: 18px; }
.btn:hover { text-decoration: none; border-color: var(--brand); color: var(--ink); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); border-radius: 999px; padding-left: 20px; padding-right: 20px; font-weight: 600; }
.btn-primary:hover { background: var(--navy); border-color: var(--navy); color: #fff; }
:root[data-theme="dark"] .btn-primary { background: #3B87CC; border-color: #3B87CC; }
:root[data-theme="dark"] .btn-primary:hover { background: #2C74B3; border-color: #2C74B3; }
.btn-secondary { border-radius: 999px; }
.btn-dark { background: var(--dark-btn); border-color: var(--dark-btn); color: var(--on-dark-btn); font-weight: 500; }
.btn-dark:hover { background: var(--dark-btn-hover); border-color: var(--dark-btn-hover); color: var(--on-dark-btn); }
.btn-accent { background: var(--sky); border-color: var(--sky); color: #0F1B2D; }
.btn-accent:hover { background: #A4D6F4; border-color: #A4D6F4; color: #0F1B2D; }
.btn-danger { background: var(--surface); border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--ink); }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 10px; }
.btn-sm.btn-primary { border-radius: 999px; padding-left: 13px; padding-right: 13px; }
.btn-lg { padding: 13px 20px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; justify-content: center; margin-top: 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---- Flash ------------------------------------------------------------ */
.flash { padding: 11px 14px; border-radius: 12px; margin-bottom: 16px; font-size: 14px; }
.flash ul { margin: 0; padding-left: 18px; }
.flash-ok { background: var(--green-soft); color: var(--green-ink); border: 1px solid transparent; }
.flash-err { background: var(--red-soft); color: var(--red-ink); border: 1px solid transparent; }

/* ---- Pills ------------------------------------------------------------ */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 500;
  background: var(--gray-soft); color: var(--gray-ink); white-space: nowrap; line-height: 1.5;
}
.pill-ok::before, .pill-warn::before, .pill-bad::before, .pill-dot::before, .pill[class*="st-"]::before {
  content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; flex: 0 0 auto;
}
.pill-role { background: var(--brand-soft); color: var(--brand-dark); }
.pill-ok { background: var(--green-soft); color: var(--green-ink); }
.pill-warn { background: var(--accent-soft); color: var(--accent-ink); }
.pill-bad { background: var(--red-soft); color: var(--red-ink); }
.pill-info { background: var(--blue-soft); color: var(--blue-ink); }
.st-pending_payment { background: var(--accent-soft); color: var(--accent-ink); }
.st-confirmed { background: var(--blue-soft); color: var(--blue-ink); }
.st-pickup_scheduled { background: var(--blue-soft); color: var(--blue-ink); }
.st-picked_up { background: var(--violet-soft); color: var(--violet-ink); }
.st-received { background: var(--violet-soft); color: var(--violet-ink); }
.st-price_approval { background: var(--accent-soft); color: var(--accent-ink); }
.st-processing { background: var(--brand-soft); color: var(--brand-dark); }
.st-ready { background: var(--green-soft); color: var(--green-ink); }
.st-balance_due { background: var(--red-soft); color: var(--red-ink); }
.st-out_for_delivery { background: var(--violet-soft); color: var(--violet-ink); }
.st-delivered { background: var(--green-soft); color: var(--green-ink); }
.st-completed { background: var(--gray-soft); color: var(--gray-ink); }
.st-cancelled { background: var(--red-soft); color: var(--red-ink); }
.st-on_hold { background: var(--accent-soft); color: var(--accent-ink); }
.st-disputed { background: var(--red-soft); color: var(--red-ink); }

/* ---- Pager ------------------------------------------------------------ */
.pager { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 14px; padding: 6px 8px 2px; }
.pager-info { color: var(--muted); font-size: 14px; }
.pager-pages { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pg {
  display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 500; font-size: 14px;
}
a.pg:hover { border-color: var(--brand); text-decoration: none; }
.pg.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pg.is-disabled { color: var(--faint); opacity: .6; }
.pg-gap { border-color: transparent; background: transparent; }

/* ---- Kanban ----------------------------------------------------------- */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 14px; align-items: flex-start; }
.kcol { flex: 0 0 264px; background: var(--surface-3); border-radius: var(--radius); padding: 12px; border: 1px solid var(--line); }
.kcol h3 { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin: 2px 4px 12px; }
.kcard { background: var(--surface); border-radius: 12px; padding: 12px; margin-bottom: 10px; border: 1px solid var(--line); border-left: 4px solid var(--brand); box-shadow: var(--shadow-sm); }
.kcard.pay-unpaid { border-left-color: var(--red); }
.kcard.pay-part { border-left-color: var(--accent); }
.kcard .row { display: flex; justify-content: space-between; gap: 6px; }
.kcard .acts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }

/* ---- Chat ------------------------------------------------------------- */
.chat-log { max-height: 520px; overflow-y: auto; padding: 4px; }
.msg { max-width: 75%; margin: 8px 0; padding: 10px 14px; border-radius: 16px 16px 16px 4px; background: var(--surface-3); }
.msg.from-admin { margin-left: auto; background: var(--brand-soft); border-radius: 16px 16px 4px 16px; }
.msg.from-system { margin: 8px auto; background: transparent; color: var(--muted); font-style: italic; text-align: center; }
.msg.internal { background: var(--accent-soft); border: 1px dashed var(--accent); }
.msg .meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.unread { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; font-weight: 600; text-align: center; }

pre.json { background: #0F1B2D; color: #D7E3F4; padding: 10px; border-radius: 10px; max-width: 520px; max-height: 260px; overflow: auto; font-size: 12px; margin: 0; white-space: pre-wrap; word-break: break-word; }
:root[data-theme="dark"] pre.json { background: #070C15; border: 1px solid var(--line); }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: inline-block; vertical-align: middle; margin: 2px; }
.intake-line { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }

/* ---- Login ------------------------------------------------------------ */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 32px 20px; background: var(--bg); }
.login-card {
  width: min(1200px, 100%); min-height: min(720px, calc(100vh - 64px)); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px;
  background: var(--surface); border-radius: 32px; padding: 14px; box-shadow: var(--shadow); border: 1px solid var(--line);
}
.login-hero {
  position: relative; border-radius: 22px; overflow: hidden; padding: 44px 48px; display: flex; flex-direction: column; justify-content: space-between; min-height: 520px;
  background:
    linear-gradient(200deg, rgba(124, 196, 238, .80) 0%, rgba(44, 116, 179, .78) 38%, rgba(27, 58, 134, .93) 72%, rgba(15, 27, 45, .96) 100%),
    url("img/login-laundry.jpg") center / cover no-repeat;
  color: #fff;
}
.login-logo-plate { align-self: flex-start; background: #fff; border-radius: 16px; padding: 8px 14px; box-shadow: 0 8px 24px rgba(15, 27, 45, .18); }
.login-logo-plate .brand-logo { display: block; width: 104px; height: auto; margin: 0; }
.login-headline { font-size: clamp(34px, 4vw, 52px); line-height: 1.08; font-weight: 500; letter-spacing: -.02em; margin: 0 0 22px; color: #fff; }
.login-headline span { color: var(--sky); }
.login-credit { position: absolute; right: 18px; bottom: 12px; margin: 0; font-size: 10.5px; color: rgba(255, 255, 255, .6); }
.login-form-wrap { display: grid; place-items: center; padding: 40px 48px; }
.login-form { width: min(460px, 100%); }
.login-form h1 { font-size: 34px; font-weight: 600; letter-spacing: -.02em; margin: 0 0 8px; }
.login-sub { margin: 0 0 26px; font-size: 15px; line-height: 1.55; }
.login-form label { font-size: 14.5px; color: var(--ink); margin-bottom: 18px; }
.login-form input[type=email], .login-form input[type=password], .login-form input[type=text] { padding: 14px 16px; margin-top: 8px; font-size: 15px; }
.pw-field { position: relative; display: block; }
.pw-field input { padding-right: 52px !important; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; display: grid; place-items: center;
  border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 10px;
}
.pw-toggle:hover { color: var(--ink); background: var(--surface-2); }
.pw-toggle .when-shown { display: none; }
.pw-toggle.is-shown .when-shown { display: inline-flex; }
.pw-toggle.is-shown .when-hidden { display: none; }
.pw-toggle span { line-height: 0; }
.login-form .btn-block { margin-top: 18px; }
.brand-logo { display: block; width: 170px; height: auto; margin: 0 auto 6px; }
@media (max-width: 900px) {
  .login-body { padding: 12px; place-items: start center; }
  .login-card { grid-template-columns: 1fr; min-height: 0; gap: 0; border-radius: 26px; padding: 10px; }
  .login-hero { min-height: 220px; padding: 22px 24px; }
  .login-headline { font-size: 30px; margin: 28px 0 8px; }
  .login-form-wrap { padding: 28px 14px 22px; }
  .login-form h1 { font-size: 26px; }
}

/* ---- App content ------------------------------------------------------ */
.content-layout { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
@media (max-width: 1180px) { .content-layout { grid-template-columns: 1fr; } }
.slot { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; background: var(--surface); }
.slot h3 { margin: 0; font-size: 15px; }
.slot-img { aspect-ratio: 1 / 1; background: var(--surface-3); border-radius: 12px; overflow: hidden; display: flex; align-items: center; justify-content: center; text-align: center; padding: 0; }
.slot-img img { width: 100%; height: 100%; object-fit: cover; }
.slot-img span { padding: 12px; font-size: 13px; }
.banner-img { max-width: 240px; }
.stack { display: flex; flex-direction: column; gap: 6px; }
.phone-card h2 { margin-top: 0; }
.phone { position: relative; width: 270px; height: 560px; margin: 8px auto 0; border: 10px solid #0F1B2D; border-radius: 38px; background: #fff; overflow: hidden; box-shadow: 0 10px 30px rgba(15, 27, 45, .18); color: #0F1B2D; }
.phone::before { content: ""; position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: 80px; height: 18px; border-radius: 10px; background: #0F1B2D; z-index: 2; }
.phone-slide { display: none; height: 100%; flex-direction: column; }
.phone-slide.is-current { display: flex; }
.phone-img { flex: 0 0 58%; background: #E7F1FA; overflow: hidden; }
.phone-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.phone-text { padding: 16px 18px; }
.phone-text h3 { margin: 0 0 8px; font-size: 24px; line-height: 1.15; color: #0F1B2D; }
.phone-text p { margin: 0; font-size: 13px; color: #6B7A90; }
.phone .accent-text { color: #2C74B3; }
.phone-dots { position: absolute; bottom: 16px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; }
.phone-dots .dot { width: 8px; height: 8px; border-radius: 999px; border: 0; padding: 0; background: #CBD3DD; cursor: pointer; }
.phone-dots .dot.is-current { width: 22px; background: #2C74B3; }

/* ---- Live riders ------------------------------------------------------ */
.live-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; }
@media (max-width: 900px) { .live-layout { grid-template-columns: 1fr; } }
.live-map { height: 560px; border-radius: var(--radius); border: 1px solid var(--line); }
.live-list ul.plain { list-style: none; margin: 0; padding: 0; }
.live-list li { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; border-radius: 8px; }
.live-list li:hover { background: var(--brand-soft); }
:root[data-theme="dark"] .leaflet-tile-pane { filter: brightness(.8) contrast(1.05) saturate(.85); }

/* ---- Misc components -------------------------------------------------- */
.person { display: inline-flex; align-items: center; gap: 10px; color: inherit; min-width: 0; }
a.person:hover { text-decoration: none; }
a.person:hover .cell-main { color: var(--brand); }
.status-bars td { padding: 10px 8px; border-bottom: 0; }
.status-bars tr:hover td { background: transparent; }
.bar-cell { width: 55%; }
progress.bar { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border: 0; border-radius: 999px; background: var(--surface-3); overflow: hidden; display: block; color: var(--brand); }
progress.bar::-webkit-progress-bar { background: var(--surface-3); border-radius: 999px; }
progress.bar::-webkit-progress-value { background: linear-gradient(90deg, var(--primary), var(--sky)); border-radius: 999px; }
progress.bar::-moz-progress-bar { background: linear-gradient(90deg, var(--primary), var(--sky)); border-radius: 999px; }
.section-title { font-size: 17px; margin: 0; }
select.select-inline { width: auto; margin: 0; padding: 9px 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 900px) {
  .login-logo-plate { padding: 6px 10px; border-radius: 12px; }
  .login-logo-plate .brand-logo { width: 78px; }
  .login-credit { font-size: 9.5px; }
}

/* ---- Fixes after visual review ---------------------------------------- */
.icon-btn.nav-toggle, .icon-btn.nav-close { display: none; }
@media (max-width: 1024px) { .icon-btn.nav-toggle, .icon-btn.nav-close { display: inline-grid; } }
.user-menu > summary { color: var(--ink); margin: 0; }
.toolbar-right { margin-left: auto; flex-wrap: nowrap; }
.search-field { flex: 0 1 300px; width: auto; min-width: 180px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.page-head-text { flex: 1 1 320px; min-width: 0; }
.page-actions { flex: 0 0 auto; }
@media (min-width: 761px) { .page-head { flex-wrap: nowrap; } }
.actions > input[type=text] { flex: 1 1 220px; width: auto; margin-top: 0; }
@media (max-width: 760px) {
  .toolbar-right { flex-wrap: wrap; margin-left: 0; width: 100%; }
  .search-field { flex: 1 1 200px; }
  .page-actions { width: 100%; }
}
img.avatar-img { object-fit: cover; background: var(--surface-3); padding: 0; display: inline-block; }
.avatar-xl { width: 96px; height: 96px; font-size: 32px; }
.profile-photo { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 16px; }
.profile-photo form { margin: 0; }
.user-dropdown-head { flex-direction: row; align-items: center; gap: 10px; }
.user-dropdown-head .user-meta { display: flex; }
form.form-foot { margin-top: 10px; }
.help .mono, p .mono { word-break: break-all; }
.col-name { min-width: 170px; }
@media (max-width: 760px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { min-height: 0; padding: 14px; }
  .kpi .label { font-size: 13px; }
  .kpi .value { font-size: 22px; margin-top: 10px; }
  .kpi-chip { width: 30px; height: 30px; }
}
