:root {
  --cream: #f8f4e9;
  --paper: #fffdf7;
  --paper-2: #f2eadb;
  --line: #dfd0b7;
  --ink: #272123;
  --muted: #8b8577;
  --teal: #56aaa2;
  --teal-deep: #2e7771;
  --gold: #ad8243;
  --dark: #2a2022;
  --danger: #a64e48;
  --success: #3d827b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(180deg, #fbf8ee 0%, var(--cream) 100%);
  font-family: "Open Sans", "Segoe UI", system-ui, sans-serif;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
input, select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  padding: 0 11px;
}

.studio-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
}

.studio-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 18px;
  background: linear-gradient(160deg, #1f1d1c 0%, #171615 55%, #121211 100%);
  color: var(--cream);
  border-right: 1px solid rgba(255,255,255,.22);
  box-shadow: inset -1px 0 0 rgba(0,0,0,.7);
}

.brand {
  display: grid;
  justify-items: center;
  gap: 9px;
  margin: 0 auto 42px;
  width: 190px;
  text-align: center;
}
.brand span { color: var(--gold); font-size: 10px; font-weight: 800; letter-spacing: .22em; text-transform: uppercase; }
.logo-brand img {
  display: block;
  width: 168px;
  height: auto;
}
.logo-brand.color {
  margin-bottom: 18px;
  color: var(--ink);
}
.logo-brand.color img { width: 210px; }

.studio-nav { display: grid; gap: 13px; margin: 0 6px; }
.studio-nav button {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  min-height: 48px;
  color: rgba(245,242,236,.82);
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  font-weight: 740;
  text-align: left;
}
.studio-nav svg {
  width: 21px;
  height: 21px;
  color: currentColor;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .76;
}
.studio-nav button.active {
  background: linear-gradient(110deg, rgba(86,170,162,.13), rgba(255,255,255,.06));
  border-color: rgba(86,170,162,.12);
  color: #7bd3cd;
  box-shadow: 0 18px 34px rgba(0,0,0,.22);
}
.studio-nav button.active svg { opacity: 1; }

.watcher-card {
  margin: auto 2px 0 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 100px;
  padding: 16px 15px;
  border: 1px solid rgba(250,247,236,.12);
  border-radius: 8px;
  background: rgba(246,242,232,.04);
}
.watcher-card p { margin: 0; display: grid; gap: 5px; }
.watcher-card small { color: rgba(248,244,233,.56); }
.heartbeat { display: block; width: 12px; height: 12px; border-radius: 999px; background: var(--teal); box-shadow: 0 0 18px rgba(86,170,162,.8); }

.workspace {
  min-width: 0;
  padding: 34px clamp(24px, 4vw, 48px) 42px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 22px;
  margin-bottom: 24px;
}
.eyebrow { margin: 0 0 7px; color: var(--gold); font-size: 11px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
h1, h2 { margin: 0; font-weight: 740; color: var(--ink); }
h1 { font-size: 34px; }
h2 { font-size: 20px; }
.topbar-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }

.dark-button, .quiet-button, .danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 15px;
  border-radius: 7px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}
.dark-button { border: 1px solid var(--dark); background: var(--dark); color: var(--cream); }
.quiet-button { border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
.danger-button {
  border: 1px solid rgba(166,78,72,.34);
  background: rgba(166,78,72,.1);
  color: var(--danger);
}
.link-button {
  border: 0;
  background: transparent;
  color: var(--teal-deep);
  font-size: 13px;
  font-weight: 800;
  min-height: 32px;
  padding: 0;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.metric, .panel {
  background: rgba(255,253,247,.86);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(39,33,35,.055);
}
.metric {
  position: relative;
  min-height: 104px;
  display: grid;
  align-content: space-between;
  gap: 10px;
  padding: 16px 17px 15px;
  overflow: hidden;
}
.metric::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: rgba(86,170,162,.58);
}
.metric.warn::before { background: rgba(173,130,67,.7); }
.metric.bad::before { background: rgba(166,78,72,.75); }
.metric div {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.metric span {
  max-width: 13ch;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}
.metric strong {
  font-size: clamp(30px, 3vw, 42px);
  line-height: .9;
  font-weight: 740;
}

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-items: start; }
.panel {
  min-width: 0;
  padding: 20px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 16px;
}
.table-panel { padding: 18px 18px 16px; }
.table-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(150px, .8fr) minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin: 0 0 16px;
  padding: 13px;
  border: 1px solid rgba(223,208,183,.64);
  border-radius: 8px;
  background: rgba(248,244,233,.52);
}
.request-tools {
  grid-template-columns: minmax(220px, 1.4fr) minmax(140px, .72fr) minmax(180px, 1fr) minmax(170px, .95fr) auto;
}
.table-result-count {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid rgba(223,208,183,.72);
  border-radius: 7px;
  background: rgba(255,253,247,.72);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.table-result-count strong { color: var(--ink); font-size: 16px; }
.table-scroll { width: 100%; overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
.panel table, .table-scroll > table { min-width: 920px; }
th {
  color: var(--muted);
  font-size: 10px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: .13em;
  border-bottom: 1px solid var(--line);
  padding: 0 10px 12px;
}
.sort-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  text-transform: inherit;
}
.sort-header:hover, .sort-header.active { color: var(--ink); }
.sort-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 12px;
  height: 12px;
  border-radius: 999px;
  color: var(--gold);
  font-size: 10px;
  line-height: 1;
}
td {
  border-bottom: 1px solid rgba(223,208,183,.72);
  padding: 13px 10px;
  vertical-align: middle;
  line-height: 1.35;
}
tbody tr:hover { background: rgba(173,130,67,.055); }
.time-cell, .action-cell, .ip-cell { font-feature-settings: "tnum"; }
.strong-cell { font-weight: 800; }
.action-cell {
  color: #51494b;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.reason-cell {
  max-width: 420px;
  color: #403839;
  overflow-wrap: anywhere;
}
.muted-cell {
  color: var(--muted);
  font-weight: 800;
}
.empty-cell {
  padding: 30px 12px;
  color: var(--muted);
  text-align: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.pill.good { color: var(--success); border-color: rgba(61,130,123,.28); background: rgba(86,170,162,.1); }
.pill.warn { color: #8a641f; border-color: rgba(173,130,67,.3); background: rgba(173,130,67,.11); }
.pill.bad { color: var(--danger); border-color: rgba(166,78,72,.28); background: rgba(166,78,72,.1); }
.flags { display: flex; flex-wrap: wrap; gap: 5px; }

.side-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, .72fr);
  gap: 18px;
}
.dashboard-support { align-items: stretch; }
.support-panel { min-height: 205px; }
.order-list, .health-list { display: grid; gap: 10px; }
.order-row, .health-list div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  padding: 13px 0;
  border-bottom: 1px solid rgba(223,208,183,.68);
}
.order-row small, .health-list small { color: var(--muted); grid-column: 1 / -1; }
.empty-mini { color: var(--muted); padding: 20px 0; }

label { display: grid; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 800; }
textarea {
  width: 100%;
  min-height: 74px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  padding: 10px;
}
.message {
  margin: 0 0 16px;
}
.message.error { border: 1px solid rgba(166,78,72,.26); background: rgba(166,78,72,.08); padding: 12px 14px; border-radius: 7px; }
.message.success, .message.activation {
  border: 1px solid rgba(61,130,123,.26);
  background: rgba(86,170,162,.1);
  padding: 12px 14px;
  border-radius: 7px;
}
.message.activation strong { font-size: 16px; letter-spacing: .03em; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 22px 70px rgba(39,33,35,.08);
}
.split {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.wide-split { grid-template-columns: 360px minmax(0, 1fr); }
.form-panel {
  display: grid;
  gap: 14px;
}
.form-panel h2 { margin-bottom: 6px; }
.event-picker {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}
.event-picker legend {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.event-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,253,247,.66);
  color: var(--ink);
}
.event-option input {
  margin-top: 3px;
  accent-color: var(--teal);
}
.event-option span { display: grid; gap: 3px; }
.event-option strong { font-size: 13px; }
.event-option small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.event-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cell-subtitle {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}
.shops-table-panel { overflow: hidden; }
.shops-table-scroll {
  margin: -2px -2px 0;
  padding: 2px;
}
.shops-table {
  min-width: 760px;
  table-layout: fixed;
}
.shops-table th:nth-child(1), .shops-table td:nth-child(1) { width: 118px; }
.shops-table th:nth-child(2), .shops-table td:nth-child(2) { width: 86px; }
.shops-table th:nth-child(3), .shops-table td:nth-child(3) { width: 122px; }
.shops-table th:nth-child(4), .shops-table td:nth-child(4) { width: 86px; }
.shops-table th:nth-child(5), .shops-table td:nth-child(5) { width: 88px; }
.shops-table th:nth-child(6), .shops-table td:nth-child(6) { width: 120px; }
.shops-table th:nth-child(7), .shops-table td:nth-child(7) { width: 128px; padding-right: 0; }
.shops-table td { overflow-wrap: anywhere; }
.row-actions {
  display: grid;
  gap: 7px;
  justify-items: stretch;
  width: 118px;
  max-width: 100%;
}
.row-actions .quiet-button, .row-actions .danger-button {
  width: 100%;
  min-height: 33px;
  padding: 0 8px;
  font-size: 11px;
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 16px;
}
.setting-toggle {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  padding: 14px;
  border: 1px solid rgba(223,208,183,.64);
  border-radius: 8px;
  background: rgba(248,244,233,.42);
  color: var(--ink);
}
.setting-toggle input {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin-top: 2px;
  accent-color: var(--teal);
}
.setting-toggle span { display: grid; gap: 4px; }
.setting-toggle small, .setting-field small { color: var(--muted); font-weight: 700; line-height: 1.35; }
.setting-field {
  padding: 14px;
  border: 1px solid rgba(223,208,183,.64);
  border-radius: 8px;
  background: rgba(248,244,233,.42);
}
.setting-field span {
  color: var(--ink);
  font-weight: 800;
}
.settings-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
}

.debug-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, .55fr);
  gap: 18px;
}
.debug-grid .full-span { grid-column: 1 / -1; }
.debug-list {
  display: grid;
  gap: 12px;
  margin: 0;
}
.debug-list div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
}
dt {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
dd {
  margin: 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.count-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.count-grid div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid rgba(223,208,183,.68);
  border-radius: 8px;
  background: rgba(248,244,233,.45);
}
.count-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.count-grid strong {
  font-size: 28px;
  line-height: 1;
}

@media (max-width: 1180px) {
  .studio-shell { grid-template-columns: 248px minmax(0, 1fr); }
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .split, .wide-split { grid-template-columns: 1fr; }
  .side-stack { grid-template-columns: 1fr; }
}

@media (min-width: 1560px) {
  .metrics { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .studio-shell { display: block; }
  .studio-sidebar {
    position: relative;
    height: auto;
    min-height: 0;
  }
  .brand { margin-bottom: 22px; }
  .studio-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .watcher-card { margin-top: 18px; }
  .workspace { padding: 24px 16px 32px; }
  .topbar { display: grid; }
  .topbar-actions { justify-content: flex-start; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-tools, .request-tools { grid-template-columns: 1fr; }
  .settings-grid, .debug-grid { grid-template-columns: 1fr; }
  .debug-grid .full-span { grid-column: auto; }
}
