:root {
  --bg: #f3efe6;
  --bg-strong: #fbf8f2;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: rgba(255, 255, 255, 0.92);
  --ink: #162127;
  --ink-soft: #2b3c45;
  --muted: #607176;
  --line: rgba(22, 33, 39, 0.1);
  --accent: #0f7b75;
  --accent-strong: #0a605b;
  --accent-soft: #d8f1ed;
  --accent-ghost: rgba(15, 123, 117, 0.1);
  --warning: #b16b14;
  --warning-soft: #f8ead3;
  --danger: #a73d31;
  --danger-soft: #f6ddd7;
  --success: #197a53;
  --success-soft: #d9f0e4;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 54px rgba(22, 33, 39, 0.08);
  --shadow-soft: 0 8px 26px rgba(22, 33, 39, 0.06);
  --font-main: "Segoe UI Variable", "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-accent: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --page-max-width: 1560px;
  --page-padding: 24px;
  --section-gap: 14px;
  font-family: var(--font-main);
}

* {
  box-sizing: border-box;
}

html {
  background:
    radial-gradient(circle at top right, rgba(15, 123, 117, 0.1), transparent 34%),
    linear-gradient(180deg, #f7f4ec, #efe9dd 72%);
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: transparent;
  overflow-x: hidden;
}

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

button {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

button.ghost:hover {
  background: rgba(255, 255, 255, 0.7);
}

button.danger {
  background: var(--danger);
}

button.danger-soft {
  color: var(--danger);
}

button.is-active,
.nav-link.active {
  background: var(--accent-soft);
  border-color: rgba(15, 123, 117, 0.16);
  color: var(--accent-strong);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(15, 123, 117, 0.2);
  border-color: rgba(15, 123, 117, 0.35);
}

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

.page {
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) 440px;
  gap: 36px;
  align-items: center;
  padding: 48px;
}

.brand h1,
.workspace-header h1,
.sidebar-brand h2,
.auth-card h2 {
  margin: 0;
  font-family: var(--font-accent);
}

.lead {
  max-width: 56ch;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1.6;
}

.brand-points {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-top: 28px;
}

.point-card {
  padding: 20px;
}

.point-card strong {
  display: block;
  margin-bottom: 8px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.card {
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.soft-card {
  background: var(--panel-strong);
}

.auth-card {
  display: grid;
  gap: 16px;
  padding: 28px;
}

.app-shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: 100vh;
  max-width: 100%;
  overflow-x: clip;
}

.sidebar {
  padding: 28px 22px;
  border-right: 1px solid rgba(22, 33, 39, 0.08);
  background: rgba(251, 248, 241, 0.84);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
}

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

.nav-link {
  text-align: left;
  background: transparent;
  color: var(--ink);
  border: 1px solid transparent;
}

.workspace {
  padding: 22px var(--page-padding) 34px;
  display: grid;
  gap: var(--section-gap);
  align-content: start;
  min-width: 0;
  max-width: 100%;
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 20px;
  position: sticky;
  top: 18px;
  z-index: 8;
}

.workspace > * {
  width: min(100%, var(--page-max-width));
  max-width: 100%;
  min-width: 0;
  margin-inline: auto;
}

.header-actions {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.view {
  display: none;
  min-width: 0;
}

.view.active {
  display: grid;
  gap: var(--section-gap);
}

.stack,
.panel-stack,
.detail-stack {
  display: grid;
  gap: var(--section-gap);
  min-width: 0;
}

.toolbar,
.toolbar-grid,
.action-row,
.chip-row,
.summary-strip,
.legend,
.list-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar.split {
  justify-content: space-between;
}

.toolbar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}

.toolbar-card {
  padding: 16px 18px;
}

.toolbar label {
  min-width: 0;
}

.search-field {
  min-width: 0;
}

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

.metrics-grid,
.summary-grid,
.content-grid,
.panel-grid,
.detail-grid,
.info-grid {
  display: grid;
  gap: var(--section-gap);
  min-width: 0;
}

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

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

.panel-grid,
.detail-grid,
.content-grid {
  grid-template-columns: minmax(0, 1fr);
}

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

.metric-card,
.section-card,
.detail-card,
.table-card,
.editor-card,
.note-card {
  padding: 18px;
  min-width: 0;
}

.metric-card .value {
  font-size: 30px;
  font-weight: 800;
}

.metric-card .subvalue {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.section-card h3,
.detail-card h3,
.table-card h3,
.editor-card h3 {
  margin: 0 0 10px;
}

.table-card header,
.section-card header,
.detail-card header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  border-radius: 16px;
  border: 1px solid rgba(22, 33, 39, 0.08);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.7);
  min-width: 100%;
  table-layout: fixed;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(22, 33, 39, 0.08);
  vertical-align: top;
  min-width: 0;
  max-width: 0;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  position: sticky;
  top: 0;
  background: rgba(248, 246, 240, 0.95);
  backdrop-filter: blur(10px);
}

td button,
td .badge,
td .chip-row,
td .action-row {
  max-width: 100%;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: rgba(15, 123, 117, 0.04);
}

.clickable-row {
  cursor: pointer;
}

.status {
  margin: 0;
  min-height: 24px;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
}

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

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

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

.badge.neutral {
  background: rgba(22, 33, 39, 0.08);
  color: var(--ink-soft);
}

.kpi-list,
.timeline-list,
.event-list,
.info-list {
  display: grid;
  gap: 10px;
}

.kpi-row,
.timeline-row,
.event-row,
.info-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(22, 33, 39, 0.08);
  flex-wrap: wrap;
}

.kpi-row:last-child,
.timeline-row:last-child,
.event-row:last-child,
.info-row:last-child {
  border-bottom: 0;
}

.timeline-row,
.event-row {
  align-items: flex-start;
}

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

.stat-chip {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.55);
}

.stat-chip .label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-chip .value {
  margin-top: 6px;
  font-size: 20px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.chart {
  display: grid;
  gap: 12px;
}

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

.chart-bars {
  display: grid;
  gap: 10px;
}

.chart-bar {
  display: grid;
  gap: 6px;
}

.chart-bar .meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.chart-bar button.meta {
  background: transparent;
  color: var(--ink);
  border: 0;
  padding: 0;
  text-align: left;
}

.chart-track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: rgba(22, 33, 39, 0.08);
  overflow: hidden;
}

.chart-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--fill, 0%);
  background: linear-gradient(90deg, var(--accent), #17a99d);
  border-radius: 999px;
}

.chart-fill.warning {
  background: linear-gradient(90deg, var(--warning), #d68d24);
}

.chart-fill.danger {
  background: linear-gradient(90deg, var(--danger), #d26053);
}

.chart-fill.neutral {
  background: linear-gradient(90deg, #7f8d93, #9eadb3);
}

.empty-state {
  padding: 28px;
  border: 1px dashed rgba(22, 33, 39, 0.15);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.45);
}

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

.pagination .meta {
  color: var(--muted);
  font-size: 13px;
}

.checkbox-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.checkbox-row input {
  width: auto;
}

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

code {
  background: rgba(22, 33, 39, 0.08);
  border-radius: 8px;
  padding: 2px 6px;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  background: #f8f5ef;
  border-radius: 14px;
  padding: 14px;
  max-width: 100%;
  overflow: auto;
}

.mono-list {
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

.hidden {
  display: none !important;
}

@media (max-width: 1240px) {
  :root {
    --page-padding: 20px;
  }
}

@media (max-width: 1024px) {
  .login-shell,
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(22, 33, 39, 0.08);
    position: static;
    height: auto;
    overflow: visible;
  }

  .workspace {
    padding: 20px;
  }

  .workspace-header {
    flex-direction: column;
    position: static;
  }

  .header-actions {
    width: 100%;
    justify-items: stretch;
  }
}

@media (max-width: 720px) {
  .login-shell,
  .workspace,
  .sidebar {
    padding: 18px;
  }

  .toolbar-grid,
  .filters-grid {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 12px;
  }
}
