:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1a2332;
  --muted: #5c6b7f;
  --border: #d8dee8;
  --accent: #0d4f8c;
  --accent-hover: #0a3d6e;
  --success: #0d7a4f;
  --danger: #b42318;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(15, 34, 58, 0.08);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #0a2540 0%, #0d4f8c 100%);
  color: #e8f0f8;
  padding: 1.25rem 0;
  display: flex;
  flex-direction: column;
}

.sidebar__brand {
  padding: 0 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar__brand small {
  display: block;
  opacity: 0.75;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}

.sidebar__brand strong {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem 0.75rem;
}

.sidebar__nav a {
  display: block;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  color: #e8f0f8;
  text-decoration: none;
  font-size: 0.92rem;
  transition: background 0.15s ease;
}

.sidebar__nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  text-decoration: none;
}

.sidebar__nav a.is-active {
  background: rgba(255, 255, 255, 0.18);
  font-weight: 600;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.main__header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0;
  box-shadow: var(--shadow);
}

.context-band {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
  padding: 0.5rem 1.75rem;
  font-size: 0.8rem;
  color: var(--text);
  background: linear-gradient(90deg, #eef5fb 0%, #f8fafc 100%);
  border-bottom: 1px solid var(--border);
}

.context-band__label {
  color: var(--muted);
  font-weight: 600;
  margin-right: 0.25rem;
}

.context-band__sep {
  width: 1px;
  height: 0.85rem;
  background: var(--border);
  flex-shrink: 0;
}

.context-band__status {
  color: var(--success);
  font-weight: 700;
}

.main__header > h1,
.main__header > p {
  padding-left: 1.75rem;
  padding-right: 1.75rem;
}

.main__header > h1 {
  padding-top: 1rem;
  margin: 0 0 0.25rem;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.main__header > p {
  padding-bottom: 1rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.main__body {
  flex: 1;
  padding: 1.5rem 1.75rem 2.5rem;
  max-width: 1200px;
  width: 100%;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: #e8f5ee;
  color: var(--success);
  font-weight: 600;
}

.status-pill--warn {
  background: #fff4e0;
  color: #a65f00;
}

.status-pill--err {
  background: #fdecea;
  color: var(--danger);
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card__label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.card__value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.card__actions {
  margin-top: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: none;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--accent-hover);
}

.btn--ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
}

.btn--ghost:hover {
  background: var(--bg);
}

.banner {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.92rem;
}

.banner--error {
  background: #fdecea;
  color: var(--danger);
  border: 1px solid #f5c4c0;
}

.banner--loading {
  background: #eef4fb;
  color: var(--accent);
  border: 1px solid var(--border);
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background 0.1s ease;
}

.data-table tbody tr:hover {
  background: #f4f8fc;
}

.data-table .mono {
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 0.82rem;
}

.trace-hint {
  font-size: 0.78rem;
  color: var(--muted);
}

.flow-diagram {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.flow-step {
  flex: 1;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  position: relative;
}

.flow-step__title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.flow-step__code {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  font-family: ui-monospace, monospace;
}

.flow-step__linkline {
  margin: 0.5rem 0 0;
  font-size: 0.88rem;
  color: var(--text);
  font-weight: 500;
  line-height: 1.45;
}

.flow-step__meta {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.card--exec-summary {
  border-left: 4px solid var(--accent);
}

.exec-summary {
  margin: 0.75rem 0 0;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.65;
}

.exec-summary > p:first-child {
  margin: 0 0 0.85rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
}

.exec-summary ul {
  margin: 0;
  padding-left: 1.2rem;
}

.exec-summary li {
  margin-bottom: 0.45rem;
}

.exec-summary li:last-child {
  margin-bottom: 0.35rem;
}

.exec-summary__footnote {
  margin: 1rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.55;
}

.col-ref {
  font-weight: 500;
  color: var(--text);
  font-size: 0.88rem;
}

.flow-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--accent);
  font-weight: 300;
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .flow-arrow {
    transform: rotate(90deg);
    width: 100%;
  }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 34, 58, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal__header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.modal__header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal__close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0.25rem;
}

.modal__body {
  padding: 1.25rem;
  overflow-y: auto;
  font-size: 0.92rem;
}

.modal__row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0.5rem 1rem;
  margin-bottom: 0.65rem;
}

.modal__row dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.modal__row dd {
  margin: 0;
  font-weight: 500;
}

.admin-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.admin-card__title {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1rem;
  max-width: 28rem;
}

.admin-form__field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.admin-form__field input,
.admin-form__field select {
  font: inherit;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}

.admin-msg {
  margin-top: 0.75rem;
}

@media (max-width: 768px) {
  .context-band {
    padding: 0.45rem 1rem;
  }
  .context-band__sep {
    display: none;
  }
  .main__header > h1,
  .main__header > p {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 0.75rem 1rem;
  }
  .sidebar__brand {
    border-bottom: none;
    padding: 0 1rem 0 0;
  }
  .sidebar__nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0;
    flex: 1;
    justify-content: flex-end;
  }
  .sidebar__nav a {
    padding: 0.4rem 0.65rem;
    font-size: 0.85rem;
  }
}
