:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5b6675;
  --line: #e6e8ec;
  --accent: #2f6df6;
  --success: #1f9d57;
  --warning: #c9871f;
  --danger: #d23b3b;
  --shadow: 0 2px 12px rgba(16, 24, 40, 0.05);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.shell-body {
  background: var(--bg);
}

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

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  padding: 8px 8px;
}

.brand-link:hover {
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #eff3fb;
  border: 1px solid #d8e0f0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text);
}

.brand-text {
  letter-spacing: 0.2px;
}

.sidebar-nav,
.sidebar-footer-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-footer-nav {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text);
  border-left: 3px solid transparent;
}

.nav-link:hover {
  background: #f7f9fe;
  text-decoration: none;
}

.nav-link.is-active {
  background: #edf2ff;
  border-left-color: var(--accent);
  color: #1846af;
}

.nav-icon {
  width: 18px;
  text-align: center;
  color: var(--muted);
}

.app-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  min-height: 50px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: default;
}

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

.admin-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eef1f7;
  border: 1px solid var(--line);
  font-weight: 700;
}

.app-content {
  padding: 14px;
}

.page-head {
  margin-bottom: 10px;
}

.page-head h1 {
  margin: 0;
  font-size: 21px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 8px;
}

.stats-strip p {
  margin: 0;
}

.warning-stack h2 {
  margin: 0 0 8px;
  font-size: 15px;
}

.warning-stack ul {
  margin: 0;
  padding-left: 18px;
}

.master-detail {
  display: grid;
  grid-template-columns: minmax(340px, 42%) minmax(420px, 58%);
  gap: 12px;
  align-items: start;
}

.queue-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 70vh;
}

.queue-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.queue-panel-head h2 {
  margin: 0;
  font-size: 26px;
}

.queue-filter-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.queue-filter {
  min-width: 130px;
}

.queue-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  overflow-x: auto;
}

.queue-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.queue-tab:hover {
  background: #f1f4fb;
}

.queue-tab.is-active,
.queue-tab[aria-selected='true'] {
  color: #1746af;
  border-color: #d5e0fb;
  background: #edf2ff;
}

.queue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  max-height: calc(100vh - 270px);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.queue-list-item + .queue-list-item {
  border-top: 1px solid var(--line);
}

.queue-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  min-height: 56px;
  color: var(--text);
  border-left: 3px solid transparent;
}

.queue-row:hover {
  background: #f8faff;
  text-decoration: none;
}

.queue-row:focus-visible {
  outline: 2px solid #bed1ff;
  outline-offset: -1px;
}

.queue-row.is-selected {
  background: #eef3ff;
  border-left-color: var(--accent);
}

.queue-type-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid #dae0e8;
  background: #f4f6fa;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
}

.type-payout {
  background: #f9f3e7;
}

.type-proposal {
  background: #eaf2ff;
}

.type-angel {
  background: #ffeef0;
}

.type-partner {
  background: #fff6e9;
}

.queue-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.queue-title {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-subtitle {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  margin-left: 8px;
}

.queue-amount {
  font-weight: 700;
}

.queue-meta {
  font-size: 12px;
  color: var(--muted);
}

.queue-empty {
  margin: 8px 0 0;
  color: var(--muted);
}

.detail-panel {
  min-width: 0;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.detail-header h2 {
  margin: 2px 0 4px;
  font-size: 33px;
}

.detail-kicker {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.detail-head-right {
  text-align: right;
}

.detail-amount {
  margin: 0 0 6px;
  font-size: 35px;
  font-weight: 700;
}

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

.detail-card h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.kv-list {
  margin: 0;
}

.kv-list div {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid #eff2f6;
}

.kv-list div:last-child {
  border-bottom: none;
}

.kv-list dt {
  color: var(--muted);
}

.kv-list dd {
  margin: 0;
  font-weight: 500;
}

.breakdown-list .total-row dt,
.breakdown-list .total-row dd {
  font-weight: 700;
  color: var(--text);
}

.notes-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.notes-block h4 {
  margin: 0 0 4px;
  font-size: 13px;
}

.notes-block p {
  margin: 0;
}

.timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  display: grid;
  grid-template-columns: 165px 1fr;
  gap: 10px;
  padding: 6px 0;
  border-left: 2px solid #d9dde5;
  padding-left: 10px;
  margin-left: 6px;
}

.timeline time {
  color: var(--muted);
  font-size: 12px;
}

.action-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.inline-template-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.chip-warning {
  color: #7c5311;
  background: #f7ebd7;
  border-color: #efdbbc;
}

.chip-danger {
  color: #922323;
  background: #fce8e8;
  border-color: #f4d0d0;
}

.chip-success {
  color: #176f3e;
  background: #e8f6ef;
  border-color: #ccead8;
}

.chip-muted {
  color: #586273;
  background: #eef1f5;
  border-color: #dbe0e7;
}

.btn {
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f7f8fb;
  color: var(--text);
  padding: 8px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.btn:hover {
  filter: brightness(0.98);
  text-decoration: none;
}

.btn-ghost {
  background: #fff;
}

.btn-primary-blue,
.action-btn.primary-blue {
  background: var(--accent);
  border-color: #2459ce;
  color: #fff;
}

.btn-primary-green,
.action-btn.primary-green {
  background: var(--success);
  border-color: #1a7f47;
  color: #fff;
}

.btn-primary-red,
.action-btn.primary-red {
  background: var(--danger);
  border-color: #b82f2f;
  color: #fff;
}

.action-btn.secondary {
  background: #f2f4f8;
  color: var(--text);
}

.action-btn {
  width: 100%;
}

.flash {
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  margin-bottom: 12px;
}

.flash-success {
  color: #176f3e;
  background: #eaf7f0;
  border-color: #c6e7d4;
}

.flash-error {
  color: #8f2626;
  background: #fdeeee;
  border-color: #f5cccc;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  color: var(--muted);
  font-weight: 600;
  background: #f8f9fb;
}

.inline-form,
.inline-actions {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

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

.form-grid label,
.stack-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
}

.form-grid .full {
  grid-column: 1 / -1;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cfd6e2;
  border-radius: 8px;
  padding: 7px 9px;
  background: #fff;
  color: var(--text);
}

input:focus,
textarea:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid #b9cdff;
  outline-offset: 1px;
}

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

.muted-list {
  margin: 6px 0 0;
  padding-left: 18px;
}

.json {
  margin: 0;
  background: #f8f9fb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.auth-main {
  width: min(460px, 100%);
}

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

.auth-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.auth-head h1 {
  margin: 0;
  font-size: 20px;
}

.auth-head p {
  margin: 2px 0 0;
}

@media (max-width: 1220px) {
  .detail-two-col {
    grid-template-columns: 1fr;
  }

  .stats-strip {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

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

  .app-sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-footer-nav {
    margin-top: 0;
  }

  .master-detail {
    grid-template-columns: 1fr;
  }

  .queue-list {
    max-height: none;
  }

  .stats-strip {
    grid-template-columns: 1fr;
  }

  .inline-template-controls,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .timeline li,
  .kv-list div {
    grid-template-columns: 1fr;
  }

  .queue-row {
    grid-template-columns: 24px minmax(0, 1fr);
  }

  .queue-side {
    grid-column: 2;
    align-items: flex-start;
    margin-left: 0;
  }
}
