/* 주소톡 Work OS — public/ styles.
   Palette matches the existing jusotok-growth ops dashboard (see
   scripts/lib/dashboard-render.mjs) so the two tools read as one system:
   categorical --series-N for identity, reserved --status-* for state
   (verdict / job status / column identity for the terminal states).
   System font stack, no external fonts, mobile-first (375px). */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --surface-2: #f2f1ec;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);

  --series-1: #2a78d6;
  --series-2: #008300;
  --series-3: #e87ba4;
  --series-4: #eda100;
  --series-5: #1baf7a;
  --series-6: #eb6834;
  --series-7: #4a3aa7;
  --series-8: #e34948;

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
  --delta-good: #006300;
  --delta-bad: #d03b3b;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-1: 0 8px 28px rgba(11, 11, 11, 0.14);
  --focus-ring: 0 0 0 3px rgba(42, 120, 214, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --surface-2: #232322;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #21a621;
    --series-3: #d55181;
    --series-4: #c98500;
    --series-5: #199e70;
    --series-6: #d95926;
    --series-7: #9085e9;
    --series-8: #e66767;
    --status-good: #21c221;
    --status-warning: #ffc94d;
    --status-serious: #ff9a70;
    --status-critical: #ff6b6b;
    --delta-good: #21c221;
    --delta-bad: #ff6b6b;
    --shadow-1: 0 8px 28px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #232322;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #21a621;
  --series-3: #d55181;
  --series-4: #c98500;
  --series-5: #199e70;
  --series-6: #d95926;
  --series-7: #9085e9;
  --series-8: #e66767;
  --status-good: #21c221;
  --status-warning: #ffc94d;
  --status-serious: #ff9a70;
  --status-critical: #ff6b6b;
  --delta-good: #21c221;
  --delta-bad: #ff6b6b;
  --shadow-1: 0 8px 28px rgba(0, 0, 0, 0.5);
}

/* --- Reset --- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body {
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  width: 100%;
}
h1, h2, h3, p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 15px; }
a { color: inherit; }
body.modal-open, body.detail-open { overflow: hidden; }

.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;
}

/* --- Buttons --- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  border-radius: 999px;
  min-height: 44px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.12s ease, background 0.12s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn-primary { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.btn-secondary { background: var(--surface-2); border-color: var(--border); color: var(--text-primary); }
.btn-danger { background: var(--status-critical); border-color: var(--status-critical); color: #fff; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-tiny { min-height: 44px; padding: 4px 14px; font-size: 12.5px; }
.btn-icon { min-width: 44px; min-height: 44px; padding: 0; border-radius: 50%; font-size: 16px; }
.btn-new { white-space: nowrap; }

/* --- Header / nav --- */
.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  position: sticky;
  top: 0;
  z-index: 15;
}
.app-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.main-nav { display: flex; gap: 4px; flex: 1 1 auto; }
.main-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
}
.main-nav a.active { background: var(--surface-2); color: var(--series-1); }
.header-user { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-name { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }

.view-root { max-width: 1400px; margin: 0 auto; padding: 12px 12px 32px; }

.loading, .empty, .empty-note {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 20px 8px;
}
.error-state {
  color: var(--status-critical);
  font-size: 13px;
  text-align: center;
  padding: 20px 8px;
}

/* --- Card shell (used by analytics + generic sections) --- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-top: 12px;
}
.card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* --- Badges / dots --- */
.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  color: #fff;
  white-space: nowrap;
  line-height: 1.7;
}
.badge-type { background: var(--text-muted); }
.badge-p1 { background: var(--status-critical); }
.badge-status-good { background: var(--status-good); }
.badge-status-warning { background: var(--status-warning); color: #241900; }
.badge-status-critical { background: var(--status-critical); }
.badge-status-neutral { background: var(--text-muted); }
.badge-status-neutral-dim { background: var(--gridline); color: var(--text-muted); }
.badge-row { display: flex; gap: 6px; flex-wrap: wrap; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-status-good { background: var(--status-good); }
.dot-status-warning { background: var(--status-warning); }
.dot-status-critical { background: var(--status-critical); }
.dot-status-neutral { background: var(--text-muted); }
.dot-status-neutral-dim { background: var(--gridline); }

/* --- Board view --- */
.board-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.board-toolbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.board-tabs { display: flex; flex-wrap: wrap; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 999px; }
.board-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
}
.board-tab.active { background: var(--surface-1); color: var(--series-1); box-shadow: 0 1px 3px rgba(0,0,0,0.12); }
.subaxis-filter { margin-top: 8px; background: transparent; padding: 0; }
.board-tab-sub {
  background: var(--surface-2);
  min-height: 38px;
  padding: 0 12px;
  font-size: 12.5px;
}
.board-tab-sub.active { background: var(--series-1); color: #fff; box-shadow: none; }

.board-columns {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 2px 2px 12px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}
.board-column {
  flex: 0 0 82vw;
  max-width: 320px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  min-height: 200px;
}
.board-column.column-blocked { background: var(--gridline); opacity: 0.92; }
.column-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; }
.column-title { font-size: 13px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.02em; }
.column-count { margin-left: auto; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.column-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
/* Column identity color cycles through the shared --series-N palette by
   column position, since the column *set* itself is server-defined per axis
   (GET /api/board?axis=) rather than a fixed local list of status names. */
.column-dot-0 { background: var(--series-1); }
.column-dot-1 { background: var(--series-2); }
.column-dot-2 { background: var(--series-3); }
.column-dot-3 { background: var(--series-4); }
.column-dot-4 { background: var(--series-5); }
.column-dot-5 { background: var(--series-6); }
.column-dot-6 { background: var(--series-7); }
.column-dot-7 { background: var(--series-8); }

.column-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 80px;
  border-radius: var(--radius-md);
  padding: 2px;
  transition: background 0.12s ease;
}
.column-body.dropzone-active { background: rgba(42, 120, 214, 0.12); outline: 2px dashed var(--series-1); }
.column-empty { color: var(--text-muted); font-size: 12px; text-align: center; padding: 14px 4px; }

.work-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gridline);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: grab;
}
.work-card:active { cursor: grabbing; }
.work-card.dragging { opacity: 0.5; }
.work-card.card-p1 { border-left-color: var(--status-critical); }
.work-card:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.card-top { display: flex; gap: 6px; align-items: center; }
.card-title { font-size: 14px; font-weight: 700; line-height: 1.35; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-muted); }
.card-assignee { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stars { letter-spacing: 1px; color: var(--gridline); font-size: 13px; }
.star-filled { color: var(--status-warning); }
.card-status-fallback { display: block; }
.status-select {
  width: 100%;
  min-height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 12.5px;
  padding: 4px 8px;
}

/* --- Forms (shared: new-item modal, meta form, login) --- */
.form-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--text-secondary); font-weight: 600; }
.field input, .field select, .field textarea {
  min-height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-primary);
  padding: 8px 10px;
  font-size: 14px;
}
.field textarea { min-height: 76px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--series-1);
}
.req { color: var(--status-critical); }
.form-error { color: var(--status-critical); font-size: 12.5px; }

@media (min-width: 620px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .field-wide { grid-column: 1 / -1; }
}

/* --- Modals --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 11, 11, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
  padding: 0;
}
.modal-card {
  background: var(--surface-1);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom, 0));
  box-shadow: var(--shadow-1);
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.modal-message { font-size: 14px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; grid-column: 1 / -1; }
.modal-actions-inline { justify-content: flex-start; }

@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal-card { border-radius: var(--radius-lg); max-height: 84vh; padding: 22px 24px; }
}

/* --- Toast --- */
.toast-root {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 90;
  width: min(92vw, 420px);
  align-items: center;
}
.toast {
  width: 100%;
  background: var(--text-primary);
  color: var(--page);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow: var(--shadow-1);
}
.toast-in { opacity: 1; transform: translateY(0); }
.toast-out { opacity: 0; transform: translateY(8px); }
.toast-good { background: var(--status-good); color: #fff; }
.toast-critical { background: var(--status-critical); color: #fff; }
.toast-warning { background: var(--status-warning); color: #241900; }

/* --- Detail panel (drawer on desktop, sheet on mobile) --- */
.detail-root { position: relative; z-index: 70; }
.detail-root:not(.open) { display: none; }
.detail-overlay { position: fixed; inset: 0; background: rgba(11, 11, 11, 0.45); }
.detail-panel {
  position: fixed;
  inset: 0;
  background: var(--surface-1);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-1);
}
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.detail-title { font-size: 16px; font-weight: 700; line-height: 1.3; }
.detail-body { overflow-y: auto; padding: 4px 16px 32px; flex: 1; -webkit-overflow-scrolling: touch; }
.detail-section { padding: 14px 0; border-bottom: 1px solid var(--gridline); }
.detail-section:last-of-type { border-bottom: none; }
.section-title { font-size: 12.5px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 10px; }
.detail-footnote { font-size: 11.5px; color: var(--text-muted); padding: 12px 0 4px; }

@media (min-width: 900px) {
  .detail-panel { inset: 0 0 0 auto; width: 440px; }
}

.action-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.eval-widget { display: flex; flex-direction: column; gap: 10px; }
.star-pick-row { display: flex; gap: 4px; }
.star-pick {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--gridline);
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
}
.star-pick.star-pick-on { color: var(--status-warning); border-color: var(--status-warning); }
.eval-widget textarea { min-height: 60px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); padding: 8px 10px; font-size: 14px; resize: vertical; color: var(--text-primary); }
.btn-eval-save { align-self: flex-start; }

.trash-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface-2);
  border: 1px solid var(--status-warning);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.trash-banner p { font-size: 13px; color: var(--text-secondary); }

.verify-widget { display: flex; flex-direction: column; gap: 8px; }
.verify-evidence {
  font-size: 12.5px;
  color: var(--text-secondary);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  word-break: break-word;
  line-height: 1.5;
}

.job-list, .event-list, .activity-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.job-row { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 12px; background: var(--surface-2); }
.job-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.job-kind { font-size: 13.5px; font-weight: 700; }
.job-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.job-cancel { margin-left: auto; }
.job-log { margin-top: 8px; }
.job-log summary { cursor: pointer; font-size: 12px; color: var(--series-1); font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.log-pre {
  background: var(--page);
  border: 1px solid var(--gridline);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 11.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
  color: var(--text-secondary);
  margin-top: 6px;
}

.event-row { border-bottom: 1px solid var(--gridline); padding-bottom: 8px; }
.event-row:last-child { border-bottom: none; }
.event-kind { display: inline-block; font-size: 11.5px; font-weight: 700; color: var(--series-1); margin-right: 6px; }
.event-detail { font-size: 13px; color: var(--text-primary); margin: 3px 0; line-height: 1.45; }
.event-meta { font-size: 11px; color: var(--text-muted); }

/* --- Activity view ("작업 기록") --- */
.activity-subtitle { font-size: 12.5px; color: var(--text-muted); margin: -6px 0 12px; }
.activity-row { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--gridline); }
.activity-row:last-child { border-bottom: none; }
.activity-row .dot { margin-top: 6px; }
.activity-main { flex: 1; min-width: 0; }
.activity-head { display: flex; align-items: center; gap: 8px; }
.activity-kind { font-size: 12.5px; font-weight: 700; color: var(--series-1); }
.activity-item-link { cursor: pointer; text-decoration: underline; }
.activity-detail { font-size: 13.5px; margin: 4px 0; line-height: 1.5; word-break: break-word; }
.activity-meta { font-size: 11px; color: var(--text-muted); }

/* --- Analytics view --- */
.verdict-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; margin-top: 4px; }
/* Text color intentionally omitted here — the paired .badge-status-* class
   sets the correct foreground for its background (dark ink on the amber
   warning tone, white everywhere else) regardless of CSS source order. */
.verdict-badge { display: inline-block; font-size: 13px; font-weight: 700; padding: 4px 12px; border-radius: 999px; margin-bottom: 8px; }
.verdict-line { font-size: 15px; line-height: 1.5; }

.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
.kpi-tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px; min-height: 96px; display: flex; flex-direction: column; gap: 4px; }
.kpi-label { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.kpi-value { font-size: 26px; font-weight: 700; font-variant-numeric: proportional-nums; line-height: 1.1; }
.kpi-sub { font-size: 11px; color: var(--text-muted); }
.kpi-foot { margin-top: auto; }
.delta { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.delta.good { color: var(--delta-good); }
.delta.bad { color: var(--delta-bad); }
.delta.flat { color: var(--text-muted); font-weight: 500; }

.chart { width: 100%; height: auto; display: block; }
.chart-baseline { stroke: var(--baseline); stroke-width: 1; }
.chart-grid { stroke: var(--gridline); stroke-width: 1; }
.chart-axis { fill: var(--text-muted); font-size: 8px; font-family: system-ui, -apple-system, sans-serif; }
.chart-value { fill: var(--text-primary); font-size: 10px; font-weight: 700; font-family: system-ui, -apple-system, sans-serif; }
.legend { display: flex; gap: 14px; margin-bottom: 6px; font-size: 12px; color: var(--text-secondary); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

@media (min-width: 640px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }

/* --- Login page --- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px 16px; }
.login-shell { width: 100%; max-width: 380px; }
.login-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-1);
}
.login-title { font-size: 20px; font-weight: 700; }
.login-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }

/* --- Responsive expansion --- */
@media (min-width: 1024px) {
  .board-column { flex-basis: 260px; }
  .view-root { padding: 20px 24px 40px; }
}
