:root {
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-2: #f9faf7;
  --line: #d9ded6;
  --text: #1f2a24;
  --muted: #667269;
  --green: #276749;
  --green-2: #dcebdd;
  --blue: #315f7c;
  --red: #9b3d3d;
  --amber: #9a6b19;
  --shadow: 0 12px 34px rgba(31, 42, 36, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

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

.auth-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  justify-items: start;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel p {
  margin: 0;
  color: var(--muted);
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  transition: grid-template-columns 0.18s ease;
}

.app.sidebar-collapsed {
  grid-template-columns: 76px minmax(0, 1fr);
}

.sidebar {
  background: #223129;
  color: #f7fbf6;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  min-width: 0;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 6px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

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

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

.brand-copy {
  min-width: 0;
}

.brand span {
  color: rgba(255, 255, 255, 0.68);
  margin-top: 2px;
}

.sidebar-toggle {
  width: 32px;
  height: 32px;
  margin-left: auto;
  display: inline-grid;
  place-items: center;
  flex: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.78);
}

.sidebar-toggle:hover {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.36);
}

.sidebar-collapsed .sidebar {
  padding-inline: 12px;
}

.sidebar-collapsed .brand {
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding-inline: 0;
}

.sidebar-collapsed .brand-copy,
.sidebar-collapsed .nav-item span,
.sidebar-collapsed .side-status span:not(.dot) {
  display: none;
}

.sidebar-collapsed .sidebar-toggle {
  margin-left: 0;
}

.sidebar-collapsed .nav-item {
  justify-content: center;
  padding-inline: 0;
}

.sidebar-collapsed .side-status {
  justify-content: center;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(255, 255, 255, 0.76);
  border-radius: 8px;
  text-align: left;
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.side-status {
  margin-top: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
}

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

.dot.ok {
  background: #83c57b;
}

.dot.bad {
  background: #d76d6d;
}

.workspace {
  min-width: 0;
  padding: 20px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 20px;
}

.top-actions,
.action-row,
.inline-checks {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.primary,
.secondary,
.icon-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 9px 14px;
  background: var(--surface);
  color: var(--text);
}

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

.primary.danger {
  background: var(--red);
  border-color: var(--red);
}

.primary.ghost {
  background: var(--surface);
  color: var(--green);
}

.secondary:hover,
.icon-button:hover,
.tab:hover,
.segmented button:hover {
  border-color: #a9b7ad;
}

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

.toast {
  margin: 0 0 14px;
  padding: 12px 14px;
  background: #edf6ed;
  border: 1px solid #c8dfc7;
  border-radius: 8px;
  color: #244d2e;
}

.status-pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 4px 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.status-pill.ok,
.status-badge.ok,
.status-badge.succeeded,
.status-badge.open {
  background: #edf6ed;
  border-color: #c8dfc7;
  color: #245232;
}

.status-pill.bad,
.status-badge.failed,
.status-badge.cancelled {
  background: #faeded;
  border-color: #e6c5c5;
  color: var(--red);
}

.status-badge.needs_review,
.status-badge.running,
.status-badge.pending {
  background: #fbf2da;
  border-color: #ecd28f;
  color: var(--amber);
}

.screen-grid {
  display: grid;
  gap: 18px;
}

.request-layout {
  grid-template-columns: minmax(0, 1fr) 360px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 18px;
}

.compact-stack {
  gap: 14px;
}

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

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

.section-head.compact {
  align-items: center;
}

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

.salary-form {
  grid-template-columns: repeat(3, minmax(210px, 1fr));
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.field input,
.field select,
.field textarea,
.filter-grid input,
.filter-grid select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 10px;
}

.field input,
.field select,
.filter-grid input,
.filter-grid select {
  min-height: 40px;
}

.field textarea {
  resize: vertical;
  min-height: 86px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 2px;
  background: #e9ede8;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  overflow: auto;
}

.segmented button,
.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  padding: 7px 10px;
  white-space: nowrap;
}

.segmented button.selected,
.tab.active {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}

.source-picker,
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.alias-form {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) minmax(180px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.alias-form-actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.pill-check,
.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
}

.pill-check {
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 7px 10px;
}

.summary-panel {
  position: sticky;
  top: 24px;
}

pre {
  overflow: auto;
  margin: 0;
  padding: 14px;
  border-radius: 8px;
  background: #1f2a24;
  color: #eaf4ea;
  font-size: 13px;
}

.notice {
  margin-top: 14px;
  padding: 12px;
  color: #5f4a19;
  background: #fbf2da;
  border: 1px solid #ecd28f;
  border-radius: 8px;
  line-height: 1.45;
}

.notice.neutral {
  color: var(--muted);
  background: #f1f4ef;
  border-color: var(--line);
}

.notice.error {
  color: var(--red);
  background: #faeded;
  border-color: #e6c5c5;
}

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

.nowrap {
  white-space: nowrap;
  overflow-wrap: normal;
}

.wide {
  grid-column: 1 / -1;
}

.empty {
  padding: 16px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

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

.tiny {
  min-height: 28px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  padding: 4px 8px;
  font-size: 13px;
}

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

.icon-link {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--green);
  text-decoration: none;
  vertical-align: top;
}

.icon-link:hover {
  border-color: #a9b7ad;
  background: #edf6ed;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

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

.kpi span,
.kpi small,
.metric span,
.hour-summary span {
  display: block;
  color: var(--muted);
}

.kpi strong {
  display: block;
  margin: 6px 0;
  font-size: 26px;
}

.table-band {
  min-width: 0;
}

.helper-text {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.45;
  max-width: 980px;
}

.section-head .helper-text {
  margin-bottom: 0;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  max-width: 100%;
}

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

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  font-size: 13px;
  background: var(--surface-2);
  white-space: nowrap;
}

tbody tr:hover {
  background: #f6faf3;
}

.cell-stack {
  display: grid;
  gap: 4px;
  min-width: 180px;
  max-width: 520px;
  white-space: normal;
}

.cell-stack strong {
  font-weight: 700;
}

.cell-stack span {
  color: var(--muted);
  font-size: 13px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(31, 42, 36, 0.38);
}

.modal {
  width: min(560px, 100%);
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 22px 70px rgba(31, 42, 36, 0.22);
  padding: 18px;
}

.log-modal {
  width: min(980px, 100%);
  max-height: min(820px, 92vh);
  overflow: auto;
}

.review-context {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.review-context span,
.review-context small {
  color: var(--muted);
}

.review-context strong {
  overflow-wrap: anywhere;
}

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

.log-viewer {
  max-height: 430px;
  white-space: pre-wrap;
  overflow: auto;
}

.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
  gap: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 21px;
}

.hour-summary {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.hour-summary strong {
  font-size: 24px;
  color: var(--blue);
}

.workflow {
  display: grid;
  gap: 14px;
}

code {
  background: rgba(0, 0, 0, 0.06);
  border-radius: 5px;
  padding: 2px 4px;
}

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

  .brand div:not(.brand-mark),
  .nav-item span,
  .side-status span {
    display: none;
  }

  .request-layout,
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .summary-panel {
    position: static;
  }
}

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

  .sidebar {
    height: auto;
    position: static;
    padding: 12px;
  }

  .brand {
    display: none;
  }

  .nav {
    grid-auto-flow: column;
    grid-auto-columns: minmax(52px, 1fr);
    overflow: auto;
  }

  .workspace {
    padding: 14px;
  }

  .topbar,
  .section-head {
    display: grid;
  }

  .form-grid,
  .filter-grid,
  .alias-form,
  .salary-form,
  .kpis,
  .metric-grid {
    grid-template-columns: 1fr;
  }

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