/* ==========================================================================
   Buddy System UrFU — design system v1.0
   Tokens -> base -> layout -> components -> pages -> responsive
   Flat surfaces, one primary colour (brand navy/blue), no gradients.
   ========================================================================== */

/* 1. Tokens ------------------------------------------------------------- */
:root {
  /* Brand */
  --c-navy: #1f3a7d;          /* wordmark / auth aside */
  --c-ink: #13224a;           /* headings */
  --c-primary: #2350a8;       /* primary actions, links, focus */
  --c-primary-hover: #1d4391;
  --c-primary-active: #183878;
  --c-primary-soft: #eef3fc;
  --c-primary-line: #c8d6f0;

  /* Neutrals */
  --c-bg: #f3f5f8;
  --c-surface: #ffffff;
  --c-surface-muted: #f7f8fa;
  --c-surface-sunk: #eef1f5;
  --c-border: #e2e6ec;
  --c-border-strong: #cdd3dc;
  --c-text: #171f2d;
  --c-text-2: #47505f;
  --c-text-3: #6b7383;
  --c-placeholder: #9099a8;

  /* Status */
  --c-success: #17704e;
  --c-success-soft: #e8f5ef;
  --c-warning: #7d5300;
  --c-warning-soft: #fdf4e0;
  --c-warning-line: #efdba8;
  --c-danger: #b1243a;
  --c-danger-soft: #fceff1;
  --c-danger-line: #efc7cf;
  --c-neutral-soft: #eef1f5;

  /* Shape, depth, motion */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(19, 34, 74, .06);
  --shadow-md: 0 16px 40px rgba(19, 34, 74, .18);
  --focus-ring: 0 0 0 3px rgba(35, 80, 168, .22);
  --ease: .15s ease;

  /* Spacing scale (4px base) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px;

  /* Layout */
  --sidebar-w: 248px;
  --topbar-h: 60px;
  --tabbar-h: 64px;

  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

/* 2. Base --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--c-bg);
  color: var(--c-text);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, dl, dd, ul { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
img { display: block; max-width: 100%; }
svg { display: block; flex-shrink: 0; }
summary { cursor: pointer; }
:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
[hidden] { display: none !important; }

.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.muted { color: var(--c-text-3); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.min-w0 { min-width: 0; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.row { display: flex; align-items: center; gap: var(--s-2); }
.wordmark { width: 168px; height: auto; }
.wordmark-sm { width: 112px; height: auto; }

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

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: var(--s-5) var(--s-4);
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
}
.sidebar-brand { padding: var(--s-1) var(--s-2) var(--s-6); }
.nav-caption {
  padding: 0 var(--s-3) var(--s-2);
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--c-text-3);
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; height: 40px; padding: 0 var(--s-3);
  border: 0; border-radius: var(--r-sm); background: none;
  color: var(--c-text-2); font-weight: 500; text-align: left;
  transition: background-color var(--ease), color var(--ease);
}
.nav-item:hover { background: var(--c-surface-muted); color: var(--c-text); }
.nav-item.is-active { background: var(--c-primary-soft); color: var(--c-primary); font-weight: 600; }
.nav-count {
  margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px;
  display: inline-grid; place-items: center;
  border-radius: 999px; background: var(--c-primary); color: #fff;
  font-size: 11px; font-weight: 600;
}
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: 0 var(--s-8);
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--c-border);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.topbar-context { display: flex; align-items: center; gap: var(--s-2); min-width: 0; font-size: 13px; color: var(--c-text-3); }
.topbar-context strong { color: var(--c-text); font-weight: 600; }
.topbar-mobile-brand { display: none; }
.topbar-actions { display: flex; align-items: center; gap: var(--s-2); }

.content {
  width: 100%; max-width: 1200px; margin: 0 auto;
  padding: var(--s-6) var(--s-8) var(--s-8);
}

/* 4. Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 36px; padding: 0 var(--s-4);
  border: 1px solid transparent; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600; line-height: 1; white-space: nowrap;
  transition: background-color var(--ease), border-color var(--ease), color var(--ease);
}
.btn .icon { width: 16px; height: 16px; }
.btn:disabled { opacity: .5; }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--c-primary-hover); }
.btn-primary:active:not(:disabled) { background: var(--c-primary-active); }
.btn-secondary { background: var(--c-surface); border-color: var(--c-border-strong); color: var(--c-text); }
.btn-secondary:hover:not(:disabled) { background: var(--c-surface-muted); border-color: #b9c1cd; }
.btn-ghost { background: transparent; color: var(--c-primary); }
.btn-ghost:hover:not(:disabled) { background: var(--c-primary-soft); }
.btn-danger { background: var(--c-surface); border-color: var(--c-danger-line); color: var(--c-danger); }
.btn-danger:hover:not(:disabled) { background: var(--c-danger-soft); }
.btn-danger-solid { background: var(--c-danger); color: #fff; }
.btn-danger-solid:hover:not(:disabled) { background: #9a1f32; }
.btn-sm { height: 32px; padding: 0 var(--s-3); font-size: 12px; }
.btn-lg { height: 44px; padding: 0 var(--s-5); font-size: 15px; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center;
  border: 1px solid var(--c-border); border-radius: var(--r-sm); background: var(--c-surface); color: var(--c-text-2);
}
.icon-btn:hover { background: var(--c-surface-muted); color: var(--c-text); }

/* 5. Form controls ------------------------------------------------------ */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 13px; font-weight: 600; color: var(--c-text-2); }
.field-hint { font-size: 12px; color: var(--c-text-3); }
.input, .select {
  width: 100%; height: 40px; padding: 0 var(--s-3);
  border: 1px solid var(--c-border-strong); border-radius: var(--r-sm);
  background: var(--c-surface); color: var(--c-text);
  font-size: 14px; outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.input::placeholder { color: var(--c-placeholder); }
.input:hover, .select:hover { border-color: #b9c1cd; }
.input:focus, .select:focus { border-color: var(--c-primary); box-shadow: var(--focus-ring); }
.select {
  padding-right: 32px; appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7383' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.select-auto { width: auto; min-width: 180px; }
.input-num { width: 96px; }
.check { display: inline-flex; align-items: center; gap: var(--s-2); font-size: 13px; color: var(--c-text-2); cursor: pointer; white-space: nowrap; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--c-primary); }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4); }
.form-grid .span-full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; }

.search { position: relative; flex: 1 1 260px; max-width: 420px; min-width: 0; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--c-text-3); pointer-events: none; }
.search .input { padding-left: 36px; }

.segmented {
  display: inline-flex; gap: 2px; max-width: 100%; padding: 3px;
  background: var(--c-surface-sunk); border-radius: var(--r-sm);
  overflow-x: auto; scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented button {
  flex-shrink: 0; height: 30px; padding: 0 var(--s-3);
  border: 0; border-radius: var(--r-xs); background: transparent;
  color: var(--c-text-2); font-size: 13px; font-weight: 500; white-space: nowrap;
}
.segmented button:hover { color: var(--c-text); }
.segmented button[aria-pressed="true"] { background: var(--c-surface); color: var(--c-ink); font-weight: 600; box-shadow: var(--shadow-xs); }

/* 6. Surfaces ----------------------------------------------------------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-6); }
.eyebrow { font-size: 12px; font-weight: 600; color: var(--c-text-3); margin-bottom: var(--s-1); }
.page-title { font-size: 24px; line-height: 32px; font-weight: 650; letter-spacing: -.01em; color: var(--c-ink); }
.page-desc { margin-top: var(--s-1); color: var(--c-text-2); font-size: 14px; max-width: 680px; }
.page-actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }

.card {
  min-width: 0;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs); overflow: hidden;
}
.card + .card { margin-top: var(--s-4); }
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap;
  padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--c-border);
}
.card-title { font-size: 15px; font-weight: 600; color: var(--c-ink); }
.card-desc { margin-top: 2px; font-size: 13px; color: var(--c-text-3); }
.card-body { padding: var(--s-5); }
.card-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--s-2); flex-wrap: wrap;
  padding: var(--s-3) var(--s-5); border-top: 1px solid var(--c-border); background: var(--c-surface-muted);
}
.card-footer.split { justify-content: space-between; }

.section { margin-bottom: var(--s-6); }
.section-title { font-size: 15px; font-weight: 600; color: var(--c-ink); margin-bottom: var(--s-3); }

.split-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--s-5); align-items: start; }
.split-layout > aside { position: sticky; top: calc(var(--topbar-h) + var(--s-4)); }
.two-col { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: var(--s-5); align-items: start; }
.two-col > .card + .card { margin-top: 0; }

/* KPI tiles */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-4); margin-bottom: var(--s-6); }
.kpi {
  display: flex; flex-direction: column; gap: var(--s-1);
  width: 100%; padding: var(--s-4) var(--s-5);
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs); text-align: left; min-width: 0;
}
button.kpi { transition: border-color var(--ease); }
button.kpi:hover { border-color: var(--c-primary-line); }
.kpi-label { font-size: 13px; font-weight: 500; color: var(--c-text-2); }
.kpi-value { font-size: 28px; line-height: 36px; font-weight: 650; color: var(--c-ink); font-variant-numeric: tabular-nums; }
.kpi-hint { font-size: 12px; color: var(--c-text-3); }

/* Badges & avatars */
.badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 var(--s-2);
  border-radius: var(--r-xs); font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--c-neutral-soft); color: var(--c-text-2);
}
.badge-primary { background: var(--c-primary-soft); color: var(--c-primary); }
.badge-success { background: var(--c-success-soft); color: var(--c-success); }
.badge-warning { background: var(--c-warning-soft); color: var(--c-warning); }
.badge-danger { background: var(--c-danger-soft); color: var(--c-danger); }
.badge-neutral { background: var(--c-neutral-soft); color: var(--c-text-2); }
.badge-navy { background: var(--c-navy); color: #fff; }

.avatar {
  width: 36px; height: 36px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 50%; background: var(--c-primary-soft); color: var(--c-primary);
  font-size: 13px; font-weight: 600; letter-spacing: .02em;
}
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }
.avatar-leader { background: var(--c-navy); color: #fff; }
.person { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th {
  height: 40px; padding: 0 var(--s-4);
  background: var(--c-surface-muted); border-bottom: 1px solid var(--c-border);
  color: var(--c-text-3); font-size: 12px; font-weight: 600; text-align: left; white-space: nowrap;
}
.table td { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfd; }
.table .cell-actions { text-align: right; white-space: nowrap; }
.table .cell-actions .btn + .btn { margin-left: var(--s-2); }
.table .cell-wide { min-width: 220px; }
.table-cell-select { min-width: 150px; }
.cell-main { font-weight: 600; color: var(--c-text); }
.cell-sub { margin-top: 2px; font-size: 12px; color: var(--c-text-3); }
.cell-stack { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.table td .input, .table td .select { height: 34px; }
.table td .input-num { width: 92px; }

/* Lists (overview, notices) */
.list-item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--c-border);
}
.list-item:last-child { border-bottom: 0; }
.list-item .meta { font-size: 12px; color: var(--c-text-3); }
.list-item time { font-size: 12px; color: var(--c-text-3); white-space: nowrap; }
.activity-text { font-size: 13px; color: var(--c-text); }
.activity-text b { font-weight: 600; }

.toolbar { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--c-border); }
.toolbar-end { display: flex; align-items: center; gap: var(--s-2); margin-left: auto; flex-wrap: wrap; }
.result-count { font-size: 12px; color: var(--c-text-3); white-space: nowrap; }

.pager {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap;
  padding: var(--s-3) var(--s-5); border-top: 1px solid var(--c-border);
  font-size: 13px; color: var(--c-text-3);
}
.pager div { display: flex; gap: var(--s-2); }

/* Notices */
.notice {
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--c-border); border-radius: var(--r-sm);
  background: var(--c-surface-muted); color: var(--c-text-2); font-size: 13px; line-height: 1.55;
}
.notice .icon { margin-top: 1px; }
.notice-info { background: var(--c-primary-soft); border-color: var(--c-primary-line); color: #1f3d7f; }
.notice-warning { background: var(--c-warning-soft); border-color: var(--c-warning-line); color: var(--c-warning); }
.notice-danger { background: var(--c-danger-soft); border-color: var(--c-danger-line); color: #8e1c2e; }
.notice ul { margin: 0; padding-left: var(--s-4); }

/* Key-value rows */
.kv { display: flex; flex-direction: column; }
.kv-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-4); padding: var(--s-3) 0; border-bottom: 1px solid var(--c-border); font-size: 13px; }
.kv-row:first-child { padding-top: 0; }
.kv-row:last-child { border-bottom: 0; padding-bottom: 0; }
.kv-row dt { color: var(--c-text-3); flex-shrink: 0; }
.kv-row dd { font-weight: 600; color: var(--c-text); text-align: right; overflow-wrap: anywhere; }

/* Empty, error, loading */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); padding: var(--s-8) var(--s-6); text-align: center; }
.empty-icon {
  width: 44px; height: 44px; margin-bottom: var(--s-2);
  display: grid; place-items: center;
  border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface-muted); color: var(--c-text-3);
}
.empty-title { font-size: 15px; font-weight: 600; color: var(--c-ink); }
.empty-desc { max-width: 380px; font-size: 13px; color: var(--c-text-3); }
.empty .btn { margin-top: var(--s-3); }

.state-page { min-height: 100vh; display: grid; place-items: center; padding: var(--s-6); background: var(--c-bg); }
.state-card {
  width: 100%; max-width: 440px; padding: var(--s-8);
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs);
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--s-3);
}
.state-card h1 { font-size: 20px; line-height: 28px; color: var(--c-ink); font-weight: 650; }
.state-card p { font-size: 14px; color: var(--c-text-2); }
.state-card .empty-icon { margin-bottom: 0; }
.state-card .state-actions { display: flex; gap: var(--s-2); margin-top: var(--s-3); flex-wrap: wrap; justify-content: center; }

.skeleton {
  position: relative; overflow: hidden;
  background: var(--c-surface-sunk); border-radius: var(--r-xs);
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .75), transparent);
  transform: translateX(-100%); animation: shimmer 1.3s ease-in-out infinite;
}
.skeleton-line { height: 12px; margin-bottom: var(--s-3); }
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-kpi { height: 92px; border-radius: var(--r-lg); }
.skeleton-block { height: 260px; border-radius: var(--r-lg); }
@keyframes shimmer { to { transform: translateX(100%); } }

.spinner {
  width: 16px; height: 16px; flex-shrink: 0;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.boot-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-6); padding: var(--s-6); }
.boot-status { display: flex; align-items: center; gap: var(--s-2); font-size: 13px; color: var(--c-text-3); }
.boot-skeleton { width: min(960px, 100%); display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-4); }

/* Tables -> stacked rows on small screens */
.table-stack td .select, .table-stack td .input { width: 100%; }

/* 7. Modal, toast, sheets ---------------------------------------------- */
.modal-layer {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-6);
  background: rgba(19, 34, 74, .42);
  animation: fade .15s ease;
}
.modal {
  width: min(640px, 100%); max-height: min(88vh, 860px);
  display: flex; flex-direction: column; outline: none;
  background: var(--c-surface); border-radius: var(--r-lg); box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: rise .18s ease-out;
}
.modal-sm { width: min(460px, 100%); }
.modal-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4);
  padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--c-border);
}
.modal-eyebrow { display: flex; gap: var(--s-2); flex-wrap: wrap; margin-bottom: var(--s-2); }
.modal-title { font-size: 18px; line-height: 26px; font-weight: 650; color: var(--c-ink); overflow-wrap: anywhere; }
.modal-desc { margin-top: 2px; font-size: 13px; color: var(--c-text-3); }
.modal-body { padding: var(--s-5) var(--s-6); overflow-y: auto; display: flex; flex-direction: column; gap: var(--s-5); }
.modal-footer {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap;
  padding: var(--s-4) var(--s-6); border-top: 1px solid var(--c-border); background: var(--c-surface-muted);
}
.modal-footer .group { display: flex; gap: var(--s-2); margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4) var(--s-5); }
.dl > div { min-width: 0; }
.dl dt { margin-bottom: 2px; font-size: 12px; font-weight: 500; color: var(--c-text-3); }
.dl dd { font-size: 14px; color: var(--c-text); white-space: pre-wrap; overflow-wrap: anywhere; }
.dl .full { grid-column: 1 / -1; }
.code-block {
  padding: var(--s-4); text-align: center;
  background: var(--c-surface-muted); border: 1px dashed var(--c-border-strong); border-radius: var(--r-sm);
  font: 600 15px/1.45 ui-monospace, Consolas, "Courier New", monospace; letter-spacing: .04em; color: var(--c-ink);
  user-select: all; overflow-wrap: anywhere; word-break: break-all; min-width: 0;
}

.toast-layer {
  position: fixed; right: var(--s-6); bottom: var(--s-6); z-index: 60;
  display: flex; flex-direction: column; align-items: flex-end; gap: var(--s-2);
  max-width: min(400px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  max-width: 100%; padding: var(--s-3) var(--s-4);
  background: #1b2433; color: #fff; border-radius: var(--r-sm);
  font-size: 13px; line-height: 1.5; box-shadow: var(--shadow-md);
  animation: rise .2s ease-out;
}
.toast.error { background: #8e1c2e; }

.sheet-layer { position: fixed; inset: 0; z-index: 45; background: rgba(19, 34, 74, .42); animation: fade .15s ease; }
.icon-tile {
  width: 32px; height: 32px; flex-shrink: 0;
  display: grid; place-items: center; border-radius: var(--r-sm);
  background: var(--c-surface-muted); border: 1px solid var(--c-border); color: var(--c-primary);
}
.activity-text { overflow-wrap: anywhere; }
.kpi-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.form-success { color: var(--c-success); }
.dropzone .spinner { width: 24px; height: 24px; color: var(--c-primary); }
.card-header .chev { color: var(--c-text-3); margin-left: auto; }
.span-full { grid-column: 1 / -1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: var(--s-2) var(--s-4) calc(var(--s-4) + env(safe-area-inset-bottom));
  background: var(--c-surface); border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow-md);
  animation: rise .18s ease-out;
}
.sheet-grip { width: 36px; height: 4px; margin: var(--s-2) auto var(--s-4); border-radius: 2px; background: var(--c-border-strong); }
.sheet-title { padding: 0 var(--s-2) var(--s-3); font-size: 13px; font-weight: 600; color: var(--c-text-3); }
.sheet-link {
  width: 100%; display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3); min-height: 48px;
  border: 0; border-radius: var(--r-sm); background: none; color: var(--c-text); font-weight: 500; text-align: left;
}
.sheet-link:hover, .sheet-link:active { background: var(--c-surface-muted); }
.sheet-link .icon { color: var(--c-text-3); }
.sheet-link .chev { margin-left: auto; color: var(--c-text-3); }
.sheet-link.danger { color: var(--c-danger); }
.sheet-link.danger .icon { color: var(--c-danger); }

/* 8. Navigation: mobile tab bar ---------------------------------------- */
.tabbar { display: none; }

/* 9. Feature blocks ----------------------------------------------------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-2);
  padding: var(--s-8) var(--s-5); min-height: 180px;
  border: 1.5px dashed var(--c-border-strong); border-radius: var(--r-md); background: var(--c-surface-muted);
  text-align: center; cursor: pointer; transition: border-color var(--ease), background-color var(--ease);
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.is-drag { border-color: var(--c-primary); background: var(--c-primary-soft); }
.dropzone .dz-icon {
  width: 44px; height: 44px; margin-bottom: var(--s-1);
  display: grid; place-items: center; border-radius: var(--r-md);
  background: var(--c-surface); border: 1px solid var(--c-border); color: var(--c-primary);
}
.dropzone .dz-title { font-size: 15px; font-weight: 600; color: var(--c-ink); }
.dropzone .dz-desc { font-size: 13px; color: var(--c-text-3); }
.file-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border: 1px solid var(--c-border); border-radius: var(--r-sm); background: var(--c-surface);
}
.file-row b { display: block; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.file-row span { font-size: 12px; color: var(--c-text-3); }
.file-row .icon { color: var(--c-primary); }
.kpi-mini-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-3); }
.kpi-mini { padding: var(--s-3) var(--s-4); background: var(--c-surface-muted); border: 1px solid var(--c-border); border-radius: var(--r-sm); }
.kpi-mini strong { display: block; font-size: 20px; line-height: 28px; color: var(--c-ink); font-variant-numeric: tabular-nums; }
.kpi-mini span { font-size: 12px; color: var(--c-text-3); }
.steps { display: flex; flex-direction: column; gap: var(--s-4); }
.step { display: flex; gap: var(--s-3); }
.step-num {
  width: 24px; height: 24px; flex-shrink: 0;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--c-primary-soft); color: var(--c-primary); font-size: 12px; font-weight: 600;
}
.step b { display: block; font-size: 13px; font-weight: 600; color: var(--c-text); }
.step span { display: block; margin-top: 2px; font-size: 13px; color: var(--c-text-3); }
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s-4); padding: var(--s-5); }
.member { display: flex; flex-direction: column; gap: var(--s-4); padding: var(--s-4); border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface); min-width: 0; }
.member-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding-top: var(--s-3); border-top: 1px solid var(--c-border); font-size: 12px; color: var(--c-text-3); }

/* Auth ------------------------------------------------------------------ */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: var(--c-surface); }
.auth-aside {
  display: flex; flex-direction: column; justify-content: space-between; gap: var(--s-8);
  padding: var(--s-8) 56px;
  background: var(--c-navy); color: #fff;
}
.auth-aside .wordmark { width: 200px; }
.auth-aside-text h2 { font-size: 28px; line-height: 36px; font-weight: 650; letter-spacing: -.01em; max-width: 440px; }
.auth-aside-text p { margin-top: var(--s-3); max-width: 440px; font-size: 15px; line-height: 1.6; color: #c9d5ee; }
.auth-aside-symbol { width: 230px; padding: var(--s-3) var(--s-4); background: #fff; border-radius: var(--r-md); }
.auth-main { display: flex; align-items: center; justify-content: center; padding: var(--s-8) var(--s-6); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .wordmark-sm { display: none; margin-bottom: var(--s-6); }
.auth-card h1 { font-size: 24px; line-height: 32px; font-weight: 650; color: var(--c-ink); }
.auth-card > p { margin-top: var(--s-2); font-size: 14px; color: var(--c-text-3); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; margin: var(--s-6) 0; padding: 3px; background: var(--c-surface-sunk); border-radius: var(--r-sm); }
.tabs button { height: 34px; border: 0; border-radius: var(--r-xs); background: transparent; color: var(--c-text-2); font-size: 13px; font-weight: 600; }
.tabs button[aria-selected="true"] { background: var(--c-surface); color: var(--c-ink); box-shadow: var(--shadow-xs); }
.auth-form { display: flex; flex-direction: column; gap: var(--s-4); }
.auth-form .btn { margin-top: var(--s-2); }
.form-error { min-height: 20px; font-size: 13px; color: var(--c-danger); }
.auth-foot { margin-top: var(--s-8); font-size: 12px; color: var(--c-text-3); }

/* 10. Responsive -------------------------------------------------------- */
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-layout { grid-template-columns: minmax(0, 1fr); }
  .split-layout > aside { position: static; }
  .two-col { grid-template-columns: minmax(0, 1fr); }
  .two-col > .card + .card { margin-top: var(--s-4); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 961px) and (max-width: 1180px) {
  .col-optional { display: none; }
}

@media (max-width: 960px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar { padding: 0 var(--s-4); height: 56px; }
  .topbar-context { display: none; }
  .topbar-mobile-brand { display: block; }
  .content { padding: var(--s-5) var(--s-5) calc(var(--tabbar-h) + var(--s-8) + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--c-surface); border-top: 1px solid var(--c-border);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-width: 0; border: 0; background: none; color: var(--c-text-3);
    font-size: 11px; font-weight: 500;
  }
  .tab .icon { width: 22px; height: 22px; }
  .tab.is-active { color: var(--c-primary); font-weight: 600; }
  .tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-width: 760px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { padding: var(--s-5) var(--s-5); gap: var(--s-4); }
  .auth-aside .wordmark { width: 150px; }
  .auth-aside-text, .auth-aside-symbol { display: none; }
  .auth-main { align-items: flex-start; padding: var(--s-6) var(--s-5) var(--s-8); }
  .auth-card { max-width: 440px; }
  .auth-card .wordmark-sm { display: none; }
  .auth-card h1 { font-size: 22px; line-height: 30px; }
}

@media (max-width: 720px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody { display: block; width: 100%; }
  .table-stack tr {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s-3) var(--s-4);
    padding: var(--s-4); border-bottom: 1px solid var(--c-border);
  }
  .table-stack tr:last-child { border-bottom: 0; }
  .table-stack tbody tr:hover td { background: none; }
  .table-stack td { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; padding: 0; border: 0; text-align: left; }
  .table-stack td::before { content: attr(data-label); font-size: 11px; font-weight: 500; color: var(--c-text-3); }
  .table-stack td.cell-wide { grid-column: 1 / -1; min-width: 0; }
  .table-stack td.cell-wide::before, .table-stack td.cell-full::before { display: none; }
  .table-stack td.cell-full { grid-column: 1 / -1; }
  .table-stack td.cell-actions { grid-column: 1 / -1; flex-direction: row; align-items: stretch; text-align: left; }
  .table-stack td.cell-actions::before { display: none; }
  .table-stack td.cell-actions .btn { flex: 1; height: 40px; }
  .table-stack td.cell-actions .btn + .btn { margin-left: 0; }
  .table-stack td .select, .table-stack td .input { width: 100%; }
  .table-stack td .input-num { width: 100%; }
  .table-stack td .check { height: 34px; }
  .table-stack .table-cell-select { min-width: 0; }
  .table-stack .person { width: 100%; }
  .table-stack .cell-main { overflow-wrap: anywhere; }
  .table-stack .cell-sub { overflow-wrap: anywhere; }
  .table-stack .cell-hide-sm { display: none; }

  .modal-layer { align-items: flex-end; padding: 0; }
  .modal { width: 100%; max-height: 92vh; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .modal-sm { width: 100%; }
  .modal-header { padding: var(--s-4) var(--s-5); }
  .modal-body { padding: var(--s-4) var(--s-5); }
  .modal-footer { padding: var(--s-3) var(--s-5) calc(var(--s-3) + env(safe-area-inset-bottom)); }
  .modal-footer .group { width: 100%; margin-left: 0; }
  .modal-footer .group .btn { flex: 1; }
  .modal-footer > .btn { width: 100%; }
  .dl { grid-template-columns: minmax(0, 1fr); }

  .toast-layer { left: var(--s-4); right: var(--s-4); bottom: calc(var(--tabbar-h) + var(--s-3) + env(safe-area-inset-bottom)); align-items: stretch; max-width: none; }
  .toast { max-width: none; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-actions .btn { width: 100%; }
  .hide-sm { display: none !important; }
  .kpi-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
  .kpi-grid-3 .kpi-value { font-size: 20px; line-height: 28px; }
  .page-title { font-size: 22px; line-height: 30px; }
  .page-header { margin-bottom: var(--s-4); }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .toolbar { padding: var(--s-3) var(--s-4); }
  .toolbar .search { max-width: none; flex-basis: 100%; }
  .toolbar-end { margin-left: 0; width: 100%; justify-content: space-between; }
  .toolbar-end .select { flex: 1; }
  .card-header, .card-body, .card-footer { padding-left: var(--s-4); padding-right: var(--s-4); }
  .card-footer .btn { flex: 1; }
  .card-footer .btn-sm { height: 36px; }
  .list-item { padding: var(--s-3) var(--s-4); }
  .kv-row { flex-direction: column; gap: 2px; }
  .kv-row dd { text-align: left; }
  .pager { padding: var(--s-3) var(--s-4); }
  .pager > span { width: 100%; }
  .pager div { width: 100%; }
  .pager .btn { flex: 1; }
  .member-grid { grid-template-columns: minmax(0, 1fr); padding: var(--s-4); }
  .split-layout { gap: var(--s-4); }
  .kpi-mini-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-mini strong { font-size: 18px; }
}

@media (max-width: 480px) {
  .kpi-grid { gap: var(--s-3); margin-bottom: var(--s-4); }
  .kpi { padding: var(--s-3) var(--s-4); }
  .kpi-value { font-size: 24px; line-height: 30px; }
  .kpi-label { font-size: 12px; }
  .kpi-hint { display: none; }
  .content { padding-left: var(--s-4); padding-right: var(--s-4); }
  .sheet-link { min-height: 52px; }
}

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

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(8px); opacity: .6; } to { transform: none; opacity: 1; } }

/* Disclosure card (create user) */
details.card > summary { list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary .chev { transition: transform var(--ease); color: var(--c-text-3); }
details.card[open] > summary .chev { transform: rotate(180deg); }
details.card > summary:focus-visible { outline-offset: -2px; }
/* v0.8 Telegram onboarding, schedules and persistent notification inbox */
.telegram-onboarding{min-height:100dvh;display:grid;place-items:center;background:linear-gradient(160deg,#f4f7fc,#e9effa);padding:24px 16px;color:#1b2c4c}
.telegram-onboarding-panel{width:100%;max-width:430px;background:#fff;border:1px solid #dae3f0;border-radius:22px;padding:clamp(22px,5vw,36px);box-shadow:0 18px 44px rgba(23,50,100,.1)}
.telegram-onboarding-panel .wordmark{width:160px;height:auto;margin-bottom:27px}
.telegram-onboarding-panel h1{font-size:26px;line-height:1.2;letter-spacing:-.5px;margin:0 0 12px}
.telegram-onboarding-panel p{font-size:14px;line-height:1.7;color:#607089;margin:0 0 25px}
.telegram-onboarding-panel .auth-form{display:flex;flex-direction:column;gap:20px}
.telegram-onboarding-panel .auth-feedback:not(:empty){display:block;background:#fff3f3;color:#a5273c;border-radius:10px;padding:12px;font-size:13px}
.notifications-list{padding:6px 20px 22px}
.notification-item{display:flex;align-items:flex-start;gap:14px;padding:18px 6px;border-bottom:1px solid #e9eef6;justify-content:space-between}
.notification-item:last-child{border-bottom:0}
.notification-item.unread{border-left:3px solid #2854a7;padding-left:12px;background:linear-gradient(90deg,#f2f6ff,transparent)}
.notification-item-content{min-width:0;flex:1}
.notification-item-content strong{display:block;font-size:14px;margin-bottom:6px}
.notification-item-content p{font-size:13px;color:#465774;line-height:1.6;margin:0 0 10px;overflow-wrap:anywhere}
.notification-item-content small{color:#8a98ad}
.notify-setting{display:flex;align-items:center;gap:10px;font-size:13px;font-weight:700;cursor:pointer}
.notify-setting input{accent-color:#2855ad;width:18px;height:18px}
.flight-rows{max-height:520px;overflow:auto}
.flight-info-row{display:grid;grid-template-columns:minmax(0,1fr) 120px auto;gap:15px;padding:15px 0;border-bottom:1px solid #e9eef6;align-items:center}
.flight-info-row:last-child{border-bottom:0}
.flight-info-row strong{display:block;font-size:13px}
.flight-info-row .small{font-size:11px;margin-top:4px}
@media(max-width:650px){.flight-info-row{grid-template-columns:minmax(0,1fr) auto}.flight-info-row>div:last-child{grid-column:1/-1}.notification-item{flex-direction:column}.notifications-list{padding:8px 12px 18px}}

/* v0.9 checklist & rating */
.score-rank{min-width:30px;text-align:center;font-weight:800;color:#2854a8}
.checklist-section{margin:22px 0 14px;padding:16px;background:#f8faff;border:1px solid #dce6f5;border-radius:16px}
.checklist-section h3{margin:0 0 12px;font-size:17px}
.checklist-heading{font-weight:750;font-size:13px;color:#325590;padding:12px 0 6px}
.checklist-line{display:flex;align-items:flex-start;gap:12px;padding:10px 0;border-bottom:1px solid #e7edf5;font-size:13px;cursor:pointer}
.checklist-line input{width:19px;height:19px;accent-color:#2854a8;flex:none}
.checklist-line span{flex:1}.checklist-line small{display:block;color:#7a8597;margin-top:3px}
.checklist-line strong{color:#27815c;font-size:12px}
