:root {
  --bg: #f4f7f8;
  --surface: #ffffff;
  --line: #dbe3e5;
  --ink: #1f2a2e;
  --muted: #69777d;
  --primary: #1d6f5f;
  --primary-ink: #ffffff;
  --accent: #c66a2e;
  --danger: #b43d3d;
  --warn: #a16d00;
  --ok: #277a4d;
  --shadow: 0 10px 28px rgba(29, 53, 58, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Malgun Gothic", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
button, input, select, textarea {
  font: inherit;
}
button {
  border: 0;
  background: var(--primary);
  color: var(--primary-ink);
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
  min-height: 40px;
}
button:hover { filter: brightness(0.96); }
button.ghost {
  background: #eef3f2;
  color: var(--ink);
}
button.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}
button.danger { background: var(--danger); }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; }
label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}
.sidebar {
  background: #243338;
  color: #f5fbfb;
  padding: 22px 18px;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--accent);
  border-radius: 8px;
  font-weight: 800;
}
.brand h1 {
  font-size: 18px;
  margin: 0 0 4px;
}
.brand p {
  margin: 0;
  color: #bdd0d3;
  font-size: 12px;
}
.nav {
  display: grid;
  gap: 6px;
}
.nav-item {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #dce8ea;
}
.nav-item.active, .nav-item:hover {
  background: rgba(255, 255, 255, 0.11);
}
.main {
  padding: 24px;
  min-width: 0;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.topbar h2 {
  margin: 0;
  font-size: 28px;
}
.eyebrow {
  margin: 0 0 5px;
  color: var(--primary);
  font-weight: 700;
  font-size: 12px;
}
.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.topbar-actions select { min-width: 220px; }
.view { display: none; }
.view.active { display: block; }
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.metric, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.metric {
  padding: 18px;
  display: grid;
  gap: 8px;
}
.metric span, .muted { color: var(--muted); }
.metric strong {
  font-size: 30px;
  line-height: 1;
}
.metric small { color: var(--muted); }
.split, .grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.panel {
  padding: 18px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-head h3 {
  margin: 0;
  font-size: 18px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.tabbar {
  margin-top: 18px;
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
}
.tab {
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--muted);
}
.tab.active {
  background: var(--primary);
  color: #fff;
}
.tab-panel {
  display: none;
  padding-top: 14px;
}
.tab-panel.active { display: block; }
.line-actions, .inline-actions, .form-actions, .summary-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.form-actions {
  justify-content: flex-end;
  margin-top: 16px;
}
.summary-row {
  margin-top: 14px;
  padding: 12px;
  background: #f7faf9;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.summary-chip {
  padding: 7px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
}
.summary-chip strong { color: var(--ink); }
.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin-top: 10px;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
}
td input, td select { min-width: 105px; }
.list, .master-list, .report-grid {
  display: grid;
  gap: 10px;
}
.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}
.item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.item-title {
  margin: 0 0 6px;
  font-weight: 800;
}
.item-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  background: #eef3f2;
  color: var(--ink);
}
.badge.ok { background: #e4f4eb; color: var(--ok); }
.badge.warn { background: #fff3d4; color: var(--warn); }
.badge.danger { background: #ffe7e7; color: var(--danger); }
.item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfdfd;
}
.master-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.master-row:last-child { border-bottom: 0; }
.master-row strong { display: block; }
.master-row span { color: var(--muted); font-size: 13px; }
.report-card h4 {
  margin: 0 0 10px;
}
.report-card table { min-width: 640px; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    padding: 14px;
  }
  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .topbar, .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }
  .kpi-grid, .split, .grid-2, .form-grid {
    grid-template-columns: 1fr;
  }
  .main { padding: 14px; }
}
