:root {
  --ink: #0f172a;
  --muted: #64748b;
  --paper: #f8fafc;
  --surface: #ffffff;
  --line: #e2e8f0;
  --teal: #0284c7;
  --teal-soft: #e0f2fe;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--teal); text-underline-offset: 0.18em; }
.skip-link { position: absolute; left: -9999px; top: 0; }
.skip-link:focus { left: 0.5rem; top: 0.5rem; z-index: 50; background: #fff; padding: 0.5rem; border-radius: 4px; }

/* Sticky App Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: #0f172a;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.brand {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.01em;
}
.site-header nav {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
}
.site-header nav a {
  color: #cbd5e1;
  font-weight: 600;
  font-size: 0.82rem;
  text-decoration: none;
  padding: 0.28rem 0.5rem;
  border-radius: 4px;
  background: rgba(255,255,255,0.05);
}
.site-header nav a:hover {
  color: #fff;
  background: rgba(255,255,255,0.12);
}

/* Page Shell & Headings */
.page-shell {
  width: min(1280px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1.25rem 0 3.5rem;
}
.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.page-heading h1 {
  margin: 0.1rem 0 0.2rem;
  font-size: clamp(1.3rem, 3.5vw, 1.75rem);
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
}
.page-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.eyebrow {
  margin: 0;
  color: #0284c7;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Filters */
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.5rem;
  padding: 0.75rem;
  margin-bottom: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.filters label {
  display: grid;
  gap: 0.2rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}
select, button, input[type="text"], input[type="number"], input[type="date"] {
  min-height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0.35rem 0.55rem;
  font: inherit;
  font-size: 0.85rem;
}

/* Panels */
.panel {
  margin-bottom: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  flex-wrap: wrap;
}
.panel-heading h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
}
.panel-heading span {
  color: var(--muted);
  font-size: 0.78rem;
}

/* Tables & Horizontal Scroll Container */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
th, td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
  vertical-align: middle;
}
th {
  color: #475569;
  background: #f8fafc;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.02em;
  border-bottom: 1px solid #e2e8f0;
}
tbody tr:hover { background: #f8fafc; }
.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.45rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-pilot_migrated { background: var(--teal-soft); color: var(--teal); }
.badge-review_required { background: var(--amber-soft); color: var(--amber); }
.empty-state { padding: 1.5rem 0.75rem; color: var(--muted); text-align: center; font-size: 0.85rem; }

/* Grids & Cards */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.75rem;
}
.amount-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
}
.amount-grid div {
  padding: 0.65rem 0.75rem;
  border-radius: 6px;
  background: #fff;
  border: 1px solid #e2e8f0;
}
.amount-grid span {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}
.amount-grid strong {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  margin-top: 0.15rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.meta-list {
  margin: 0;
  padding: 0.5rem 0.75rem;
  display: grid;
  gap: 0.3rem;
  font-size: 0.82rem;
}
.meta-list div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
  border-bottom: 1px solid #f1f5f9;
}
.meta-list div:last-child { border-bottom: none; }
.meta-list dt { color: var(--muted); font-weight: 600; }
.meta-list dd { margin: 0; font-weight: 600; text-align: right; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-height: 34px;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn-primary { background: #0284c7; color: #fff; }
.btn-primary:hover { background: #0369a1; }
.btn-secondary { background: #fff; color: #334155; border-color: #cbd5e1; }
.btn-secondary:hover { background: #f8fafc; border-color: #94a3b8; }
.btn-group { display: flex; gap: 0.3rem; align-items: center; flex-wrap: wrap; }

/* Mobile Edge-to-Edge Fluid Layout (< 768px) */
@media (max-width: 768px) {
  body {
    font-size: 13px;
    background: #f1f5f9;
  }
  .site-header {
    flex-direction: column;
    align-items: stretch;
    padding: 0.5rem 0.6rem;
    gap: 0.4rem;
  }
  .site-header nav {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 0.15rem;
    gap: 0.3rem;
  }
  .site-header nav a {
    font-size: 0.78rem;
    padding: 0.25rem 0.45rem;
  }
  .page-shell {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0.4rem 0.35rem 3rem !important;
    margin: 0 !important;
  }
  .page-heading {
    margin-bottom: 0.6rem;
    padding: 0 0.25rem;
  }
  .page-heading h1 {
    font-size: 1.25rem;
  }
  .panel {
    border-radius: 6px;
    margin-bottom: 0.6rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  }
  .panel-heading {
    padding: 0.5rem 0.65rem;
  }
  .panel-heading h2 {
    font-size: 0.92rem;
  }
  .filters {
    grid-template-columns: 1fr;
    padding: 0.5rem 0.6rem;
    gap: 0.4rem;
  }
  .detail-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  .amount-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
    margin: 0.4rem 0.5rem !important;
  }
  .amount-grid div {
    padding: 0.45rem 0.55rem !important;
  }
  .amount-grid span {
    font-size: 0.7rem !important;
  }
  .amount-grid strong {
    font-size: 1rem !important;
  }

  /* Compact Fluid Tables on Mobile */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }
  table {
    min-width: 480px;
    font-size: 0.78rem;
  }
  th, td {
    padding: 0.42rem 0.5rem;
    white-space: nowrap;
  }
  th {
    font-size: 0.72rem;
  }
  .btn {
    min-height: 30px;
    padding: 0.25rem 0.55rem;
    font-size: 0.75rem;
  }
  .container {
    padding: 0.4rem 0.25rem !important;
  }
}
