:root {
  --teal: #00a99d;
  --teal-dark: #007f76;
  --teal-deep: #065f58;
  --lime: #8cc63f;
  --lime-dark: #6fa32b;
  --gray: #828f97;
  --ink: #142326;
  --ink-soft: #3a4a4e;
  --line: #d8e0e2;
  --paper: #f3f6f6;
  --white: #ffffff;
  --sidebar: #0e1f21;
  --sidebar-hover: #173033;
  --sidebar-text: #c5d2d4;
  --danger-bg: #fff6e5;
  --danger-ink: #7a4b00;
  --danger-line: #f0d49a;
  --shadow: 0 10px 30px rgba(14, 31, 33, 0.08);
  --radius: 14px;
  --sidebar-width: 260px;
  --topbar-height: 72px;
  --font: "DM Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  min-width: 1100px;
}

button, input { font-family: inherit; }

.hidden { display: none !important; }

/* ---------- Sign in ---------- */
#signin {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 48px 24px;
  background:
    radial-gradient(circle at 15% 20%, rgba(0, 169, 157, 0.22), transparent 36%),
    radial-gradient(circle at 90% 80%, rgba(140, 198, 63, 0.18), transparent 32%),
    #0b1618;
  color: white;
}

.signin-card {
  width: 460px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 40px 40px 32px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(16px);
}

.signin-card img {
  height: 72px;
  width: auto;
  display: block;
  margin-bottom: 20px;
}

.signin-card h1 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.signin-card .subtitle {
  margin: 0 0 24px;
  color: #b8c6c8;
  font-size: 15px;
}

.test-banner {
  background: var(--danger-bg);
  color: var(--danger-ink);
  border: 1px solid var(--danger-line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 24px;
  font-weight: 600;
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #d5e0e1;
}
.field input {
  width: 100%;
  height: 46px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: white;
  padding: 0 14px;
  font-size: 15px;
}
.field input::placeholder { color: #8aa0a3; }

.primary-btn {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 10px;
  background: var(--teal);
  color: white;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}
.primary-btn:hover { background: var(--teal-dark); }

.signin-note {
  margin: 18px 0 0;
  font-size: 12px;
  color: #8aa0a3;
  text-align: center;
}

.form-error {
  background: rgba(160, 36, 36, 0.28);
  color: #ffd6d6;
  border: 1px solid rgba(255, 160, 160, 0.35);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 18px;
  font-weight: 600;
}

.form-hint {
  margin: 0 0 18px;
  color: #b8c6c8;
  font-size: 13px;
  line-height: 1.45;
}

.code-input {
  letter-spacing: 0.4em;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
}

.signin-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--lime);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
.link-btn:hover { text-decoration: underline; }
.link-btn:disabled { opacity: 0.55; cursor: not-allowed; text-decoration: none; }

.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}


/* ---------- App shell ---------- */
#app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
}

.topbar {
  grid-area: topbar;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px 0 20px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 420px;
}

.brand img {
  height: 48px;
  width: auto;
  display: block;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-copy strong {
  font-size: 16px;
  letter-spacing: -0.02em;
}
.brand-copy span {
  font-size: 12px;
  color: var(--gray);
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.pill {
  background: var(--danger-bg);
  color: var(--danger-ink);
  border: 1px solid var(--danger-line);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--teal);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink-soft);
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.ghost-btn:hover { border-color: var(--teal); color: var(--teal-deep); }

.sidebar {
  grid-area: sidebar;
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 20px 14px;
  min-height: calc(100vh - var(--topbar-height));
}

.sidebar h2 {
  margin: 6px 12px 16px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7f9194;
}

.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: 0;
  color: inherit;
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}
.nav-btn:hover { background: var(--sidebar-hover); color: white; }
.nav-btn.active {
  background: rgba(0, 169, 157, 0.18);
  color: white;
  box-shadow: inset 3px 0 0 var(--teal);
}
.nav-btn .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lime);
  flex: 0 0 auto;
}
.nav-btn:not(.active) .dot { background: #466166; }

.main {
  grid-area: main;
  padding: 28px 32px 48px;
}

.page { max-width: none; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-header h1 {
  margin: 0 0 4px;
  font-size: 28px;
  letter-spacing: -0.03em;
}
.page-header p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 8px 0 24px;
}
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.card .label {
  font-size: 12px;
  font-weight: 700;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.card .value {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.card .hint {
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-soft);
}

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-head h2 {
  margin: 0;
  font-size: 16px;
}
.panel-head span {
  font-size: 12px;
  font-weight: 700;
  color: var(--danger-ink);
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  border-radius: 999px;
  padding: 4px 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  text-align: left;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--gray);
  background: #f8fafa;
  font-weight: 700;
}
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f6fbfa; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
}
.status.example {
  background: #eef7e3;
  color: #44651d;
}
.status.planned {
  background: #e8f6f5;
  color: var(--teal-deep);
}

.example-tag {
  display: inline-block;
  margin-left: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--danger-ink);
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  border-radius: 999px;
  padding: 2px 7px;
  vertical-align: middle;
}

.muted { color: var(--ink-soft); }
.empty-note {
  padding: 20px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.5;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 20px;
}
.settings-grid .field label { color: var(--ink-soft); }
.settings-grid input, .settings-grid select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  background: #f8fafa;
  color: var(--ink);
}

/* ---------- Build 3: operators, settings, overview, audit ---------- */
#app .panel { margin-bottom: 20px; }
#app .field { display: flex; flex-direction: column; gap: 6px; }
#app .field label { font-size: 12px; font-weight: 700; color: var(--ink-soft); text-transform: none; letter-spacing: 0; }
#app .field input, #app .field select {
  width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 10px;
  padding: 0 12px; background: #f8fafa; color: var(--ink); font-size: 14px;
}
#app .field input[type="file"] { padding: 9px 12px; height: auto; }
#app .field input:focus, #app .field select:focus { outline: 2px solid rgba(0,169,157,.35); border-color: var(--teal); background: #fff; }
#app .field.inline { min-width: 240px; }
#app .primary-btn { width: auto; height: 40px; padding: 0 18px; margin: 0; white-space: nowrap; }
#app .ghost-btn { white-space: nowrap; }
#app .ghost-btn.dark { height: 40px; padding: 0 16px; }
#app .ghost-btn.small { height: 34px; margin: 0 20px 20px; }
.settings-grid.four { grid-template-columns: repeat(4, 1fr); }
.sub-h { margin: 0; padding: 4px 20px 0; font-size: 13px; color: var(--ink-soft); }
.info-banner {
  background: #e8f6f5; color: var(--teal-deep); border: 1px solid #bfe5e1;
  border-radius: 12px; padding: 12px 16px; font-size: 13px; line-height: 1.5; margin-bottom: 18px;
}
.test-banner.warn, #db-banner {
  background: var(--danger-bg); color: var(--danger-ink); border: 1px solid var(--danger-line);
  border-radius: 12px; padding: 12px 16px; font-size: 13px; line-height: 1.5; margin-bottom: 18px; font-weight: 600;
}
.panel-head span.ok { color: #2f5a12; background: #eef7e3; border-color: #cfe7b0; }
.panel-head span.plain { color: var(--ink-soft); background: #f3f6f6; border-color: var(--line); }
.status.test { background: #e8f6f5; color: var(--teal-deep); }
.status.seed { background: var(--danger-bg); color: var(--danger-ink); }
.status.saved { background: #eef7e3; color: #44651d; }
.op-cell { display: flex; align-items: center; gap: 12px; }
.op-cell img { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; background: #f3f6f6; border: 1px solid var(--line); }
.op-cell strong { display: block; }
.op-cell small { color: var(--gray); }
.chips { display: flex; gap: 4px; }
.chip { width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(0,0,0,.12); display: inline-block; }
.create-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 28px; padding: 20px; }
.create-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-content: start; }
.create-fields .field:nth-child(5), .create-fields .field:nth-child(6), .theme-inputs, .form-actions { grid-column: 1 / -1; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; min-height: 42px; align-items: center; }
.swatch { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px 6px 6px; font-size: 12px; font-weight: 700; background: #fff; }
.swatch i { width: 26px; height: 26px; border-radius: 6px; border: 1px solid rgba(0,0,0,.1); }
.theme-inputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.theme-inputs .field > div { display: flex; gap: 6px; }
.theme-inputs input[type="color"] { width: 46px !important; padding: 2px !important; flex: none; }
.form-actions { display: flex; align-items: center; gap: 12px; }
.form-actions.sticky { padding: 4px 0 14px; }
.form-msg { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.form-msg.err { color: #a02424; }
.form-msg.good { color: #2f6a12; }
.preview-wrap label { font-size: 12px; font-weight: 700; color: var(--ink-soft); display: block; margin-bottom: 8px; }
.theme-preview { border-radius: 16px; overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); }
.tp-top { display: flex; align-items: center; gap: 12px; padding: 14px 18px; }
.tp-top img { height: 40px; max-width: 120px; object-fit: contain; }
.tp-top strong { font-size: 16px; }
.tp-body { padding: 18px; display: grid; gap: 12px; }
.tp-card { border-radius: 12px; padding: 14px 16px; background: #fff; border: 1px solid rgba(0,0,0,.06); }
.tp-card .big { font-size: 26px; font-weight: 700; }
.tp-btn { border: 0; border-radius: 10px; height: 40px; padding: 0 16px; font-weight: 700; font-family: inherit; }
.tp-row { display: flex; gap: 10px; }
.packs-table input { width: 120px; height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: #f8fafa; font-family: inherit; }
.packs-table td { padding: 8px 18px; }
.link-del { background: none; border: 0; color: #a02424; font-weight: 700; cursor: pointer; font-family: inherit; }
.sidebar-status { margin: 24px 12px 0; font-size: 12px; line-height: 1.7; color: #8fa3a6; }
.sidebar-status b { color: #c5d2d4; }
.dot-ok, .dot-off { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot-ok { background: var(--lime); }
.dot-off { background: #c58b2a; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.changes { margin: 0; padding: 0; list-style: none; font-size: 13px; }
.changes li { margin: 2px 0; }
.changes code { background: #f3f6f6; border-radius: 4px; padding: 1px 4px; }
.table-scroll { max-height: 520px; overflow: auto; }

/* Build 3: Optional section, toggles, people */
.section-h { margin: 28px 0 12px; font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.note-line { margin: 4px 20px 14px; font-size: 13px; color: var(--ink-soft); }
.opt-body { border: 0; margin: 0; padding: 0; min-width: 0; transition: opacity .15s; }
.opt-body:disabled { opacity: .45; }
.opt-body:disabled input, .opt-body:disabled select { cursor: not-allowed; }
.panel.optional.off .panel-head h2 { color: var(--ink-soft); }
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 13px; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle .track { width: 44px; height: 24px; border-radius: 12px; background: #c5d0d2; position: relative; transition: background .15s; }
.toggle .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .15s; }
.toggle input:checked + .track { background: var(--teal); }
.toggle input:checked + .track::after { left: 23px; }
.toggle input:focus-visible + .track { outline: 2px solid rgba(0,169,157,.45); outline-offset: 2px; }
.person-form { display: grid; grid-template-columns: 1.4fr 1fr .8fr auto; gap: 14px; padding: 16px 20px 0; align-items: end; }
.person-form .btn-field { justify-content: flex-end; }
.form-msg.pad { padding: 6px 20px 0; margin: 0; min-height: 18px; }
.people-table select { height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; background: #f8fafa; font-family: inherit; }
.status.disabled { background: #f1f1f1; color: #6b6b6b; }
.status.active { background: #eef7e3; color: #44651d; }
.row-actions { display: flex; gap: 8px; }
.detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 24px; padding: 16px 20px 20px; }
.detail-grid div small { display: block; font-size: 12px; color: var(--ink-soft); font-weight: 700; margin-bottom: 3px; }
