:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-alt: #eef3f7;
  --text: #17202a;
  --muted: #617083;
  --line: #d7dee7;
  --blue: #1467c6;
  --green: #16845b;
  --yellow: #b7791f;
  --red: #c43d4b;
  --ink: #243140;
  --shadow: 0 12px 30px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 244px 1fr;
}

.sidebar {
  background: #172433;
  color: #eef5fb;
  padding: 18px 14px;
}

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

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #2e9f7f;
  color: #ffffff;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: #9fb1c5;
  font-size: 12px;
  margin-top: 3px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #d5e1ee;
  padding: 0 10px;
  text-align: left;
}

.nav-item svg {
  width: 18px;
  height: 18px;
}

.nav-item.active,
.nav-item:hover {
  background: #24384d;
  color: #ffffff;
}

.content {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 700;
}

h2 {
  font-size: 16px;
  font-weight: 700;
}

.topbar p {
  color: var(--muted);
  margin-top: 4px;
}

.top-actions,
.panel-head,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-actions,
.modal-actions {
  justify-content: flex-end;
}

.icon-button,
.primary-button,
.ghost-button,
.segment {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.top-actions .icon-button {
  width: auto;
  min-width: 38px;
  padding: 0 12px;
}

.button-text {
  display: inline;
}

.icon-button svg,
.primary-button svg,
.ghost-button svg {
  width: 17px;
  height: 17px;
}

.primary-button {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

.ghost-button:hover,
.icon-button:hover {
  background: var(--surface-alt);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow);
}

.metric svg {
  width: 26px;
  height: 26px;
  color: var(--blue);
}

.metric label {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 3px;
  font-size: 28px;
}

.dashboard-grid,
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow);
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.segmented {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.segment {
  min-height: 32px;
  border: 0;
  border-radius: 0;
  background: #ffffff;
}

.segment.active {
  background: #dbeafe;
  color: #0f4f9e;
}

.bar-list,
.queue-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 116px 1fr 42px;
  gap: 10px;
  align-items: center;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: #e7edf3;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--blue);
}

.queue-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.queue-item small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.status-pill,
.type-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  background: #e8f6ef;
  color: #126646;
}

.type-pill.sei {
  background: #fff4df;
  color: #8a5815;
}

.status-pill.paused,
.type-pill.paused {
  background: #fdecef;
  color: #9b2432;
}

.settings-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.busy {
  cursor: progress;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

td.actions {
  text-align: right;
  white-space: nowrap;
}

.small-action {
  min-width: 34px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.small-action svg {
  width: 15px;
  height: 15px;
}

.rules {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
}

.rules dt {
  font-weight: 700;
}

.rules dd {
  margin: 0 0 8px;
  color: var(--muted);
}

.check-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-list svg {
  width: 16px;
  height: 16px;
  color: var(--green);
}

dialog {
  border: 0;
  padding: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(15, 23, 32, 0.45);
}

.modal-card {
  display: grid;
  gap: 14px;
  width: min(520px, calc(100vw - 28px));
  border-radius: 8px;
  background: #ffffff;
  padding: 18px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.22);
}

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

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  background: #ffffff;
}

.form-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
}

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

.toggle-line input {
  width: 18px;
  min-height: 18px;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 3;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    padding: 10px;
  }

  .nav {
    display: flex;
    overflow-x: auto;
  }

  .nav-item {
    white-space: nowrap;
  }

  .metrics-grid,
  .dashboard-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }
}

@media (max-width: 560px) {
  .content {
    padding: 16px;
  }

  .brand span,
  .nav-item span:last-child {
    display: none;
  }

  .metrics-grid {
    gap: 10px;
  }

  .metric {
    min-height: 72px;
  }

  .bar-row {
    grid-template-columns: 84px 1fr 34px;
  }

  .top-actions .button-text {
    display: none;
  }

  .top-actions .icon-button {
    width: 38px;
    padding: 0;
  }
}
