:root {
  --bg: #f4efe7;
  --surface: rgba(255, 252, 247, 0.88);
  --line: rgba(71, 55, 32, 0.12);
  --text: #2c2217;
  --muted: #715d47;
  --accent: #9d4b22;
  --accent-strong: #6e2f12;
  --success: #2d6c4f;
  --warning: #8b5a12;
  --shadow: 0 24px 60px rgba(79, 50, 25, 0.12);
  --radius: 24px;
  --sidebar-width: 300px;
  --sidebar-collapsed-width: 76px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(244, 201, 173, 0.85), transparent 32%),
    radial-gradient(circle at bottom right, rgba(157, 75, 34, 0.12), transparent 28%),
    linear-gradient(180deg, #f9f4ed 0%, var(--bg) 48%, #efe7db 100%);
  color: var(--text);
  font-family: "Bricolage Grotesque", sans-serif;
}

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.shell.sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed-width) minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1rem 0.85rem;
  background: rgba(86, 56, 29, 0.08);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(12px);
  overflow: hidden;
}

.brand h1,
.topbar h2,
.panel h3 {
  margin: 0;
  font-family: "Literata", serif;
}

.brand h1 { font-size: 2rem; line-height: 1.1; }

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand-copy {
  display: grid;
  gap: 0.5rem;
}

.sidebar-toggle {
  min-width: 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 700;
}

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

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

.nav { display: grid; gap: 0.5rem; }

.nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: inherit;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.nav a:hover,
.nav .active {
  background: rgba(255, 250, 244, 0.78);
  border-color: var(--line);
  transform: translateX(4px);
}

.nav-main {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: rgba(157, 75, 34, 0.12);
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  flex: 0 0 auto;
}

.nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-caret {
  color: var(--muted);
  font-size: 0.95rem;
}

.status-card,
.panel,
.card,
.table-wrap,
.hero {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status-card { padding: 0.95rem; }
.status-card h2 { margin-top: 0; font-size: 1rem; }
.status-card ul { margin: 0; padding-left: 1rem; color: var(--muted); line-height: 1.45; font-size: 0.92rem; }

.content { padding: 1rem; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.session-bar,
.button-row,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.list-pager {
  justify-content: flex-end;
  margin-top: 0.55rem;
}

.checkbox-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
  align-items: start;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 252, 247, 0.72);
}

.checkbox-row input {
  margin-top: 0.18rem;
}

.panel {
  padding: 0.85rem;
  display: grid;
  gap: 0.8rem;
  min-height: calc(100vh - 7rem);
  align-content: start;
}

.hero {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  margin-bottom: 0;
  background: linear-gradient(135deg, rgba(157, 75, 34, 0.9), rgba(110, 47, 18, 0.92));
  color: #fff8f0;
}

.hero .eyebrow {
  color: rgba(255, 223, 196, 0.78);
}

.hero p,
.hero strong,
.hero .helper,
.hero .code {
  color: #fff8f0;
}

.hero-grid,
.stats,
.split,
.form-grid,
.stack {
  display: grid;
  gap: 0.75rem;
}

.hero-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stats { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); margin: 0; }
.split {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  grid-auto-flow: dense;
  align-items: start;
}
.split > .full-span {
  grid-column: 1 / -1;
}
.form-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }

.card {
  padding: 0.85rem;
  min-width: 0;
}

.metric {
  display: block;
  margin-top: 0.2rem;
  font-size: 1.25rem;
  font-weight: 700;
}

label {
  display: grid;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.84rem;
}

input, select, textarea {
  width: 100%;
  padding: 0.6rem 0.72rem;
  border: 1px solid rgba(71, 55, 32, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  font: inherit;
}

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

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.58rem 0.82rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--accent);
  color: #fff8f0;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

button:hover, .button:hover {
  transform: translateY(-1px);
  background: var(--accent-strong);
  color: #fff8f0;
}

.secondary {
  border-color: var(--line);
  background: rgba(255, 252, 247, 0.7);
  color: var(--text);
}

.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--accent-strong);
}

.table-wrap {
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 28rem;
  border-radius: 16px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.section-head .toolbar {
  margin-left: auto;
  justify-content: flex-end;
}

.inline-form-panel {
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 252, 247, 0.75);
}

.inline-form-toolbar {
  justify-content: space-between;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
  table-layout: fixed;
  font-size: 0.84rem;
}

th, td {
  padding: 0.48rem 0.55rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  position: sticky;
  top: 0;
  background: rgba(255, 252, 247, 0.96);
  z-index: 1;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.26rem 0.52rem;
  border-radius: 999px;
  background: rgba(157, 75, 34, 0.12);
  color: var(--accent-strong);
  font-size: 0.74rem;
  font-weight: 700;
}

.pill.success { background: rgba(45, 108, 79, 0.14); color: var(--success); }
.pill.warning { background: rgba(139, 90, 18, 0.14); color: var(--warning); }

.empty {
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.code-block {
  margin: 0;
  padding: 1rem;
  border-radius: 18px;
  background: rgba(44, 34, 23, 0.92);
  color: #fff8f0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font: 0.92rem/1.5 "Courier New", monospace;
}

.flash {
  margin-bottom: 1rem;
  padding: 0.72rem 0.85rem;
  border-radius: 18px;
  background: rgba(45, 108, 79, 0.12);
  color: var(--success);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.warn { background: rgba(139, 90, 18, 0.12); color: var(--warning); }

.flash-close {
  padding: 0.2rem 0.55rem;
  min-width: 0;
  border: 1px solid rgba(44, 34, 23, 0.12);
  background: rgba(255, 252, 247, 0.72);
  color: inherit;
  font-size: 1rem;
  line-height: 1;
}

.code {
  padding: 0.2rem 0.4rem;
  border-radius: 8px;
  background: rgba(44, 34, 23, 0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
}

.panel > .split > .card,
.panel > .split > section,
.panel > .stats > .card {
  align-self: start;
}

.panel .stack {
  min-width: 0;
}

.shell.sidebar-collapsed .brand-copy,
.shell.sidebar-collapsed .status-card,
.shell.sidebar-collapsed .nav-label,
.shell.sidebar-collapsed .nav-caret,
.shell.sidebar-collapsed .sidebar-head .eyebrow {
  display: none;
}

.shell.sidebar-collapsed .sidebar {
  padding-inline: 0.4rem;
  align-items: center;
}

.shell.sidebar-collapsed .brand,
.shell.sidebar-collapsed .nav {
  width: 100%;
}

.shell.sidebar-collapsed .sidebar-head {
  justify-content: center;
}

.shell.sidebar-collapsed .nav a {
  justify-content: center;
  padding: 0.55rem 0.35rem;
}

.shell.sidebar-collapsed .nav-main {
  justify-content: center;
}

.shell.sidebar-collapsed .nav a:hover,
.shell.sidebar-collapsed .nav .active {
  transform: none;
}

.shell.sidebar-collapsed .nav-icon {
  width: 38px;
  height: 38px;
}

.shell.sidebar-collapsed .sidebar-toggle {
  width: 36px;
  min-width: 36px;
  height: 36px;
}

.shell.sidebar-collapsed .content {
  padding-left: 0.85rem;
}

@media (max-width: 1100px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .split, .hero-grid, .stats, .form-grid { grid-template-columns: 1fr; }
  .shell.sidebar-collapsed { grid-template-columns: 1fr; }
  .shell.sidebar-collapsed .brand-copy,
  .shell.sidebar-collapsed .status-card,
  .shell.sidebar-collapsed .nav-label,
  .shell.sidebar-collapsed .nav-caret,
  .shell.sidebar-collapsed .sidebar-head .eyebrow {
    display: initial;
  }
  .shell.sidebar-collapsed .nav a {
    justify-content: space-between;
    padding: 0.65rem 0.8rem;
  }
  .shell.sidebar-collapsed .nav-main { justify-content: flex-start; }
}

@media (max-width: 720px) {
  .content, .sidebar { padding: 0.8rem; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .panel { padding: 0.7rem; min-height: auto; }
}
