:root {
  color-scheme: light;
  --canvas: #f4f6f7;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --surface-soft: #eef3f2;
  --border: #d9e1df;
  --border-strong: #c5d0cd;
  --ink: #10201d;
  --secondary: #5f6d66;
  --muted: #82877f;
  --faint: #a6a59d;
  --pine: #10241f;
  --pine-raised: #1d332b;
  --accent: #067a80;
  --accent-dark: #005f65;
  --accent-soft: #dff3ef;
  --blue: #2d7ff9;
  --success: #0f766e;
  --warning: #8a5a18;
  --danger: #9a3f2f;
  --danger-soft: #f8dfd8;
  --shadow: 0 1px 2px rgba(16, 32, 29, 0.04), 0 10px 22px rgba(16, 32, 29, 0.035);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button.success,
.button.success {
  border-color: #7bbda9;
  background: #0e8a78;
  color: #ffffff;
}

.hidden {
  display: none !important;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  display: grid;
  gap: 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-card h1,
.topbar h1,
.inspector h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

.login-card label,
.field label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--secondary);
}

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

input[type="checkbox"] {
  width: auto;
  min-height: 0;
  padding: 0;
  accent-color: var(--accent);
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

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

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px 16px;
  background: var(--pine);
  color: #eef5ee;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #d8eadf;
  color: var(--pine);
  font-weight: 900;
}

.brand span {
  display: block;
  margin-top: 3px;
  color: #aebdb5;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #dfe7df;
  text-align: left;
  padding: 0 14px;
  font-weight: 800;
}

.nav-item:hover {
  background: var(--pine-raised);
}

.nav-item.active {
  background: #d8eadf;
  color: var(--pine);
}

.rail-foot {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.workspace {
  min-width: 0;
  padding: 22px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.topbar,
.content-panel,
.inspector,
.toolbar,
.bulkbar,
.metric {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  border-radius: 8px;
  padding: 16px;
}

.muted {
  margin: 6px 0 0;
  color: var(--secondary);
  font-size: 13px;
  line-height: 1.45;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.header-actions,
.pager,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 0 13px;
  background: #fff;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 850;
}

.button.primary {
  border-color: var(--accent-dark);
  background: var(--accent);
  color: white;
}

.button.primary:hover {
  background: var(--accent-dark);
}

.button.secondary:hover,
.button.quiet:hover {
  border-color: #b8dad3;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.button.danger {
  border-color: #efc5ba;
  background: var(--danger-soft);
  color: var(--danger);
}

.button.compact {
  min-height: 32px;
  padding: 0 9px;
  font-size: 12px;
}

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

.metric {
  border-radius: 8px;
  padding: 12px;
}

.metric strong {
  display: block;
  font-size: 22px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(4, minmax(132px, 170px));
  gap: 10px;
  border-radius: 8px;
  padding: 12px;
}

.bulkbar {
  display: grid;
  grid-template-columns: auto minmax(150px, 190px) minmax(190px, 250px) minmax(120px, 150px) minmax(120px, 150px) auto auto;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
  padding: 10px 12px;
}

.bulkbar select,
.bulkbar input {
  min-height: 38px;
}

.content-panel {
  min-width: 0;
  overflow: hidden;
  border-radius: 8px;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 370px);
}

table {
  width: 100%;
  min-width: 1280px;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid #eee8df;
  padding: 10px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f6f8f8;
  color: var(--secondary);
  font-size: 11px;
  font-weight: 900;
  height: 44px;
  text-transform: uppercase;
  vertical-align: middle;
}

th:first-child {
  width: 44px;
  text-align: center;
  padding-top: 0;
}

td:first-child {
  width: 44px;
  text-align: center;
  padding-top: 18px;
}

th:nth-child(2),
td:nth-child(2) {
  width: 270px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 330px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 240px;
}

th:nth-child(5),
td:nth-child(5) {
  width: 104px;
}

th:nth-child(6),
td:nth-child(6) {
  width: 78px;
}

th:nth-child(7),
td:nth-child(7) {
  width: 76px;
}

th:nth-child(8),
td:nth-child(8) {
  width: 138px;
}

tbody tr {
  cursor: default;
}

tbody tr:hover {
  background: #f8fbfa;
}

tbody tr.selected {
  background: #eaf6f3;
  box-shadow: inset 3px 0 0 var(--accent);
}

.cell-stack {
  display: grid;
  grid-template-rows: 34px 18px;
  gap: 6px;
  align-items: start;
  width: 100%;
}

.cell-control {
  width: 100%;
  height: 34px;
  min-height: 34px;
  display: flex;
  align-items: center;
}

.cell-stack input:not([type="checkbox"]),
.cell-stack select {
  height: 34px;
  min-height: 34px;
  border-radius: 7px;
  padding: 0 9px;
  font-size: 12px;
}

.cell-stack select {
  padding-right: 28px;
}

.cell-label {
  min-height: 18px;
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-spacer {
  min-height: 18px;
  display: block;
}

.row-title {
  min-width: 230px;
}

.row-title strong {
  color: var(--ink);
}

.quick-edit-cell {
  display: grid;
  gap: 6px;
}

.quick-edit-cell input,
.quick-edit-cell select,
.quick-group {
  min-height: 34px;
  border-radius: 7px;
  padding: 0 9px;
  font-size: 12px;
}

.provider-category-cell {
  min-width: 300px;
}

.provider-category-cell strong {
  display: block;
  max-width: 330px;
  font-size: 12px;
  line-height: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-edit-line {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.quick-hint {
  max-width: 100%;
}

.quick-status {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.compact-status {
  min-height: 18px;
  height: 18px;
  line-height: 18px;
}

.compact-status .pill {
  min-height: 18px;
  padding: 0 6px;
  font-size: 10.5px;
}

.visibility-cell {
  width: 104px;
}

.toggle-control {
  position: relative;
  display: inline-grid;
  grid-template-columns: 42px auto;
  align-items: center;
  gap: 7px;
  width: max-content;
  min-height: 24px;
  color: var(--secondary);
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  user-select: none;
}

.toggle-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  width: 42px;
  height: 24px;
  border: 1px solid #efc5ba;
  border-radius: 999px;
  background: #f8dfd8;
  transition: 140ms ease;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 32, 29, 0.22);
  transition: 140ms ease;
}

.toggle-control input:checked + .toggle-track {
  border-color: #9ed5c2;
  background: #dff3ef;
}

.toggle-control input:checked ~ .toggle-copy {
  color: var(--success);
}

.toggle-control input:not(:checked) ~ .toggle-copy {
  color: var(--danger);
}

.toggle-control input:checked + .toggle-track::after {
  transform: translateX(18px);
  background: var(--accent);
}

.toggle-control input:focus-visible + .toggle-track {
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.toggle-copy {
  min-width: 34px;
}

.toggle-control input:not(:checked) ~ .toggle-copy .toggle-on,
.toggle-control input:checked ~ .toggle-copy .toggle-off {
  display: none;
}

.row-toggle {
  grid-template-columns: 42px 34px;
}

.category-toggle {
  grid-template-columns: 42px 32px;
}

.setting-toggle {
  grid-template-columns: 42px 26px;
}

.setting-toggle .toggle-track {
  border-color: var(--border-strong);
  background: #e8eeee;
}

.setting-toggle input:not(:checked) ~ .toggle-copy {
  color: var(--secondary);
}

.row-check,
#selectPage {
  width: 18px;
  height: 18px;
  min-height: 18px;
  vertical-align: middle;
}

.table-actions {
  flex-wrap: nowrap;
  align-items: center;
}

.table-actions .button.compact {
  height: 30px;
  min-height: 30px;
}

.badge-cell .cell-control,
.action-cell .cell-control {
  align-items: center;
}

.pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  padding: 0 8px;
  color: var(--secondary);
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
}

.pill.visible {
  border-color: #b8dccf;
  background: #e3f3ec;
  color: var(--success);
}

.pill.hidden-row {
  border-color: #efc5ba;
  background: #f8dfd8;
  color: var(--danger);
}

.pill.override {
  border-color: #ead8a6;
  background: #fff7df;
  color: var(--warning);
}

.panel-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-top: 1px solid #eee8df;
}

.selection-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.inspector {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-width: 0 0 0 1px;
  border-radius: 0;
  padding: 18px;
}

.inspector-empty {
  margin-top: 18px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  padding: 18px;
  background: #fffaf2;
}

.inspector-card {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fbfa;
}

.switch-row input {
  width: auto;
  min-height: 0;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  padding: 14px;
}

.group-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.group-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.category-list {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.category-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) 88px 88px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.publish-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.status-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.release-card {
  display: grid;
  gap: 12px;
}

.release-card .status-grid {
  margin-top: 0;
}

.release-status {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: #f8fbfa;
}

.release-status strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
}

.release-status p {
  margin: 4px 0 0;
  color: var(--secondary);
  font-size: 13px;
  line-height: 1.4;
}

.release-status.ok {
  border-color: #a8d8c7;
  background: #eef8f3;
}

.release-status.warn {
  border-color: #ead8a6;
  background: #fff9e8;
}

.status-grid {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 8px 12px;
  margin-top: 14px;
  font-size: 13px;
}

.status-grid span {
  color: var(--muted);
  font-weight: 800;
}

.status-grid strong {
  min-width: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.compact-grid {
  grid-template-columns: 128px minmax(0, 1fr);
  margin-top: 10px;
}

.scheduler-form {
  display: grid;
  grid-template-columns: minmax(240px, 1.15fr) minmax(210px, 0.9fr) minmax(140px, 0.55fr) minmax(160px, 0.65fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 14px;
}

.scheduler-form .switch-row {
  min-height: 76px;
}

.preservation-box {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: #f8fbfa;
}

.preservation-box.ok {
  border-color: #b8dccf;
  background: #eef8f3;
}

.preservation-box.warn {
  border-color: #ead8a6;
  background: #fff9e8;
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  border: 1px solid #b8dad3;
  border-radius: 8px;
  background: #f7fbfa;
  color: var(--accent-dark);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 850;
  transition: 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1500px) {
  .app-shell {
    grid-template-columns: 196px minmax(0, 1fr);
  }

  .inspector {
    position: fixed;
    inset: auto 12px 12px 12px;
    height: min(72vh, 620px);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    z-index: 5;
  }

  .inspector:has(.inspector-empty) {
    display: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .rail {
    position: static;
    height: auto;
  }

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

  .topbar {
    display: grid;
  }

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

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

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

  .settings-grid,
  .scheduler-form {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    max-height: none;
  }

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