:root {
  --ink: #17211d;
  --muted: #69736f;
  --line: #dce3df;
  --surface: #ffffff;
  --surface-soft: #f6f8f7;
  --nav: #182923;
  --nav-2: #223a32;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --warning: #a15c12;
  --warning-bg: #fff4e4;
  --danger: #b42318;
  --good: #147447;
  --info: #315aa8;
  --shadow: 0 20px 45px rgba(18, 32, 27, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--surface-soft);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.sidebar {
  background: var(--nav);
  color: white;
  display: flex;
  flex-direction: column;
  padding: 22px;
  gap: 24px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--accent);
  border-radius: 8px;
  font-weight: 800;
}

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

.brand small {
  color: rgba(255, 255, 255, 0.68);
}

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

.nav-item {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.76);
  padding: 11px 12px;
  text-align: left;
  border-radius: 8px;
}

.nav-item.active,
.nav-item:hover {
  background: var(--nav-2);
  color: white;
}

.logout-form {
  margin-top: auto;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 22px;
}

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

h1 {
  font-size: 28px;
  line-height: 1.18;
  margin-bottom: 6px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 16px;
}

.topbar p,
.muted,
.empty {
  color: var(--muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary,
.secondary,
.text-button {
  border: 0;
  min-height: 38px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.primary {
  color: white;
  background: var(--accent);
}

.primary:hover {
  background: var(--accent-strong);
}

.secondary {
  background: #e9efed;
  color: var(--ink);
}

.text-button {
  color: var(--accent-strong);
  background: transparent;
  padding: 0;
}

.full {
  width: 100%;
}

.chip,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.chip {
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
}

.status-good {
  background: #e8f6ee;
  color: var(--good);
}

.status-warn {
  background: var(--warning-bg);
  color: var(--warning);
}

.status-info {
  background: #edf3ff;
  color: var(--info);
}

.alert {
  background: #eaf7f5;
  border: 1px solid #b8dfda;
  color: var(--accent-strong);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 18px;
}

.alert.error {
  background: #fff0ef;
  border-color: #ffcfca;
  color: var(--danger);
}

.hidden,
.view {
  display: none;
}

.hidden {
  display: none !important;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.setup-panel {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  background: var(--warning-bg);
  border: 1px solid #f1d0a8;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 18px;
}

.setup-panel h2 {
  margin: 8px 0 4px;
}

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

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

.metric,
.panel,
.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(18, 32, 27, 0.04);
}

.metric {
  padding: 18px;
}

.metric span,
.detail-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  display: block;
  font-size: 30px;
  margin-top: 6px;
}

.metric.warning {
  border-color: #f1d0a8;
}

.metric.action {
  border-color: #a9d9d4;
}

.dashboard-grid,
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.68fr);
  gap: 18px;
}

.panel {
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.panel-header h2 {
  margin-bottom: 0;
}

.stack,
.list,
.timeline {
  display: grid;
  gap: 10px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 160px 170px 150px 160px 160px auto;
  gap: 10px;
  margin-bottom: 14px;
}

.market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.market-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 14px;
}

.market-card h3 {
  margin: 10px 0 4px;
}

.market-card p {
  margin-bottom: 4px;
  color: var(--muted);
}

.market-summary {
  display: grid;
  gap: 8px;
}

.market-chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.market-chip-row.compact .status {
  min-height: 24px;
  padding: 0 8px;
  font-size: 12px;
}

.bulkbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.pagination-actions {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
}

.pagination-actions label {
  min-width: 96px;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 0 12px;
}

.table-shell {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.table-shell.small {
  max-height: 320px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
}

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

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

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

.link-cell {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
  text-align: left;
}

.switch {
  display: inline-flex;
  align-items: center;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch span {
  width: 44px;
  height: 24px;
  background: #cbd5d1;
  border-radius: 999px;
  position: relative;
  transition: background 0.2s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s ease;
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.form-grid {
  display: grid;
  gap: 12px;
}

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

.check-label {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.check-label input,
.row-check {
  width: 18px;
  min-height: 18px;
}

.list-row,
.approval-item,
.compact-item,
.timeline-item,
.health-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: white;
}

.top-gap {
  margin-top: 18px;
}

.list-row,
.approval-item,
.timeline-item,
.health-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.list-row span,
.compact-item span {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.approval-item h3 {
  margin: 8px 0 4px;
}

.approval-item p,
.timeline-item p {
  margin-bottom: 0;
  color: var(--muted);
}

.price-line,
.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.row-actions {
  justify-content: flex-end;
  min-width: 180px;
}

.timeline-item {
  justify-content: flex-start;
}

.error-text {
  color: var(--danger) !important;
}

dialog {
  width: min(900px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
}

dialog::backdrop {
  background: rgba(15, 27, 23, 0.45);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin: 0;
}

.dialog-body {
  padding: 18px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 18px 18px;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 8px;
  font-weight: 800;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.market-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.country-block {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.country-block h3,
.country-block h4 {
  margin-bottom: 0;
}

.detail-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
}

.detail-card strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(rgba(24, 41, 35, 0.78), rgba(24, 41, 35, 0.78)),
    url("https://images.unsplash.com/photo-1510812431401-41d2bd2722f3?auto=format&fit=crop&w=1600&q=80");
  background-size: cover;
  background-position: center;
}

.login-panel {
  width: min(420px, calc(100vw - 28px));
  padding: 28px;
}

.login-panel .brand small {
  color: var(--muted);
}

.login-panel h1 {
  margin-top: 28px;
}

.login-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  width: 100%;
  margin: 12px 0;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 14px;
  }

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

  .logout-form {
    display: none;
  }

  .topbar,
  .dashboard-grid,
  .split {
    grid-template-columns: 1fr;
    display: grid;
  }

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

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

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

@media (max-width: 640px) {
  .workspace {
    padding: 16px;
  }

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

  .metric-grid,
  .metric-grid.compact,
  .toolbar,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .approval-item,
  .list-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .row-actions {
    width: 100%;
    justify-content: stretch;
  }

  .row-actions button {
    flex: 1;
  }
}
