/* Crewbook: design tokens, app shell and shared components. */

:root {
  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
  --bg: #f3f6f6;
  --surface: #ffffff;
  --surface-2: #f4f7f7;
  --surface-3: #e8eded;
  --hover: #eef3f3;
  --border: #dfe6e6;
  --border-strong: #c7d1d1;
  --grid: #e6ebeb;
  --text: #12201f;
  --text-2: #3f5156;
  --text-3: #5c6d72;
  --accent: #0f766e;
  --accent-hover: #0b6159;
  --accent-soft: #e1f2ef;
  --accent-soft-2: #c4e6df;
  --accent-text: #0b6a62;
  --on-accent: #ffffff;
  --focus: #0f766e;

  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100;
  --c5: #e87ba4; --c6: #008300; --c7: #6250d6; --c8: #e34948;

  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --crit: #d03b3b;
  --good-text: #006300; --warn-text: #7a5000; --serious-text: #9a3c14; --crit-text: #ac2828;
  --good-soft: #e2f4e2; --warn-soft: #fdf2d6; --serious-soft: #fde9df; --crit-soft: #fbe4e4;
  --leave: #6250d6; --leave-soft: #ebe8fb; --leave-text: #4636ad; --on-leave: #ffffff;
  --wfh: #2a78d6; --wfh-soft: #e2edfb; --wfh-text: #1a5aa5;
  --neutral-soft: #eceff0; --neutral-text: #4d5d62;
  --off-bg: #eef1f1;

  --shadow-sm: 0 1px 2px rgba(16, 32, 32, .06);
  --shadow: 0 1px 2px rgba(16, 32, 32, .05), 0 6px 20px rgba(16, 32, 32, .06);
  --shadow-lg: 0 18px 48px rgba(10, 24, 24, .2);
  --scrim: rgba(9, 20, 22, .48);
  --radius: 14px; --radius-sm: 10px; --radius-xs: 7px;
  --sidebar-w: 248px; --rail-w: 72px; --topbar-h: 64px; --tabbar-h: 64px;
  --gutter: 32px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a1112; --surface: #111a1c; --surface-2: #162124; --surface-3: #1d2a2d; --hover: #1a2629;
    --border: #253539; --border-strong: #34474c; --grid: #203034;
    --text: #e4eded; --text-2: #b4c3c5; --text-3: #93a5a8;
    --accent: #2fb3a3; --accent-hover: #4cc6b7; --accent-soft: rgba(47, 179, 163, .15); --accent-soft-2: rgba(47, 179, 163, .3); --accent-text: #5fd2c3; --on-accent: #052421; --focus: #5fd2c3;
    --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #008300; --c7: #9085e9; --c8: #e66767;
    --good-text: #6fd56f; --warn-text: #f4c55c; --serious-text: #f2a382; --crit-text: #f28b8b;
    --good-soft: rgba(12, 163, 12, .18); --warn-soft: rgba(250, 178, 25, .15); --serious-soft: rgba(236, 131, 90, .16); --crit-soft: rgba(208, 59, 59, .2);
    --leave: #9085e9; --leave-soft: rgba(144, 133, 233, .18); --leave-text: #b8b0f5; --on-leave: #15103a;
    --wfh: #3987e5; --wfh-soft: rgba(57, 135, 229, .18); --wfh-text: #91bdf3;
    --neutral-soft: #1f2c2f; --neutral-text: #a9b9bc; --off-bg: #152023;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25); --shadow-lg: 0 18px 48px rgba(0, 0, 0, .55);
    --scrim: rgba(0, 0, 0, .62);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a1112; --surface: #111a1c; --surface-2: #162124; --surface-3: #1d2a2d; --hover: #1a2629;
  --border: #253539; --border-strong: #34474c; --grid: #203034;
  --text: #e4eded; --text-2: #b4c3c5; --text-3: #93a5a8;
  --accent: #2fb3a3; --accent-hover: #4cc6b7; --accent-soft: rgba(47, 179, 163, .15); --accent-soft-2: rgba(47, 179, 163, .3); --accent-text: #5fd2c3; --on-accent: #052421; --focus: #5fd2c3;
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #008300; --c7: #9085e9; --c8: #e66767;
  --good-text: #6fd56f; --warn-text: #f4c55c; --serious-text: #f2a382; --crit-text: #f28b8b;
  --good-soft: rgba(12, 163, 12, .18); --warn-soft: rgba(250, 178, 25, .15); --serious-soft: rgba(236, 131, 90, .16); --crit-soft: rgba(208, 59, 59, .2);
  --leave: #9085e9; --leave-soft: rgba(144, 133, 233, .18); --leave-text: #b8b0f5; --on-leave: #15103a;
  --wfh: #3987e5; --wfh-soft: rgba(57, 135, 229, .18); --wfh-text: #91bdf3;
  --neutral-soft: #1f2c2f; --neutral-text: #a9b9bc; --off-bg: #152023;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25); --shadow-lg: 0 18px 48px rgba(0, 0, 0, .55);
  --scrim: rgba(0, 0, 0, .62);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html.scroll-lock, html.scroll-lock body { overflow: hidden; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; overflow-x: hidden;
}
h1, h2, h3, p { margin: 0; }
img, svg, video { max-width: 100%; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
ul, ol { margin: 0; padding: 0; list-style: none; }
dl, dd { margin: 0; }
table { border-collapse: collapse; }
[hidden] { display: none !important; }
[id] { scroll-margin-top: calc(var(--topbar-h) + 16px); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.icon { flex: none; display: inline-block; vertical-align: middle; }
.sr-only { position: absolute !important; 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: 12px; top: -60px; z-index: 100; background: var(--accent); color: var(--on-accent); padding: 10px 14px; border-radius: 8px; font-weight: 600; }
.skip-link:focus { top: 10px; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.strong { font-weight: 700; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .01em; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.block { display: block; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.phone-only, .phone-only-inline { display: none; }

/* ---------- shell ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 0 20px; background: var(--surface); background: color-mix(in srgb, var(--surface) 92%, transparent); border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); min-width: 0; }
.brand:hover { text-decoration: none; }
.brand > span:first-child { display: inline-flex; }
.brand-word { font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.logo-mark { display: block; }
.demo-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent-text); white-space: nowrap; border: 1px solid var(--accent-soft-2);
}
.demo-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.demo-short { display: none; }
.topbar-org { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 13px; font-weight: 600; margin-left: 8px; padding-left: 14px; border-left: 1px solid var(--border); white-space: nowrap; }
.topbar-org > span:first-child { display: inline-flex; }
.topbar-spacer { flex: 1; min-width: 0; }
.topbar .nav-toggle { display: none; }
.user-btn {
  display: inline-flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 999px; border: 1px solid transparent; background: none; min-height: 44px;
}
.user-btn:hover { background: var(--hover); }
.user-btn[aria-expanded="true"] { background: var(--hover); border-color: var(--border); }
.user-meta { display: flex; flex-direction: column; text-align: left; line-height: 1.2; }
.user-name { font-weight: 700; font-size: 13.5px; }
.user-role { font-size: 12px; color: var(--text-3); }
.user-chev { display: inline-flex; color: var(--text-3); }

.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w); z-index: 20; display: flex; flex-direction: column;
  padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto;
}
.sidebar nav { flex: 1; }
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 12px; border-radius: 10px;
  color: var(--text-2); font-weight: 600; font-size: 14px;
}
.nav-link:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }
.nav-link[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-badge { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--warn-soft); color: var(--warn-text); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.sidebar-foot .nav-link > span:first-child { display: inline-flex; }
.credit { font-size: 12px; color: var(--text-3); padding: 0 12px; }
.credit strong { color: var(--text-2); }
.sidebar-head { display: none; }
.nav-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 25; }

.content { margin-left: var(--sidebar-w); padding: calc(var(--topbar-h) + 28px) var(--gutter) 48px; min-width: 0; max-width: calc(1480px + var(--sidebar-w)); outline: none; }
.tabbar { display: none; }

/* tablet: icon rail with tooltips */
@media (max-width: 1023.98px) {
  :root { --gutter: 24px; }
  .sidebar { width: var(--rail-w); padding: 12px 10px; overflow: visible; }
  .nav-link { justify-content: center; padding: 10px; gap: 0; }
  .nav-link[aria-current="page"]::before { left: -10px; }
  .nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .nav-badge { position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; font-size: 11px; padding: 0 4px; }
  .nav-link::after {
    content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%); white-space: nowrap;
    background: var(--text); color: var(--surface); font-size: 12.5px; font-weight: 600; padding: 5px 9px; border-radius: 7px; pointer-events: none;
    opacity: 0; transition: opacity .12s; z-index: 40; box-shadow: var(--shadow);
  }
  .nav-link:hover::after, .nav-link:focus-visible::after { opacity: 1; }
  .credit { display: none; }
  .content { margin-left: var(--rail-w); }
  .topbar-org { display: none; }
}

/* phone: top app bar + off-canvas drawer + bottom tab bar */
@media (max-width: 639.98px) {
  :root { --gutter: 16px; --topbar-h: 56px; }
  body { font-size: 14.5px; }
  .topbar { padding: 0 8px 0 4px; gap: 4px; }
  .topbar .nav-toggle { display: inline-flex; }
  .brand-word { font-size: 17px; }
  .brand { gap: 8px; }
  .demo-long { display: none; }
  .demo-short { display: inline; }
  .demo-pill { padding: 2px 8px; font-size: 11.5px; margin-left: 2px; }
  .user-meta, .user-chev { display: none; }
  .user-btn { padding: 4px; }
  .sidebar {
    top: 0; width: min(300px, 86vw); padding: 16px 12px calc(16px + env(safe-area-inset-bottom)); z-index: 35; overflow-y: auto;
    transform: translateX(-100%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s; box-shadow: var(--shadow-lg);
  }
  .sidebar { padding-top: 8px; }
  .sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 0 10px 8px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
  html.nav-open .sidebar { transform: none; visibility: visible; transition: transform .22s ease; }
  .nav-link { justify-content: flex-start; padding: 8px 12px; gap: 12px; }
  .nav-label { position: static; width: auto; height: auto; clip: auto; overflow: hidden; }
  .nav-badge { position: static; }
  .nav-link::after { display: none; }
  .nav-link[aria-current="page"]::before { left: -12px; }
  .credit { display: block; }
  .content { margin-left: 0; padding: calc(var(--topbar-h) + 18px) var(--gutter) calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 28; background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 16px rgba(0, 0, 0, .04);
  }
  .tabbar ul { display: grid; grid-template-columns: repeat(5, 1fr); height: var(--tabbar-h); }
  .tab-link { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 100%; color: var(--text-3); font-size: 11.5px; font-weight: 600; }
  .tab-link:hover { text-decoration: none; }
  .tab-link[aria-current="page"] { color: var(--accent-text); }
  .tab-link[aria-current="page"] .tab-ico { background: var(--accent-soft); }
  .tab-ico { position: relative; display: inline-flex; padding: 3px 14px; border-radius: 999px; }
  .tab-dot { position: absolute; top: -4px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--warn); color: #3b2800; font-size: 10.5px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
  .phone-only { display: block; }
  .phone-only-inline { display: inline; }
  .phone-hidden, .wide-only { display: none !important; }
}
@media (min-width: 640px) { .wide-hidden { display: none !important; } }
@media (max-width: 359.98px) { .demo-pill { display: none; } }

/* ---------- typography + page ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-titles { min-width: 0; }
.page-title { font-size: 26px; line-height: 1.2; font-weight: 800; letter-spacing: -.02em; }
.page-sub { color: var(--text-3); margin-top: 4px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
@media (max-width: 639.98px) { .page-title { font-size: 22px; } .page-head { margin-bottom: 16px; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border-radius: 10px;
  border: 1px solid transparent; font-weight: 650; font-size: 14px; line-height: 1.2; white-space: nowrap; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--hover); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-danger { background: var(--crit); color: #fff; }
.btn-danger:hover { background: #b52f2f; }
.btn-good { background: var(--good-soft); color: var(--good-text); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.btn-good:hover { background: color-mix(in srgb, var(--good) 22%, var(--surface)); }
.btn-ghost-crit { background: transparent; color: var(--crit-text); border-color: color-mix(in srgb, var(--crit) 30%, transparent); }
.btn-ghost-crit:hover { background: var(--crit-soft); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 13px; border-radius: 9px; gap: 6px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--text-2); flex: none;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn-outline { border-color: var(--border-strong); background: var(--surface); width: 40px; height: 40px; }
.icon-btn-sm { width: 36px; height: 36px; }
.icon-btn:disabled { opacity: .45; }
.link-more { display: inline-flex; align-items: center; gap: 4px; font-weight: 650; font-size: 13.5px; color: var(--accent-text); white-space: nowrap; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 6px 0; color: var(--accent-text); font-weight: 650; min-height: 36px; }
.link-like { display: inline-flex; align-items: center; gap: 2px; color: var(--accent-text); font-weight: 650; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); min-width: 0; }
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head-pad { padding: 18px 20px 0; }
.card-titles { min-width: 0; flex: 1 1 200px; }
.card-title { font-size: 16px; font-weight: 750; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.card-sub { color: var(--text-3); font-size: 13px; margin-top: 2px; }
.card-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; min-width: 0; }
.card-head-pad .card-tools { flex: 1 1 auto; }
.card-tools .search { flex: 0 1 280px; min-width: 220px; }
.card-tools select.input { width: auto; max-width: 100%; }
@media (max-width: 639.98px) { .card-tools { width: 100%; } .card-tools .search { flex: 1 1 100%; min-width: 0; } .card-tools select.input { flex: 1 1 100%; } }
@media (max-width: 639.98px) { .card { padding: 16px; } .card-head-pad { padding: 16px 16px 0; } .card-flush { padding: 0; } }

/* ---------- chips, avatars, meters ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 7px; border-radius: 999px; font-size: 12.5px; font-weight: 650;
  white-space: nowrap; line-height: 1.35; max-width: 100%;
}
.chip > span { overflow: hidden; text-overflow: ellipsis; }
.chip-good { background: var(--good-soft); color: var(--good-text); }
.chip-warn { background: var(--warn-soft); color: var(--warn-text); }
.chip-serious { background: var(--serious-soft); color: var(--serious-text); }
.chip-crit { background: var(--crit-soft); color: var(--crit-text); }
.chip-leave { background: var(--leave-soft); color: var(--leave-text); }
.chip-wfh { background: var(--wfh-soft); color: var(--wfh-text); }
.chip-neutral { background: var(--neutral-soft); color: var(--neutral-text); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.avatar {
  --av: 36px; flex: none; width: var(--av); height: var(--av); border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: calc(var(--av) * .36); font-weight: 750; letter-spacing: .02em;
}
.avatar-sm { --av: 32px; }
.avatar-lg { --av: 44px; }
.avatar-xl { --av: 60px; }
.tint-1 { background: #dbe8fb; color: #1d4f91; } .tint-2 { background: #fde3d6; color: #8d3511; }
.tint-3 { background: #d6f2e7; color: #0d5e40; } .tint-4 { background: #fbefcf; color: #6e4b00; }
.tint-5 { background: #fbe1ec; color: #8a2a52; } .tint-6 { background: #dff0dc; color: #1f5a12; }
.tint-7 { background: #e6e2fa; color: #3f2fa3; } .tint-8 { background: #fbdede; color: #8f2424; }
:root[data-theme="dark"] .avatar { filter: none; }
:root[data-theme="dark"] .tint-1 { background: #1d3550; color: #b5d2f6; } :root[data-theme="dark"] .tint-2 { background: #4a2a1c; color: #f6c3aa; }
:root[data-theme="dark"] .tint-3 { background: #173f33; color: #a8e6cf; } :root[data-theme="dark"] .tint-4 { background: #45360f; color: #f4d690; }
:root[data-theme="dark"] .tint-5 { background: #47233a; color: #f3bad2; } :root[data-theme="dark"] .tint-6 { background: #1f3b1a; color: #b9e2ae; }
:root[data-theme="dark"] .tint-7 { background: #2d2856; color: #cbc4f7; } :root[data-theme="dark"] .tint-8 { background: #4a2323; color: #f5b9b9; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tint-1 { background: #1d3550; color: #b5d2f6; } :root:not([data-theme="light"]) .tint-2 { background: #4a2a1c; color: #f6c3aa; }
  :root:not([data-theme="light"]) .tint-3 { background: #173f33; color: #a8e6cf; } :root:not([data-theme="light"]) .tint-4 { background: #45360f; color: #f4d690; }
  :root:not([data-theme="light"]) .tint-5 { background: #47233a; color: #f3bad2; } :root:not([data-theme="light"]) .tint-6 { background: #1f3b1a; color: #b9e2ae; }
  :root:not([data-theme="light"]) .tint-7 { background: #2d2856; color: #cbc4f7; } :root:not([data-theme="light"]) .tint-8 { background: #4a2323; color: #f5b9b9; }
}
.meter { display: block; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; min-width: 40px; }
.meter-fill { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.meter-good .meter-fill { background: var(--good); }
.meter-leave .meter-fill { background: var(--leave); }
.meter-crit .meter-fill { background: var(--crit); }
.meter-accent .meter-fill { background: var(--accent); }
.tone-accent { background: var(--accent-soft); color: var(--accent-text); }
.tone-good { background: var(--good-soft); color: var(--good-text); }
.tone-warn { background: var(--warn-soft); color: var(--warn-text); }
.tone-serious { background: var(--serious-soft); color: var(--serious-text); }
.tone-crit { background: var(--crit-soft); color: var(--crit-text); }
.tone-leave { background: var(--leave-soft); color: var(--leave-text); }
.tone-wfh { background: var(--wfh-soft); color: var(--wfh-text); }
.tone-neutral { background: var(--neutral-soft); color: var(--neutral-text); }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); box-shadow: var(--shadow-sm); min-width: 0; transition: border-color .12s, box-shadow .12s;
}
a.kpi:hover { text-decoration: none; border-color: var(--accent-soft-2); box-shadow: var(--shadow); }
.kpi-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.kpi-icon { width: 32px; height: 32px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.kpi-label { font-size: 13px; font-weight: 650; color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.kpi-unit { font-size: 15px; font-weight: 650; color: var(--text-3); letter-spacing: 0; }
.kpi-sub { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; }
.delta-up { color: var(--good-text); }
@media (max-width: 639.98px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpis > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 23px; }
  .kpi-icon { width: 28px; height: 28px; }
  .kpi-label { white-space: normal; line-height: 1.25; }
}

/* ---------- forms ---------- */
.input {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: 14px; transition: border-color .12s, box-shadow .12s; min-width: 0;
}
.input::placeholder { color: var(--text-3); opacity: .85; }
.input:hover { border-color: color-mix(in srgb, var(--text-3) 60%, var(--border-strong)); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft-2); }
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7c80' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
textarea.input { resize: vertical; min-height: 84px; }
.input[aria-invalid="true"] { border-color: var(--crit); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--crit-soft); }
.checkbox { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; flex: none; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; min-height: 40px; cursor: pointer; white-space: nowrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-full { grid-column: 1 / -1; }
.field-label { font-size: 13px; font-weight: 650; color: var(--text-2); }
.field-opt { font-weight: 500; color: var(--text-3); }
.field-hint { font-size: 12px; color: var(--text-3); }
.field-error { font-size: 12.5px; color: var(--crit-text); font-weight: 600; }
.field-error:empty { display: none; }
.form-note { font-size: 13px; color: var(--text-2); }
.form-note:empty { display: none; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
@media (max-width: 639.98px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .input, select.input, textarea.input { font-size: 16px; min-height: 44px; }
}

.search { position: relative; flex: 1 1 220px; min-width: 0; max-width: 360px; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 38px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; min-width: 0; }
.toolbar > * { min-width: 0; }
.toolbar select.input { width: auto; max-width: 100%; }
.toolbar-filters { display: flex; gap: 8px; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; }
.toolbar-note { flex: 1 1 260px; }
@media (max-width: 639.98px) {
  .search { max-width: none; flex-basis: 100%; }
  .toolbar-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .toolbar-filters select.input { width: 100%; }
  .toolbar > select.input { flex: 1 1 140px; }
}

/* segmented + tabs */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: 11px; max-width: 100%; overflow-x: auto; scrollbar-width: none; flex: none; }
.seg::-webkit-scrollbar { display: none; }
.seg-btn {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; min-height: 36px; padding: 6px 12px; border-radius: 8px; font-weight: 650;
  font-size: 13px; color: var(--text-2); white-space: nowrap;
}
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg-count { min-width: 20px; padding: 0 6px; height: 20px; border-radius: 999px; background: var(--surface-2); font-size: 11.5px; display: inline-flex; align-items: center; justify-content: center; }
.seg-btn[aria-pressed="true"] .seg-count { background: var(--accent-soft); color: var(--accent-text); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 7px; border: 0; background: none; padding: 10px 14px 12px; min-height: 44px; font-weight: 650;
  color: var(--text-3); white-space: nowrap; border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--text); background: var(--hover); }
.tab[aria-selected="true"] { color: var(--accent-text); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); }
.tab-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--warn-soft); color: var(--warn-text); font-size: 11.5px; display: inline-flex; align-items: center; justify-content: center; }
@media (max-width: 639.98px) { .tab { padding: 10px 10px 12px; } .tabs { margin-left: calc(-1 * var(--gutter)); margin-right: calc(-1 * var(--gutter)); padding: 0 var(--gutter); } }

/* ---------- tables ---------- */
.table-wrap { position: relative; overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
.table { width: 100%; font-size: 13.5px; }
.table th, .table td { padding: 11px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table thead th { font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); white-space: nowrap; }
.table tbody th { font-weight: 600; }
.table tbody tr:last-child th, .table tbody tr:last-child td { border-bottom: 0; }
.table tfoot th, .table tfoot td { font-weight: 750; background: var(--surface-2); border-top: 1px solid var(--border-strong); border-bottom: 0; }
.table .num { text-align: right; }
.table-compact th, .table-compact td { padding: 8px 12px; }
.row-click { cursor: pointer; }
.row-click:hover th, .row-click:hover td { background: var(--hover); }
.table td.act { text-align: right; width: 1%; white-space: nowrap; }
.has-lop { color: var(--crit-text); font-weight: 700; }

/* people */
.person-link { display: inline-flex; align-items: center; gap: 10px; background: none; border: 0; padding: 2px; text-align: left; min-width: 0; max-width: 100%; color: inherit; border-radius: 8px; min-height: 40px; }
button.person-link:hover .person-name { color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; }
.person-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.person-name { font-weight: 650; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-sub { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.list { display: flex; flex-direction: column; }
.person-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.person-row:last-child { border-bottom: 0; }
.person-row > .person-link { flex: 1 1 auto; }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 28px 16px; }
.empty-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); color: var(--text-3); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 4px; }
.empty-title { font-weight: 700; }
.empty-text { color: var(--text-3); font-size: 13px; max-width: 360px; }
.empty .btn { margin-top: 8px; }
.kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; }
.kv { min-width: 0; }
.kv dt { font-size: 12px; font-weight: 650; color: var(--text-3); display: flex; align-items: center; gap: 6px; text-transform: uppercase; letter-spacing: .03em; }
.kv dd { font-weight: 600; margin-top: 2px; overflow-wrap: anywhere; }
.kv-tight { gap: 8px 16px; }
@media (max-width: 479.98px) { .kv-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- layers ---------- */
.layer { position: fixed; inset: 0; z-index: 60; }
.layer .scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity .18s; }
.layer.open .scrim { opacity: 1; }
.layer-modal { display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal {
  position: relative; width: 100%; max-width: 560px; max-height: calc(100vh - 48px); display: flex; flex-direction: column; background: var(--surface);
  border-radius: 18px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); opacity: 0; transform: translateY(10px) scale(.98); transition: opacity .18s, transform .18s; outline: none;
}
.layer.open .modal { opacity: 1; transform: none; }
.modal-sm { max-width: 460px; }
.modal-lg { max-width: 820px; }
.dlg-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 16px 12px 22px; border-bottom: 1px solid var(--border); }
.dlg-titles { flex: 1; min-width: 0; padding-top: 4px; }
.dlg-title { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.dlg-sub { color: var(--text-3); font-size: 13px; margin-top: 2px; }
.dlg-body { padding: 18px 22px; overflow-y: auto; overscroll-behavior: contain; flex: 1 1 auto; min-height: 0; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.confirm-body p { color: var(--text-2); }
.layer-drawer .drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(620px, 100%); background: var(--surface); box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .22s ease; outline: none; overflow-y: auto; overscroll-behavior: contain;
}
.layer-drawer.open .drawer { transform: none; }
.drawer-top { position: sticky; top: 0; z-index: 2; display: flex; justify-content: flex-end; padding: 10px 12px 0; height: 0; }
.drawer-close { background: var(--surface); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.layer-menu { inset: auto; }
.menu {
  position: fixed; z-index: 70; width: 290px; max-width: calc(100vw - 16px); background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 8px; animation: pop .14s ease;
}
.menu-head { display: flex; gap: 12px; align-items: center; padding: 10px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; min-width: 0; }
.menu-head > div { min-width: 0; }
.menu-name { font-weight: 750; }
.menu-sub { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 8px 10px; border-radius: 9px; border: 0; background: none; color: var(--text); font-weight: 600; text-align: left; }
.menu-item:hover { background: var(--hover); text-decoration: none; }
.menu-item .icon { color: var(--text-3); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }
.menu-credit { font-size: 12px; color: var(--text-3); padding: 6px 10px 4px; }
.layer-pop { inset: auto; }
.layer-pop-sheet { inset: 0; }
.popover {
  position: fixed; z-index: 70; width: 320px; max-width: calc(100vw - 16px); background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 12px 14px 14px; animation: pop .14s ease; outline: none;
}
.pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.pop-title { font-size: 14.5px; font-weight: 750; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

@media (max-width: 639.98px) {
  .layer-modal { padding: 0; align-items: flex-end; }
  .modal, .modal-sm, .modal-lg {
    max-width: none; width: 100%; max-height: 92vh; max-height: 92dvh; border-radius: 18px 18px 0 0; border-bottom: 0; transform: translateY(40px);
  }
  .modal::before { content: ""; position: absolute; top: 7px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--border-strong); }
  .dlg-head { padding: 20px 10px 10px 16px; }
  .dlg-body { padding: 16px; }
  .dlg-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .dlg-foot .btn { flex: 1 1 0; }
  .layer-drawer .drawer { width: 100%; }
  .popover-sheet { position: absolute; left: 0; right: 0; bottom: 0; top: auto; width: 100%; max-width: none; border-radius: 18px 18px 0 0; padding: 14px 16px calc(18px + env(safe-area-inset-bottom)); animation: sheet .2s ease; }
  @keyframes sheet { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 90; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; max-width: calc(100vw - 32px); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px; border-radius: 12px; background: var(--text); color: var(--surface);
  box-shadow: var(--shadow-lg); font-weight: 600; font-size: 13.5px; max-width: 440px; opacity: 0; transform: translateY(8px); transition: opacity .18s, transform .18s;
}
.toast.in { opacity: 1; transform: none; }
.toast-icon { display: inline-flex; flex: none; }
.toast-good .toast-icon { color: #5fd17a; }
.toast-crit .toast-icon { color: #ff9a9a; }
.toast-info .toast-icon { color: #8cc6ff; }
:root[data-theme="dark"] .toast-good .toast-icon { color: #0b7a0b; }
:root[data-theme="dark"] .toast-crit .toast-icon { color: #b02a2a; }
:root[data-theme="dark"] .toast-info .toast-icon { color: #1d5fae; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .toast-good .toast-icon { color: #0b7a0b; }
  :root:not([data-theme="light"]) .toast-crit .toast-icon { color: #b02a2a; }
  :root:not([data-theme="light"]) .toast-info .toast-icon { color: #1d5fae; }
}
.toast-msg { flex: 1; min-width: 0; }
.toast-act { border: 0; background: none; color: inherit; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; padding: 6px 8px; min-height: 36px; white-space: nowrap; }
.toast-x { border: 0; background: none; color: inherit; opacity: .7; display: inline-flex; padding: 6px; min-height: 36px; align-items: center; }
.toast-x:hover { opacity: 1; }
html.scroll-lock .toasts { bottom: auto; top: 16px; }
@media (max-width: 639.98px) {
  html.scroll-lock .toasts { bottom: auto; top: 12px; }
  .toasts { left: 12px; right: 12px; bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); align-items: stretch; max-width: none; }
  .toast { max-width: none; }
}

/* ---------- charts ---------- */
.chart-card .card-head { margin-bottom: 8px; }
.chart-host { position: relative; width: 100%; min-width: 0; }
.chart-card.has-fill { display: flex; flex-direction: column; }
.chart-host.chart-fill { flex: 1 1 auto; }
.chart-host.chart-fill > .chart-svg { position: absolute; left: 0; top: 0; }
.chart-svg { display: block; overflow: visible; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; }
.chart-svg .axis { stroke: var(--border-strong); stroke-width: 1; }
.chart-svg .tick { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; font-family: var(--font); }
.chart-svg .hb-label { fill: var(--text-2); font-size: 12.5px; font-weight: 600; font-family: var(--font); }
.chart-svg .hb-value, .chart-svg .cap-label { fill: var(--text); font-size: 12px; font-weight: 700; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart-svg .hit { fill: transparent; }
.chart-svg .mark { outline: none; cursor: default; }
.chart-svg .mark.active .hit { fill: var(--hover); }
.chart-svg .mark:focus-visible .hit { fill: var(--hover); stroke: var(--focus); stroke-width: 2; }
.chart-svg .mark.active .bar { filter: brightness(1.08) saturate(1.05); }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 150px; max-width: 240px; padding: 9px 11px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); font-size: 12.5px; opacity: 0; transform: translateY(4px); transition: opacity .1s, transform .1s;
}
.chart-tip.on { opacity: 1; transform: none; }
.tip-title { font-weight: 700; color: var(--text-2); margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 8px; line-height: 1.6; }
.tip-key { width: 12px; height: 3px; border-radius: 2px; flex: none; }
.tip-key-none { background: transparent; }
.tip-val { font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.tip-lbl { color: var(--text-3); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 10px; font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.legend li { display: inline-flex; align-items: center; gap: 7px; }
.swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.chart-toggle { margin-left: auto; }
.chart-table .table-wrap { border: 1px solid var(--border); border-radius: 10px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; scroll-behavior: auto !important; }
}
#print-area { display: none; }
