:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0f4fbf;
  --brand-soft: #eaf2ff;
  --accent: #0891b2;
  --danger: #b91c1c;
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  background: var(--bg);
  color: var(--ink);
  margin: 0;
}

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

button {
  align-items: center;
  background: var(--brand);
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
}

button:hover {
  filter: brightness(0.96);
}

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

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

button.linkButton {
  align-self: start;
  background: transparent;
  color: var(--brand);
  min-height: auto;
  padding: 0;
  text-decoration: underline;
}

input,
select,
textarea {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 42px;
  outline: none;
  padding: 9px 11px;
  width: 100%;
}

textarea {
  line-height: 1.5;
  min-height: 360px;
  resize: vertical;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
}

main {
  margin: 0 auto;
  max-width: 1180px;
  padding: 24px;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 18px 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h1 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: 0;
  margin: 2px 0 0;
}

.session {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 10px;
}

.eyebrow {
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0;
  text-transform: uppercase;
}

.muted,
.notice {
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
}

.notice.error {
  color: var(--danger);
}

.panel,
.listPanel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
  padding: 20px;
}

.grid {
  display: grid;
  gap: 14px;
}

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

.authRow {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.6fr) auto;
}

.tabs {
  background: #eef2f7;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
}

.tab {
  background: transparent;
  color: var(--muted);
  flex: 1;
}

.tab.active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.tabPanel {
  display: none;
}

.tabPanel.active {
  display: block;
}

.metricGrid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.metric {
  background: linear-gradient(135deg, #ffffff, #edf6ff);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 18px;
}

.metric strong {
  font-size: 30px;
}

.metric span {
  color: var(--muted);
  font-weight: 700;
}

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

.sectionHead h2,
.panel h2,
.listPanel h2 {
  font-size: 20px;
  font-weight: 650;
  margin: 0;
}

.formGrid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.formGrid button {
  align-self: end;
}

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

.search {
  max-width: 330px;
}

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

.row {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 14px;
}

.row h3 {
  font-size: 18px;
  font-weight: 650;
  margin: 0 0 5px;
}

.rowMeta {
  color: var(--muted);
  line-height: 1.4;
}

.rowActions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.pill {
  background: var(--brand-soft);
  border-radius: 999px;
  color: var(--brand);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  margin-right: 6px;
  padding: 4px 9px;
}

.templateLayout {
  display: grid;
  gap: 16px;
  grid-template-columns: 280px minmax(0, 1fr);
}

.templateList {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.templateButton {
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  justify-content: flex-start;
  min-height: 44px;
  width: 100%;
}

.templateButton.active {
  background: var(--brand-soft);
  color: var(--brand);
}

.templateEditor {
  font-size: 13px;
}

.toast {
  background: #0f172a;
  border-radius: 8px;
  bottom: 22px;
  box-shadow: var(--shadow);
  color: #ffffff;
  font-weight: 700;
  left: 50%;
  padding: 12px 16px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 40;
}

@media (max-width: 820px) {
  main {
    padding: 14px;
  }

  .topbar,
  .sectionHead {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid.two,
    .formGrid,
    .materialsForm,
    .metricGrid,
  .templateLayout,
  .authRow {
    grid-template-columns: 1fr;
  }

  .tabs {
    overflow-x: auto;
  }

  .tab {
    min-width: 140px;
  }

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

  .search {
    max-width: none;
  }
}
