/* =====================================================================
   OnTime - application styles
   Neutral palette, left navigation, cards with rounded corners.
   No external fonts or frameworks: everything is bundled here.
   ===================================================================== */

:root {
  --bg: #f3f4f2;
  --surface: #ffffff;
  --surface-2: #f7f8f6;
  --line: #dde1de;
  --line-strong: #c6cdc9;
  --text: #1f2a30;
  --muted: #5e6a72;
  --ink: #26313a;          /* sidebar */
  --ink-2: #33404a;
  --ink-text: #c3ccd2;
  --accent: #2f5d62;
  --accent-hover: #244a4e;
  --accent-soft: #e3edec;
  --danger: #a33a32;
  --danger-soft: #f8e5e3;
  --warn: #8a5a00;
  --warn-soft: #fbf0d9;
  --ok: #2e6b47;
  --ok-soft: #e3f1e8;
  --info: #3e6a9e;
  --info-soft: #e7eef7;
  --violet: #6b4fa0;
  --violet-soft: #efeaf8;

  --radius-lg: 10px;
  --radius: 7px;
  --radius-sm: 4px;
  --shadow: 0 1px 2px rgba(31, 42, 48, .06);
  --shadow-pop: 0 8px 28px rgba(31, 42, 48, .16);
  --sidebar-w: 236px;
  --drawer-w: 400px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); font-variant-numeric: tabular-nums; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 600; }
p { margin: 0 0 .75rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.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; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: var(--radius); z-index: 100; }
.skip-link:focus { left: 8px; }
.muted { color: var(--muted); }
.text-danger { color: var(--danger) !important; }
.nowrap { white-space: nowrap; }

.icon { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.icon--sm { width: 13px; height: 13px; vertical-align: -2px; }
.icon--xs { width: 11px; height: 11px; vertical-align: -1px; }

/* ---------- App shell ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--ink); color: var(--ink-text);
  display: flex; flex-direction: column; z-index: 40; transition: transform .2s ease;
}
.sidebar__brand { padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand { display: flex; flex-direction: column; gap: 8px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand__logo { max-width: 150px; height: auto; display: block; }
.brand__name { font-size: 17px; font-weight: 600; letter-spacing: .01em; color: #fff; }
.sidebar__nav { flex: 1; overflow-y: auto; padding: 10px 10px 16px; }
.nav-section { margin: 16px 10px 6px; font-size: 12px; color: #8995a0; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); color: var(--ink-text); }
.nav-link:hover { background: var(--ink-2); color: #fff; text-decoration: none; }
.nav-link.is-active { background: #3d4a55; color: #fff; box-shadow: inset 3px 0 0 #9fc3c6; }
.nav-count { margin-left: auto; background: #9fc3c6; color: var(--ink); border-radius: 999px; font-size: 11px; font-weight: 600; padding: 0 7px; }
.sidebar__foot { padding: 12px 18px 16px; font-size: 12px; color: #7d8994; border-top: 1px solid rgba(255,255,255,.07); }
.sidebar-backdrop { display: none; }

.shell { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin-right .2s ease; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px;
  min-height: 62px; padding: 8px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar .topbar__menu { display: none; }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.tenant-switch { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tenant-switch__label { font-size: 12px; color: var(--muted); padding: 2px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.tenant-switch__name { display: flex; align-items: center; gap: 6px; font-size: 18px; font-weight: 600; color: var(--text); cursor: pointer; list-style: none; padding: 4px 8px; border-radius: var(--radius); min-width: 0; }
.tenant-switch__name::-webkit-details-marker { display: none; }
.tenant-switch__name:hover { background: var(--surface-2); }
.tenant-switch__name--static { cursor: default; }
.tenant-switch__name--static:hover { background: none; }
.tenant-switch__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 42vw; }
.role-pill { font-size: 12px; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu__panel {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); padding: 6px; z-index: 50;
}
.menu__panel--left { left: 0; right: auto; min-width: 280px; }
.menu__title { font-size: 12px; color: var(--muted); padding: 6px 10px; }
.menu__item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; text-align: left;
  padding: 8px 10px; border: 0; background: none; border-radius: var(--radius); font: inherit; color: var(--text); cursor: pointer;
}
.menu__item small { color: var(--muted); }
.menu__item:hover { background: var(--surface-2); }
.menu__item.is-current { background: var(--accent-soft); }
.menu__meta { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu__meta span { color: var(--muted); font-size: 13px; }
.menu__meta .badge { align-self: flex-start; }

.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 999px; cursor: pointer; }
.user-chip:hover { background: var(--surface-2); }
.user-chip__avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600; flex: none;
}
.user-chip__name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border: 1px solid transparent; background: none; border-radius: var(--radius); color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; border-color: var(--line); }
.icon-btn--sm { width: 30px; height: 30px; }
.icon-btn--danger:hover { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.dot-count { position: absolute; top: 2px; right: 1px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 600; line-height: 17px; text-align: center; }

.content { padding: 22px 24px 48px; flex: 1; outline: none; max-width: 1600px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.page-sub { color: var(--muted); margin: 4px 0 0; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-title { font-size: 16px; margin: 26px 0 12px; }

/* ---------- Layout helpers ---------- */
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.grid-2, .grid-3, .grid-auto { display: grid; gap: 14px 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-span-2 { grid-column: span 2; }
.grid-span-3 { grid-column: 1 / -1; }
.layout-split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.layout-split--wide { grid-template-columns: minmax(0, 1fr) 380px; }
.layout-sidepanel { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; align-items: start; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.inline { display: inline; }
.hidden-form { display: none; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); min-width: 0; }
.card--pad { padding: 18px 20px; }
.card--danger { border-color: #ecc9c5; }
.card__title { font-size: 15px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card__heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card__heading .card__title { margin: 0; }
.card__toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card__toolbar .card__title { margin: 0; }
.card__toolbar .input { max-width: 280px; }
.card__intro { padding: 12px 16px 0; margin: 0; }
.subhead { font-size: 14px; margin: 16px 0 8px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); border-radius: var(--radius);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--ghost { border-color: transparent; background: none; color: var(--muted); }
.btn--ghost:hover { color: var(--text); background: var(--surface-2); }
.btn--danger { border-color: var(--danger); color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); }
.btn--link { border: 0; background: none; color: var(--accent); padding: 0; min-height: 0; }
.btn--link:hover { background: none; text-decoration: underline; }
.btn--sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn--lg { min-height: 44px; font-size: 15px; }
.btn--block { width: 100%; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field__label { font-size: 13px; font-weight: 500; color: var(--text); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.req { color: var(--danger); font-weight: 700; }
.field-kind { font-size: 11px; font-weight: 500; color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 5px; line-height: 17px; }
.field-kind--auto { color: var(--info); border-color: #c9d7ea; background: var(--info-soft); }
.field-kind--readonly { color: var(--muted); background: var(--surface-2); display: inline-flex; align-items: center; gap: 3px; }
.form-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12px; color: var(--muted); margin: -2px 0 16px; padding-bottom: 12px; border-bottom: 1px dashed var(--line); }
.form-legend > span { display: inline-flex; align-items: center; gap: 6px; }

.input {
  width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit;
}
textarea.input { resize: vertical; min-height: 60px; }
select.input { padding-right: 28px; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47, 93, 98, .18); }
.input.is-readonly { background: var(--surface-2); color: var(--muted); border-style: dashed; }
.input.is-auto { background: var(--info-soft); color: #2d4c72; border-color: #c9d7ea; border-style: dashed; }
.input--lg { min-height: 44px; font-size: 15px; }
.input--otp { font-size: 26px; letter-spacing: 10px; text-align: center; font-family: var(--mono); min-height: 54px; }
.input--code { text-transform: uppercase; }
.field__hint { font-size: 12px; color: var(--muted); margin: 0; }
.field__error { font-size: 12px; color: var(--danger); margin: 0; font-weight: 500; }
.has-error .input, .has-error .picker__control { border-color: var(--danger); }
.form-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.form-actions--sticky {
  position: sticky; bottom: 0; margin: 0; padding: 12px 16px; background: rgba(255,255,255,.96);
  border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: 0 -2px 10px rgba(31,42,48,.06); z-index: 5;
}
.subtle-details { margin-top: 14px; }
.subtle-details summary { cursor: pointer; color: var(--accent); font-size: 13px; margin-bottom: 12px; }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; padding: 14px 16px; margin-bottom: 16px; }
.filters .field { min-width: 150px; flex: 0 1 180px; }
.filters .field--grow { flex: 1 1 240px; }
.filters .field--range { flex: 0 1 290px; }
.range { display: flex; gap: 6px; }
.filters__actions { display: flex; gap: 6px; margin-left: auto; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
.table tbody tr:hover { background: #fafbf9; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table tr.is-muted td { color: var(--muted); }
.col-actions { text-align: right !important; white-space: nowrap; width: 1%; }
.col-actions > * { vertical-align: middle; }
.col-actions .btn + .btn, .col-actions .btn + .icon-btn { margin-left: 2px; }
.cell-main { font-weight: 500; }
.cell-sub { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; }
.cell-labels { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 8px; margin-top: 5px; }
.tag-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 1px 7px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); white-space: nowrap; }
.tag small { color: var(--muted); }
.tag--strong { border-color: #b9cfd0; background: var(--accent-soft); color: var(--accent); }
.code-chip { display: inline-block; font-family: var(--mono); font-size: 12px; padding: 1px 6px; border-radius: var(--radius-sm); background: #eceeec; color: #36434c; white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.code-chip--reg { background: var(--accent-soft); color: var(--accent); }
.person { white-space: nowrap; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: var(--radius-sm); line-height: 18px; white-space: nowrap; background: #eceeec; color: #4a5660; }
.badge--new { background: var(--info-soft); color: var(--info); }
.badge--in-progress { background: var(--warn-soft); color: var(--warn); }
.badge--under-review { background: var(--violet-soft); color: var(--violet); }
.badge--completed, .badge--active, .badge--yes { background: var(--ok-soft); color: var(--ok); }
.badge--overdue { background: var(--danger-soft); color: var(--danger); }
.badge--cancelled, .badge--inactive, .badge--no { background: #eceeec; color: #66717a; }
.badge--accent { background: var(--accent-soft); color: var(--accent); }
.badge--assigned, .badge--reassigned { background: var(--info-soft); color: var(--info); }
.badge--reminder { background: var(--warn-soft); color: var(--warn); }
.badge--prio { background: none; border: 1px solid var(--line-strong); color: var(--muted); font-weight: 500; }
.badge--prio-high { border-color: #e2c48a; color: var(--warn); }
.badge--prio-critical { border-color: #e0a7a1; color: var(--danger); font-weight: 600; }
.badge--prio-low { border-style: dashed; }

/* ---------- Alerts, empty states, notes ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid; }
.alert .icon { margin-top: 2px; }
.alert--success { background: var(--ok-soft); border-color: #bcdcc8; color: #1f4f33; }
.alert--error { background: var(--danger-soft); border-color: #e9bfba; color: #7d2b25; }
.alert--warning { background: var(--warn-soft); border-color: #ead39f; color: #6b4600; }
.alert--info { background: var(--info-soft); border-color: #c9d7ea; color: #2d4c72; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 36px 20px; text-align: center; color: var(--muted); }
.empty .icon { width: 22px; height: 22px; }
.empty p { margin: 0; max-width: 460px; }
.note { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); margin: 10px 0 0; }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager__info { color: var(--muted); font-size: 13px; }
.pager__links { display: flex; gap: 4px; flex-wrap: wrap; }
.pager__links a, .pager__links span { min-width: 32px; height: 30px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius); border: 1px solid var(--line); font-size: 13px; }
.pager__links a:hover { background: var(--surface-2); text-decoration: none; }
.pager__links .is-current { background: var(--accent); color: #fff; border-color: var(--accent); }
.pager__links .is-disabled { color: #a6aeb3; }
.pager__links .pager__gap { border: 0; }

/* ---------- Details lists ---------- */
.details { margin: 0; }
.detail dt { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.detail dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.plain-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.split-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.people-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.people-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.people-list__text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.people-list__text small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

/* ---------- Dashboard ---------- */
.metric-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.metric-group .card__title { color: var(--muted); font-weight: 500; font-size: 13px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.metric { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line); color: var(--text); background: var(--surface-2); }
.metric:hover { text-decoration: none; border-color: var(--line-strong); background: var(--surface); }
.metric__value { font-size: 28px; font-weight: 600; line-height: 1.1; }
.metric__label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.metric__label::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: currentColor; opacity: .5; }
.metric--new .metric__label::before { background: var(--info); opacity: 1; }
.metric--in-progress .metric__label::before { background: #c58a10; opacity: 1; }
.metric--overdue .metric__label::before { background: var(--danger); opacity: 1; }
.metric--overdue .metric__value { color: var(--danger); }

.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.board__col { background: #eceeeb; border-radius: var(--radius-lg); padding: 12px; border-top: 3px solid var(--info); }
.board__col--in-progress { border-top-color: #c58a10; }
.board__col--overdue { border-top-color: var(--danger); }
.board__head { display: flex; justify-content: space-between; align-items: center; }
.board__head h3 { font-size: 14px; }
.board__count { font-size: 12px; font-weight: 600; background: var(--surface); border-radius: 999px; padding: 0 8px; }
.board__hint { font-size: 12px; color: var(--muted); margin: 2px 0 10px; }
.board__empty { font-size: 13px; color: var(--muted); padding: 14px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius); margin: 0; }
.task-cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.task-card { display: flex; gap: 12px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); }
.task-card:hover { text-decoration: none; border-color: var(--line-strong); box-shadow: var(--shadow); }
.due-tile { flex: none; width: 46px; height: 50px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.due-tile__day { font-size: 19px; font-weight: 600; }
.due-tile__mon { font-size: 11px; color: var(--muted); margin-top: 3px; }
.due-tile--late { background: var(--danger-soft); border-color: #e9bfba; color: var(--danger); }
.due-tile--late .due-tile__mon { color: var(--danger); }
.task-card__body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.task-card__codes { display: flex; gap: 4px; flex-wrap: wrap; }
.task-card__name { font-weight: 500; overflow-wrap: anywhere; }
.task-card__due { font-size: 12px; color: var(--muted); }

/* ---------- Dropdown list navigation ---------- */
.list-nav { padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.list-nav__item { display: flex; flex-direction: column; padding: 8px 10px; border-radius: var(--radius); color: var(--text); }
.list-nav__item small { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.list-nav__item:hover { background: var(--surface-2); text-decoration: none; }
.list-nav__item.is-active { background: var(--accent-soft); color: var(--accent); }

/* ---------- Documents ---------- */
.doc-list { list-style: none; margin: 0 0 12px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.doc-list__item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.doc-list__item:last-child { border-bottom: 0; }
.doc-list__item > .icon { color: var(--muted); }
.doc-list__meta { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.doc-list__meta a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.doc-list__meta span { font-size: 12px; }
.doc-panel__empty { margin-bottom: 12px; }
.dropzone { display: block; border: 1.5px dashed var(--line-strong); border-radius: var(--radius-lg); padding: 18px; background: var(--surface-2); cursor: pointer; text-align: center; transition: background .15s, border-color .15s; }
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone__input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone__prompt { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); }
.dropzone__prompt .icon { width: 22px; height: 22px; color: var(--accent); }
.dropzone__prompt strong { color: var(--text); }
.dropzone__prompt small { font-size: 12px; }
.dropzone__files { list-style: none; margin: 10px 0 0; padding: 0; text-align: left; display: flex; flex-direction: column; gap: 4px; }
.dropzone__files:empty { display: none; }
.dropzone__files li { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 5px 8px; font-size: 13px; }
.dropzone__files li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone__files li.is-invalid { border-color: #e9bfba; background: var(--danger-soft); color: var(--danger); }

/* ---------- Timeline (logs and reviews) ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.timeline__item { position: relative; }
.timeline__item::before { content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.timeline--reviews .timeline__item::before { border-color: var(--violet); }
.timeline__meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); }
.timeline__meta span { color: var(--text); font-weight: 500; }
.timeline__status { margin-top: 4px; font-size: 12px; color: var(--muted); }
.timeline__text { margin: 4px 0 0; overflow-wrap: anywhere; }

/* ---------- Side drawer (logs) ---------- */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--drawer-w); max-width: 100vw; background: var(--surface);
  border-left: 1px solid var(--line); box-shadow: var(--shadow-pop); z-index: 60; display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .2s ease; visibility: hidden;
}
.drawer.is-open { transform: none; visibility: visible; }
.drawer__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer__head h2 { font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
.drawer__body { padding: 16px; overflow-y: auto; flex: 1; }
.drawer__context { color: var(--muted); font-size: 13px; }
@media (min-width: 1280px) {
  body.drawer-open .shell { margin-right: var(--drawer-w); }
  .drawer { box-shadow: none; }
}

/* ---------- Notifications ---------- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg__item { padding: 5px 12px; color: var(--muted); font-size: 13px; }
.seg__item + .seg__item { border-left: 1px solid var(--line); }
.seg__item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.seg__item:hover { text-decoration: none; }
.notice-list { list-style: none; margin: 0; padding: 0; }
.notice { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.notice.is-unread { background: #f8fbfb; box-shadow: inset 3px 0 0 var(--accent); }
.notice__head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.notice__meta { font-size: 12px; color: var(--muted); }

.json-details summary { cursor: pointer; font-size: 12px; color: var(--accent); }
.json-details pre { font-family: var(--mono); font-size: 11px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; max-width: 520px; max-height: 260px; overflow: auto; white-space: pre-wrap; }

/* ---------- Searchable select (picker) ---------- */
.picker { position: relative; }
.picker__native { position: absolute !important; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.picker__control {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px; min-height: 36px; padding: 4px 30px 4px 8px; border: 1px solid var(--line-strong);
  border-radius: var(--radius); background: var(--surface); cursor: pointer; position: relative;
}
.picker__control::after { content: ""; position: absolute; right: 11px; top: 50%; width: 6px; height: 6px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: translateY(-70%) rotate(45deg); }
.picker.is-open .picker__control, .picker__control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47, 93, 98, .18); }
.picker__placeholder { color: #8b959c; padding: 2px; }
.picker__single { padding: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.picker__chip { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--accent); border-radius: var(--radius-sm); padding: 1px 4px 1px 7px; font-size: 12px; max-width: 100%; }
.picker__chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker__chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 3px; border-radius: 3px; }
.picker__chip button:hover { background: rgba(47,93,98,.15); }
.picker__panel { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop); z-index: 45; padding: 6px; min-width: 220px; }
.picker__search { width: 100%; min-height: 32px; padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); font: inherit; margin-bottom: 4px; }
.picker__search:focus { outline: none; border-color: var(--accent); }
.picker__list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; }
.picker__option { padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; display: flex; align-items: center; gap: 8px; }
.picker__option.is-active { background: var(--surface-2); }
.picker__option.is-selected { color: var(--accent); font-weight: 500; }
.picker__option.is-selected::before { content: "\2713"; font-size: 12px; }
.picker__empty { padding: 8px; color: var(--muted); font-size: 13px; }

/* ---------- Sign-in pages ---------- */
body.auth { min-height: 100vh; }
.auth-shell { display: grid; grid-template-columns: minmax(280px, 40%) 1fr; min-height: 100vh; }
.auth-aside { background: var(--ink); color: var(--ink-text); padding: 40px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-aside .brand__name { font-size: 22px; }
.auth-aside__line { font-size: 18px; line-height: 1.5; max-width: 26ch; color: #e1e7ea; margin: 0; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-form { width: 100%; max-width: 380px; }
.auth-form h1 { font-size: 24px; margin-bottom: 6px; }
.auth-form .stack { margin-top: 20px; }
.auth-secondary { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.auth-card { max-width: 460px; margin: 12vh auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 32px; }
.auth-card h1 { font-size: 22px; margin-bottom: 8px; }
.auth-card__code { font-family: var(--mono); color: var(--muted); margin: 0 0 6px; }
.error-detail { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 10px; border-radius: var(--radius); white-space: pre-wrap; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .hide-md { display: none; }
  .layout-split, .layout-split--wide { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-span-2 { grid-column: 1 / -1; }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-pop); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(31, 42, 48, .35); z-index: 35; }
  .shell { margin-left: 0; }
  .topbar .topbar__menu { display: inline-flex; }
  .topbar { padding: 8px 14px; }
  .content { padding: 18px 14px 40px; }
  .metric-groups { grid-template-columns: minmax(0, 1fr); }
  .board { grid-template-columns: minmax(0, 1fr); }
  .layout-sidepanel { grid-template-columns: minmax(0, 1fr); }
  .list-nav { flex-direction: row; overflow-x: auto; }
  .list-nav__item { white-space: nowrap; }
  .list-nav__item small { display: none; }
}
@media (max-width: 720px) {
  .hide-sm { display: none; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .grid-span-2, .grid-span-3 { grid-column: auto; }
  .tenant-switch__label, .role-pill, .user-chip__name { display: none; }
  .tenant-switch__name { font-size: 16px; }
  .tenant-switch__text { max-width: 52vw; }
  .filters .field, .filters .field--grow, .filters .field--range { flex: 1 1 100%; }
  .filters__actions { margin-left: 0; width: 100%; }
  .filters__actions .btn { flex: 1; }
  .metrics { gap: 6px; }
  .metric { padding: 10px; }
  .metric__value { font-size: 22px; }
  .table th, .table td { padding: 9px 10px; }
  .auth-shell { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { padding: 22px 20px; gap: 12px; }
  .auth-aside__line { font-size: 15px; }
  .menu__panel--left { min-width: 240px; }
  :root { --drawer-w: 100vw; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print {
  .sidebar, .topbar, .drawer, .page-actions, .filters, .form-actions { display: none !important; }
  .shell { margin: 0; }
}
.table tbody tr.is-highlighted { background: var(--accent-soft); }
@media (min-width: 721px) { .table th.col-wide { min-width: 260px; } }
.transcript { font-family: var(--mono); font-size: 11.5px; line-height: 1.5; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; max-height: 320px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 12px; }
.detail--row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px; }
.detail--row dt { margin: 0; }
.detail--row dd { font-weight: 400; }
code { font-family: var(--mono); font-size: .92em; background: var(--surface-2); padding: 1px 4px; border-radius: 3px; }