:root {
  --ink: #132237;
  --muted: #6d7887;
  --line: #dfe5ea;
  --canvas: #f3f5f4;
  --surface: #ffffff;
  --nav: #102033;
  --nav-soft: #1b3046;
  --teal: #0a9f91;
  --teal-soft: #dff4f0;
  --amber: #c57a17;
  --amber-soft: #fff2dc;
  --red: #c14e4e;
  --red-soft: #fae9e7;
  --shadow: 0 12px 32px rgba(16, 32, 51, .07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

button { font: inherit; }

.login-screen {
  min-height: 100vh;
  padding: 32px 20px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 14% 15%, rgba(10,159,145,.14), transparent 30%),
    radial-gradient(circle at 88% 84%, rgba(16,32,51,.12), transparent 34%),
    var(--canvas);
}
.login-card { width: min(440px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: 0 24px 70px rgba(16,32,51,.13); }
.login-brand { margin-bottom: 34px; display: flex; align-items: center; gap: 12px; }
.login-brand strong, .login-brand small { display: block; }
.login-brand strong { font-size: 20px; letter-spacing: .08em; }
.login-brand small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.login-card h1 { font-size: 30px; }
.login-copy { margin: 12px 0 26px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.login-form { display: grid; gap: 9px; }
.login-form label { margin-top: 7px; color: #425064; font-size: 12px; font-weight: 700; }
.login-form input { width: 100%; min-height: 45px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; outline: none; background: #fff; color: var(--ink); font: inherit; }
.login-form input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(10,159,145,.11); }
.login-form .primary-button { margin-top: 13px; min-height: 45px; }
.login-error { margin: 5px 0 0; color: var(--red); font-size: 12px; }
.login-footnote { margin: 22px 0 0; padding-top: 18px; border-top: 1px solid var(--line); color: #8a949f; font-size: 10px; line-height: 1.6; }

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 30px 18px 22px;
  display: flex;
  flex-direction: column;
  background: var(--nav);
  color: #fff;
}

.brand { display: flex; gap: 12px; align-items: center; color: #fff; text-decoration: none; padding: 0 10px 30px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--teal); font-weight: 800; letter-spacing: -.04em; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 19px; letter-spacing: .08em; }
.brand small { margin-top: 3px; color: #98a9ba; font-size: 11px; }

nav { display: grid; gap: 5px; }
.nav-item { width: 100%; border: 0; border-radius: 10px; padding: 11px 12px; display: flex; align-items: center; gap: 11px; color: #b7c2ce; background: transparent; text-align: left; cursor: pointer; }
.nav-item span { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 7px; background: rgba(255,255,255,.07); font-size: 12px; }
.nav-item.active { color: #fff; background: var(--nav-soft); }
.nav-item.active span { background: var(--teal); }

.sidebar-note { margin-top: auto; padding: 14px; border: 1px solid rgba(255,255,255,.09); border-radius: 12px; display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.035); }
.sidebar-note strong, .sidebar-note small { display: block; }
.sidebar-note strong { font-size: 12px; }
.sidebar-note small { color: #91a1b1; margin-top: 3px; font-size: 10px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #38c9a8; box-shadow: 0 0 0 5px rgba(56,201,168,.12); }

main { min-width: 0; padding: 38px clamp(24px, 4vw, 58px) 60px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 7px; color: var(--teal); font-size: 10px; font-weight: 800; letter-spacing: .18em; }
h1, h2 { margin: 0; letter-spacing: -.035em; }
h1 { font-size: clamp(28px, 3vw, 38px); }
h2 { font-size: 19px; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.admin-identity { padding: 6px 10px; border-radius: 999px; background: var(--teal-soft); color: #087e73; font-size: 11px; font-weight: 700; }
.muted { color: var(--muted); font-size: 12px; }
.secondary-button { padding: 9px 15px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); cursor: pointer; box-shadow: 0 3px 10px rgba(16,32,51,.04); }
.secondary-button:hover { border-color: #aebbc5; }
.secondary-button:disabled { opacity: .6; cursor: wait; }

.notice { margin-bottom: 18px; padding: 13px 16px; border: 1px solid #e6beb8; border-radius: 10px; background: var(--red-soft); color: #8f3838; font-size: 13px; }
.hidden { display: none !important; }
.view { display: none; }
.view.active-view { display: block; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.metric-card { min-height: 138px; padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: var(--shadow); }
.metric-card span, .metric-card small { display: block; }
.metric-card span { color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; margin: 15px 0 8px; font-size: clamp(24px, 2.4vw, 34px); letter-spacing: -.045em; }
.metric-card small { color: #8a949f; font-size: 11px; }
.metric-card.accent { color: #fff; border-color: var(--teal); background: linear-gradient(140deg, #087e78, #0aa99a); }
.metric-card.accent span, .metric-card.accent small { color: rgba(255,255,255,.75); }
.danger-card strong { color: var(--red); }

.dashboard-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; }
.panel { min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: var(--shadow); }
.wide-panel { grid-column: 1 / -1; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 19px; }
.table-subline { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }
.panel-tag { padding: 5px 9px; border-radius: 999px; background: var(--teal-soft); color: #087e73; font-size: 10px; font-weight: 700; }
.panel-footnote { margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.6; }

.attention-list, .integration-list { display: grid; gap: 9px; }
.attention-row, .integration-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 13px; border-radius: 10px; background: #f7f8f8; }
.attention-row { width: 100%; border: 0; color: var(--ink); text-align: left; }
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: #f0f5f4; }
.attention-row div, .integration-row div { min-width: 0; }
.attention-row strong, .attention-row small, .integration-row strong, .integration-row small { display: block; }
.attention-row strong, .integration-row strong { font-size: 13px; }
.attention-row small, .integration-row small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.count-pill, .state-pill { flex: none; min-width: 30px; padding: 5px 8px; border-radius: 999px; text-align: center; font-size: 11px; font-weight: 800; }
.count-pill { background: var(--amber-soft); color: var(--amber); }
.count-pill.zero { background: var(--teal-soft); color: var(--teal); }
.state-pill.off { background: #edf0f2; color: #7b8793; }
.state-pill.on { background: var(--teal-soft); color: var(--teal); }

.run-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.run-card { padding: 16px; border: 1px solid var(--line); border-radius: 11px; }
.run-card span, .run-card strong, .run-card small { display: block; }
.run-card span { color: var(--muted); font-size: 11px; }
.run-card strong { margin: 8px 0 4px; font-size: 14px; }
.run-card small { color: #8a949f; font-size: 10px; }

.loading-line { height: 40px; border-radius: 9px; background: linear-gradient(90deg, #f0f2f3 25%, #fafbfb 50%, #f0f2f3 75%); background-size: 200% 100%; animation: pulse 1.3s infinite; }
.loading-line.short { width: 72%; }
@keyframes pulse { to { background-position: -200% 0; } }

.split-toolbar { min-height: 44px; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.section-hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.inline-filter { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; }
.inline-filter select { min-width: 130px; padding: 8px 10px; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; }
.primary-button, .danger-button, .text-button { border: 0; border-radius: 9px; cursor: pointer; }
.primary-button { padding: 10px 16px; background: var(--teal); color: #fff; font-weight: 700; box-shadow: 0 7px 15px rgba(10,159,145,.18); }
.primary-button:hover { background: #078a7e; }
.primary-button:disabled, .danger-button:disabled { opacity: .55; cursor: wait; box-shadow: none; }
.danger-button { padding: 9px 14px; background: var(--red); color: #fff; }
.text-button { padding: 6px 9px; background: var(--teal-soft); color: #087e73; font-size: 11px; font-weight: 700; }
.text-button.neutral { background: #edf0f2; color: #596775; }
.text-button.warning { background: var(--amber-soft); color: #986013; }

.segmented { display: flex; padding: 3px; border-radius: 10px; background: #e7ebed; }
.segment { border: 0; border-radius: 8px; padding: 8px 14px; background: transparent; color: var(--muted); cursor: pointer; }
.segment.active { background: #fff; color: var(--ink); box-shadow: 0 2px 7px rgba(16,32,51,.08); }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 0 12px 11px; border-bottom: 1px solid var(--line); color: #7b8793; text-align: left; font-size: 10px; font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
td { padding: 13px 12px; border-bottom: 1px solid #edf0f2; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfb; }
.empty-cell { padding: 28px 10px !important; color: var(--muted); text-align: center; font-size: 12px; }
.pagination { min-height: 42px; margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; }
.pagination-controls { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.pagination-controls label { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.pagination-size { min-width: 58px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font: inherit; }
.pagination-button { padding: 7px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font: inherit; cursor: pointer; }
.pagination-button:hover:not(:disabled) { border-color: var(--teal); color: var(--teal); }
.pagination-button:disabled { opacity: .45; cursor: not-allowed; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 11px; }
.nowrap { white-space: nowrap; }
.status-chip { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; background: #edf0f2; color: #63717d; font-size: 10px; font-weight: 800; white-space: nowrap; }
.status-chip.good { background: var(--teal-soft); color: #087e73; }
.status-chip.warn { background: var(--amber-soft); color: #986013; }
.status-chip.bad { background: var(--red-soft); color: #9c4141; }

.referral-rate-button { width: 100%; margin-top: 12px; }
.detail-head { margin-bottom: 18px; display: flex; justify-content: space-between; gap: 15px; align-items: flex-start; }
.detail-head h2 { margin-bottom: 5px; }
.detail-head p { margin: 0; color: var(--muted); font-size: 11px; }
.customer-identity { margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 7px 18px; color: var(--muted); font-size: 11px; }
.customer-identity span { display: inline-flex; align-items: baseline; gap: 5px; }
.customer-identity strong { color: var(--ink); font-size: 12px; }
.detail-grid { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(0, 1.4fr); gap: 20px; }
.wallet-card { padding: 18px; border-radius: 13px; background: var(--nav); color: #fff; }
.wallet-card > span { color: #9fb0c1; font-size: 11px; }
.wallet-card > strong { display: block; margin: 10px 0 5px; font-size: 28px; }
.wallet-card > small { color: #9fb0c1; }
.subheading { margin: 22px 0 10px; font-size: 13px; }
.compact-list { display: grid; gap: 7px; }
.compact-row { padding: 10px 11px; border: 1px solid var(--line); border-radius: 9px; display: flex; justify-content: space-between; gap: 10px; font-size: 11px; }
.compact-row small { color: var(--muted); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { color: #566474; font-size: 11px; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid #ccd5dc; border-radius: 9px; padding: 10px 11px; background: #fff; color: var(--ink); font: inherit; font-size: 12px; outline: none; }
.field textarea { min-height: 100px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(10,159,145,.11); }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 9px; margin-top: 3px; }
.form-help { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.toggle-field { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 10px; background: #f7f8f8; cursor: pointer; }
.toggle-field.full { grid-column: 1 / -1; }
.toggle-field span, .toggle-field strong, .toggle-field small { display: block; }
.toggle-field strong { color: var(--ink); font-size: 12px; }
.toggle-field small { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.toggle-field input { flex: none; width: 18px; height: 18px; accent-color: var(--teal); }
.sms-config-panels { align-items: start; }
.sms-provider-meta { display: flex; flex-wrap: wrap; gap: 5px 10px; }
.provider-credential-panel { margin-bottom: 18px; }

.two-panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.stack-list { display: grid; gap: 9px; }
.stack-row { padding: 13px; border: 1px solid var(--line); border-radius: 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack-row > div { min-width: 0; }
.stack-row strong, .stack-row small { display: block; }
.stack-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.stack-row small { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.stack-actions { display: flex; gap: 6px; flex: none; }

dialog { width: min(680px, calc(100vw - 30px)); max-height: calc(100vh - 40px); padding: 0; border: 0; border-radius: 15px; box-shadow: 0 24px 80px rgba(16,32,51,.3); }
dialog::backdrop { background: rgba(10,24,39,.57); backdrop-filter: blur(3px); }
.dialog-shell { margin: 0; }
.dialog-shell header { position: sticky; top: 0; z-index: 2; padding: 20px 22px 16px; display: flex; justify-content: space-between; gap: 15px; background: #fff; border-bottom: 1px solid var(--line); }
.dialog-body { padding: 20px 22px 24px; overflow: auto; }
.customer-detail-dialog { width: min(1120px, calc(100vw - 32px)); height: min(820px, calc(100vh - 32px)); max-height: none; }
.customer-detail-dialog .dialog-shell { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.customer-detail-body { min-height: 0; background: #fff; }
.icon-button { width: 34px; height: 34px; border: 0; border-radius: 9px; background: #edf0f2; color: var(--ink); cursor: pointer; font-size: 20px; }
.json-block { margin: 0; padding: 13px; border-radius: 9px; background: #111d2c; color: #c9d6e2; overflow: auto; white-space: pre-wrap; font: 11px/1.55 "SFMono-Regular", Consolas, monospace; }
.dialog-note { margin: 0 0 15px; padding: 12px; border-radius: 9px; background: var(--amber-soft); color: #7a531d; font-size: 11px; line-height: 1.55; }
.dialog-action-row { margin-top: 16px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: min(390px, calc(100vw - 44px)); padding: 12px 15px; border-radius: 10px; background: var(--nav); color: #fff; box-shadow: 0 14px 40px rgba(16,32,51,.25); font-size: 12px; animation: toast-in .2s ease-out; }
.toast.bad { background: #a44242; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 980px) {
  .shell { grid-template-columns: 84px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .brand { padding-inline: 9px; }
  .brand > span:last-child, .nav-item:not(.active) { font-size: 0; }
  .nav-item { justify-content: center; padding-inline: 8px; }
  .nav-item.active { font-size: 0; }
  .nav-item span { font-size: 12px; }
  .sidebar-note div { display: none; }
  .sidebar-note { justify-content: center; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 14px 18px; flex-direction: row; align-items: center; }
  .brand { padding: 0; }
  .brand > span:last-child, .sidebar-note { display: none; }
  nav { margin-left: auto; display: flex; gap: 3px; overflow-x: auto; }
  .nav-item, .nav-item.active { display: flex; width: auto; font-size: 0; padding: 7px; }
  main { padding: 25px 18px 42px; }
  .topbar { align-items: flex-start; }
  .top-actions .muted { display: none; }
  .metrics, .dashboard-grid, .run-grid, .two-panels, .form-grid { grid-template-columns: 1fr; }
  .field.full, .form-actions, .toggle-field.full { grid-column: auto; }
  .split-toolbar, .detail-head { align-items: stretch; flex-direction: column; }
  .customer-detail-dialog { width: calc(100vw - 20px); height: calc(100vh - 20px); }
  .customer-identity { display: grid; gap: 6px; }
  .stack-actions { flex-wrap: wrap; }
  .pagination { align-items: flex-start; flex-direction: column; }
  .pagination-controls { width: 100%; justify-content: space-between; flex-wrap: wrap; }
  .split-toolbar .primary-button { width: 100%; }
  .wide-panel { grid-column: auto; }
}
