:root {
  --bg: #edf4fb;
  --bg-strong: #dbe8f5;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-strong: #ffffff;
  --ink: #1a2430;
  --muted: #617285;
  --line: rgba(27, 55, 86, 0.12);
  --accent: #2f96e5;
  --accent-strong: #256da9;
  --accent-soft: rgba(47, 150, 229, 0.12);
  --teal: #1f5f94;
  --gold: #bf8b2e;
  --danger: #b42318;
  --shadow: 0 18px 40px rgba(25, 47, 78, 0.12);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --font-body: "Avenir Next", "Segoe UI", "Trebuchet MS", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(47, 150, 229, 0.18), transparent 24%),
    radial-gradient(circle at bottom right, rgba(31, 95, 148, 0.12), transparent 20%),
    linear-gradient(180deg, #f7fbff 0%, #e9f1f8 100%);
  color: var(--ink);
  font-family: var(--font-body);
}

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

.shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  padding: 24px;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

.rail,
.panel {
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.panel {
  background: var(--surface);
}

.rail {
  position: sticky;
  top: 24px;
  align-self: start;
  border-radius: 28px;
  padding: 24px;
  background: linear-gradient(180deg, #26384c 0%, #31485f 100%);
  border-color: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.95);
}

.brand h1 {
  color: #ffffff;
  letter-spacing: -0.04em;
}

.brand h1,
.workspace-header h2,
.panel h3,
.panel h4,
.auth-card h2 {
  font-family: var(--font-display);
  letter-spacing: -0.03em;
}

.brand h1,
.workspace-header h2 {
  margin: 0;
  font-size: clamp(2rem, 3.6vw, 3rem);
  line-height: 0.95;
}

.subtitle,
.muted,
.empty-state,
.panel-subtitle,
.meta-row span {
  color: var(--muted);
}

.rail .subtitle,
.rail .muted,
.rail .panel-subtitle,
.rail .meta-row span {
  color: rgba(230, 238, 247, 0.76);
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--accent-strong);
  font-weight: 700;
}

.rail .eyebrow {
  color: #9fd2ff;
}

.nav {
  display: grid;
  gap: 10px;
  margin: 28px 0;
}

.nav-link,
.button {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.nav-link {
  text-align: left;
  padding: 15px 16px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.95);
}

.nav-link:hover,
.button:hover {
  transform: translateY(-1px);
}

.nav-link.is-active {
  background: linear-gradient(135deg, var(--accent) 0%, #4ba8ef 100%);
  border-color: transparent;
  color: white;
}

.auth-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.rail .auth-card,
.rail .auth-card h2,
.rail label span {
  color: rgba(255, 255, 255, 0.95);
}

.auth-card h2 {
  margin: 0;
  font-size: 1.2rem;
}

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

label span {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(24, 34, 45, 0.16);
  background: rgba(255, 255, 255, 0.9);
}

.rail input,
.rail select,
.rail textarea {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.workspace {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
}

.header-actions,
.filters,
.stat-grid,
.detail-actions,
.form-row,
.list-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.filters {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 251, 244, 0.72);
  border: 1px solid var(--line);
}

.filter-chip {
  display: grid;
  gap: 6px;
  min-width: 160px;
}

.button {
  padding: 11px 16px;
  font-weight: 700;
}

.button-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #4ba8ef 100%);
  color: white;
  border-color: transparent;
}

.button-secondary {
  background: rgba(255, 255, 255, 0.85);
}

.button-danger {
  background: rgba(180, 35, 24, 0.12);
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.2);
}

.button-ghost {
  background: transparent;
  color: var(--accent-strong);
  border-color: rgba(47, 150, 229, 0.18);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.9fr);
  gap: 18px;
  align-items: start;
  min-width: 0;
}

.content-grid.is-single {
  grid-template-columns: 1fr;
}

.panel {
  border-radius: var(--radius-lg);
  padding: 20px;
  min-height: 68vh;
}

.panel h3,
.panel h4 {
  margin: 0;
}

.panel-main {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.panel-detail {
  align-self: stretch;
  position: static;
  height: auto;
  max-height: none;
  overflow: visible;
}

.content-grid.has-sticky-detail .panel-detail {
  position: sticky;
  top: 24px;
  align-self: start;
  max-height: calc(100vh - 48px);
  overflow: auto;
}

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

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

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

.chart-grid-alert {
  grid-template-columns: minmax(0, 640px);
  justify-content: start;
}

.chart-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
  padding: 16px;
  display: grid;
  gap: 10px;
}

.chart-card-large {
  padding: 18px;
}

.chart-card-alert {
  width: min(100%, 520px);
  max-width: 520px;
}

.chart-svg {
  width: 100%;
  height: 220px;
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(31, 107, 114, 0.06), rgba(181, 81, 45, 0.02)),
    rgba(24, 34, 45, 0.03);
}

.chart-card-large .chart-svg {
  height: 320px;
}

.chart-card-alert .chart-svg {
  width: 100%;
  height: auto;
  max-height: 190px;
  aspect-ratio: 12 / 7;
}

.chart-svg-compact {
  display: block;
}

.chart-gridline {
  stroke: rgba(24, 34, 45, 0.1);
  stroke-dasharray: 4 4;
}

.chart-axis {
  stroke: rgba(24, 34, 45, 0.24);
  stroke-width: 1.2;
}

.chart-axis-label,
.chart-tick-label {
  fill: var(--muted);
  font-family: var(--font-body);
}

.chart-axis-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chart-tick-label {
  font-size: 10px;
}

.chart-dot {
  fill: var(--accent);
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 1.5;
}

.chart-dot-sparse {
  fill: var(--teal);
  stroke-width: 2;
}

.chart-caption {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.profile-main,
.profile-side,
.range-controls {
  display: grid;
  gap: 18px;
}

.range-controls {
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  align-items: center;
}

.button.is-active-filter {
  background: linear-gradient(135deg, var(--accent) 0%, #4ba8ef 100%);
  color: white;
  border-color: transparent;
}

.stat-card {
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.stat-card.is-clickable {
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.stat-card.is-clickable:hover {
  transform: translateY(-1px);
  border-color: rgba(47, 150, 229, 0.24);
  box-shadow: 0 14px 28px rgba(25, 47, 78, 0.1);
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-family: var(--font-display);
  font-size: 2rem;
}

.section-card,
.item-card,
.detail-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.6);
}

.section-card {
  padding: 18px;
}

.item-list {
  display: grid;
  gap: 10px;
}

.item-card {
  padding: 14px 16px;
  cursor: pointer;
  min-width: 0;
}

.item-card.is-selected {
  border-color: rgba(181, 81, 45, 0.4);
  box-shadow: inset 0 0 0 1px rgba(181, 81, 45, 0.2);
  background: linear-gradient(180deg, rgba(181, 81, 45, 0.08), rgba(255, 255, 255, 0.7));
}

.item-card-header,
.detail-header,
.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  min-width: 0;
}

.item-card h4,
.detail-card h3 {
  margin: 0 0 4px;
}

.item-card h4,
.detail-card h3,
.detail-card p,
.meta-row strong,
.meta-row span,
.item-card .muted,
.dense {
  overflow-wrap: anywhere;
}

.detail-stack,
.meta-stack,
.event-list {
  display: grid;
  gap: 12px;
}

.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.pagination-label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.day-group {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(31, 107, 114, 0.14);
  background: linear-gradient(180deg, rgba(31, 107, 114, 0.06), rgba(255, 255, 255, 0.92));
}

.day-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(31, 107, 114, 0.1);
  color: var(--teal);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.day-group-count {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.assignment-card {
  cursor: default;
}

.item-card.is-clickable,
.assignment-card.is-clickable {
  cursor: pointer;
}

.detail-card {
  padding: 16px;
}

.detail-card pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: rgba(24, 34, 45, 0.04);
  padding: 12px;
  border-radius: var(--radius-sm);
}

.chem-list {
  display: grid;
  gap: 8px;
}

.chem-chip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(24, 34, 45, 0.04);
  border: 1px solid rgba(24, 34, 45, 0.08);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.pill-critical,
.pill-high,
.pill-open {
  background: rgba(180, 35, 24, 0.12);
  color: var(--danger);
}

.pill-warning,
.pill-normal,
.pill-snoozed {
  background: rgba(191, 139, 46, 0.14);
  color: #8f6417;
}

.pill-info,
.pill-acknowledged,
.pill-completed,
.pill-resolved {
  background: rgba(31, 107, 114, 0.14);
  color: var(--teal);
}

.pill-muted,
.pill-canceled,
.pill-cleared {
  background: rgba(24, 34, 45, 0.08);
  color: var(--muted);
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.button-inline {
  padding: 8px 12px;
  min-height: 0;
  border-radius: 999px;
  font-size: 0.82rem;
}

.dense {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.split {
  display: grid;
  gap: 16px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(24, 34, 45, 0.92);
  color: white;
  box-shadow: var(--shadow);
}

.empty-state {
  padding: 28px;
  text-align: center;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(24, 34, 45, 0.18);
  background: rgba(255, 255, 255, 0.48);
}

@media (max-width: 1120px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .rail,
  .panel-detail {
    position: static;
    height: auto;
    max-height: none;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }

  .chart-grid-wide {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 14px;
  }

  .rail,
  .panel {
    border-radius: 20px;
  }

  .workspace-header {
    align-items: start;
    flex-direction: column;
  }

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

  .range-controls {
    grid-auto-flow: row;
  }
}
