:root {
  --charcoal: #121417;
  --charcoal-2: #1c2128;
  --royal: #0b3d91;
  --royal-soft: #e8eef8;
  --tangerine: #f15a29;
  --tangerine-soft: #fff1eb;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1a1d21;
  --muted: #5c6570;
  --line: #e2e5ea;
  --danger: #b42318;
  --danger-soft: #fdecec;
  --ok-soft: #e8eef8;
  --radius: 6px;
  --font-sans: "Merriweather Sans", "Segoe UI", system-ui, sans-serif;
  --font-serif: Merriweather, Georgia, "Times New Roman", serif;
  --space: 8px;
  --header-h: 56px;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

h1, h2, .brand-title {
  font-family: var(--font-serif);
  font-weight: 700;
  letter-spacing: -0.01em;
}

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

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 7px 12px;
  cursor: pointer;
  line-height: 1.25;
}

button:hover { border-color: #b8bfc9; background: #fafbfc; }
button:focus-visible {
  outline: 2px solid var(--royal);
  outline-offset: 2px;
}
button.primary {
  background: var(--royal);
  border-color: var(--royal);
  color: #fff;
}
button.primary:hover { background: #0a347c; border-color: #0a347c; }
button.accent {
  background: var(--tangerine);
  border-color: var(--tangerine);
  color: #fff;
}
button.accent:hover { filter: brightness(0.95); }
button:disabled { opacity: .5; cursor: not-allowed; }

/* —— Login —— */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--bg);
}
.login-wrap[hidden],
#login[hidden],
#app[hidden],
.app-shell[hidden] {
  display: none !important;
}
.login-masthead {
  background: var(--charcoal);
  color: #fff;
  padding: 14px 20px 0;
}
.login-masthead .brand-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 14px;
}
.login-masthead .brand-title {
  margin: 0;
  font-size: 1.15rem;
  color: #fff;
}
.login-masthead .brand-sub {
  margin: 0;
  color: #a8b0ba;
  font-size: 12px;
}
.login-accent {
  height: 3px;
  background: var(--royal);
}
.login-body {
  display: grid;
  place-items: center;
  padding: 32px 20px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 28px 24px;
  box-shadow: 0 1px 2px rgba(18, 20, 23, .04);
  display: grid;
  gap: 12px;
}
.login-card h1 {
  margin: 0;
  font-size: 1.45rem;
  color: var(--charcoal);
}
.login-card .rule {
  height: 2px;
  width: 48px;
  background: var(--royal);
  margin: 2px 0 4px;
}
.login-card p { margin: 0; color: var(--muted); }
.login-card input {
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
}
.login-card input:focus {
  outline: 2px solid var(--royal);
  outline-offset: 1px;
  border-color: var(--royal);
}
.login-card button[type="submit"] {
  background: var(--tangerine);
  border-color: var(--tangerine);
  color: #fff;
  padding: 10px 14px;
  font-weight: 600;
}
.login-card button[type="submit"]:hover { filter: brightness(0.96); }
.err { color: var(--danger); margin: 0; }
.hint { color: var(--muted); margin: 0; }

/* —— App shell —— */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: var(--header-h);
  background: var(--charcoal);
  color: #f4f6f8;
  position: sticky;
  top: 0;
  z-index: 5;
}
.top .brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.top .brand strong {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
}
.top .brand span {
  font-size: 11px;
  color: #9aa3ad;
}
.top-accent {
  height: 3px;
  background: var(--royal);
  flex-shrink: 0;
}
.top-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.top button {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, .22);
}
.top button:hover { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .35); }
.top .primary {
  background: var(--royal);
  border-color: var(--royal);
}
.top .accent {
  background: var(--tangerine);
  border-color: var(--tangerine);
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  flex: 1;
  min-height: 0;
}

aside {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - var(--header-h) - 3px);
}
.filters {
  padding: 12px;
  display: grid;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
}
.filters input,
.filters select {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
}
.filters button {
  width: 100%;
  text-align: center;
}
#list { overflow: auto; }

.nav {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding: 11px 14px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.nav:hover { background: #f7f8fa; }
.nav.active {
  background: var(--royal-soft);
  box-shadow: inset 3px 0 0 var(--royal);
}
.nav .name { flex: 1; min-width: 0; }
.nav small { display: block; color: var(--muted); margin-top: 2px; font-size: 12px; }
.badge {
  background: var(--tangerine);
  color: #fff;
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  align-self: center;
}
.st-approved { color: var(--royal); font-weight: 650; }
.st-pending, .st-in_progress { color: var(--muted); }
.st-stale { color: var(--danger); }

#mid {
  overflow: auto;
  padding: 20px 22px 56px;
  min-width: 0;
  background: var(--bg);
}
#mid > h1 {
  margin: 0 0 12px;
  font-size: 1.55rem;
  color: var(--charcoal);
}

.meta {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 6px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 4px;
}
.meta > div:nth-child(odd) {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 12px 0;
}
.symbols button { min-width: 34px; padding: 6px 8px; }
#mid > label {
  display: grid;
  gap: 6px;
  margin: 8px 0 16px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
#mid > label textarea {
  font-size: 14px;
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink);
  min-height: 64px;
}

.main-bar {
  background: var(--charcoal-2);
  color: #fff;
  padding: 9px 14px;
  margin-top: 20px;
  border-radius: var(--radius) var(--radius) 0 0;
  font-weight: 650;
  font-size: 13px;
  letter-spacing: .02em;
  border-left: 3px solid var(--royal);
}

.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 0;
  padding: 12px 14px 14px;
  border-radius: 0 0 var(--radius) var(--radius);
}
.section.sub {
  margin-left: 16px;
  border-left: 3px solid var(--royal);
}
.section h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
  color: var(--charcoal);
}
.section.sub h2 { color: var(--royal); }
.section h2 small { color: var(--muted); font-family: var(--font-sans); font-weight: 400; }

.card {
  border: 1px solid var(--line);
  background: #fafbfc;
  margin: 10px 0;
  padding: 12px;
  border-radius: var(--radius);
  display: grid;
  gap: 8px;
}
.card.edited { box-shadow: inset 3px 0 0 var(--royal); }
.card.suspicious { outline: 2px solid var(--tangerine); outline-offset: -1px; }
.card h3 {
  margin: 0;
  font-size: 11px;
  letter-spacing: .05em;
  color: var(--muted);
  font-family: var(--font-sans);
  font-weight: 650;
  text-transform: uppercase;
}
.card.subheading .body,
.card.subheading textarea {
  color: var(--royal);
  font-style: italic;
  font-family: var(--font-serif);
}

textarea,
.section-tools input {
  width: 100%;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: #fff;
}
.section-tools input { min-height: 0; }
textarea:focus,
.section-tools input:focus,
.filters input:focus,
.filters select:focus {
  outline: 2px solid var(--royal);
  outline-offset: 1px;
  border-color: var(--royal);
}

.body { white-space: pre-wrap; overflow-wrap: anywhere; }
.preview {
  white-space: pre-wrap;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
}
.tools { display: flex; flex-wrap: wrap; gap: 4px; }
.tools select,
.tools button,
.tools input { padding: 4px 8px; font-size: 13px; }

table.grid,
table.show {
  border-collapse: collapse;
  width: 100%;
  background: #fff;
}
table.grid th,
table.grid td,
table.show th,
table.show td {
  border: 1px solid var(--line);
  padding: 4px 6px;
  vertical-align: top;
}
table.grid th,
table.show th {
  background: var(--royal-soft);
  color: var(--charcoal);
  font-weight: 650;
  font-size: 12px;
}
table.grid input {
  width: 100%;
  border: 0;
  background: transparent;
}

.sym-ok { background: #d4edda; }
.sym-bad { background: #f8d7da; }

.pill-approved {
  display: inline-block;
  background: var(--tangerine-soft);
  color: var(--tangerine);
  border: 1px solid #f5c4b0;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 650;
  font-family: var(--font-sans);
  vertical-align: middle;
}
.banner-approved {
  margin: 0 0 12px;
  padding: 10px 12px;
  background: var(--tangerine-soft);
  border: 1px solid #f5c4b0;
  border-left: 3px solid var(--tangerine);
  border-radius: var(--radius);
  color: var(--charcoal);
  font-size: 13px;
}

#modal {
  position: fixed;
  inset: 0;
  background: rgba(18, 20, 23, .4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
#modal.open { display: flex; }
#modal .box {
  background: var(--panel);
  max-width: 720px;
  width: calc(100% - 24px);
  max-height: 80vh;
  overflow: auto;
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(18, 20, 23, .18);
}
.warn { color: var(--danger); }

/* legacy toast node hidden; toast.js owns #sileo-root */
#toast { display: none !important; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  aside {
    max-height: 38vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .section.sub { margin-left: 8px; }
  .top {
    height: auto;
    min-height: var(--header-h);
    flex-direction: column;
    align-items: stretch;
    padding: 10px 14px;
  }
  .top-actions { justify-content: flex-start; }
}
