:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-muted: #eef3fb;
  --border: #d7deea;
  --text: #172033;
  --muted: #5b677d;
  --primary: #0f62fe;
  --primary-strong: #0446bf;
  --success: #0e8b4f;
  --success-bg: #def7e8;
  --warning: #8b5d00;
  --warning-bg: #fff1cf;
  --danger: #b42318;
  --danger-bg: #fee4e2;
  --accent: #6648c8;
  --accent-bg: #ece9fe;
  --shadow: 0 20px 45px rgba(15, 31, 69, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

pre,
code,
.code {
  font-family: "SFMono-Regular", ui-monospace, "Cascadia Code", Consolas, monospace;
}

.app-shell {
  width: min(1440px, 100vw - 3rem);
  margin: 0 auto;
}

.app-header {
  background: linear-gradient(180deg, #182847 0%, #13203a 100%);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-shell-header {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 0;
}

.app-brand {
  display: inline-block;
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.app-brand:hover {
  text-decoration: none;
}

.app-tagline {
  margin: 0.35rem 0 0;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.95rem;
}

.app-nav {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-link {
  color: rgba(255, 255, 255, 0.85);
  padding: 0.65rem 0.95rem;
  border-radius: 999px;
  font-weight: 600;
}

.nav-link:hover,
.nav-link.is-active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  text-decoration: none;
}

.app-main {
  padding: 1.5rem 0 3rem;
}

.flash {
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid transparent;
  font-weight: 600;
}

.flash-notice {
  color: var(--success);
  background: var(--success-bg);
  border-color: #9dd8b6;
}

.flash-alert {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: #f1a9a4;
}

.error-list {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
  font-weight: 500;
}

.page-header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.page-header h1 {
  margin: 0.2rem 0 0;
  font-size: 2rem;
  letter-spacing: -0.03em;
}

.page-subtitle,
.muted {
  color: var(--muted);
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--primary);
}

.page-actions,
.button-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.7rem;
  padding: 0.7rem 1rem;
  border: 0;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(15, 98, 254, 0.2);
}

.button:hover {
  background: var(--primary-strong);
  text-decoration: none;
}

.button-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.button-secondary:hover {
  background: var(--surface-muted);
}

.stats-grid,
.panel-grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.panel-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.panel-grid-wide {
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
}

.card,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.card {
  padding: 1.15rem;
}

.card h2,
.panel h2,
.panel h3 {
  margin-top: 0;
}

.metric-value {
  display: block;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-top: 0.35rem;
}

.panel {
  padding: 1.2rem;
}

.panel-header,
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.inline-list {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
}

.filters,
.stack {
  display: grid;
  gap: 1rem;
}

.filters {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.field,
.form-field {
  display: grid;
  gap: 0.4rem;
}

label {
  font-size: 0.92rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 8rem;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(15, 98, 254, 0.16);
  border-color: var(--primary);
}

.table-wrapper {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 0.85rem 0.9rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #fafcff;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 0;
}

.detail-grid > div {
  min-width: 0;
}

.detail-grid dt {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
}

.detail-grid dd {
  margin: 0;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.detail-grid dd .code {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.detail-grid-item-wide {
  grid-column: 1/-1;
}

.detail-grid dd .code {
  display: inline-block;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.58rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.badge-danger {
  color: var(--danger);
  background: var(--danger-bg);
}

.badge-success {
  color: var(--success);
  background: var(--success-bg);
}

.badge-warning {
  color: var(--warning);
  background: var(--warning-bg);
}

.badge-accent {
  color: var(--accent);
  background: var(--accent-bg);
}

.badge-neutral {
  color: #344054;
  background: #e9eef6;
}

.code-block {
  overflow: auto;
  max-height: 34rem;
  padding: 1rem;
  border-radius: 14px;
  background: #101828;
  color: #d0d5dd;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.empty-state {
  padding: 1.4rem;
  border: 1px dashed var(--border);
  border-radius: 14px;
  color: var(--muted);
  background: #fbfcfe;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
}

.pagination-status {
  color: var(--muted);
  font-weight: 600;
}

.form-card {
  max-width: 680px;
}

.split-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

@media (max-width: 960px) {
  .app-shell {
    width: min(100vw - 1.5rem, 1440px);
  }
  .app-shell-header,
  .page-header,
  .panel-header,
  .section-header,
  .split-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .app-nav {
    justify-content: flex-start;
  }
  .pagination {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}
