:root {
  color-scheme: dark;
  --bg: #101412;
  --surface: #171d1a;
  --surface-2: #202822;
  --line: #344038;
  --text: #eef5ef;
  --muted: #9eaca2;
  --green: #44c278;
  --green-2: #206c47;
  --amber: #e6b84f;
  --red: #de5b5b;
  --blue: #6eb7d8;
  --focus: #f0cf72;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

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

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  border: 1px solid var(--line);
  border-radius: 8px;
}

button {
  min-height: 40px;
  padding: 0 14px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: var(--focus);
}

button:disabled {
  cursor: not-allowed;
  opacity: .48;
}

input,
select {
  min-height: 40px;
  padding: 0 12px;
  background: #0c100e;
  color: var(--text);
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 16px;
}

.hidden {
  display: none !important;
}

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

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.login-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 4px;
}

.login-head p,
.brand span,
.label,
.inline-message {
  color: var(--muted);
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--green-2);
  color: var(--text);
  font-weight: 800;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
}

.primary {
  background: var(--green);
  color: #07110b;
  border-color: var(--green);
  font-weight: 700;
}

.danger {
  background: #311a1a;
  border-color: #633232;
  color: #ffd7d7;
}

.ghost {
  background: transparent;
}

.small {
  min-height: 34px;
  padding: 0 10px;
}

.wide {
  width: 100%;
}

.app-view {
  min-height: 100vh;
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: #121814;
  position: sticky;
  top: 0;
  z-index: 5;
}

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

.brand div {
  display: grid;
  gap: 2px;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgb(0 0 0 / .62);
}

.modal-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 22px 60px rgb(0 0 0 / .36);
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: calc(100vh - 64px);
  min-width: 0;
}

.rail {
  border-right: 1px solid var(--line);
  background: #121814;
  padding: 16px;
}

.rail-head,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.rail-head span {
  color: var(--amber);
  font-weight: 700;
}

.bot-list {
  display: grid;
  gap: 10px;
}

.bot-item {
  width: 100%;
  min-height: 72px;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 12px;
  text-align: left;
  background: var(--surface);
}

.bot-item.active {
  border-color: var(--focus);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

.dot.online {
  background: var(--green);
}

.dot.warn {
  background: var(--amber);
}

.bot-item strong,
.bot-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bot-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

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

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  min-width: 120px;
}

.tab.active {
  background: var(--green-2);
  border-color: var(--green);
}

.tab-panel {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.status-strip > div,
.table-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  min-width: 0;
}

.status-strip strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.label {
  font-size: 12px;
  text-transform: uppercase;
}

.command-bar,
.whisper-row,
.license-form {
  display: grid;
  grid-template-columns: 120px repeat(5, minmax(96px, 1fr));
  gap: 8px;
  min-width: 0;
}

.command-bar > *,
.whisper-row > *,
.license-form > * {
  min-width: 0;
  width: 100%;
}

.whisper-row {
  grid-template-columns: minmax(120px, 180px) minmax(180px, 1fr) 120px;
}

.license-form {
  grid-template-columns: minmax(180px, 1fr) 140px 140px 120px;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px;
  min-width: 0;
}

.slot-card {
  min-height: 192px;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  min-width: 0;
}

.slot-card.active {
  border-color: var(--focus);
}

.slot-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.slot-state {
  color: var(--amber);
  font-weight: 700;
}

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

.meter {
  display: grid;
  gap: 5px;
}

.meter-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.meter-track {
  height: 8px;
  overflow: hidden;
  border-radius: 8px;
  background: #0b0f0d;
}

.meter-fill {
  height: 100%;
  width: 0;
  background: var(--green);
}

.meter-fill.mp {
  background: var(--blue);
}

.slot-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.slot-meta div {
  min-height: 46px;
  padding: 8px;
  border: 1px solid #2a352e;
  border-radius: 8px;
  background: #121814;
}

.slot-meta span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.slot-meta strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.whisper-alert {
  color: #ffd4d4;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: var(--surface);
}

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

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

tr:last-child td {
  border-bottom: 0;
}

.inline-message {
  min-height: 22px;
}

.device-list {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.device-list strong {
  color: var(--text);
}

.license-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.license-actions button {
  min-height: 32px;
  padding: 0 9px;
  font-size: 13px;
}

.command-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.command-tags span {
  padding: 3px 6px;
  border: 1px solid #2a352e;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
}

.policy-editor {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.policy-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.policy-options label {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121814;
  color: var(--text);
}

.policy-options input {
  width: 18px;
  min-height: 18px;
}

.policy-actions {
  display: flex;
  justify-content: flex-end;
}

.audit-detail {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1411;
  box-shadow: 0 16px 38px rgb(0 0 0 / .28);
}

.toast.good {
  border-color: var(--green);
}

.toast.bad {
  border-color: var(--red);
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
    min-height: 0;
    align-content: start;
  }

  .rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    align-self: start;
  }

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

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

  .command-bar select {
    grid-column: span 3;
  }
}

@media (max-width: 720px) {
  body {
    font-size: 14px;
  }

  .topbar {
    height: auto;
    min-height: 64px;
    align-items: flex-start;
    padding: 12px;
  }

  .top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .content {
    padding: 12px;
  }

  .bot-list,
  .status-strip,
  .slot-grid,
  .whisper-row,
  .license-form,
  .policy-options {
    grid-template-columns: 1fr;
  }

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

  .command-bar select {
    grid-column: span 2;
  }

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

  .tab {
    min-width: 0;
  }
}
