:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --ink: #18202c;
  --muted: #657181;
  --line: #d9e0e7;
  --panel: #ffffff;
  --panel-2: #eef3f7;
  --accent: #167a72;
  --accent-2: #234b77;
  --danger: #b42318;
  --warn: #9a6700;
  --ok: #217346;
  --shadow: 0 10px 28px rgba(31, 41, 55, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  min-height: 40px;
  border-radius: 6px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover,
.nav-button:hover {
  border-color: #9fb0bf;
  background: #f8fafc;
}

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

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.secondary {
  background: #e9f3f2;
  border-color: #b7d7d3;
  color: #0f5f59;
}

.danger {
  color: var(--danger);
}

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

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

.login-panel {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.brand-row,
.topbar,
.panel-head,
.actions,
.field-row,
.metric-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 6px;
  background: #111827;
  color: #fff;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

h3 {
  font-size: 14px;
  line-height: 1.2;
}

form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  min-height: 40px;
}

textarea {
  resize: vertical;
  min-height: 180px;
  line-height: 1.45;
}

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

.sidebar {
  background: #111827;
  color: #eef2f7;
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 18px;
}

.sidebar .brand-row {
  min-height: 46px;
}

.sidebar .brand-mark {
  background: #f8fafc;
  color: #111827;
}

.sidebar small {
  color: #aab4c1;
}

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

.nav-button {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #dce5ef;
  text-decoration: none;
  padding: 0 10px;
}

.nav-button.active {
  background: #263244;
  border-color: #36465c;
  color: #fff;
}

.nav-icon {
  color: #9fb7cc;
  font-size: 12px;
  font-weight: 700;
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-title {
  min-width: 0;
}

.topbar-title p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.content {
  padding: 20px;
  display: grid;
  gap: 16px;
  align-content: start;
}

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

.span-4 {
  grid-column: span 4;
}

.span-5 {
  grid-column: span 5;
}

.span-7 {
  grid-column: span 7;
}

.span-8 {
  grid-column: span 8;
}

.span-12 {
  grid-column: span 12;
}

.panel,
.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 16px;
  box-shadow: var(--shadow);
}

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

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

.tile {
  padding: 12px;
  display: grid;
  gap: 8px;
  color: inherit;
  text-decoration: none;
}

.tile.inline {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.pill.ok {
  background: #e7f3ec;
  color: var(--ok);
}

.pill.warn {
  background: #fff3d7;
  color: var(--warn);
}

.pill.danger {
  background: #fde8e5;
  color: var(--danger);
}

.metric-row {
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.tr {
  display: grid;
  grid-template-columns: 1.2fr 1.3fr 0.7fr;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  align-items: center;
}

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

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

.terminal {
  min-height: 170px;
  max-height: 360px;
  overflow: auto;
  border-radius: 8px;
  background: #101820;
  color: #d9f2e6;
  padding: 14px;
  white-space: pre-wrap;
  line-height: 1.45;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  background: #111827;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.empty {
  min-height: 140px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

@media (max-width: 980px) {
  .workbench {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 6;
    grid-template-columns: 1fr;
    gap: 12px;
  }

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

  .nav-button {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    padding: 8px 4px;
  }

  .span-4,
  .span-5,
  .span-7,
  .span-8 {
    grid-column: span 12;
  }
}

@media (max-width: 640px) {
  .content,
  .topbar {
    padding: 14px;
  }

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

  .topbar,
  .panel-head,
  .actions,
  .field-row {
    align-items: stretch;
    flex-direction: column;
  }

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