:root {
  color: #171a1f;
  background: #f4f5f7;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --surface: #ffffff;
  --surface-alt: #f7f8fa;
  --ink: #171a1f;
  --muted: #68707c;
  --divider: #dfe3e8;
  --accent: #1769e0;
  --accent-hover: #0f58c5;
  --danger: #c63f3f;
  --danger-hover: #ab3232;
  --green: #18794e;
  --amber: #8a5a00;
  --purple: #7050b5;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { min-width: 320px; }
button, input, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.55; }

.login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef1f4;
}

.login-panel {
  width: min(100%, 360px);
  padding: 28px;
  border: 1px solid var(--divider);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 2px 4px rgba(23, 26, 31, 0.06), 0 12px 32px rgba(23, 26, 31, 0.08);
}

.wordmark { padding-left: 9px; border-left: 3px solid #22a06b; color: var(--ink); font-size: 24px; font-weight: 750; line-height: 1; }
.wordmark.small { font-size: 18px; }
.client-name { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; font-weight: 600; }

.login-panel h1 { margin: 30px 0 20px; font-size: 20px; font-weight: 650; }
form { display: grid; gap: 8px; }
label { color: #454c57; font-size: 12px; font-weight: 650; }
input, textarea {
  width: 100%;
  border: 1px solid #cbd1d8;
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}
input { height: 38px; padding: 0 10px; margin-bottom: 8px; }
textarea { min-height: 64px; padding: 9px 10px; resize: vertical; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.14); }

.button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
}
.button.primary { color: #fff; background: var(--accent); }
.button.primary:hover { background: var(--accent-hover); }
.button.secondary { color: #343b45; border-color: #cbd1d8; background: var(--surface); }
.button.secondary:hover { background: var(--surface-alt); }
.button.danger { color: #fff; background: var(--danger); }
.button.danger:hover { background: var(--danger-hover); }
.button.compact { min-height: 30px; padding: 5px 10px; }
.form-error { margin: 4px 0 6px; color: #a62f2f; font-size: 12px; font-weight: 600; line-height: 1.4; }

.app-shell { min-height: 100dvh; }
.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.profile-name { max-width: 240px; overflow: hidden; color: var(--muted); font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 24px 10px; }
.section-head h1 { margin: 0; font-size: 20px; font-weight: 680; }
.section-meta { min-height: 17px; margin: 4px 0 0; color: var(--muted); font-size: 12px; font-weight: 550; }

.dashboard-widgets { padding: 0 24px 14px; }
.dashboard-widgets-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 12px; }
.dashboard-widget { min-width: 0; overflow: hidden; border: 1px solid var(--divider); border-radius: 6px; background: var(--surface); }
.dashboard-widget h2 { margin: 0; padding: 10px 12px; border-bottom: 1px solid var(--divider); color: #454c57; background: var(--surface-alt); font-size: 11px; font-weight: 750; }
.widget-counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); margin: 0; }
.widget-count { min-width: 0; padding: 12px; border-right: 1px solid #edf0f2; }
.widget-count:last-child { border-right: 0; }
.widget-count dt { overflow-wrap: anywhere; text-transform: none; }
.widget-count dd { margin-top: 7px; color: var(--ink); font-size: 20px; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1; }
.widget-count.tone-info dd { color: #125aa8; }
.widget-count.tone-warning dd { color: var(--amber); }
.widget-count.tone-success dd { color: var(--green); }
.widget-count.tone-critical dd { color: var(--danger); }

.status-filters {
  display: flex;
  gap: 3px;
  overflow-x: auto;
  padding: 7px 24px 10px;
  border-bottom: 1px solid var(--divider);
  scrollbar-width: none;
}
.status-filters button {
  flex: 0 0 auto;
  min-height: 30px;
  border: 0;
  border-radius: 5px;
  padding: 5px 10px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 650;
}
.status-filters button:hover { color: var(--ink); background: #e9ecf0; }
.status-filters button.active { color: var(--ink); background: var(--surface); box-shadow: 0 0 0 1px var(--divider), 0 1px 2px rgba(23, 26, 31, 0.08); }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 420px); min-height: calc(100dvh - 147px); }
.orders-pane { min-width: 0; padding: 16px 16px 28px 24px; }
.table-wrap { overflow: auto; border: 1px solid var(--divider); border-radius: 6px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { height: 52px; padding: 8px 12px; border-bottom: 1px solid #edf0f2; text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; height: 38px; color: var(--muted); background: var(--surface-alt); font-size: 11px; font-weight: 700; }
td { color: #343b45; font-size: 12px; font-weight: 550; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr.selected { background: #f0f6ff; }
tbody tr:last-child td { border-bottom: 0; }
.cell-primary { display: block; overflow: hidden; color: var(--ink); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.cell-secondary { display: block; overflow: hidden; margin-top: 3px; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.amount-column { width: 112px; text-align: right; }
td.amount-column { font-variant-numeric: tabular-nums; font-weight: 700; }
.state-row { padding: 32px 16px; color: var(--muted); text-align: center; font-size: 12px; font-weight: 600; }
.state-row.error { color: #a62f2f; }

.status-badge { display: inline-flex; align-items: center; min-height: 23px; border: 1px solid #cbd1d8; border-radius: 999px; padding: 3px 8px; color: #454c57; background: #f4f5f7; font-size: 10px; font-weight: 750; white-space: nowrap; }
.status-badge.submitted { color: #125aa8; border-color: #a9c9ed; background: #edf6ff; }
.status-badge.payment_pending { color: var(--amber); border-color: #e6cd96; background: #fff7df; }
.status-badge.paid { color: var(--green); border-color: #a9d8c2; background: #edfaf4; }
.status-badge.rejected, .status-badge.canceled { color: #9d3232; border-color: #e7b7b7; background: #fff1f1; }
.status-badge.create_unknown { color: var(--purple); border-color: #cfbfe9; background: #f7f2ff; }
.status-badge.create_failed, .status-badge.chargeback { color: #9d3232; border-color: #e7b7b7; background: #fff1f1; }
.status-badge.refunded { color: var(--purple); border-color: #cfbfe9; background: #f7f2ff; }

.detail-pane { min-width: 0; padding: 20px 24px; border-left: 1px solid var(--divider); background: var(--surface); }
.detail-empty { padding: 48px 0; color: var(--muted); text-align: center; font-size: 12px; font-weight: 600; }
.detail-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 18px; border-bottom: 1px solid var(--divider); }
.eyebrow { margin: 0 0 5px; color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.detail-title-row h2 { margin: 0; font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 16px; margin: 20px 0; }
.detail-grid div { min-width: 0; }
dt { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
dd { margin: 4px 0 0; overflow-wrap: anywhere; color: #343b45; font-size: 12px; font-weight: 650; line-height: 1.4; }
.mono { font-variant-numeric: tabular-nums; }
.detail-block { padding: 16px 0; border-top: 1px solid var(--divider); }
.detail-block h3 { margin: 0 0 8px; font-size: 12px; font-weight: 750; }
.detail-block p { margin: 0 0 10px; color: #4f5762; font-size: 12px; font-weight: 550; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.decision-actions { display: grid; gap: 18px; padding-top: 18px; border-top: 1px solid var(--divider); }
.reject-row { display: grid; gap: 7px; }
.reject-row .button { justify-self: start; }

.confirm-dialog {
  width: min(calc(100% - 32px), 430px);
  border: 1px solid var(--divider);
  border-radius: 6px;
  padding: 22px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 18px 56px rgba(23, 26, 31, 0.22);
}
.confirm-dialog::backdrop { background: rgba(23, 26, 31, 0.48); }
.confirm-dialog h2 { margin: 0 0 10px; font-size: 17px; }
.confirm-dialog > p { margin: 0 0 18px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.confirm-dialog dl { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 22px; }
.confirm-dialog dl div { min-width: 0; padding: 10px; border: 1px solid var(--divider); border-radius: 5px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .detail-pane { border-top: 1px solid var(--divider); border-left: 0; }
  .orders-pane { padding: 12px 16px 20px; }
  .section-head, .dashboard-widgets, .status-filters { padding-right: 16px; padding-left: 16px; }
}

@media (max-width: 620px) {
  .topbar { height: 56px; padding: 0 14px; }
  .profile-name { display: none; }
  .section-head { padding-top: 16px; }
  .section-head h1 { font-size: 18px; }
  .workspace { min-height: calc(100dvh - 139px); }
  .table-wrap { border-right: 0; border-left: 0; border-radius: 0; }
  table { table-layout: auto; }
  th:nth-child(2), td:nth-child(2), th:nth-child(5), td:nth-child(5) { display: none; }
  th, td { padding: 8px 10px; }
  .amount-column { width: 96px; }
  .detail-pane { padding: 18px 16px 28px; }
  .detail-grid { grid-template-columns: 1fr; gap: 13px; }
  .widget-counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .widget-count { border-bottom: 1px solid #edf0f2; }
  .widget-count:nth-child(2n) { border-right: 0; }
  .widget-count:last-child { border-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
