:root {
  color-scheme: light;
  --bg: #eef2f7;
  --panel: #ffffff;
  --panel-soft: #f5f8fc;
  --text: #06162d;
  --muted: #7d8da4;
  --line: #cfd9e6;
  --blue: #0875e1;
  --blue-weak: #e7f0ff;
  --green: #0f9f6e;
  --amber: #bd6b00;
  --red: #cc202c;
  --shadow: 0 1px 6px rgba(12, 25, 48, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f5f7fa;
  color: var(--text);
  font-size: 13px;
}

button,
input,
select {
  font: inherit;
}

select {
  border: 1px solid #c6d5e8;
  border-radius: 7px;
  height: 32px;
  background: #fff;
  padding: 0 8px;
}

button {
  border: 1px solid #9fc2f7;
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  min-height: 31px;
  padding: 0 12px;
  cursor: pointer;
}

button.secondary {
  background: #fff;
  color: #07499d;
}

button.ghost {
  background: transparent;
}

button.danger {
  border-color: #ffb5bb;
  color: var(--red);
}

button.active-filter {
  border-color: #bd6b00;
  background: #fff1da;
  color: var(--amber);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

.topbar {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(8, 21, 38, 0.18);
}

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

.reload-mark {
  width: 32px;
  min-width: 32px;
  padding: 0;
  font-size: 19px;
  line-height: 1;
  background: #fff;
  color: var(--blue);
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.topbar p {
  display: inline-block;
  margin: 0 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  display: flex;
  gap: 0;
}

.top-actions button {
  border-radius: 0;
  margin-left: -1px;
  min-width: 72px;
}

.top-actions button:first-child {
  border-radius: 7px 0 0 7px;
}

.top-actions button:last-child {
  border-radius: 0 7px 7px 0;
}

.app-shell {
  height: calc(100vh - 54px);
  display: grid;
  grid-template-rows: 38px minmax(280px, 1fr) minmax(300px, 0.88fr);
  gap: 4px;
  padding: 4px;
  overflow: hidden;
}

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

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 5px 9px;
  box-shadow: none;
}

.metric b {
  display: block;
  font-size: 18px;
  line-height: 1;
}

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

.panel {
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-head {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 9px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(#fff, #f2f6fb);
}

.panel h2 {
  margin: 0;
  font-size: 15px;
}

.panel-head span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.panel-head input {
  width: min(320px, 32vw);
  height: 32px;
  border: 1px solid #c6d5e8;
  border-radius: 7px;
  padding: 0 10px;
}

.panel-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.panel-tools span {
  margin: 0;
  white-space: nowrap;
}

.table-wrap {
  min-height: 0;
  overflow: auto;
}

.table-wrap.small {
  flex: 1;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 29px;
  background: #f2f6fb;
  border-bottom: 1px solid var(--line);
  color: #37506f;
  font-size: 12px;
  text-align: left;
  padding: 0 10px;
}

td {
  height: 29px;
  border-bottom: 1px solid #e5edf7;
  padding: 0 10px;
  vertical-align: middle;
}

tr:hover td {
  background: #f8fbff;
}

tr.selected td {
  background: #e7f1ff;
  box-shadow: inset 3px 0 0 var(--blue);
}

tbody tr {
  cursor: context-menu;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border-radius: 999px;
  padding: 0 8px;
  background: #edf3fb;
  color: #41536c;
  font-weight: 700;
  font-size: 12px;
}

.badge.live {
  background: #fff0e0;
  color: var(--amber);
}

.badge.staging,
.badge.done {
  background: #e5fbf1;
  color: var(--green);
}

.badge.failed {
  background: #ffe9ec;
  color: var(--red);
}

.badge.running {
  background: var(--blue-weak);
  color: var(--blue);
}

.actions {
  display: flex;
  gap: 4px;
}

.actions button {
  min-height: 24px;
  padding: 0 7px;
}

.column-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

button.mini {
  min-height: 23px;
  padding: 0 7px;
  font-size: 12px;
}

.link-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  min-height: 0;
}

.count-pill {
  min-width: 28px;
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
}

.count-pill.no-updates {
  color: #708298;
  background: #eef3f8;
}

.count-pill.has-updates {
  color: var(--amber);
  background: #fff1da;
}

.count-pill.neutral {
  min-width: 48px;
  color: #07499d;
  background: var(--blue-weak);
}

.status-dot {
  min-width: 34px;
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
}

.status-dot.ok {
  color: #08784f;
  background: #e5fbf1;
}

.status-dot.warn {
  color: var(--amber);
  background: #fff1da;
}

.status-dot.bad {
  color: var(--red);
  background: #ffe9ec;
}

.status-dot.muted {
  color: #708298;
  background: #eef3f8;
}

.table-link {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}

.details {
  flex: 1;
  padding: 8px;
  overflow: auto;
}

.bottom-panel {
  min-height: 0;
}

.tabbar {
  display: flex;
  align-items: center;
  gap: 3px;
  min-height: 42px;
  padding: 5px 7px;
  border-bottom: 1px solid var(--line);
  background: #edf3fa;
  overflow-x: auto;
}

.tab {
  min-width: max-content;
  min-height: 30px;
  border-color: transparent;
  background: transparent;
  color: #708298;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.tab.active {
  border-color: #9fc2f7;
  background: var(--blue-weak);
  color: var(--blue);
}

.tab span {
  min-width: 20px;
  min-height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
}

.tab-pane {
  min-height: 0;
  flex: 1;
  display: none;
  flex-direction: column;
}

.tab-pane.active {
  display: flex;
}

.panel-head.inline {
  box-shadow: none;
}

.cli-box {
  border-bottom: 1px solid var(--line);
  background: #f8fbff;
  padding: 8px 10px;
}

.cli-row {
  display: grid;
  grid-template-columns: minmax(150px, 210px) minmax(180px, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.cli-row input[type="text"] {
  height: 32px;
  border: 1px solid #c6d5e8;
  border-radius: 7px;
  padding: 0 10px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

.cli-row.compact {
  display: flex;
  flex-wrap: wrap;
  margin-top: 7px;
}

.command-palette,
.command-strip,
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.task-composer {
  display: grid;
  grid-template-columns: minmax(150px, 210px) minmax(150px, 220px) minmax(120px, 180px) minmax(180px, 1fr) auto auto auto;
  gap: 6px;
  align-items: center;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  background: #f8fbff;
}

.task-composer input[type="text"] {
  height: 32px;
  border: 1px solid #c6d5e8;
  border-radius: 7px;
  padding: 0 9px;
}

.task-composer label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  white-space: nowrap;
}

.command-palette {
  margin-top: 7px;
}

.command-palette button,
.command-strip button,
.detail-actions button {
  min-height: 26px;
  padding: 0 9px;
}

.detail-actions {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: #f8fbff;
}

.command-strip {
  margin: 9px 0;
}

.cli-row.compact button {
  min-height: 27px;
}

.cli-row label {
  color: var(--muted);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.details.empty {
  color: var(--muted);
}

.details pre {
  margin: 0;
  white-space: pre-wrap;
  background: #101828;
  color: #e9f1ff;
  border-radius: 8px;
  padding: 14px;
  min-height: 180px;
}

.error-box {
  border: 1px solid #ffb5bb;
  background: #fff0f1;
  color: var(--red);
  border-radius: 7px;
  padding: 10px 12px;
  font-weight: 700;
}

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

.detail-box {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 9px;
  background: var(--panel-soft);
}

.table-wrap.embedded {
  max-height: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.empty-state {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f8fbff;
  color: var(--muted);
}

.empty-state b {
  color: var(--text);
}

.detail-box h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.detail-box p {
  margin: 4px 0;
}

dialog {
  border: 0;
  border-radius: 10px;
  padding: 0;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

.modal {
  width: min(520px, 94vw);
  padding: 18px;
}

.modal h3 {
  margin: 0 0 8px;
}

.modal label {
  display: grid;
  gap: 6px;
  margin: 14px 0;
  font-weight: 700;
}

.modal input[type="text"] {
  height: 38px;
  border: 1px solid #c6d5e8;
  border-radius: 7px;
  padding: 0 10px;
}

.confirm-line {
  display: flex !important;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: var(--amber);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.context-menu {
  position: fixed;
  z-index: 50;
  min-width: 190px;
  padding: 6px;
  border: 1px solid #bfd0e5;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 35px rgba(12, 25, 48, 0.22);
}

.context-menu[hidden] {
  display: none;
}

.context-menu button {
  width: 100%;
  justify-content: flex-start;
  min-height: 31px;
  padding: 0 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.context-menu button:hover {
  background: var(--blue-weak);
  color: var(--blue);
}

@media (max-width: 1100px) {
  .app-shell {
    overflow: auto;
    height: auto;
    min-height: calc(100vh - 56px);
  }

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

  .app-shell {
    grid-template-rows: auto auto minmax(360px, auto);
  }

  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    padding: 8px;
  }

  .top-actions {
    width: 100%;
    overflow-x: auto;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-tools {
    width: 100%;
    justify-content: space-between;
  }

  .panel-head input {
    width: min(420px, 100%);
  }

  .task-composer {
    grid-template-columns: 1fr;
  }
}
