:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #637083;
  --line: #dce4ee;
  --blue: #2563eb;
  --green: #12805c;
  --amber: #b76e00;
  --red: #c2415b;
  --shadow: 0 18px 40px rgba(20, 31, 49, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
  font-family: "Segoe UI", "Malgun Gothic", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button, input, select, textarea {
  font: inherit;
}

.sidebar {
  min-height: 100vh;
  padding: 22px 16px;
  background: #111827;
  color: white;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--blue);
  font-weight: 800;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: #a9b4c5;
}

nav {
  display: grid;
  gap: 8px;
}

.nav {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  text-align: left;
  color: #d5dce8;
  background: transparent;
  cursor: pointer;
}

.nav.active,
.nav:hover {
  color: white;
  background: #22304a;
}

.app {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 32px; letter-spacing: 0; }
h2 { margin-bottom: 14px; font-size: 19px; letter-spacing: 0; }
h3 { margin-bottom: 8px; font-size: 16px; letter-spacing: 0; }

.actions,
.toolbar,
menu {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn,
.file-btn {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--blue);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.btn.secondary {
  background: white;
  color: var(--blue);
}

.btn.ghost {
  border-color: var(--line);
  background: white;
  color: var(--ink);
}

.btn.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.file-btn input {
  display: none;
}

.view { display: none; }
.view.active { display: block; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metrics article,
.panel,
.table-wrap,
.case-column {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metrics article {
  min-height: 124px;
  padding: 18px;
  display: grid;
  align-content: space-between;
}

.metrics small,
.hint {
  color: var(--muted);
}

.metrics strong {
  font-size: 34px;
}

.metrics span {
  color: var(--muted);
  font-size: 13px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.toolbar {
  margin-bottom: 14px;
}

input, select, textarea {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
}

.toolbar input {
  min-width: min(360px, 100%);
  flex: 1;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

th, td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.pill {
  display: inline-flex;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  align-items: center;
  background: #eef3fb;
  color: #2b405f;
  font-size: 12px;
  font-weight: 800;
}

.pill.ok { background: #e8f7f1; color: var(--green); }
.pill.warn { background: #fff2d9; color: var(--amber); }
.pill.red { background: #ffe8ee; color: var(--red); }

.icon-btn {
  min-width: 34px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  cursor: pointer;
}

.compact-list,
.task-list,
.routine-list {
  display: grid;
  gap: 10px;
}

.task-list {
  padding-left: 18px;
}

.compact-item,
.routine-item,
.case-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.compact-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 14px;
}

.case-column {
  min-height: 420px;
  padding: 14px;
}

.case-column h3 {
  display: flex;
  justify-content: space-between;
}

.case-card {
  margin-bottom: 10px;
}

.case-card small,
.case-card p {
  color: var(--muted);
}

.routine-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.routine-item input {
  margin-top: 2px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.form-grid label.full {
  grid-column: 1 / -1;
}

dialog {
  width: min(720px, calc(100% - 28px));
  border: 0;
  border-radius: 10px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .2);
}

dialog form {
  padding: 22px;
}

menu {
  justify-content: flex-end;
  padding: 0;
  margin: 18px 0 0;
}

.notice {
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  background: #eef3fb;
  color: #2b405f;
}

.mt {
  margin-top: 16px;
}

.diagnosis-list {
  display: grid;
  gap: 12px;
}

.diagnosis-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  background: #fbfcff;
}

.diagnosis-card p {
  margin: 8px 0;
  color: var(--muted);
  line-height: 1.55;
}

.diagnosis-card small {
  color: var(--muted);
}

.diagnosis-card.risk {
  border-left-color: var(--red);
}

.diagnosis-card.warn {
  border-left-color: var(--amber);
}

.diagnosis-card.ok {
  border-left-color: var(--green);
}

.diagnosis-card.action {
  border-left-color: var(--blue);
}

.guide-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.8;
}

code {
  padding: 2px 6px;
  border-radius: 6px;
  background: #eef3fb;
  color: #2b405f;
  font-family: Consolas, "Courier New", monospace;
  word-break: break-all;
}

.api-result {
  min-height: 220px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: #e5edf8;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metrics,
  .split,
  .kanban,
  .form-grid {
    grid-template-columns: 1fr;
  }
}
