/* ═══════════════════════════════════════════════════════════════
   삼우물산 OPS — 공용 컴포넌트
   tokens.css 다음에 import 하세요.
   ═══════════════════════════════════════════════════════════════ */

@import url('./tokens.css');

* { margin: 0; padding: 0; box-sizing: border-box; }

/* Reset cosmic-theme h*-tag colors (inherited via tokens.css → colors_and_type.css).
   In ops_design, plain <h1>–<h6> use the light theme's primary text colour. */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-1);
  font-family: var(--font-ui);
  font-weight: 700;
  line-height: var(--lh-snug);
  letter-spacing: -0.01em;
}

html, body {
  background: var(--surface);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: var(--fs-13);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ─── Type primitives ────────────────────────────── */
.h1 { font-size: var(--fs-32); font-weight: 800; line-height: var(--lh-tight); letter-spacing: -0.02em; color: var(--text-1); }
.h2 { font-size: var(--fs-24); font-weight: 800; line-height: var(--lh-snug); letter-spacing: -0.015em; color: var(--text-1); }
.h3 { font-size: var(--fs-18); font-weight: 700; line-height: var(--lh-snug); letter-spacing: -0.01em; color: var(--text-1); }
.h4 { font-size: var(--fs-14); font-weight: 700; color: var(--text-1); }

.body  { font-size: var(--fs-14); color: var(--text-2); line-height: var(--lh-normal); }
.body-sm { font-size: var(--fs-13); color: var(--text-3); }
.meta  { font-size: var(--fs-11); color: var(--text-3); letter-spacing: 0.04em; }
.label { font-size: var(--fs-11); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.eyebrow { font-size: var(--fs-11); color: var(--accent); text-transform: uppercase; letter-spacing: 0.10em; font-weight: 600; }

/* Numbers — always use these classes for any numeric display */
.num   { font-family: var(--font-numeric); font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: 0; }
.num-display { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-weight: 900; letter-spacing: -0.02em; }

.kpi-num {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  font-size: var(--fs-48);
  line-height: var(--lh-tight);
  letter-spacing: -0.025em;
  color: var(--text-1);
}
.kpi-num-sm {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: var(--fs-28);
  line-height: var(--lh-tight);
  letter-spacing: -0.015em;
  color: var(--text-1);
}

/* ─── Card / surface ─────────────────────────────── */
.card {
  background: var(--surface-card);
  border: var(--bd-soft);
  border-radius: var(--r-4);
  box-shadow: var(--shadow-2);
}
.card-flat {
  background: var(--surface-card);
  border-top: var(--bd);
  border-bottom: var(--bd);
}
.card-pad   { padding: var(--s-6); }
.card-pad-l { padding: var(--s-8); }

/* ─── Hairline divider ───────────────────────────── */
.hr  { height: 1px; background: var(--hairline); border: 0; }
.hr-soft { height: 1px; background: var(--hairline-soft); border: 0; }

/* ─── Buttons ────────────────────────────────────── */
.btn {
  font-family: var(--font-ui);
  font-size: var(--fs-13);
  font-weight: 600;
  line-height: 1;
  border-radius: var(--r-2);
  padding: 9px 14px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
}
.btn-primary:hover { background: var(--accent-deep); }
.btn-secondary {
  background: var(--surface-card);
  color: var(--text-1);
  border-color: var(--hairline);
}
.btn-secondary:hover { background: var(--surface-sunk); }
.btn-ghost {
  background: transparent;
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--surface-sunk); color: var(--text-1); }
.btn-danger {
  background: var(--st-urgent);
  color: white;
}
.btn-danger:hover { background: #B71823; }
.btn-sm  { padding: 6px 10px; font-size: var(--fs-12); }
.btn-lg  { padding: 12px 20px; font-size: var(--fs-14); }
.btn-icon { padding: 8px; }

/* ─── Status chip (shape + colour + dot) ────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 3px 10px 3px 8px;
  border-radius: var(--r-pill);
  font-size: var(--fs-11);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  line-height: 1.4;
}
.chip::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.chip-urgent   { background: var(--st-urgent-bg);   color: var(--st-urgent); }
.chip-todo     { background: var(--st-todo-bg);     color: var(--st-todo); }
.chip-progress { background: var(--st-progress-bg); color: var(--st-progress); }
.chip-done     { background: var(--st-done-bg);     color: var(--st-done); }
.chip-info     { background: var(--st-info-bg);     color: var(--st-info); }

/* Squared variant — for table cells where rounded pills feel out of place */
.chip-sq { border-radius: var(--r-2); padding: 2px 8px; }

/* ─── Input ──────────────────────────────────────── */
.input {
  font-family: var(--font-ui);
  font-size: var(--fs-13);
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  padding: 10px 12px;
  color: var(--text-1);
  width: 100%;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  outline: none;
}
.input::placeholder { color: var(--text-4); }
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.input-lg { padding: 14px 16px; font-size: var(--fs-15); }
.input-sm { padding: 6px 10px; font-size: var(--fs-12); }

.field-row { display: flex; flex-direction: column; gap: 6px; }

/* ─── Table ──────────────────────────────────────── */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-13);
}
.tbl thead th {
  font-size: var(--fs-11);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-3);
  text-align: left;
  padding: 10px 14px;
  border-bottom: var(--bd);
  background: var(--surface-sunk);
}
.tbl tbody td {
  padding: 14px;
  border-bottom: var(--bd-soft);
  vertical-align: middle;
  color: var(--text-1);
}
.tbl tbody tr:hover td { background: var(--surface-sunk); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num-cell { font-family: var(--font-numeric); font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }
.tbl .num-cell.urgent { color: var(--st-urgent); }

/* ─── KPI card ───────────────────────────────────── */
.kpi {
  background: var(--surface-card);
  border: var(--bd-soft);
  border-radius: var(--r-4);
  padding: var(--s-6);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.kpi .kpi-label {
  font-size: var(--fs-11);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 600;
}
.kpi .kpi-delta {
  font-family: var(--font-numeric);
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--text-3);
}
.kpi .kpi-delta.up { color: var(--st-done); }
.kpi .kpi-delta.down { color: var(--st-urgent); }

/* ─── Top bar / app frame ────────────────────────── */
.topbar {
  height: 56px;
  background: var(--surface-card);
  border-bottom: var(--bd);
  display: flex;
  align-items: center;
  padding: 0 var(--s-6);
  gap: var(--s-6);
  position: sticky; top: 0; z-index: 50;
}
.topbar .brand {
  font-weight: 900;
  font-size: var(--fs-15);
  letter-spacing: -0.01em;
}

/* ─── Sidebar ────────────────────────────────────── */
.sidebar {
  width: 240px;
  background: var(--surface-card);
  border-right: var(--bd);
  display: flex;
  flex-direction: column;
  padding: var(--s-4) var(--s-3);
  gap: 2px;
  flex-shrink: 0;
}
.sidebar .nav-section {
  font-size: var(--fs-10);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--text-4);
  font-weight: 600;
  padding: var(--s-4) var(--s-3) var(--s-1);
}
.sidebar .nav-item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 8px 12px;
  border-radius: var(--r-2);
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.sidebar .nav-item:hover { background: var(--surface-sunk); color: var(--text-1); }
.sidebar .nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-weight: 600;
}
.sidebar .nav-item .ic { font-size: 16px; line-height: 1; }
.sidebar .nav-item .count {
  margin-left: auto;
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: var(--fs-11);
  padding: 0 6px;
  border-radius: var(--r-2);
  background: var(--surface-sunk);
  color: var(--text-3);
}
.sidebar .nav-item.urgent .count { background: var(--st-urgent-bg); color: var(--st-urgent); }

/* ─── Layouts ────────────────────────────────────── */
.app-grid { display: grid; grid-template-columns: 240px 1fr; height: 100vh; }
.main { overflow-y: auto; }
.page-pad { padding: var(--s-7) var(--s-8); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-5); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--s-5); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-5); }

.row { display: flex; align-items: center; gap: var(--s-3); }
.col { display: flex; flex-direction: column; gap: var(--s-3); }
.spread { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); }

/* ─── Icon (currentColor 1.5px stroke) ──────────── */
.ic-svg { width: 16px; height: 16px; flex-shrink: 0; stroke: currentColor; stroke-width: 1.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* ─── Sparkline placeholder ─────────────────────── */
.spark {
  height: 32px; width: 100%;
  background: linear-gradient(to bottom, var(--accent-soft) 0%, transparent 100%);
  position: relative;
}
.spark svg { width: 100%; height: 100%; }

/* ═══════════════════════════════════════════════════════════════
   Mobile responsive (≤640 px)
   ───────────────────────────────────────────────────────────────
   • Sidebar collapses behind a burger; tap-out closes it.
   • KPI grid 4 → 2×2, two-col splits stack.
   • Tables compact: hide secondary cols, primary stays.
   • Topbar tightens; modal goes full-screen.
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {

  /* App frame */
  .app-grid { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 200;
    width: 280px; max-width: 86vw;
    transform: translateX(-100%);
    transition: transform 240ms var(--ease);
    box-shadow: var(--shadow-4);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed; inset: 0; z-index: 190;
    background: rgba(0,0,0,0.55);
    opacity: 0; pointer-events: none;
    transition: opacity 240ms var(--ease);
  }
  .sidebar-backdrop.on { opacity: 1; pointer-events: auto; }

  /* Burger button — shown only on mobile */
  .burger {
    display: inline-flex !important;
    width: 40px; height: 40px;
    align-items: center; justify-content: center;
    background: transparent; border: 1px solid var(--hairline);
    border-radius: var(--r-2); color: var(--text-1); cursor: pointer;
  }
  .burger svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; }

  .topbar { padding: 0 var(--s-4); gap: var(--s-3); }
  .topbar .breadcrumb { font-size: var(--fs-12); }
  .topbar .search { display: none; }    /* search moves into a tap-to-open overlay */
  .topbar .meta-right { gap: var(--s-2); }
  .topbar .meta-right span:nth-child(1),
  .topbar .meta-right span:nth-child(2) { display: none; }   /* keep avatar only */

  /* Pages */
  .page-pad { padding: var(--s-5) var(--s-4); }

  /* Headings tighten */
  .h1 { font-size: var(--fs-22); }
  .h2 { font-size: var(--fs-18); }

  /* KPI 4 → 2×2 */
  .kpi-row,
  .grid-4 { grid-template-columns: 1fr 1fr !important; gap: var(--s-3); }
  .grid-3, .grid-2, .grid-83 { grid-template-columns: 1fr !important; }
  .kpi { padding: var(--s-4); }
  .kpi .kpi-num { font-size: var(--fs-28); }

  /* Tables: hide secondary columns on mobile.
     Mark them with .mobile-hide and they vanish below 640px. */
  .tbl .mobile-hide { display: none; }
  .tbl thead th,
  .tbl tbody td { padding: 10px 10px; }
  .tbl thead th { font-size: 9px; letter-spacing: 0.06em; }

  /* Two-pane layouts stack */
  .work-grid,
  .grid-83 { grid-template-columns: 1fr !important; height: auto !important; }

  /* Buttons tighter */
  .btn { padding: 10px 12px; font-size: var(--fs-13); }
  .btn-sm { padding: 6px 10px; }

  /* Modal becomes full-screen sheet */
  .backdrop { padding: 0 !important; align-items: stretch !important; }
  .modal {
    max-width: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    height: 100vh;
  }

  /* Filter pill rows scroll horizontally */
  .filter-bar,
  .filter-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .filter-bar::-webkit-scrollbar,
  .filter-tabs::-webkit-scrollbar { display: none; }

  /* Health foot wraps */
  .health-foot { flex-wrap: wrap; gap: var(--s-2); font-size: var(--fs-11); }
  .health-foot .health-bar { max-width: 100%; }
}

/* Burger is hidden on desktop by default */
.burger { display: none; }
