:root {
  color-scheme: dark;
  --canvas: #111412;
  --surface: #191d1a;
  --surface-raised: #222722;
  --surface-soft: #27231f;
  --divider: #343a35;
  --ink: #f3eee3;
  --muted: #a9aea8;
  --gold: #d6ba79;
  --green: #3f8068;
  --green-bright: #75b59a;
  --burgundy: #8b3442;
  --burgundy-bright: #c56370;
  --silver: #9ca5b0;
  --danger: #dc6f70;
  --shadow: rgba(0, 0, 0, 0.3);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  line-height: 1.45;
}

button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

[hidden] { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background-color: #101411;
  background-image:
    linear-gradient(rgba(214, 186, 121, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(214, 186, 121, 0.04) 1px, transparent 1px);
  background-size: 32px 32px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 36px;
  background: var(--surface);
  border: 1px solid #4b4537;
  border-radius: 8px;
  box-shadow: 0 22px 60px var(--shadow);
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  color: var(--gold);
  font-size: 25px;
}

.brand-logo {
  width: 64px;
  height: 64px;
  display: block;
  object-fit: cover;
  margin-bottom: 18px;
  border: 1px solid var(--gold);
  border-radius: 6px;
}

.brand-logo-small {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  object-fit: cover;
  border: 1px solid #665a3e;
  border-radius: 5px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-family: Georgia, serif; font-size: 2rem; font-weight: 500; }
h2 { margin-bottom: 0; font-family: Georgia, serif; font-size: 1.7rem; font-weight: 500; }
h3 { margin-bottom: 0; font-size: 1rem; font-weight: 650; }

.login-copy { margin-bottom: 28px; color: var(--muted); }
label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 0.82rem; }
.field-spacing { margin-top: 14px; }

input, select {
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  color: var(--ink);
  background: #101310;
  border: 1px solid var(--divider);
  border-radius: 6px;
  outline: none;
}

input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(214, 186, 121, 0.13); }
.secret-row { display: grid; grid-template-columns: minmax(0, 1fr) 42px; gap: 8px; margin-bottom: 16px; }

.primary-button, .secondary-button, .text-button, .icon-button, .row-button {
  border: 0;
  border-radius: 6px;
}

.primary-button {
  min-height: 42px;
  padding: 0 18px;
  color: #fff9ec;
  background: var(--burgundy);
  border: 1px solid #b55d68;
  font-weight: 700;
}

.primary-button:hover { background: #9c3d4b; }
.login-panel > .primary-button { width: 100%; }

.secondary-button {
  min-height: 36px;
  padding: 0 14px;
  color: var(--ink);
  background: var(--surface-raised);
  border: 1px solid var(--divider);
}

.icon-button {
  width: 38px;
  height: 38px;
  color: var(--muted);
  background: var(--surface-raised);
  border: 1px solid var(--divider);
  font-weight: 700;
}

.text-button {
  padding: 5px 0;
  color: var(--gold);
  background: transparent;
}

.row-button {
  min-height: 30px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--surface-raised);
  border: 1px solid var(--divider);
  white-space: nowrap;
}

.row-button.danger { color: #f4b6bb; border-color: #673842; }
.row-button.success { color: #a4d3bc; border-color: #355d4d; }
.form-error { min-height: 20px; margin: 12px 0 0; color: var(--danger); font-size: 0.84rem; }
.portal-link {
  display: block;
  margin-top: 14px;
  color: var(--gold);
  font-size: 0.82rem;
  text-align: center;
  text-decoration: none;
}
.portal-link:hover { text-decoration: underline; }

.app-shell { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 30px;
  background: rgba(17, 20, 18, 0.96);
  border-bottom: 1px solid var(--divider);
  backdrop-filter: blur(12px);
}

.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-lockup strong, .brand-lockup span { display: block; }
.brand-lockup strong { font-family: Georgia, serif; font-size: 1.1rem; font-weight: 600; }
.brand-lockup div > span { margin-top: 2px; color: var(--muted); font-size: 0.72rem; }
.brand-spade { color: var(--gold); font-size: 25px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.health-indicator { display: flex; align-items: center; gap: 7px; margin-right: 6px; color: var(--muted); font-size: 0.78rem; }
.health-indicator i { width: 7px; height: 7px; border-radius: 50%; background: var(--green-bright); box-shadow: 0 0 0 3px rgba(117, 181, 154, 0.1); }

.section-tabs {
  position: sticky;
  top: 68px;
  z-index: 9;
  display: flex;
  gap: 4px;
  padding: 10px 30px;
  overflow-x: auto;
  background: var(--canvas);
  border-bottom: 1px solid var(--divider);
}

.tab-button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 16px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
}

.tab-button.active { color: #fffaf0; background: #264f42; }

main { width: min(1460px, 100%); margin: 0 auto; padding: 30px; }
.page-section { display: none; }
.page-section.active { display: block; }

.section-heading {
  min-height: 54px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.updated-time, .muted-label { margin: 0; color: var(--muted); font-size: 0.78rem; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
.metric-card {
  position: relative;
  min-height: 126px;
  padding: 18px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 8px;
}
.metric-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--silver); }
.metric-card.accent-green::before { background: var(--green-bright); }
.metric-card.accent-gold::before { background: var(--gold); }
.metric-card.accent-burgundy::before { background: var(--burgundy-bright); }
.metric-card span, .metric-card small { display: block; color: var(--muted); }
.metric-card span { font-size: 0.8rem; }
.metric-card strong { display: block; margin: 9px 0 5px; font-family: Georgia, serif; font-size: 2rem; font-weight: 500; }
.metric-card small { font-size: 0.72rem; }

.overview-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 16px; }
.data-block { min-width: 0; background: var(--surface); border: 1px solid var(--divider); border-radius: 8px; }
.block-heading { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 16px; border-bottom: 1px solid var(--divider); }

.table-wrap { width: 100%; overflow-x: auto; background: var(--surface); border: 1px solid var(--divider); border-radius: 8px; }
.data-block .table-wrap { border: 0; border-radius: 0 0 8px 8px; }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th { color: var(--muted); font-size: 0.7rem; font-weight: 650; text-align: left; text-transform: uppercase; }
th, td { height: 48px; padding: 8px 14px; border-bottom: 1px solid #2a2f2b; white-space: nowrap; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(214, 186, 121, 0.025); }
.compact-table th, .compact-table td { height: 44px; }
.empty-row { color: var(--muted); text-align: center; }
.mono { max-width: 270px; overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: #cbcfc9; }
.positive { color: var(--green-bright); }
.negative { color: var(--burgundy-bright); }

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--divider);
  border-radius: 999px;
  color: var(--muted);
  background: #151815;
  font-size: 0.7rem;
}
.status-pill.success, .status-pill.active { color: #9fd0b7; border-color: #355e4e; background: #18281f; }
.status-pill.failed, .status-pill.disabled { color: #ec9da5; border-color: #673842; background: #28181b; }
.status-pill.processing, .status-pill.new { color: #e5c985; border-color: #67593a; background: #292317; }
.status-pill.reviewed { color: #b8c1cb; border-color: #49515b; background: #1c2126; }

.filter-row { display: flex; align-items: center; gap: 8px; }
.filter-input { width: min(310px, 52vw); }
.filter-select { min-width: 140px; }

.account-tool {
  display: grid;
  grid-template-columns: minmax(560px, 1.25fr) minmax(320px, 0.75fr);
  gap: 16px;
  margin-bottom: 18px;
}
.account-form, .credential-result {
  min-height: 144px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 8px;
}
.account-form { display: grid; grid-template-columns: 1fr 1fr 1.25fr auto; align-items: end; gap: 12px; }
.account-form input { width: 100%; }
.inline-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.credential-result .block-heading { min-height: 34px; padding: 0 0 10px; }
.credential-result > p { margin: 10px 0 13px; color: var(--muted); font-size: 0.78rem; }
.credential-result dl { display: grid; gap: 6px; margin: 0; }
.credential-result dl div { display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 10px; }
.credential-result dt { color: var(--muted); font-size: 0.76rem; }
.credential-result dd { margin: 0; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: #f0d89c; }

.recharge-tool {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(380px, 1.2fr);
  gap: 16px;
  margin-bottom: 18px;
}
.recharge-form, .generated-codes { min-height: 150px; padding: 18px; background: var(--surface); border: 1px solid var(--divider); border-radius: 8px; }
.recharge-form { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 12px; }
.agent-fuel-form { grid-template-columns: 1fr; }
.recharge-form input { width: 100%; }
.generated-codes .block-heading { min-height: 34px; padding: 0 0 10px; }
.generated-codes > p { margin: 12px 0; color: var(--muted); font-size: 0.78rem; }
.code-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 38px; padding: 5px 10px; margin-top: 6px; background: #101310; border: 1px solid var(--divider); border-radius: 6px; }
.code-row code { overflow-wrap: anywhere; color: #f0d89c; }

.feedback-list { display: grid; gap: 10px; }
.feedback-item { display: grid; grid-template-columns: 180px minmax(0, 1fr) auto; gap: 20px; align-items: start; padding: 16px; background: var(--surface); border: 1px solid var(--divider); border-radius: 8px; }
.feedback-meta strong, .feedback-meta span { display: block; }
.feedback-meta span { margin-top: 4px; color: var(--muted); font-size: 0.74rem; }
.feedback-content { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: #ddd9cf; }
.feedback-actions { display: flex; gap: 7px; }
.section-spacing { margin-top: 18px; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin: 12px 0 18px; color: var(--muted); font-size: 0.78rem; }
.pagination .secondary-button { min-width: 78px; }
.security-panel { width: min(620px, 100%); display: grid; gap: 14px; padding: 20px; background: var(--surface); border: 1px solid var(--divider); border-radius: 8px; }
.security-panel input { width: 100%; }
.security-panel .primary-button { justify-self: start; min-width: 150px; }
.security-panel p { margin: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 32px));
  padding: 11px 16px;
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  color: var(--ink);
  background: #252b27;
  border: 1px solid #4a534c;
  border-radius: 7px;
  box-shadow: 0 12px 34px var(--shadow);
  transition: opacity 160ms ease, transform 160ms ease;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: #7b4148; }

@media (max-width: 980px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid { grid-template-columns: 1fr; }
  .account-tool { grid-template-columns: 1fr; }
  .account-form { grid-template-columns: 1fr 1fr; }
  .account-form .password-field { grid-column: 1 / -1; }
  .account-form > .primary-button { grid-column: 1 / -1; }
  .recharge-tool { grid-template-columns: 1fr; }
  .feedback-item { grid-template-columns: 140px minmax(0, 1fr); }
  .feedback-actions { grid-column: 2; }
}

@media (max-width: 680px) {
  .topbar { height: 60px; padding: 0 16px; }
  .brand-lockup div > span, .health-indicator { display: none; }
  .topbar .secondary-button { width: 38px; padding: 0; font-size: 0; }
  .topbar .secondary-button::before { content: "↻"; font-size: 18px; }
  .section-tabs { top: 60px; padding: 8px 12px; }
  .tab-button { padding: 0 13px; }
  main { padding: 22px 14px 36px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
  .section-heading .filter-row { width: 100%; }
  .filter-input { width: 100%; }
  .filter-select { min-width: 118px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric-card { min-height: 112px; padding: 14px; }
  .metric-card strong { font-size: 1.55rem; }
  .account-form { grid-template-columns: 1fr; }
  .account-form .password-field, .account-form > .primary-button { grid-column: 1; }
  .recharge-form { grid-template-columns: 1fr 1fr; }
  .recharge-form .primary-button { grid-column: 1 / -1; }
  .feedback-item { grid-template-columns: 1fr; gap: 10px; }
  .feedback-actions { grid-column: 1; flex-wrap: wrap; }
  .login-panel { padding: 26px 20px; }
}

@media (max-width: 420px) {
  .metric-grid { grid-template-columns: 1fr; }
  .recharge-form { grid-template-columns: 1fr; }
  .recharge-form .primary-button { grid-column: 1; }
}
