/* =====================================================================
   FGSS Design System — Foundations
   Colors, typography, spacing, radii, shadows.
   ===================================================================== */

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable.css');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* -------------------------------------------------------------------
     COLOR — Brand
     #0F6E56 is the user-supplied brand color. Tints/shades derived in
     OKLCH so they remain perceptually balanced.
     ------------------------------------------------------------------- */
  --brand-50:  oklch(96% 0.025 165);
  --brand-100: oklch(92% 0.045 165);
  --brand-200: oklch(85% 0.075 165);
  --brand-300: oklch(74% 0.105 165);
  --brand-400: oklch(60% 0.115 165);
  --brand-500: #0F6E56;            /* primary */
  --brand-600: oklch(40% 0.085 165);
  --brand-700: oklch(32% 0.07 165);
  --brand-800: oklch(24% 0.055 165);
  --brand-900: oklch(16% 0.04 165);

  --brand:        var(--brand-500);
  --brand-hover:  oklch(43% 0.092 165);
  --brand-press:  oklch(36% 0.078 165);

  /* -------------------------------------------------------------------
     COLOR — Neutrals (warm-cool slate)
     ------------------------------------------------------------------- */
  --neutral-0:   #FFFFFF;
  --neutral-25:  #FAFBFB;
  --neutral-50:  #F4F5F6;
  --neutral-75:  #EDEEF0;
  --neutral-100: #E4E6E9;
  --neutral-200: #D4D7DC;
  --neutral-300: #B8BDC4;
  --neutral-400: #969CA5;
  --neutral-500: #6E747D;
  --neutral-600: #4F555E;
  --neutral-700: #363B43;
  --neutral-800: #20242B;
  --neutral-900: #0F1217;

  /* -------------------------------------------------------------------
     COLOR — Semantic / Status
     The traffic-light system is core product content, not decoration.
     ------------------------------------------------------------------- */
  --status-green:        #178A52;  /* GREEN — pass / compliant */
  --status-green-bg:     #E6F5EC;
  --status-green-border: #B7E0C5;

  --status-yellow:        #B86A00;  /* YELLOW — warning / approaching */
  --status-yellow-bg:     #FFF3DD;
  --status-yellow-border: #F2CE85;

  --status-red:        #C33232;  /* RED — violation / blocked */
  --status-red-bg:     #FCE9E9;
  --status-red-border: #F0B5B5;

  --status-gray:        #6E747D;  /* GRAY — insufficient data */
  --status-gray-bg:     #EDEEF0;
  --status-gray-border: #D4D7DC;

  /* Critical redline — slightly more saturated than status-red,
     reserved for DS-System legal redline alerts only. */
  --redline:        #A6181A;
  --redline-bg:     #FFF0F0;
  --redline-border: #F4A6A8;

  /* -------------------------------------------------------------------
     COLOR — Tier
     ------------------------------------------------------------------- */
  --tier-free:  var(--neutral-500);
  --tier-basic: #2563A8;
  --tier-pro:   var(--brand-500);
  /* MAX 등급은 제거됨 — 외부 연동(B/C 법인 대리 제출 등)으로 기획 전환 중 */

  /* -------------------------------------------------------------------
     COLOR — Surface / Foreground (semantic)
     ------------------------------------------------------------------- */
  --bg-canvas:        #F7F8F8;
  --bg-surface:       var(--neutral-0);
  --bg-surface-alt:   var(--neutral-25);
  --bg-sunken:        var(--neutral-50);
  --bg-hover:         rgba(15, 110, 86, 0.04);
  --bg-press:         rgba(15, 110, 86, 0.08);
  --bg-row-hover:     var(--neutral-25);
  --bg-disabled:      var(--neutral-50);

  --fg-default:       var(--neutral-800);   /* body text */
  --fg-strong:        var(--neutral-900);   /* headings */
  --fg-muted:         var(--neutral-500);   /* labels, captions */
  --fg-subtle:        var(--neutral-400);   /* placeholder */
  --fg-disabled:      var(--neutral-300);
  --fg-on-brand:      var(--neutral-0);
  --fg-link:          var(--brand-500);

  --border-default:   var(--neutral-100);
  --border-strong:    var(--neutral-200);
  --border-focus:     var(--brand-500);
  --focus-ring:       rgba(15, 110, 86, 0.4);

  /* -------------------------------------------------------------------
     TYPOGRAPHY — Families
     ------------------------------------------------------------------- */
  --font-sans: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont,
               system-ui, 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic',
               sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* -------------------------------------------------------------------
     TYPOGRAPHY — Scale (raw)
     ------------------------------------------------------------------- */
  --fs-11: 11px;   --lh-11: 16px;   /* micro / overline */
  --fs-12: 12px;   --lh-12: 18px;   /* caption */
  --fs-13: 13px;   --lh-13: 20px;   /* small */
  --fs-14: 14px;   --lh-14: 22px;   /* body-sm — table cells */
  --fs-16: 16px;   --lh-16: 24px;   /* body */
  --fs-18: 18px;   --lh-18: 28px;   /* body-lg / sub-heading */
  --fs-22: 22px;   --lh-22: 30px;   /* h3 */
  --fs-28: 28px;   --lh-28: 36px;   /* h2 / page title */
  --fs-36: 36px;   --lh-36: 44px;   /* h1 / hero */

  /* -------------------------------------------------------------------
     TYPOGRAPHY — Weights
     Pretendard Variable: 100–900. We use 400/500/600/700.
     ------------------------------------------------------------------- */
  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;

  /* -------------------------------------------------------------------
     SPACING (4px base)
     ------------------------------------------------------------------- */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-14: 56px;
  --space-20: 80px;

  /* -------------------------------------------------------------------
     RADIUS
     ------------------------------------------------------------------- */
  --radius-xs:   2px;
  --radius-sm:   4px;
  --radius-md:   6px;
  --radius-lg:   10px;
  --radius-pill: 999px;  /* status capsules ONLY */

  /* -------------------------------------------------------------------
     ELEVATION (used sparingly)
     ------------------------------------------------------------------- */
  --shadow-popover: 0 4px 12px rgba(15, 18, 23, 0.08), 0 1px 2px rgba(15, 18, 23, 0.04);
  --shadow-modal:   0 16px 40px rgba(15, 18, 23, 0.16), 0 2px 6px rgba(15, 18, 23, 0.06);

  /* -------------------------------------------------------------------
     LAYOUT
     ------------------------------------------------------------------- */
  --layout-sidebar:  240px;
  --layout-topbar:   56px;
  --layout-redline:  40px;        /* extra strip when redline active */
  --layout-max:      1440px;

  /* -------------------------------------------------------------------
     MOTION
     ------------------------------------------------------------------- */
  --ease-out:   cubic-bezier(0.2, 0, 0, 1);
  --ease-in:    cubic-bezier(0.4, 0, 1, 1);
  --ease-inout: cubic-bezier(0.4, 0, 0.2, 1);

  --dur-fast:   120ms;
  --dur-base:   180ms;
  --dur-slow:   240ms;
}

/* =====================================================================
   BASE — element defaults using semantic tokens above
   ===================================================================== */
html, body {
  font-family: var(--font-sans);
  font-size: var(--fs-16);
  line-height: var(--lh-16);
  font-weight: var(--fw-regular);
  color: var(--fg-default);
  background: var(--bg-canvas);
  font-feature-settings: 'ss01', 'cv01';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, .h1 {
  font-size: var(--fs-36); line-height: var(--lh-36);
  font-weight: var(--fw-bold);
  letter-spacing: -0.02em;
  color: var(--fg-strong);
}
h2, .h2 {
  font-size: var(--fs-28); line-height: var(--lh-28);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.015em;
  color: var(--fg-strong);
}
h3, .h3 {
  font-size: var(--fs-22); line-height: var(--lh-22);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
  color: var(--fg-strong);
}
h4, .h4 {
  font-size: var(--fs-18); line-height: var(--lh-18);
  font-weight: var(--fw-semibold);
  color: var(--fg-strong);
}
.body-lg { font-size: var(--fs-18); line-height: var(--lh-18); }
.body    { font-size: var(--fs-16); line-height: var(--lh-16); }
.body-sm { font-size: var(--fs-14); line-height: var(--lh-14); }
.caption { font-size: var(--fs-12); line-height: var(--lh-12); color: var(--fg-muted); }
.overline {
  font-size: var(--fs-11); line-height: var(--lh-11);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}

code, .mono, .num {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum', 'zero';
}
.tabular { font-variant-numeric: tabular-nums; }

/* The liability disclaimer style — appears beside primary action buttons
   throughout the product. It's a typographic component, not legalese. */
.liability {
  font-size: var(--fs-12);
  line-height: var(--lh-12);
  color: var(--fg-muted);
  max-width: 56ch;
}

/* Kit-local layout helpers, building on ../../colors_and_type.css */
* { box-sizing: border-box; margin: 0; padding: 0; word-break: keep-all; overflow-wrap: normal; }
html, body { height: 100%; }
body { background: var(--bg-canvas); color: var(--fg-default); }
.sidebar-item, .btn, .cap, .dday, .tier-badge, .alarm-title, .kpi .lbl, .kpi .delta, .redline, .sidebar-brand .name, .ve-row .name, .ve-row .meta, .ve-row .code, .card-head h3, .page-head .sub, .overline, th { white-space: nowrap; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; }

#root { display: flex; min-height: 100vh; min-height: 100dvh; }

.app {
  display: grid;
  grid-template-columns: var(--layout-sidebar) 1fr;
  width: 100%;
  transition: grid-template-columns var(--dur-fast) ease;
}
.app.sidebar-collapsed {
  grid-template-columns: 64px 1fr;
}

/* SIDEBAR */
.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-default);
  display: flex; flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: sticky; top: 0;
  overflow: hidden;
  min-width: 0;
}
.sidebar-brand { padding: 14px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border-default); min-height: 60px; }
.sidebar-brand .hamburger { width: 32px; height: 32px; display: grid; place-items: center; border-radius: var(--radius-sm); color: var(--fg-default); flex-shrink: 0; }
.sidebar-brand .hamburger:hover { background: var(--bg-row-hover); }
.sidebar-brand .brand-logo {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 800;
  letter-spacing: 0.04em;
  font-size: 20px;
  color: var(--brand-700);
  background: linear-gradient(135deg, var(--brand-700) 0%, var(--brand) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sidebar-brand .tier { margin-left: auto; }
.sidebar.collapsed .sidebar-brand { padding: 14px; justify-content: center; }
.sidebar-section { padding: 12px 12px 4px; }
.sidebar-section .overline { padding: 0 8px 6px; }
.sidebar-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--fg-default); font-size: 13px; font-weight: 500; cursor: pointer; transition: background var(--dur-fast); }
.sidebar.collapsed .sidebar-item { justify-content: center; padding: 10px; }
.sidebar-item:hover { background: var(--bg-row-hover); }
.sidebar-item.active { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.sidebar-item.active svg { color: var(--brand); }
.sidebar-item svg { color: var(--fg-muted); flex-shrink: 0; }
.sidebar-item .badge { margin-left: auto; font-family: var(--font-mono); font-size: 10px; padding: 1px 6px; border-radius: var(--radius-pill); background: var(--status-red-bg); color: var(--status-red); }

.sidebar-foot-wrap { margin-top: auto; position: relative; }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--border-default); display: flex; align-items: center; gap: 10px; cursor: pointer; transition: background var(--dur-fast); }
.sidebar-foot:hover { background: var(--bg-row-hover); }
.sidebar-foot .av { width: 28px; height: 28px; border-radius: 50%; background: var(--brand-100); color: var(--brand-700); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.sidebar.collapsed .sidebar-foot { justify-content: center; padding: 14px 12px; }

/* DROPUP MENU */
.userdropup { position: relative; }
.dropup-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 12px;
  right: 12px;
  background: #fff;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
  padding: 6px;
  z-index: 100;
  min-width: 200px;
}
.sidebar.collapsed .dropup-menu { left: 100%; right: auto; bottom: 0; margin-left: 8px; min-width: 220px; }
.dropup-header { display: flex; align-items: center; gap: 10px; padding: 10px 8px; }
.dropup-header .av { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-100); color: var(--brand-700); display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.dropup-name { font-size: 13px; font-weight: 600; color: var(--fg-strong); }
.dropup-mail { font-size: 11px; color: var(--fg-muted); }
.dropup-sep { height: 1px; background: var(--border-default); margin: 4px 0; }
.dropup-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; color: var(--fg-default); position: relative; }
.dropup-item:hover { background: var(--bg-row-hover); }
.dropup-item.danger { color: var(--status-red); }
.dropup-item.danger:hover { background: var(--status-red-bg); }
.dropup-item.on { color: var(--brand-700); font-weight: 600; }
.dropup-submenu {
  position: absolute;
  left: 100%;
  top: -6px;
  margin-left: 6px;
  background: #fff;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
  padding: 6px;
  min-width: 160px;
}

/* PAGE */
.page {
  width: 100%;
  max-width: none;
  padding: 8px 4px 24px;
}
.biz-dashboard-page {
  width: 100%;
  min-width: 0;
  max-width: none;
  margin: 0;
  padding: 10px 20px 30px;
}
.biz-dashboard-page .page-head { margin-bottom: 22px; }
.biz-dashboard-page .page-head h2 { font-size: 30px; line-height: 1.2; }
.biz-dashboard-page .page-head .sub { font-size: 17px; margin-top: 6px; }
.biz-dashboard-page .btn { font-size: 16px; padding: 11px 19px; }
.biz-dashboard-page .card-head { padding: 16px 20px; }
.biz-dashboard-page .card-head h3 { font-size: 17px; }
.biz-dashboard-page .card-head .meta { font-size: 13px; }
.biz-dashboard-page .card-body { padding: 22px; }
.biz-dashboard-page .kpi-grid { gap: 14px; margin-bottom: 30px; }
.biz-dashboard-page .kpi { min-height: 128px; padding: 16px 18px; }
.biz-dashboard-page .kpi .lbl { font-size: 12px; }
.biz-dashboard-page .kpi .val { font-size: 40px; }
.biz-dashboard-page .kpi .delta { font-size: 12px; }
.biz-dashboard-page .kpi-extra { font-size: 12px; }
.biz-dashboard-page .split { gap: 12px; }
.biz-dashboard-page .main-stack > .card { margin-bottom: 0px; }
.biz-dashboard-page .main-stack > .card:last-child { margin-bottom: 0; }
.biz-dashboard-page .side-stack { gap: 10px; }
.biz-dashboard-page .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.biz-dashboard-page .table-scroll .tbl { min-width: 760px; }
.biz-dashboard-page .ve-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.biz-dashboard-page .rt-row { font-size: 15px; padding: 12px 0; }
.biz-dashboard-page .rt-nat,
.biz-dashboard-page .rt-visa,
.biz-dashboard-page .rt-meta { font-size: 13px; }
.biz-dashboard-page .legend-row { font-size: 14px; }
.biz-dashboard-page .legend-val { font-size: 13px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 16px; gap: 16px; }
.page-head h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.015em; color: var(--fg-strong); white-space: nowrap; }
.page-head .sub { font-size: 13px; color: var(--fg-muted); margin-top: 4px; }

/* CARDS */
.card { background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-md); }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--border-default); display: flex; align-items: center; gap: 10px; }
.card-head h3 { font-size: 14px; font-weight: 600; color: var(--fg-strong); }
.card-head .meta { margin-left: auto; font-size: 12px; color: var(--fg-muted); white-space: nowrap; }
.card-body { padding: 18px; }

/* KPI tiles — clickable, with optional right-side detail */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  display: flex; align-items: stretch; gap: 12px;
  padding: 14px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  text-align: left;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast);
  width: 100%;
  min-height: 96px;
}
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.kpi.clickable:active { transform: translateY(1px); }
.kpi:disabled { cursor: default; }

.kpi-main { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.kpi .lbl { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--fg-muted); }
.kpi .val { font-family: var(--font-mono); font-feature-settings: 'tnum'; font-size: 28px; font-weight: 700; color: var(--fg-strong); letter-spacing: -0.01em; line-height: 1.1; margin: 4px 0 2px; }
.kpi .delta { font-size: 11px; color: var(--fg-muted); }

.val-yellow { color: var(--status-yellow) !important; }
.val-red    { color: var(--status-red) !important; }
.val-green  { color: var(--status-green) !important; }

.kpi-yellow { background: var(--status-yellow-bg); border-color: var(--status-yellow-border); }
.kpi-red    { background: var(--status-red-bg);    border-color: var(--status-red-border); }
.kpi-green  { background: var(--status-green-bg);  border-color: var(--status-green-border); }

.kpi-extra {
  display: flex; flex-direction: column; gap: 3px;
  padding-left: 12px;
  border-left: 1px solid var(--border-default);
  font-family: var(--font-mono); font-feature-settings: 'tnum';
  font-size: 11px;
  color: var(--fg-muted);
  justify-content: center;
  min-width: 0;
}
.kpi-yellow .kpi-extra, .kpi-red .kpi-extra, .kpi-green .kpi-extra {
  border-left-color: rgba(0,0,0,0.08);
}
.kpi-extra-row { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.split {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}
.split > .main-stack { grid-column: span 3; }
.split > .side-stack { grid-column: span 1; }

/* CHART CARDS */
.chart-row { display: flex; align-items: center; gap: 16px; }
.donut-wrap { width: 96px; height: 96px; flex: 0 0 96px; }
.donut-wrap canvas { width: 96px !important; height: 96px !important; display: block; }
.legend { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.legend-sw { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.legend-name { color: var(--fg-strong); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-val { color: var(--fg-muted); font-size: 11px; flex-shrink: 0; }

.dist-block { padding: 4px 0; }
.dist-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--fg-muted); margin-bottom: 12px; }
.dist-divider { height: 1px; background: var(--border-default); margin: 14px 0; }

/* REAL-TIME WORKER LIST */
.rt-list { display: flex; flex-direction: column; }
.rt-row {
  display: grid;
  grid-template-columns: 60px 1.4fr 1fr 50px 1.6fr;
  align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-default);
  font-size: 13px;
}
.rt-row:last-child { border-bottom: none; }
.rt-name { font-weight: 600; color: var(--fg-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rt-nat  { color: var(--fg-default); font-size: 12px; }
.rt-visa { color: var(--fg-muted); font-size: 12px; }
.rt-meta { color: var(--fg-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: var(--radius-md); border: 1px solid transparent; transition: background var(--dur-fast); text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-secondary { background: var(--bg-surface); color: var(--fg-strong); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-row-hover); }
.btn-cta-hover:hover {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.btn:active { transform: translateY(1px); }
.btn-ghost { color: var(--fg-default); }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-sm { font-size: 12px; padding: 5px 10px; }

/* STATUS CAPS */
.cap { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 600; border: 1px solid; line-height: 16px; }
.cap .dot { width: 6px; height: 6px; border-radius: 50%; }
.cap-green  { background: var(--status-green-bg); color: #0d5e36; border-color: var(--status-green-border); }
.cap-yellow { background: var(--status-yellow-bg); color: #8f4f00; border-color: var(--status-yellow-border); }
.cap-red    { background: var(--status-red-bg); color: #962525; border-color: var(--status-red-border); }
.cap-gray   { background: var(--status-gray-bg); color: var(--neutral-700); border-color: var(--status-gray-border); }

.dday { font-family: var(--font-mono); font-feature-settings: 'tnum'; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: var(--radius-sm); }
.dday-ok   { background: var(--status-green-bg); color: #0d5e36; }
.dday-warn { background: var(--status-yellow-bg); color: #8f4f00; }
.dday-bad  { background: var(--status-red-bg); color: #962525; }

.tier-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--radius-pill); font-size: 10px; font-weight: 700; letter-spacing: 0.04em; color: #fff; }
.tier-free  { background: var(--tier-free); }
.tier-basic { background: var(--tier-basic); }
.tier-pro   { background: var(--tier-pro); }

/* TABLE */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--fg-muted); text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border-default); background: var(--bg-sunken); white-space: nowrap; }
.tbl td { font-size: 13px; padding: 12px 14px; border-bottom: 1px solid var(--border-default); color: var(--fg-strong); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover td { background: var(--bg-row-hover); }
.tbl tr.selected td { background: var(--brand-50); }
.tbl td.status-cell { text-align: center; }
.tbl td.status-cell .cap { min-width: 52px; justify-content: center; text-align: center; gap: 0; }
.tbl td.status-cell .cap .dot { display: none; }
.tbl th.status-head { text-align: center; }
.mono { font-family: var(--font-mono); font-feature-settings: 'tnum'; }
.uid  { font-family: var(--font-mono); font-size: 12px; color: var(--fg-muted); }

/* ARM ALARM */
.alarm { background: var(--bg-surface); border: 1px solid var(--border-default); border-left: 3px solid var(--status-red); border-radius: var(--radius-md); padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; margin-bottom: 8px; }
.alarm.warn { border-left-color: var(--status-yellow); }
.alarm.info { border-left-color: var(--brand); }
.alarm-icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.alarm-icon.red  { background: var(--status-red-bg); color: var(--status-red); }
.alarm-icon.warn { background: var(--status-yellow-bg); color: var(--status-yellow); }
.alarm-icon.info { background: var(--brand-50); color: var(--brand); }
.alarm-body { flex: 1; min-width: 0; }
.alarm-head { display: flex; gap: 6px; align-items: center; margin-bottom: 3px; flex-wrap: wrap; }
.alarm-head .cap { min-width: 52px; justify-content: center; text-align: center; gap: 0; }
.alarm-head .cap .dot { display: none; }
.alarm-src { font-family: var(--font-mono); font-size: 12px; color: var(--fg-muted); padding: 1px 5px; background: var(--bg-surface-alt); border-radius: 3px; }
.alarm-title { font-size: 14px; font-weight: 600; color: var(--fg-strong); }
.alarm-risk { font-size: 13px; color: var(--neutral-600); }
.liability { font-size: 11px; color: var(--fg-muted); margin-top: 6px; max-width: 64ch; line-height: 16px; }
.alarm .liability { max-width: none; }
.alarm-actions { display: flex; gap: 6px; margin-top: 8px; }

/* SIGNAL TILE */
.signals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sig { padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-default); display: flex; flex-direction: column; gap: 4px; background: var(--bg-surface); }
.sig .name { font-size: 11px; font-weight: 600; color: var(--fg-muted); }
.sig .val { font-family: var(--font-mono); font-feature-settings: 'tnum'; font-size: 18px; font-weight: 600; color: var(--fg-strong); }
.sig.green .val  { color: var(--status-green); }
.sig.yellow .val { color: var(--status-yellow); }
.sig.red .val    { color: var(--status-red); }
.sig.gray .val   { color: var(--status-gray); }

/* DRAWER */
.drawer-scrim { position: fixed; inset: 0; background: rgba(15, 18, 23, 0.4); backdrop-filter: blur(4px); z-index: 50; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 520px; background: #fff; border-left: 1px solid var(--border-default); box-shadow: var(--shadow-modal); z-index: 51; display: flex; flex-direction: column; }
.drawer-head { padding: 16px 20px; border-bottom: 1px solid var(--border-default); display: flex; align-items: center; gap: 10px; }
.drawer-head h2 { font-size: 16px; font-weight: 600; color: var(--fg-strong); }
.drawer-head .close { margin-left: auto; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--border-default); display: flex; align-items: center; gap: 10px; }

/* FORM */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--fg-strong); }
.field input, .field select, .field textarea { padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: #fff; color: var(--fg-strong); font-size: 13px; }
.field input:focus, .field select:focus { outline: 2px solid var(--focus-ring); outline-offset: 1px; border-color: var(--brand); }
.field .hint { font-size: 11px; color: var(--fg-muted); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* VE engine list */
.ve-list { display: flex; flex-direction: column; gap: 8px; }
.ve-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--bg-surface-alt); border: 1px solid var(--border-default); border-radius: var(--radius-sm); }
.ve-row .code { font-family: var(--font-mono); font-size: 11px; color: var(--fg-muted); width: 72px; }
.ve-row .name { font-size: 13px; font-weight: 500; color: var(--fg-strong); flex: 1; }
.ve-row .meta { font-size: 11px; color: var(--fg-muted); }

/* utility */
.gap-2 { display: flex; gap: 8px; }
.gap-3 { display: flex; gap: 12px; }
.gap-4 { display: flex; gap: 16px; }
.col   { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.spacer { flex: 1; }

/* WORKER INFO GRID */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border-default); border: 1px solid var(--border-default); border-radius: var(--radius-md); overflow: hidden; }
.info-row { background: #fff; padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.info-lbl { font-size: 11px; color: var(--fg-muted); }
.info-val { font-size: 13px; font-weight: 500; color: var(--fg-strong); }
.info-val.mono { font-family: var(--font-mono); font-weight: 400; }

/* VERIFY STACK BADGE — table 검증 column */
.verify-stack { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.vbadge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 600;
  border: 1px solid;
  line-height: 16px;
  white-space: nowrap;
}
.vbadge .vbadge-dot { width: 6px; height: 6px; border-radius: 50%; }
.vbadge-yellow { background: var(--status-yellow-bg); color: #8f4f00; border-color: var(--status-yellow-border); }
.vbadge-yellow .vbadge-dot { background: var(--status-yellow); }
.vbadge-red    { background: var(--status-red-bg); color: #962525; border-color: var(--status-red-border); }
.vbadge-red    .vbadge-dot { background: var(--status-red); }

/* STAFF PAGE */
.staff-page-layout {
  display: grid;
  grid-template-columns: 1.9fr 0.615fr;
  gap: 16px;
  margin-bottom: 24px;
}
.staff-page .btn {
  font-size: 14px;
  padding: 8px 14px;
}
.staff-page .btn-sm {
  font-size: 12px;
  padding: 6px 10px;
}
.staff-page .btn svg {
  flex-shrink: 0;
}
.staff-left-card-body { padding: 0 !important; }
.staff-row-clickable { cursor: pointer; }
.staff-name-cell { font-weight: 600; }
.staff-date-text { font-size: 12px; color: var(--fg-muted); }
.staff-date-missing { font-size: 12px; color: var(--status-red); }
.staff-verify-badge { min-width: 52px; justify-content: center; gap: 0; }
.staff-risk-col { font-size: 12px; color: var(--fg-muted); }
.staff-action-head { width: 72px; }
.staff-action-col { text-align: right; white-space: nowrap; }
.staff-delete-btn {
  color: var(--status-red);
  border: 1px solid var(--status-red-border);
  background: transparent;
}
.staff-delete-btn:hover { background: var(--status-red-bg); }
.staff-empty-row { text-align: center; padding: 40px; color: var(--fg-muted); }

.staff-register-page .page-head-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--fg-muted);
  text-decoration: none;
  margin-bottom: 8px;
}
.staff-register-page .page-head-back:hover { color: var(--brand); }
.staff-register-tabs {
  display: flex;
  gap: 16px;
  border-bottom: 1px solid var(--border-default);
  margin-bottom: 20px;
}
.staff-register-tab {
  padding: 8px 0;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  font-size: 13px;
  color: var(--fg-muted);
  cursor: pointer;
}
.staff-register-tab.active {
  border-bottom-color: var(--brand);
  color: var(--brand);
  font-weight: 600;
}
.staff-register-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(360px, 1.4fr);
  gap: 16px;
  align-items: start;
}
.staff-register-scan .card-body,
.staff-register-form .card-body { padding: 18px 20px !important; }
.staff-register-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  margin: 16px 0 10px;
}
.staff-register-section-title:first-child { margin-top: 0; }
.staff-register-form-actions {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
@media (max-width: 960px) {
  .staff-register-layout { grid-template-columns: 1fr; }
}
.staff-detail-stack { gap: 8px; }
.staff-detail-title { font-size: 15px; }
.staff-detail-edit-btn { margin-left: 8px; }
.staff-detail-body { padding: 14px 18px !important; }
.staff-detail-actions { margin-top: 14px; }
.staff-verify-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.staff-verify-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--fg-strong);
}
.staff-verify-meta {
  font-size: 11px;
  color: var(--fg-muted);
}
.staff-verify-placeholder {
  font-size: 12px;
  color: var(--fg-muted);
}
.staff-verify-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  background: var(--bg-surface-alt);
  margin-bottom: 8px;
}
.staff-verify-row-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-strong);
}
.staff-verify-row-detail {
  font-size: 12px;
  color: var(--fg-muted);
  flex: 1.2;
}
.staff-verify-row-badge {
  min-width: 52px;
  justify-content: center;
  gap: 0;
}

.ve-toggle-btn {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: border-color var(--dur-fast), background var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast);
}
.ve-toggle-btn:hover {
  border-color: var(--brand);
  background: var(--bg-sunken);
}
.ve-toggle-btn:active {
  transform: translateY(1px);
}
.ve-toggle-btn.is-open {
  border-color: var(--brand);
  background: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-50);
}
.ve-toggle-btn.is-open span {
  color: #fff !important;
}

/* Sync design tokens with app light/dark themes */
:root[data-theme="light"] {
  --bg-canvas: #f3f6fb;
  --bg-surface: #ffffff;
  --bg-surface-alt: #f7f9fd;
  --bg-sunken: #f1f5f9;
  --bg-row-hover: #edf2f8;
  --fg-default: #1f2937;
  --fg-strong: #111827;
  --fg-muted: #4b5563;
  --fg-subtle: #6b7280;
  --border-default: #d8e0ec;
  --border-strong: #c8d3e3;
}

:root[data-theme="dark"] {
  --bg-canvas: #0f1117;
  --bg-surface: #181c27;
  --bg-surface-alt: #1e2333;
  --bg-sunken: #1b2130;
  --bg-row-hover: #252a3a;
  --fg-default: #e8eaf0;
  --fg-strong: #f3f5fb;
  --fg-muted: #8b92a5;
  --fg-subtle: #6f778b;
  --border-default: #2a2f3d;
  --border-strong: #3a4258;
  --focus-ring: rgba(29, 158, 117, 0.35);
}

@media (max-width: 1360px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 1200px) {
  .biz-dashboard-page .ve-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .page { padding: 8px 0 16px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-head h2 { font-size: 22px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .signals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rt-row { grid-template-columns: 60px 1.2fr 1fr 50px 1.4fr; gap: 8px; }
  .biz-dashboard-page { padding: 16px 16px 24px; }
  .biz-dashboard-page .ve-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   FGSS Mobile 1차 대응 (임무17)
   - 640px 이하 전용
   - PC/태블릿 무영향 원칙
   ============================================================ */

/* 스크롤 락 (사이드바 오버레이 시) */
body.no-scroll {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

/* 사이드바 모바일 오버레이 기본 규칙 (640px↑에서는 무영향) */
@media (max-width: 640px) {
  /* 사이드바를 화면 밖으로 밀고 오버레이 형태로 재구성 */
  .fgss-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    padding-top: 56px;
    box-sizing: border-box;
    width: 280px !important;
    max-width: 88vw;
    transform: translateX(-100%);
    transition: transform 0.2s ease-out, visibility 0s linear 0.2s;
    visibility: hidden;
    z-index: 55;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #ffffff !important;
  }
  [data-theme="dark"] .fgss-sidebar.fgss-sidebar-biz {
    background: var(--bg-page) !important;
  }
  .fgss-sidebar.is-mobile-open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.2s ease-out, visibility 0s;
  }
  /* 모바일에서는 사이드바 텍스트 강제 표시 (오버레이 280px 폭) */
  .fgss-sidebar .sidebar-text,
  .fgss-sidebar .sidebar-profile-text {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    overflow: visible;
    white-space: nowrap;
  }
  .fgss-sidebar > nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .fgss-sidebar .sidebar-link {
    justify-content: flex-start !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
    width: 100%;
    overflow: visible;
  }
  /* 사업자 계정 드롭다운: 모바일에서는 아래로 펼침 (위로 열면 잘림) */
  .fgss-sidebar.is-mobile-open #bizUserDropdown {
    position: relative !important;
    left: 0 !important;
    right: 0 !important;
    bottom: auto !important;
    top: auto !important;
    margin-top: 8px;
    box-shadow: none;
    border: 1px solid var(--border-sub, #e5e7eb);
  }
  .fgss-sidebar.is-mobile-open .mt-auto.border-t {
    flex-shrink: 0;
    overflow: visible;
  }

  /* main 영역 좌측 여백 제거 (사이드바가 오버레이이므로) */
  .fgss-main-shell {
    width: 100%;
  }

  /* 헤더 로고 좌측 margin 축소 */
  .fgss-wordmark { font-size: 16px; }

  /* 페이지 공통 여백 축소 */
  .page { padding: 8px 12px 16px; }
  .page-head h2 { font-size: 18px; }

  /* 카드 padding 축소 */
  .card-body { padding: 12px; }

  /* KPI/그리드 단일 열 */
  .kpi-grid { grid-template-columns: 1fr !important; gap: 8px; }
  .biz-dashboard-page .ve-grid { grid-template-columns: 1fr !important; }
  .signals { grid-template-columns: 1fr !important; }
  .split { grid-template-columns: 1fr !important; }

  /* 테이블 기본 폰트 축소 및 padding 축소 */
  .tbl th { font-size: 10px; padding: 8px 8px; }
  .tbl td { font-size: 12px; padding: 8px 8px; }

  /* notices-table 대응 */
  .notices-table { font-size: 11px; }
  .notices-table th, .notices-table td { padding: 4px 6px; }

  /* 폼 요소 터치 타겟 최소 44px 보장 (iOS HIG) */
  input[type="text"], input[type="email"], input[type="password"],
  input[type="tel"], input[type="number"], input[type="search"],
  select, textarea, button {
    min-height: 44px;
    font-size: 16px; /* iOS 자동 zoom 방지 */
  }

  /* diagnose form 단일 열 */
  .grid.grid-cols-1.lg\:grid-cols-2 { grid-template-columns: 1fr !important; }

  /* 관리자 모바일 하단 카드 - 오버레이 open 시 텍스트 표시 */
  .fgss-sidebar.is-mobile-open .fgss-sidebar-admin-mobile .sidebar-profile-text {
    display: block !important;
  }

  /* 백드롭 헤더 포함 전체 화면 커버 */
  #sidebarBackdrop {
    top: 0 !important;
    z-index: 45;
  }

  /* staff 2열 → 단일열 (전체 가로 스크롤 제거) */
  .staff-page-layout {
    grid-template-columns: 1fr !important;
  }

  /* 페이지 전체 가로 스크롤 방지 */
  html, body {
    overflow-x: hidden;
  }
}

/* iOS 터치 최적화 (전역) */
.fgss-mobile-safe {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
.fgss-mobile-safe button,
.fgss-mobile-safe a { touch-action: manipulation; }
