:root {
  --bg: #eef3f5;
  --surface: #ffffff;
  --surface-2: #f7fafb;
  --ink: #153238;
  --muted: #6f8287;
  --line: #d8e2e5;
  --teal: #176d75;
  --teal-2: #0f535a;
  --red: #b63a3a;
  --amber: #9a6a10;
  --green: #1f7a4d;
  --shadow: 0 14px 36px rgba(34, 61, 66, .12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
.hidden { display: none !important; }

.login-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-box {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}
.login-box p {
  color: var(--muted);
  line-height: 1.4;
}
.login-msg {
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
}

.shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}
.userbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

h1, h2, p { margin: 0; }
h1 { font-size: 26px; font-weight: 760; letter-spacing: 0; }
h2 { font-size: 16px; }
.topbar p { color: var(--muted); margin-top: 4px; }

.pill, .badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.badge.ok { color: var(--green); border-color: rgba(31,122,77,.35); background: #edf8f2; }
.badge.warn { color: var(--amber); border-color: rgba(154,106,16,.35); background: #fff8e8; }
.badge.muted { color: var(--muted); }

.toolbar, .summary, article {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto auto;
  gap: 12px;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  align-items: end;
}

.field span, .label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

input, select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  font: inherit;
  color: var(--ink);
  background: var(--surface-2);
}

.clinical-panel {
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.clinical-content { padding: 16px; display: grid; gap: 16px; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.procedure-list { display: grid; gap: 10px; }
.procedure-fields { border: 1px solid var(--line); border-radius: 6px; padding: 12px; background: var(--surface-2); }
.procedure-fields .field-grid { margin-top: 10px; }
.send-confirm { border-top: 1px solid var(--line); padding-top: 16px; max-width: 620px; }

button {
  height: 42px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}
button.primary {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal-2);
}
button:disabled {
  cursor: not-allowed;
  opacity: .48;
}

.summary {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) repeat(3, minmax(130px, 1fr));
  gap: 1px;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
}
.summary > div {
  background: var(--surface);
  padding: 16px;
}
.summary strong {
  display: block;
  font-size: 20px;
  line-height: 1.2;
}
.summary.empty strong { color: var(--muted); }

.warnings {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}
.warning {
  border-radius: 8px;
  padding: 12px 14px;
  border: 1px solid rgba(154,106,16,.32);
  background: #fff8e8;
  color: var(--amber);
}
.warning.danger {
  border-color: rgba(182,58,58,.32);
  background: #fff0f0;
  color: var(--red);
}
.warning.success { border-color: rgba(31,122,77,.35); background: #edf8f2; color: var(--green); }

.grid {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 16px;
}

.audit-panel {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

article {
  border-radius: 8px;
  overflow: hidden;
  min-width: 0;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.table-wrap {
  overflow: auto;
  max-height: 62vh;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: 12px;
  background: #fbfdfe;
  position: sticky;
  top: 0;
}
.sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}
.code {
  font-family: Consolas, monospace;
  font-weight: 700;
}
.missing { color: var(--red); font-weight: 700; }

pre {
  margin: 0;
  padding: 16px;
  max-height: 62vh;
  overflow: auto;
  background: #0f2529;
  color: #d7eef0;
  font-size: 13px;
  line-height: 1.45;
}

@media (max-width: 900px) {
  .shell { padding: 16px; }
  .toolbar, .summary, .grid {
    grid-template-columns: 1fr;
  }
}
