/**
 * Airpart estimate — styles.
 *
 * Token values copied verbatim from okko_crm `web/src/styles.css` so the two
 * estimate pages are the same document in two projects: same surfaces, same
 * borders, same teal accent family, same type scale, same slim scrollbar.
 *
 * The teal `--est-*` family is deliberately NOT the product palette. An estimate
 * is a commercial document that sits next to the product, so it carries its own
 * accent — changing a button inside the ERP must not repaint this chart. The
 * Airpart ERP's own functional colour system (SOW §6.4) lives in `tech_task/01`.
 */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --fg: #1e1e1e;
  --muted: #5f6672;
  --border: #e5e8ec;
  --link: #1f5182;
  --ring: #2456c8;

  --est-accent: #0d9488;
  --est-accent-hover: #0f766e;
  --est-accent-fg: #ffffff;
  --est-accent-subtle: #ecfdf9;
  --est-accent-border: #99e6d9;
  --est-accent-text: #0f766e;
  --est-grid: #eef1f5;
  --est-weekend: #f7f9fb;

  --elevation-sm: 0 1px 2px 0 rgb(30 30 30 / 0.05), 0 1px 3px 0 rgb(30 30 30 / 0.06);
  --elevation-lg: 0 16px 40px -12px rgb(30 30 30 / 0.22), 0 4px 12px -6px rgb(30 30 30 / 0.1);

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1e1e1e;
    --surface: #242424;
    --surface-2: #2c2c2c;
    --fg: #f4f5f7;
    --muted: #a5aab1;
    --border: #343434;
    --link: #8fbce8;

    --est-accent: #2dd4bf;
    --est-accent-hover: #5eead4;
    --est-accent-fg: #06302b;
    --est-accent-subtle: #10322e;
    --est-accent-border: #1f5a52;
    --est-accent-text: #7fe6d6;
    --est-grid: #2a2a2a;
    --est-weekend: #1d1d1d;

    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.55;
  overflow-x: hidden;
}

img { max-width: 100%; }
[hidden] { display: none !important; }

/* ── type scale ──────────────────────────────────────────────────────────── */

.type-h1 { font-size: 1.5rem; font-weight: 700; line-height: 1.25; letter-spacing: -0.02em; }
.type-h2 { font-size: 1.25rem; font-weight: 600; line-height: 1.3; letter-spacing: -0.015em; }
.type-h3 { font-size: 1.125rem; font-weight: 600; line-height: 1.35; letter-spacing: -0.01em; }
.type-body { font-size: 0.9375rem; font-weight: 400; line-height: 1.55; }
.type-small { font-size: 0.8125rem; font-weight: 400; line-height: 1.5; }
.type-caption { font-size: 0.75rem; font-weight: 500; line-height: 1.4; }

.muted { color: var(--muted); }
.tabular { font-variant-numeric: tabular-nums; }
.track { letter-spacing: 0.12em; }

/* ── slim scrollbar ──────────────────────────────────────────────────────── */

.scrollbar-slim { scrollbar-width: thin; scrollbar-color: color-mix(in oklab, var(--muted) 30%, transparent) transparent; }
.scrollbar-slim::-webkit-scrollbar { width: 8px; height: 8px; }
.scrollbar-slim::-webkit-scrollbar-track { background: transparent; }
.scrollbar-slim::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  background-clip: content-box;
  border-radius: 9999px;
  background-color: color-mix(in oklab, var(--muted) 22%, transparent);
  transition: background-color 160ms ease-out;
}
.scrollbar-slim:hover::-webkit-scrollbar-thumb { background-color: color-mix(in oklab, var(--muted) 42%, transparent); }

/* ── page frame ──────────────────────────────────────────────────────────── */

.page { min-height: 100vh; padding: 20px 16px 40px; }
@media (min-width: 640px) { .page { padding: 24px 24px 48px; } }
@media (min-width: 1024px) { .page { padding: 24px 32px 48px; } }

.wrap { margin: 0 auto; max-width: 1900px; display: flex; flex-direction: column; gap: 20px; }

.card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--elevation-sm);
}

/* ── live bar ────────────────────────────────────────────────────────────── */

.livebar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
}
@media (min-width: 640px) { .livebar { padding: 14px 24px; } }
@media (min-width: 1024px) { .livebar { padding: 14px 32px; } }

.livebar-inner { margin: 0 auto; max-width: 1900px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 24px; }
.livebar-group { display: flex; align-items: baseline; gap: 8px; }
.livebar-cost { color: var(--est-accent-text); }

/* ── header ──────────────────────────────────────────────────────────────── */

.head { padding: 16px; }
.head-top { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; }
.head-id { display: flex; align-items: center; gap: 12px; }
.head-mark {
  display: flex; width: 40px; height: 40px; align-items: center; justify-content: center;
  border-radius: 8px; background: var(--est-accent-subtle); color: var(--est-accent-text);
}
.head-eyebrow { text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); margin: 0; }
.head-title { margin: 0; }
.head-actions { display: flex; align-items: center; gap: 8px; position: relative; }

.kpis { margin-top: 16px; display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.kpi { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 12px; }
.kpi.accent { border-color: var(--est-accent-border); background: var(--est-accent-subtle); }
.kpi-ico { display: flex; width: 36px; height: 36px; flex: none; align-items: center; justify-content: center; border-radius: 8px; background: var(--surface-2); color: var(--muted); }
.kpi.accent .kpi-ico { background: var(--est-accent); color: var(--est-accent-fg); }
.kpi-body { min-width: 0; }
.kpi-body p { margin: 0; }
.kpi-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

/* ── buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--fg);
  border-radius: 8px; padding: 8px 12px; cursor: pointer;
  font: inherit; font-size: 0.8125rem; line-height: 1.5;
  transition: background-color 140ms ease-out;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }

/* ── toolbar ─────────────────────────────────────────────────────────────── */

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px; }
.search { display: flex; flex: 1 1 260px; min-width: 260px; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.search input { width: 100%; border: 0; background: transparent; color: var(--fg); font: inherit; font-size: 0.8125rem; outline: none; }
.search input::placeholder { color: var(--muted); }

.switch { position: relative; display: inline-flex; height: 20px; width: 36px; flex: none; align-items: center; border-radius: 9999px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); transition: background-color 140ms ease-out; }
.switch.on { background: var(--est-accent); box-shadow: none; }
.switch span { position: absolute; left: 2px; width: 16px; height: 16px; border-radius: 9999px; background: var(--surface); box-shadow: var(--elevation-sm); transition: left 140ms ease-out; }
.switch.on span { left: 18px; }

/* ── roadmap ─────────────────────────────────────────────────────────────── */

.roadmap { overflow: hidden; }
.roadmap-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); padding: 12px 16px; }
.roadmap-head h2 { margin: 0; }
.chip { border-radius: 6px; background: var(--surface-2); padding: 2px 8px; color: var(--muted); }

.split { display: flex; }
.left { flex: none; }
.left-head { display: flex; height: 45px; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); padding: 0 16px; color: var(--muted); font-weight: 500; letter-spacing: 0.04em; }
.col-wbs { width: 56px; flex: none; }
.col-title { min-width: 0; flex: 1; }
.col-cost { width: 96px; flex: none; text-align: right; }
.col-switch { width: 40px; flex: none; }

.row { display: flex; height: 36px; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); padding: 0 16px; }
.row.epic { background: var(--surface-2); }
.row.task { background: var(--surface); transition: background-color 140ms ease-out; }
.row.task:hover { background: var(--surface-2); }
.row.task.active { background: var(--est-accent-subtle); }
.row .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .off { color: var(--muted); text-decoration: line-through; }

.row-open { display: flex; min-width: 0; flex: 1; align-items: center; gap: 8px; border: 0; background: none; padding: 0; text-align: left; cursor: pointer; color: inherit; font: inherit; }
.row-caret { display: inline-block; transition: transform 140ms ease-out; }
.row-caret.open { transform: rotate(90deg); }
.icon-btn { border: 0; background: none; padding: 0; cursor: pointer; color: inherit; font: inherit; display: flex; }
.icon-btn.right { width: 40px; flex: none; justify-content: flex-end; }

.resizer {
  position: relative; width: 6px; flex: none; cursor: col-resize;
  border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  background: var(--surface-2); transition: background-color 140ms ease-out;
}
.resizer:hover, .resizer.active { background: var(--est-accent); }
.resizer i { position: absolute; left: 50%; top: 64px; height: 32px; width: 3px; transform: translateX(-50%); border-radius: 9999px; background: var(--border); }
.resizer:hover i, .resizer.active i { background: var(--est-accent-fg); }

.chart { min-width: 0; flex: 1; overflow-x: auto; cursor: grab; }
.chart.panning { cursor: grabbing; }
.chart-head { border-bottom: 1px solid var(--border); }
.chart-weeks, .chart-days { display: flex; height: 22px; }
.chart-weeks > div { flex: none; overflow: hidden; border-right: 1px solid var(--border); padding: 0 8px; color: var(--muted); font-size: 0.75rem; font-weight: 500; line-height: 22px; }
.chart-days > div { flex: none; overflow: hidden; text-align: center; color: var(--muted); font-size: 0.75rem; font-weight: 500; line-height: 22px; }
.we { background: var(--est-weekend); }

.chart-body { position: relative; }
.grid-layer { pointer-events: none; position: absolute; inset: 0; display: flex; }
.grid-layer > div { flex: none; border-right: 1px solid var(--est-grid); }

.bar-row { position: relative; height: 36px; border-bottom: 1px solid var(--border); }
.bar-row.epic { background: color-mix(in oklab, var(--surface-2) 85%, transparent); }
.bar-row.active { background: color-mix(in oklab, var(--est-accent-subtle) 80%, transparent); }

.epic-line { position: absolute; top: 50%; height: 3px; transform: translateY(-50%); border-radius: 9999px; background: var(--est-accent); }
.epic-line.off { background: var(--border); }
.epic-tip { position: absolute; top: 50%; width: 10px; height: 10px; transform: translateY(-50%) rotate(45deg); background: var(--est-accent); }
.epic-tip.off { background: var(--border); }

.bar {
  position: absolute; top: 50%; display: flex; height: 20px; transform: translateY(-50%);
  align-items: center; gap: 4px; overflow: hidden; border: 0; border-radius: 4px; padding: 0 6px;
  cursor: pointer; background: var(--est-accent); color: var(--est-accent-fg);
  font: inherit; font-size: 0.75rem; font-weight: 500; line-height: 1;
  transition: opacity 140ms ease-out;
}
.bar:hover { opacity: 0.9; }
.bar.off { background: var(--surface-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }

.footnote { padding-bottom: 32px; color: var(--muted); }
.footnote a { color: var(--link); text-underline-offset: 2px; }
.footnote a:hover { text-decoration: none; }

/* ── date picker ─────────────────────────────────────────────────────────── */

.pop { position: absolute; right: 0; top: 100%; z-index: 50; margin-top: 8px; width: 300px; border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 12px; box-shadow: var(--elevation-lg); }
.pop-head { margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; }
.pop-nav { border: 0; background: none; cursor: pointer; border-radius: 6px; padding: 4px 8px; color: var(--muted); font: inherit; }
.pop-nav:hover { background: var(--surface-2); color: var(--fg); }
.dow, .grid7 { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.dow { margin-bottom: 4px; }
.dow span { text-align: center; color: var(--muted); font-size: 0.75rem; font-weight: 500; }
.day { height: 32px; border: 0; background: none; border-radius: 6px; cursor: pointer; color: inherit; font: inherit; font-size: 0.75rem; font-weight: 500; transition: background-color 140ms ease-out; }
.day:hover:not(:disabled) { background: var(--surface-2); }
.day:disabled { cursor: not-allowed; color: var(--muted); opacity: 0.4; }
.day.start { background: var(--est-accent); color: var(--est-accent-fg); }
.scrim { position: fixed; inset: 0; z-index: 40; border: 0; background: none; cursor: default; }

/* ── detail panel ────────────────────────────────────────────────────────── */

.panel-scrim { position: fixed; inset: 0; z-index: 40; border: 0; background: rgb(0 0 0 / 0.25); cursor: default; }
.panel {
  position: fixed; inset-block: 0; right: 0; z-index: 50; width: 100%; max-width: 720px;
  overflow-y: auto; border-left: 1px solid var(--border); background: var(--surface); box-shadow: var(--elevation-lg);
}
.panel-head { border-bottom: 1px solid var(--border); padding: 20px; }
.panel-head-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.panel-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.panel-close { border: 0; background: none; border-radius: 6px; padding: 4px; cursor: pointer; color: var(--muted); font: inherit; }
.panel-close:hover { background: var(--surface-2); color: var(--fg); }
.panel-body { display: flex; flex-direction: column; gap: 24px; padding: 20px; }

.badge { border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; color: var(--muted); font-size: 0.75rem; font-weight: 500; }
.badge.accent { border-color: var(--est-accent-border); background: var(--est-accent-subtle); color: var(--est-accent-text); }

.ministats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ministat { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 8px 12px; }
.ministat.accent { border-color: var(--est-accent-border); background: var(--est-accent-subtle); }
.ministat p { margin: 0; }
.ministat.accent .ministat-v { color: var(--est-accent-text); }

.block > .block-head { margin-bottom: 8px; display: flex; align-items: center; gap: 8px; color: var(--muted); }
.block-head h3 { margin: 0; font-size: 0.75rem; font-weight: 500; letter-spacing: 0.04em; }
.boxed { border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; }
.boxed.accent { border-color: var(--est-accent-border); background: var(--est-accent-subtle); }
.schedule { display: flex; align-items: center; justify-content: space-between; }

.bullets { margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.bullets li { display: flex; gap: 8px; font-size: 0.8125rem; line-height: 1.5; }
.dot { margin-top: 7px; width: 6px; height: 6px; flex: none; border-radius: 9999px; background: var(--est-accent); }
.dot.grey { background: var(--muted); }
.sublabel { margin: 16px 0 0; color: var(--muted); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.04em; }

.shots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.shot { min-width: 0; margin: 0; }
.shot button { display: block; width: 100%; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; padding: 0; background: none; cursor: zoom-in; transition: border-color 140ms ease-out; }
.shot button:hover { border-color: var(--est-accent); }
.shot img { aspect-ratio: 16 / 10; width: 100%; background: var(--surface-2); object-fit: cover; object-position: top; display: block; }
.shot figcaption { margin-top: 4px; color: var(--muted); font-size: 0.75rem; font-weight: 500; }
.shot figcaption .n { display: block; font-weight: 400; opacity: 0.85; }

/* ── lightbox ────────────────────────────────────────────────────────────── */

.lightbox { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; background: rgb(0 0 0 / 0.8); padding: 16px; }
@media (min-width: 640px) { .lightbox { padding: 24px; } }
.lightbox-head { margin-bottom: 12px; display: flex; flex: none; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.lightbox-head p { margin: 0; color: #fff; }
.lightbox-head .count { color: rgb(255 255 255 / 0.7); }
.lightbox-stage { position: relative; display: flex; min-height: 0; flex: 1; align-items: center; justify-content: center; }
.lightbox-stage img { max-height: 100%; max-width: 100%; border-radius: 8px; object-fit: contain; box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.5); }
.nav {
  position: absolute; z-index: 10; display: flex; width: 48px; height: 48px; align-items: center; justify-content: center;
  border: 1px solid rgb(255 255 255 / 0.25); border-radius: 9999px; background: rgb(0 0 0 / 0.4);
  color: #fff; font-size: 1.5rem; cursor: pointer;
}
.nav:hover { background: rgb(0 0 0 / 0.7); }
.nav.prev { left: 0; }
.nav.next { right: 0; }
.lightbox .btn-ghost { border: 1px solid rgb(255 255 255 / 0.25); background: none; color: #fff; border-radius: 8px; padding: 8px 12px; cursor: pointer; font: inherit; font-size: 0.8125rem; }
.lightbox .btn-ghost:hover { background: rgb(255 255 255 / 0.1); }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}
