/* =========================================================
   FlexFlow — base, tokens, layout, components
   Design language: Apple / macOS-iOS (SF type, system colours,
   vibrancy, hairlines, pill controls)
   ========================================================= */

/* ---------- tokens ---------- */
:root {
  /* Apple system colours — light */
  --primary: #0071e3;
  --primary-600: #0058b9;
  --primary-soft: rgba(0, 122, 255, .1);
  --success: #34c759;
  --success-soft: rgba(52, 199, 89, .13);
  --warn: #ff9500;
  --warn-soft: rgba(255, 149, 0, .14);
  --danger: #ff3b30;
  --danger-soft: rgba(255, 59, 48, .11);
  --info: #5ac8fa;
  --info-soft: rgba(90, 200, 250, .16);
  --indigo: #5856d6;
  --purple: #af52de;

  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #f0f0f2;
  --border: rgba(0, 0, 0, .07);
  --border-strong: #d2d2d7;
  --text: #1d1d1f;
  --text-2: #424245;
  --muted: #86868b;

  --sidebar-bg: rgba(246, 246, 248, .72);
  --chrome-bg: rgba(255, 255, 255, .72);

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --r-xl: 22px;
  --r-pill: 980px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow: 0 2px 10px rgba(0, 0, 0, .05);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .18), 0 2px 8px rgba(0, 0, 0, .06);
  --ring: 0 0 0 4px rgba(0, 122, 255, .26);
  --vibrancy: saturate(180%) blur(20px);

  --sidebar-w: 250px;
  --topbar-h: 60px;
  --fast: .2s cubic-bezier(.4, 0, .2, 1);
}

[data-theme="dark"] {
  /* Apple system colours — dark */
  --primary: #0a84ff;
  --primary-600: #0071e3;
  --primary-soft: rgba(10, 132, 255, .18);
  --success: #30d158;
  --success-soft: rgba(48, 209, 88, .16);
  --warn: #ff9f0a;
  --warn-soft: rgba(255, 159, 10, .16);
  --danger: #ff453a;
  --danger-soft: rgba(255, 69, 58, .16);
  --info: #64d2ff;
  --info-soft: rgba(100, 210, 255, .16);
  --indigo: #5e5ce6;
  --purple: #bf5af2;

  --bg: #000000;
  --surface: #1c1c1e;
  --surface-2: #222224;
  --surface-3: #2c2c2e;
  --border: rgba(255, 255, 255, .1);
  --border-strong: #48484a;
  --text: #f5f5f7;
  --text-2: #d1d1d6;
  --muted: #98989d;

  --sidebar-bg: rgba(28, 28, 30, .7);
  --chrome-bg: rgba(28, 28, 30, .72);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow: 0 2px 12px rgba(0, 0, 0, .5);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, .7);
  --ring: 0 0 0 4px rgba(10, 132, 255, .35);
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; padding: 0; }
h1, h2, h3, h4 { line-height: 1.12; font-weight: 600; letter-spacing: -.022em; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
::selection { background: rgba(0, 122, 255, .22); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, .22); border: 2.5px solid transparent; background-clip: content-box; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, .38); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .24); background-clip: content-box; }

.ic { width: 18px; height: 18px; flex: none; }
.ic--xs { width: 14px; height: 14px; }
.ic--lg { width: 22px; height: 22px; }
.only-mobile { display: none !important; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.tr { text-align: right; }
.tc { text-align: center; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
[hidden] { display: none !important; }

/* =========================================================
   layout
   ========================================================= */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--sidebar-bg);
  -webkit-backdrop-filter: var(--vibrancy);
  backdrop-filter: var(--vibrancy);
  color: var(--text-2);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 18px 18px 16px; }
.brand__mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(180deg, #0a84ff, #0056d6);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 60, 160, .35), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.brand__mark .ic { width: 19px; height: 19px; }
.brand__text { display: flex; flex-direction: column; line-height: 1.22; min-width: 0; }
.brand__text strong { color: var(--text); font-size: 15px; font-weight: 600; letter-spacing: -.02em; }
.brand__text small {
  font-size: 11px; color: var(--muted); letter-spacing: .01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.nav { flex: 1; overflow-y: auto; padding: 4px 10px 16px; }
.nav__label {
  font-size: 11px; letter-spacing: .01em; color: var(--muted);
  padding: 15px 10px 5px; font-weight: 600;
}
.nav__item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--r-sm); margin-bottom: 1px;
  font-weight: 450; font-size: 13.5px; color: var(--text);
  transition: background var(--fast), color var(--fast);
}
.nav__item .ic { color: var(--muted); transition: color var(--fast); }
.nav__item:hover { background: rgba(0, 0, 0, .045); }
[data-theme="dark"] .nav__item:hover { background: rgba(255, 255, 255, .06); }
.nav__item.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.nav__item.is-active .ic { color: var(--primary); }
.nav__badge {
  margin-left: auto; font-style: normal; font-size: 11.5px; font-weight: 600;
  background: var(--primary); color: #fff; padding: 0 6px; border-radius: 99px;
  min-width: 19px; text-align: center; line-height: 18px;
}
.nav__item.is-active .nav__badge { background: var(--primary); color: #fff; }

.sidebar__foot { padding: 12px; border-top: 1px solid var(--border); }
.usage {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 12px; box-shadow: var(--shadow-sm);
}
.usage__top { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--text-2); margin-bottom: 9px; font-weight: 500; }
.usage__hint { font-size: 11px; color: var(--muted); margin: 8px 0 10px; letter-spacing: 0; }
.bar { height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--primary); transition: width .5s cubic-bezier(.4, 0, .2, 1); }
.chip.chip--pro { background: linear-gradient(180deg, #0a84ff, #0064d2); color: #fff; border: 0; font-weight: 500; }

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

.topbar {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  background: var(--chrome-bg);
  -webkit-backdrop-filter: var(--vibrancy);
  backdrop-filter: var(--vibrancy);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.searchbox { position: relative; display: flex; align-items: center; gap: 9px; width: 100%; max-width: 340px; }
.searchbox > .ic { position: absolute; left: 9px; color: var(--muted); pointer-events: none; width: 16px; height: 16px; }
.searchbox input[type="search"] {
  width: 100%; padding: 7px 38px 7px 32px; -webkit-appearance: none; appearance: none;
  background: var(--surface-3); border: 1px solid transparent;
  border-radius: var(--r-sm); font-size: 13px; transition: var(--fast);
}
.searchbox input[type="search"]::placeholder { color: var(--muted); }
.searchbox input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.searchbox input[type="search"]:focus {
  background: var(--surface); border-color: var(--primary); box-shadow: var(--ring); outline: none;
}
.searchbox kbd {
  position: absolute; right: 8px; font-size: 11px; font-family: inherit; color: var(--muted);
  border: 1px solid var(--border-strong); border-radius: 5px; padding: 0 5px; background: var(--surface);
  line-height: 17px;
}
.searchbox__results {
  position: absolute; top: calc(100% + 9px); left: 0; right: 0; z-index: 50;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow-lg); padding: 6px; max-height: 340px; overflow-y: auto;
}
.sres { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--r-sm); width: 100%; text-align: left; }
.sres:hover, .sres:focus-visible { background: var(--primary); color: #fff; }
.sres:hover .muted, .sres:hover small { color: rgba(255, 255, 255, .8); }
.sres__meta { min-width: 0; }
.sres__meta strong { display: block; font-size: 13px; font-weight: 500; }
.sres__meta small { color: var(--muted); font-size: 11.5px; }
.sres__tag { margin-left: auto; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  color: var(--text-2); border: 1px solid transparent; position: relative; transition: var(--fast);
}
.icon-btn:hover { background: rgba(0, 0, 0, .055); color: var(--text); }
[data-theme="dark"] .icon-btn:hover { background: rgba(255, 255, 255, .09); }
.icon-btn .dot {
  position: absolute; top: 5px; right: 6px; width: 8px; height: 8px; border-radius: 99px;
  background: var(--danger); border: 1.5px solid var(--surface);
}
#themeBtn .ic--moon { display: none; }
[data-theme="dark"] #themeBtn .ic--sun { display: none; }
[data-theme="dark"] #themeBtn .ic--moon { display: block; }

.userbtn { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: var(--r-pill); transition: var(--fast); }
.userbtn:hover { background: rgba(0, 0, 0, .05); }
[data-theme="dark"] .userbtn:hover { background: rgba(255, 255, 255, .08); }
.userbtn__meta { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.userbtn__meta strong { font-size: 12.5px; font-weight: 500; }
.userbtn__meta small { font-size: 11px; color: var(--muted); }

.view { flex: 1; padding: 28px 26px 40px; max-width: 1560px; width: 100%; }
.view:focus { outline: none; }

.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 35; backdrop-filter: blur(2px); }

/* =========================================================
   popovers
   ========================================================= */
.pop { position: relative; }
.pop__panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60;
  min-width: 230px; background: var(--chrome-bg);
  -webkit-backdrop-filter: var(--vibrancy); backdrop-filter: var(--vibrancy);
  border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow-lg); padding: 5px;
  animation: pop .18s cubic-bezier(.4, 0, .2, 1);
}
.pop__panel--wide { min-width: 330px; padding: 0; overflow: hidden; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.pop__head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.pop__item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 7px 9px; border-radius: 7px; font-size: 13px; color: var(--text); transition: var(--fast);
}
.pop__item .ic { color: var(--muted); }
.pop__item:hover { background: var(--primary); color: #fff; }
.pop__item:hover .ic { color: #fff; }
.pop__item--danger { color: var(--danger); }
.pop__item--danger:hover { background: var(--danger); color: #fff; }
.pop__sep { height: 1px; background: var(--border); margin: 5px 0; }
.link { color: var(--primary); font-size: 12.5px; font-weight: 500; }
.link:hover { text-decoration: underline; }

.notif { max-height: 380px; overflow-y: auto; }
.notif li { display: flex; gap: 11px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.notif li:last-child { border-bottom: 0; }
.notif li.is-unread { background: var(--primary-soft); }
.notif__ic { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.notif p { font-size: 12.8px; color: var(--text); }
.notif small { color: var(--muted); font-size: 11.5px; }

/* =========================================================
   buttons
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 16px; border-radius: var(--r-pill); font-size: 13.5px; font-weight: 500;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: var(--fast); white-space: nowrap; box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn .ic { width: 16px; height: 16px; }
.btn--primary {
  background: var(--primary); border-color: transparent; color: #fff;
  box-shadow: 0 1px 2px rgba(0, 60, 160, .2);
}
.btn--primary:hover { background: var(--primary-600); }
.btn--danger { background: var(--danger); border-color: transparent; color: #fff; box-shadow: none; }
.btn--danger:hover { filter: brightness(.93); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--primary); box-shadow: none; }
.btn--ghost:hover { background: var(--primary-soft); }
.btn--soft { background: var(--primary-soft); border-color: transparent; color: var(--primary); box-shadow: none; }
.btn--soft:hover { background: color-mix(in srgb, var(--primary) 20%, transparent); }
.btn--sm { padding: 5px 13px; font-size: 12.5px; }
.btn--xs { padding: 3px 10px; font-size: 12px; box-shadow: none; }
.btn--block { width: 100%; }
.btn--icon { padding: 6px; width: 30px; height: 30px; }

.segment {
  display: inline-flex; background: var(--surface-3); border-radius: var(--r-sm); padding: 2px; gap: 2px;
}
.segment button {
  padding: 5px 14px; border-radius: 6px; font-size: 12.5px; font-weight: 500; color: var(--text); transition: var(--fast);
}
.segment button.is-active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .1); font-weight: 500;
}

/* =========================================================
   cards, page header
   ========================================================= */
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { font-size: 30px; letter-spacing: -.026em; font-weight: 600; }
.page-head p { color: var(--muted); font-size: 14px; margin-top: 5px; letter-spacing: -.005em; }
.page-head__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card__head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card__head h3 { font-size: 15.5px; font-weight: 600; }
.card__head p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card__tools { margin-left: auto; display: flex; align-items: center; gap: 7px; }
.card__body { padding: 20px; }
.card__foot { padding: 13px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }

.grid { display: grid; gap: 16px; }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(212px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr); gap: 16px; }

/* =========================================================
   badges / chips / avatars
   ========================================================= */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2.5px 9px; border-radius: 99px;
  font-size: 11.5px; font-weight: 500; letter-spacing: -.005em; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.badge--no-dot::before { display: none; }
.badge--success { background: var(--success-soft); color: #248a3d; }
.badge--warn { background: var(--warn-soft); color: #c93400; }
.badge--danger { background: var(--danger-soft); color: #d70015; }
.badge--info { background: var(--info-soft); color: #0071a4; }
.badge--primary { background: var(--primary-soft); color: var(--primary); }
[data-theme="dark"] .badge--success { color: #30d158; }
[data-theme="dark"] .badge--warn { color: #ff9f0a; }
[data-theme="dark"] .badge--danger { color: #ff6961; }
[data-theme="dark"] .badge--info { color: #64d2ff; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--surface-3); font-size: 12px; font-weight: 450; color: var(--text-2);
}

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 12px; font-weight: 600; letter-spacing: 0;
  color: #fff; background: var(--av, var(--primary));
  box-shadow: inset 0 -1px 2px rgba(0, 0, 0, .12), inset 0 1px 1px rgba(255, 255, 255, .25);
}
.avatar--sm { width: 28px; height: 28px; font-size: 10.5px; }
.avatar--lg { width: 54px; height: 54px; font-size: 18px; }
.avatar--xl { width: 72px; height: 72px; font-size: 24px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -9px; box-shadow: 0 0 0 2.5px var(--surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }

.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person__meta { min-width: 0; }
.person__meta strong { display: block; font-size: 13.3px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person__meta small { display: block; color: var(--muted); font-size: 11.8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* =========================================================
   tables
   ========================================================= */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.2px; }
.tbl thead th {
  text-align: left; padding: 9px 18px; font-size: 11.5px; font-weight: 500;
  letter-spacing: -.005em; color: var(--muted);
  background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.tbl thead th.is-sortable { cursor: pointer; user-select: none; }
.tbl thead th.is-sortable:hover { color: var(--text); }
.tbl thead th .sort { opacity: .6; font-size: 8.5px; color: var(--primary); }
.tbl tbody td { padding: 11px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background var(--fast); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr.is-selected { background: var(--primary-soft); }
.tbl .col-x { width: 44px; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; opacity: .4; transition: var(--fast); }
tr:hover .row-actions, .row-actions:focus-within { opacity: 1; }
.row-actions .icon-btn { width: 28px; height: 28px; }
.row-actions .icon-btn .ic { width: 15px; height: 15px; }
.row-actions .icon-btn.is-danger:hover { background: var(--danger-soft); color: var(--danger); }

input[type="checkbox"] { accent-color: var(--primary); }

.toolbar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; padding: 13px 18px; border-bottom: 1px solid var(--border); }
.toolbar .field { margin: 0; }
.toolbar__spacer { margin-left: auto; }

.pager { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.pager__nav { margin-left: auto; display: flex; align-items: center; gap: 3px; }
.pager__nav button {
  min-width: 30px; height: 30px; border-radius: var(--r-sm); border: 1px solid transparent;
  background: transparent; font-size: 12.5px; font-weight: 450; color: var(--text); display: grid; place-items: center; padding: 0 7px;
  transition: var(--fast);
}
.pager__nav button:hover:not(:disabled) { background: var(--surface-3); }
.pager__nav button.is-active { background: var(--primary); color: #fff; font-weight: 500; }
.pager__nav button:disabled { opacity: .35; cursor: not-allowed; }

.bulkbar {
  display: flex; align-items: center; gap: 11px; padding: 9px 18px;
  background: var(--primary-soft); border-bottom: 1px solid var(--border);
  font-size: 12.8px; font-weight: 500; color: var(--primary);
}
.bulkbar .btn { margin-left: auto; }

/* =========================================================
   forms
   ========================================================= */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 15px; }
.field > label { font-size: 12.5px; font-weight: 450; color: var(--text-2); }
.field > label .req { color: var(--danger); }
.field .hint { font-size: 11.5px; color: var(--muted); letter-spacing: 0; }
.field .err { font-size: 11.5px; color: var(--danger); font-weight: 450; }
input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
input[type="date"], input[type="time"], input[type="search"], input[type="password"], select, textarea {
  width: 100%; padding: 8px 11px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 13.5px; transition: var(--fast); color: var(--text);
  -webkit-appearance: none; appearance: none;
}
textarea { resize: vertical; min-height: 76px; line-height: 1.45; }
select {
  padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 15px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
input.is-invalid, select.is-invalid { border-color: var(--danger); }
input::placeholder, textarea::placeholder { color: var(--muted); }
input[type="date"], input[type="time"] { min-height: 37px; }
.select--sm, .input--sm { padding: 6px 10px; font-size: 12.5px; }
.select--sm { padding-right: 30px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .col-span { grid-column: 1 / -1; }
.form-sep { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; margin: 6px 0 14px; }
.form-sep span { font-size: 11.5px; font-weight: 600; letter-spacing: -.005em; color: var(--muted); }
.form-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: 13px; }
.check input { width: 17px; height: 17px; margin: 1px 0 0; cursor: pointer; flex: none; }
.check small { display: block; color: var(--muted); font-size: 11.7px; }

/* iOS switch */
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track {
  width: 44px; height: 26px; border-radius: 99px; background: rgba(120, 120, 128, .24);
  position: relative; transition: background var(--fast); flex: none;
}
.switch__track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; transition: transform var(--fast);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .18), 0 0 1px rgba(0, 0, 0, .1);
}
.switch input:checked + .switch__track { background: var(--success); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--ring); }
.switch__label strong { display: block; font-size: 13.3px; font-weight: 450; }
.switch__label small { color: var(--muted); font-size: 11.7px; letter-spacing: 0; }

/* =========================================================
   modal
   ========================================================= */
.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; }
.modal__scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, .28); backdrop-filter: blur(6px); animation: fade .2s ease; }
.modal__card {
  position: relative; width: 100%; max-width: 560px; max-height: calc(100vh - 48px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  animation: rise .28s cubic-bezier(.2, .9, .28, 1);
}
.modal--lg .modal__card { max-width: 780px; }
.modal--sm .modal__card { max-width: 420px; }
.modal__head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal__head h3 { font-size: 16px; flex: 1; font-weight: 600; }
.modal__body { padding: 22px; overflow-y: auto; }
.modal__foot {
  padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 9px; justify-content: flex-end;
  background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl);
}
.modal__foot:empty { display: none; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.97); } }

/* =========================================================
   toasts
   ========================================================= */
.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 120; display: flex; flex-direction: column; gap: 10px; max-width: 350px; }
.toast {
  display: flex; align-items: flex-start; gap: 11px; padding: 13px 15px;
  background: var(--chrome-bg);
  -webkit-backdrop-filter: var(--vibrancy); backdrop-filter: var(--vibrancy);
  border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  animation: slide .3s cubic-bezier(.2, .9, .28, 1);
}
.toast.is-out { animation: slide-out .2s ease forwards; }
.toast__ic { width: 20px; height: 20px; color: var(--primary); flex: none; margin-top: 1px; }
.toast--success .toast__ic { color: var(--success); }
.toast--danger .toast__ic { color: var(--danger); }
.toast--warn .toast__ic { color: var(--warn); }
.toast strong { display: block; font-size: 13.3px; font-weight: 600; }
.toast p { font-size: 12.4px; color: var(--muted); letter-spacing: 0; }
@keyframes slide { from { opacity: 0; transform: translateX(24px) scale(.97); } }
@keyframes slide-out { to { opacity: 0; transform: translateX(24px); } }

/* =========================================================
   misc states
   ========================================================= */
.empty { padding: 56px 24px; text-align: center; }
.empty__ic {
  width: 54px; height: 54px; border-radius: 50%; margin: 0 auto 15px; display: grid; place-items: center;
  background: var(--surface-3); color: var(--muted);
}
.empty__ic .ic { width: 25px; height: 25px; }
.empty h4 { font-size: 16px; margin-bottom: 5px; }
.empty p { color: var(--muted); font-size: 13.4px; max-width: 330px; margin: 0 auto 16px; letter-spacing: -.005em; }

.sep { height: 1px; background: var(--border); margin: 18px 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row--wrap { flex-wrap: wrap; }

/* =========================================================
   responsive
   ========================================================= */
@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .only-mobile { display: grid !important; }
  .only-desktop { display: none !important; }
  .sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-102%);
    transition: transform .3s cubic-bezier(.32, .72, 0, 1); box-shadow: var(--shadow-lg);
    background: var(--surface);
  }
  .sidebar.is-open { transform: none; }
  .view { padding: 20px 16px 32px; }
  .page-head h1 { font-size: 26px; }
  .topbar { padding: 0 14px; gap: 9px; }
  .searchbox kbd { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .toasts { left: 14px; right: 14px; bottom: 14px; max-width: none; }
  .pop__panel--wide { min-width: min(330px, calc(100vw - 28px)); }
}
@media (max-width: 560px) {
  .page-head h1 { font-size: 23px; }
  .page-head__actions { width: 100%; }
  .page-head__actions .btn { flex: 1; }
  .modal { padding: 0; align-items: flex-end; }
  .modal__card { max-width: none; border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 92vh; }
  .modal__foot { border-radius: 0; }
}

@media print {
  .sidebar, .topbar, .toasts, .page-head__actions { display: none !important; }
  body { background: #fff; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
