/* ==========================================================================
   PO / PR Approval Tracker — professional theme
   ========================================================================== */

:root {
  color-scheme: light;

  --bg: #f4f6fb;
  --bg-glow: #e8eefc;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --line: #e5e9f1;
  --line-strong: #d3dae6;

  --ink: #0f172a;
  --muted: #64748b;

  --brand: #14306b;
  --brand-2: #1d4ed8;
  --accent: #2563eb;
  --focus-ring: rgba(37, 99, 235, 0.18);

  --ok: #15803d;
  --ok-bg: #e7f6ec;
  --ok-line: #b6e3c4;
  --warn: #b45309;
  --warn-bg: #fdf3e3;
  --warn-line: #f2d9a8;
  --danger: #b91c1c;
  --danger-bg: #fdeaea;
  --danger-line: #f3bcbc;
  --info-bg: #eef2f9;
  --info-line: #d7dfec;
  --info-text: #334155;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-md: 0 6px 20px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 24px 60px rgba(16, 24, 40, 0.16);
  --radius: 12px;
  --radius-lg: 16px;
  --on-accent: #ffffff;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #080d1a;
  --bg-glow: #101c38;
  --surface: #0f172a;
  --surface-2: #131d33;
  --line: #1f2b45;
  --line-strong: #2b3a5c;

  --ink: #e6ebf5;
  --muted: #93a1bd;

  --brand: #1d4ed8;
  --brand-2: #3b82f6;
  --accent: #3b82f6;
  --focus-ring: rgba(59, 130, 246, 0.22);

  --ok: #86efac;
  --ok-bg: rgba(34, 197, 94, 0.14);
  --ok-line: rgba(34, 197, 94, 0.4);
  --warn: #fcd34d;
  --warn-bg: rgba(245, 158, 11, 0.14);
  --warn-line: rgba(245, 158, 11, 0.4);
  --danger: #fecaca;
  --danger-bg: rgba(239, 68, 68, 0.14);
  --danger-line: rgba(239, 68, 68, 0.42);
  --info-bg: rgba(148, 163, 184, 0.12);
  --info-line: rgba(148, 163, 184, 0.28);
  --info-text: #cbd5e1;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", "Segoe UI", Roboto, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .15s ease, color .15s ease;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
.muted { color: var(--muted); }

/* ------------------------------- topbar --------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 10px 24px;
  display: flex; align-items: center; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; background: linear-gradient(140deg, var(--brand-2), var(--brand));
  box-shadow: var(--shadow-sm);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; }
.brand-text small { color: var(--muted); font-size: 11.5px; white-space: nowrap; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 600; color: var(--info-text);
}
.user-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }

/* --------------------------- segmented tabs ----------------------------- */

.view-tabs {
  display: inline-flex; gap: 3px; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
}
.view-tab {
  appearance: none; border: 0; cursor: pointer;
  padding: 7px 18px; border-radius: 8px; background: transparent;
  color: var(--muted); font: inherit; font-size: 13px; font-weight: 600;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.view-tab:hover { color: var(--ink); }
.view-tab.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

/* ------------------------------ buttons --------------------------------- */

button { font: inherit; }
.btn-primary, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; font-size: 13.5px; font-weight: 650;
  cursor: pointer; border: 1px solid transparent; transition: all .15s ease; white-space: nowrap;
}
.btn-primary {
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  box-shadow: 0 1px 2px rgba(29, 78, 216, 0.25);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: .55; cursor: default; filter: none; }
.btn-ghost {
  color: var(--ink); background: var(--surface); border-color: var(--line-strong);
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--muted); }
.btn-ghost:disabled { opacity: .5; cursor: default; }

.icon-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px; border-radius: 10px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink);
  font-size: 12.5px; font-weight: 600;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { display: block; }

/* ------------------------------ layout ---------------------------------- */

.container { max-width: 1240px; margin: 0 auto; padding: 24px; }
.view[hidden] { display: none; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow-sm);
}
.card h2 { font-size: 15px; margin-bottom: 4px; }
.card h2 .n { color: var(--muted); font-weight: 500; }

/* ------------------------------- filters -------------------------------- */

.filters {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow-sm);
}
.filters-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.filters-head h2 { font-size: 14px; }
.filters-hint { color: var(--muted); font-size: 12px; }

.filter-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { color: var(--muted); font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; }
.field select, .field input:not([type="checkbox"]):not([type="radio"]) {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font-size: 13.5px; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field select:focus, .field input:not([type="checkbox"]):not([type="radio"]):focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.field-wide { grid-column: span 2; }
@media (max-width: 720px) { .field-wide { grid-column: span 1; } }

.radio-group { display: flex; gap: 8px; padding: 3px 0; }
.radio-group label {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: var(--surface); font-size: 13.5px; font-weight: 600; color: var(--muted);
}
.radio-group label:has(input:checked) { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.radio-group input { accent-color: var(--accent); margin: 0; }

.filter-actions { display: flex; gap: 10px; margin-top: 16px; }

/* --------------------------- multi-select (BU) -------------------------- */

.multi { position: relative; }
.multi-toggle {
  width: 100%; text-align: left; padding: 10px 32px 10px 12px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-size: 13.5px; font-weight: 500; cursor: pointer; position: relative;
}
.multi-toggle:hover { border-color: var(--accent); }
.multi-toggle:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.multi-toggle::after { content: "▾"; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.multi-panel {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0;
  width: 100%; min-width: 320px; max-width: 460px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px;
  padding: 10px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 8px;
}
.multi-panel[hidden] { display: none; }
.multi-search { width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink); font-size: 13px; outline: none; }
.multi-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.multi-all {
  display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 650;
  color: var(--ink); padding: 8px 6px; border-bottom: 1px solid var(--line); cursor: pointer; white-space: nowrap;
}
.multi-list { overflow: auto; max-height: 240px; display: flex; flex-direction: column; }
.multi-item { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 8px; font-size: 13px; color: var(--ink); cursor: pointer; }
.multi-item:hover { background: var(--surface-2); }
.multi-item input, .multi-all input { width: auto; flex: 0 0 auto; padding: 0; border: 0; background: transparent; accent-color: var(--accent); margin: 0; }
.multi-item span, .multi-all span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.multi-empty { color: var(--muted); font-size: 13px; padding: 8px 6px; }

/* --------------------------- status / loading --------------------------- */

.status { margin: 16px 0; padding: 12px 14px; border-radius: 10px; font-size: 13.5px; border: 1px solid transparent; }
.status.error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }
.loading { margin: 16px 0; color: var(--muted); font-size: 13.5px; }

/* ----------------------------- search bar ------------------------------- */

.intro p { margin-top: 6px; }
.search-bar { display: flex; gap: 10px; margin-top: 16px; }
.search-bar input {
  flex: 1; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font-size: 14px; outline: none;
}
.search-bar input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }

/* --------------------------- detail (search view) ----------------------- */

.po-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.po-no { font-size: 19px; font-weight: 700; letter-spacing: 0.2px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 650; border: 1px solid transparent;
}
.chip.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.chip.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.chip.miss { background: var(--info-bg); color: var(--info-text); border-color: var(--info-line); }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kv { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; }
.kv .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 650; }
.kv .v { margin-top: 4px; font-size: 14px; word-break: break-word; }

.timeline { position: relative; margin: 0; padding: 0; list-style: none; }
.timeline::before { content: ""; position: absolute; left: 15px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.layer { position: relative; padding: 0 0 16px 46px; }
.layer:last-child { padding-bottom: 0; }
.layer .dot {
  position: absolute; left: 6px; top: 2px; width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
  border: 2px solid var(--line); background: var(--surface);
}
.layer.approved .dot { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.layer.pending .dot { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.layer-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.layer-title { font-weight: 650; font-size: 14px; }
.layer-sub { color: var(--muted); font-size: 12.5px; }
.layer-body { margin-top: 8px; }
.approvers { display: flex; flex-wrap: wrap; gap: 8px; }
.person { display: inline-flex; align-items: center; gap: 7px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 7px 11px; font-size: 12.5px; }
.person.approved { border-color: var(--ok-line); background: var(--ok-bg); }
.person .who { font-weight: 650; }
.person .mail { color: var(--muted); font-size: 11.5px; }
.pending-box { border: 1px solid var(--warn-line); background: var(--warn-bg); }
.pending-box h2 { color: var(--warn); }
.steps { margin: 10px 0 0; padding-left: 20px; }
.steps li { margin: 6px 0; font-size: 13.5px; }
.empty { color: var(--muted); font-size: 13.5px; }

/* ------------------------------- table ---------------------------------- */

.table-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); max-height: 70vh; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 1000px; }
.data-table thead th {
  position: sticky; top: 0; z-index: 2;
  text-align: left; padding: 12px 16px; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); background: var(--surface-2);
  border-bottom: 1px solid var(--line-strong); white-space: nowrap;
}
.data-table tbody td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; color: var(--ink); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.data-table tbody tr:hover td { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.data-table .doc-no { font-weight: 650; color: var(--brand-2); }
.data-table .chip { padding: 3px 10px; font-size: 11.5px; }

.list-empty { background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); padding: 44px 24px; text-align: center; color: var(--muted); font-size: 14px; }

.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 16px; }
.pager-info { color: var(--muted); font-size: 13px; }

/* ------------------------------- login ---------------------------------- */

.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1100px 620px at 15% -10%, var(--bg-glow) 0%, var(--bg) 60%);
  padding: 24px;
}
.login-wrap { width: 100%; max-width: 400px; }
.login-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 30px 30px 24px; box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.login-brand-text { display: flex; flex-direction: column; }
.login-brand-text strong { font-size: 14.5px; }
.login-brand-text small { color: var(--muted); font-size: 11.5px; }
.login-card h1 { font-size: 21px; }
.login-sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.login-field { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }
.login-field > span { color: var(--muted); font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; }
.login-field input {
  padding: 12px 13px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font-size: 14px; outline: none;
}
.login-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.login-card .btn-primary { width: 100%; margin-top: 20px; padding: 12px; font-size: 14px; }
.login-error { margin-top: 14px; padding: 10px 12px; border-radius: 9px; font-size: 13px; background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-line); }
.login-foot { text-align: center; color: var(--muted); font-size: 11.5px; margin-top: 18px; }

@media (max-width: 820px) {
  .topbar-inner { flex-wrap: wrap; gap: 12px; padding: 10px 16px; }
  .brand-text small { display: none; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .container { padding: 16px; }
}
