.billing { --bill-panel:#fff; --bill-bg:#f5f7fb; --bill-ink:#16283e; --bill-muted:#596c80; --bill-line:#dbe3ec; --bill-accent:#174b71; color:var(--bill-ink); margin:20px auto; max-width:1320px; padding:24px; background:var(--bill-panel); border:1px solid var(--bill-line); border-radius:14px; box-sizing:border-box; }
.billing[hidden], .billing [hidden], #billing-nav[hidden] { display:none !important; }
.billing *, .billing *::before, .billing *::after { box-sizing:border-box; }
.damage-dashboard .billing h2 { margin:0; font-size:1.7rem; line-height:1.3; color:var(--bill-ink); }
.damage-dashboard .billing h3 { font-size:1.25rem; margin:0 0 16px; color:var(--bill-ink); }
.billing p { margin:6px 0 12px; }
.billing-eyebrow { font-size:.7rem; letter-spacing:.16em; font-weight:700; color:var(--bill-accent); }
.billing-muted { color:var(--bill-muted); font-size:.85rem; }
.billing-header, .billing-header-actions, .billing-toolbar, .billing-pagination { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:12px; }
.billing-header { margin-bottom:14px; }
.billing button { background:var(--bill-panel); color:var(--bill-ink); border:1px solid var(--bill-line); border-radius:7px; padding:8px 13px; cursor:pointer; font:inherit; font-size:.85rem; line-height:1.4; box-shadow:none; margin:0; }
.billing button:hover { background:var(--bill-bg); border-color:var(--bill-accent); }
.billing button:focus-visible, .billing input:focus-visible, .billing select:focus-visible, .billing textarea:focus-visible { outline:3px solid #77b7df; outline-offset:2px; }
.billing button:disabled { opacity:.5; cursor:wait; }
.billing button.billing-primary { background:var(--bill-accent); color:white; border-color:var(--bill-accent); }
.billing .billing-nav { display:flex; flex-wrap:wrap; gap:6px; border-bottom:1px solid var(--bill-line); padding:14px 0; margin-bottom:18px; }
.billing-nav button[aria-pressed="true"] { background:var(--bill-bg); color:var(--bill-accent); border-color:var(--bill-accent); font-weight:650; }
.billing-toolbar { justify-content:flex-start; margin:12px 0 18px; align-items:flex-end; }
.billing label { display:flex; flex-direction:column; gap:5px; font-size:.8rem; font-weight:600; margin:0; }
.billing input, .billing select, .billing textarea { color:var(--bill-ink); background:var(--bill-panel); border:1px solid var(--bill-line); padding:9px; border-radius:6px; width:100%; min-width:0; box-shadow:none; margin:0; font:inherit; font-weight:400; font-size:.9rem; }
.billing textarea { resize:vertical; }
.billing .billing-check { flex-direction:row; align-items:center; margin:14px 0; font-weight:400; }
.billing-check input { width:auto; accent-color:var(--bill-accent); }
.billing-table-scroll { overflow:auto; border:1px solid var(--bill-line); border-radius:8px; }
.billing table { border-collapse:collapse; width:100%; background:var(--bill-panel); margin:0; font-size:.85rem; }
.billing th { text-align:left; font-weight:650; font-size:.75rem; background:var(--bill-bg); color:var(--bill-muted); white-space:nowrap; }
.billing th, .billing td { padding:12px; border:0; border-bottom:1px solid var(--bill-line); vertical-align:top; }
.billing tr:last-child td { border-bottom:0; }
.billing td .billing-muted { display:block; margin-top:4px; white-space:nowrap; }
.billing td.billing-money { font-variant-numeric:tabular-nums; white-space:nowrap; text-align:right; }
.billing td.billing-description { white-space:pre-wrap; min-width:220px; max-width:560px; overflow-wrap:anywhere; }
.billing td.billing-actions { display:flex; gap:6px; flex-wrap:wrap; min-width:140px; }
.billing-badge { display:inline-block; border-radius:20px; padding:3px 9px; font-size:.73rem; font-weight:600; background:#eaf0f6; color:#244561; white-space:nowrap; }
.billing-badge[data-state="paid"], .billing-badge[data-state="sent"], .billing-badge[data-state="active"], .billing-badge[data-state="minted"] { color:#155739; background:#e5f3ea; }
.billing-badge[data-state="unknown"], .billing-badge[data-state="issue_failed"], .billing-badge[data-state="failed"] { color:#823710; background:#fff0da; }
.billing-badge[data-state="void"], .billing-badge[data-state="paused"] { color:#666; background:#eee; }
.billing-notice { padding:11px 14px; border-radius:7px; background:var(--bill-bg); border-left:4px solid var(--bill-accent); overflow-wrap:anywhere; }
.billing-notice[data-error="true"], .billing-form-error { color:#8d341d; background:#fff1eb; border-left:4px solid #c76535; padding:10px; }
.billing-pagination { justify-content:flex-end; font-size:.8rem; margin:14px 0; }
.billing-detail { margin-top:22px; border:1px solid var(--bill-line); border-radius:10px; padding:20px; background:var(--bill-bg); }
.billing-detail header { display:flex; flex-wrap:wrap; justify-content:space-between; gap:10px; }
.billing-detail dl { display:grid; grid-template-columns:130px 1fr; gap:6px 16px; font-size:.9rem; }
.billing-detail dt { color:var(--bill-muted); }
.billing-detail dd { margin:0; overflow-wrap:anywhere; white-space:pre-wrap; }
.billing-detail details, .billing details { margin-top:18px; }
.billing-detail summary { cursor:pointer; font-size:.85rem; }
.billing-audit { font-size:.8rem; overflow-wrap:anywhere; padding:9px 0; border-bottom:1px solid var(--bill-line); }
.billing-empty { padding:35px !important; text-align:center; color:var(--bill-muted); }
.billing dialog { color:var(--bill-ink); background:var(--bill-panel); width:min(900px, 96vw); max-height:90vh; padding:24px; border:1px solid var(--bill-line); border-radius:12px; box-shadow:0 24px 100px #102b4a55; overflow:auto; }
.billing dialog::backdrop { background:#07172b88; }
.billing dialog footer { display:flex; justify-content:flex-end; gap:10px; padding-top:18px; }
.billing dialog form > label { margin:14px 0; }
.billing-form-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; margin-bottom:16px; }
.billing-lines { overflow-x:auto; margin:16px 0 8px; }
.billing-line { display:grid; grid-template-columns:minmax(230px,1fr) 60px 100px 100px 80px 36px; min-width:700px; gap:8px; align-items:end; padding-bottom:14px; }
.billing-line button { padding:8px; }
.billing-file-label input { font-size:.75rem; max-width:230px; }
.billing-sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); }
.dark-mode .billing { --bill-panel:#1b2635; --bill-bg:#233244; --bill-ink:#edf4fc; --bill-muted:#b2c2d4; --bill-line:#3c4c60; --bill-accent:#6ba8d3; }
.dark-mode .billing button.billing-primary { color:#0b2335; }
@media(max-width:700px) { .billing { padding:15px; margin:12px 0; } .billing-header { align-items:flex-start; } .billing-form-grid { grid-template-columns:1fr; } .billing-detail { padding:13px; } .billing-detail dl { grid-template-columns:1fr; gap:3px; } .billing-detail dd { margin-bottom:10px; } .billing dialog { padding:17px; } .billing table { min-width:640px; } }
@media print { .billing-nav, .billing-toolbar, .billing-pagination, .billing button { display:none; } .billing { border:0; } }

/* Billing workspace overview and settlement rewards. */
#billing-nav-group[hidden] { display:none !important; }
.billing-overview { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; margin:18px 0; }
.billing-stat { border:1px solid var(--bill-line); background:var(--bill-bg); border-radius:10px; padding:15px; min-width:0; }
.billing-stat > span { display:block; color:var(--bill-muted); font-size:.75rem; font-weight:650; text-transform:uppercase; letter-spacing:.05em; }
.billing-stat > strong { display:block; margin:5px 0 3px; font-size:1.55rem; line-height:1.15; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
.billing-stat > small { color:var(--bill-muted); font-size:.75rem; line-height:1.35; }
.billing-commandbar { display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap; border:1px solid var(--bill-line); border-radius:10px; padding:14px 16px; background:var(--bill-panel); }
.billing-commandbar > div:first-child { display:flex; flex-direction:column; gap:2px; }
.billing-reward-option { margin:16px 0; padding:14px; border:1px solid var(--bill-line); border-radius:9px; background:var(--bill-bg); }
.billing-reward-option .billing-check { margin:0 0 8px; font-weight:650; }
.billing-reward-card { margin-top:16px; padding:14px; border:1px solid var(--bill-line); border-radius:9px; background:var(--bill-panel); }
.billing-reward-card strong { display:block; margin-bottom:5px; }
.billing-token-ref { font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; overflow-wrap:anywhere; font-size:.8rem; }
@media(max-width:1000px) { .billing-overview { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media(max-width:560px) { .billing-overview { grid-template-columns:1fr; } .billing-commandbar .billing-header-actions { width:100%; } .billing-commandbar .billing-header-actions button { flex:1 1 auto; } }
.billing-settings-form fieldset { border:1px solid var(--bill-line); border-radius:10px; padding:18px; margin:0 0 18px; }
.billing-settings-form legend { padding:0 7px; font-weight:700; color:var(--bill-accent); }
.billing-settings-heading { display:flex; justify-content:space-between; align-items:flex-start; gap:20px; margin-bottom:18px; }
.billing-settings-form > footer { display:flex; justify-content:flex-end; padding-top:4px; }
.billing-logo-preview-wrap { min-width:150px; min-height:72px; display:flex; align-items:center; justify-content:flex-end; }
.billing-logo-preview-wrap img { display:block; max-width:180px; max-height:72px; object-fit:contain; border:1px solid var(--bill-line); border-radius:8px; padding:8px; background:#fff; }
.billing code { font-size:.9em; }
@media(max-width:700px) { .billing-settings-heading { flex-direction:column; } .billing-logo-preview-wrap { justify-content:flex-start; } }

/* -------------------------------------------------------------------------
 * Dashboard shell integration
 *
 * Billing is a dashboard workspace, not a standalone light modal. Keep the
 * generic rules above as a fallback, then map the component onto the shell's
 * design tokens when it is rendered inside .damage-dashboard.
 * ------------------------------------------------------------------------- */
.damage-dashboard #billing-tab {
  overflow-x: clip;
}

.damage-dashboard .billing {
  --bill-panel: var(--ws-panel);
  --bill-bg: var(--ws-bg);
  --bill-input: var(--ws-input);
  --bill-raised: var(--ws-raised);
  --bill-ink: var(--ws-text);
  --bill-muted: var(--ws-muted);
  --bill-line: var(--ws-line);
  --bill-accent: var(--ws-accent);
  --bill-accent-text: var(--ws-accent-text);

  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--bill-ink);
  color-scheme: dark;
}

.damage-dashboard .billing-header {
  min-height: 72px;
  margin: 0 0 18px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--bill-line);
}
.damage-dashboard .billing-header > div:first-child {
  min-width: 0;
}
.damage-dashboard .billing-eyebrow {
  margin: 0 0 5px;
  color: #91a4bc;
  font-size: 10px;
  line-height: 1.4;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.damage-dashboard .billing h2#billing-title {
  margin: 0;
  color: var(--bill-ink);
  font-size: clamp(22px, 2vw, 28px);
  font-weight: 650;
  letter-spacing: -.5px;
}
.damage-dashboard .billing-header .billing-muted {
  margin: 5px 0 0;
  font-size: 12px;
}
.damage-dashboard .billing-muted {
  color: var(--bill-muted);
}

.damage-dashboard .billing button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--bill-line);
  border-radius: 7px;
  background: var(--bill-raised);
  color: var(--bill-ink);
  box-shadow: none;
  font-size: 12px;
  font-weight: 550;
  transform: none;
}
.damage-dashboard .billing button:hover {
  border-color: #697b90;
  background: #28364a;
  color: var(--bill-ink);
  transform: none;
}
.damage-dashboard .billing button.billing-primary {
  border-color: var(--bill-accent);
  background: var(--bill-accent);
  color: var(--bill-accent-text);
  font-weight: 700;
}
.damage-dashboard .billing button.billing-primary:hover {
  border-color: #c5ef95;
  background: #c5ef95;
  color: var(--bill-accent-text);
}
.damage-dashboard .billing button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.damage-dashboard .billing-overview {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 14px;
}
.damage-dashboard .billing-stat {
  min-height: 112px;
  padding: 15px 16px;
  border: 1px solid var(--bill-line);
  border-radius: 10px;
  background: var(--bill-panel);
}
.damage-dashboard .billing-stat > span {
  color: #93a5bb;
  font-size: 10px;
  letter-spacing: .8px;
}
.damage-dashboard .billing-stat > strong {
  margin: 7px 0 5px;
  color: var(--bill-ink);
  font-size: 23px;
  font-weight: 650;
}
.damage-dashboard .billing-stat > small {
  color: var(--bill-muted);
  font-size: 11px;
}

.damage-dashboard .billing-commandbar {
  margin: 0 0 8px;
  padding: 13px 15px;
  border: 1px solid var(--bill-line);
  border-radius: 10px;
  background: var(--bill-panel);
}
.damage-dashboard .billing-commandbar strong {
  color: var(--bill-ink);
  font-size: 13px;
}
.damage-dashboard #billing-clock {
  margin: 8px 1px 0;
  font-size: 11px;
}

.damage-dashboard .billing .billing-nav {
  gap: 4px;
  margin: 16px 0 14px;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--bill-line);
}
.damage-dashboard .billing .billing-nav button {
  min-height: 34px;
  padding: 7px 10px;
  border-color: transparent;
  background: transparent;
  color: #adbbce;
}
.damage-dashboard .billing .billing-nav button:hover {
  border-color: var(--bill-line);
  background: var(--bill-raised);
  color: var(--bill-ink);
}
.damage-dashboard .billing .billing-nav button[aria-pressed="true"] {
  border-color: #46573d;
  background: #213027;
  color: #d7efbb;
  font-weight: 650;
}

.damage-dashboard .billing > section[data-billing-content] {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--bill-line);
  border-radius: 12px;
  background: var(--bill-panel);
}
.damage-dashboard .billing-toolbar {
  gap: 10px;
  margin: 0 0 14px;
}
.damage-dashboard .billing label {
  color: #c8d3e2;
  font-size: 11px;
  font-weight: 600;
}
.damage-dashboard .billing input,
.damage-dashboard .billing select,
.damage-dashboard .billing textarea {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid #35455a;
  border-radius: 7px;
  background: var(--bill-input);
  color: var(--bill-ink);
  box-shadow: none;
  font-size: 13px;
}
.damage-dashboard .billing textarea {
  min-height: 84px;
}
.damage-dashboard .billing input::placeholder,
.damage-dashboard .billing textarea::placeholder {
  color: #718299;
}
.damage-dashboard .billing :is(input, select, textarea):hover {
  border-color: #53647a;
}
.damage-dashboard .billing :is(input, select, textarea):focus {
  border-color: #768d65;
  outline: none;
}
.damage-dashboard .billing .billing-check {
  color: var(--bill-muted);
}
.damage-dashboard .billing-check input {
  min-height: 0;
  accent-color: var(--bill-accent);
}

.damage-dashboard .billing-table-scroll {
  max-width: 100%;
  border: 1px solid var(--bill-line);
  border-radius: 9px;
  background: var(--bill-input);
  scrollbar-color: #46566b transparent;
}
.damage-dashboard .billing table {
  background: transparent;
  color: var(--bill-ink);
}
.damage-dashboard .billing th {
  padding: 11px 12px;
  border-bottom: 1px solid var(--bill-line);
  background: #182231;
  color: #9aabc0;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .25px;
}
.damage-dashboard .billing td {
  padding: 12px;
  border-bottom: 1px solid #253345;
  background: transparent;
  color: #dce5f1;
  font-size: 12px;
}
.damage-dashboard .billing tbody tr:hover td {
  background: #172130;
}
.damage-dashboard .billing-empty {
  min-height: 106px;
  padding: 34px !important;
  color: #8899af !important;
}
.damage-dashboard .billing-pagination {
  margin: 12px 0 0;
  color: var(--bill-muted);
}

.damage-dashboard .billing-badge {
  border: 1px solid #3b4b60;
  background: #1b2737;
  color: #c8d4e4;
}
.damage-dashboard .billing-badge[data-state="paid"],
.damage-dashboard .billing-badge[data-state="sent"],
.damage-dashboard .billing-badge[data-state="active"],
.damage-dashboard .billing-badge[data-state="minted"] {
  border-color: #3e604d;
  background: #193126;
  color: #aee0bd;
}
.damage-dashboard .billing-badge[data-state="unknown"],
.damage-dashboard .billing-badge[data-state="issue_failed"],
.damage-dashboard .billing-badge[data-state="failed"] {
  border-color: #765235;
  background: #392719;
  color: #ffd0a3;
}
.damage-dashboard .billing-badge[data-state="void"],
.damage-dashboard .billing-badge[data-state="paused"] {
  border-color: #444f5e;
  background: #252d38;
  color: #aeb9c8;
}

.damage-dashboard .billing-notice {
  margin: 0 0 14px;
  border: 1px solid #40546a;
  border-left: 3px solid var(--bill-accent);
  background: #172232;
  color: #d8e3f1;
}
.damage-dashboard .billing-notice[data-error="true"],
.damage-dashboard .billing-form-error {
  border: 1px solid #704844;
  border-left: 3px solid #d17066;
  background: #321f20;
  color: #ffc2bd;
}

.damage-dashboard .billing-detail {
  margin-top: 16px;
  padding: 18px;
  border-color: var(--bill-line);
  background: var(--bill-input);
}
.damage-dashboard .billing-detail dt {
  color: #91a4bb;
}
.damage-dashboard .billing-detail dd {
  color: #dce5f1;
}
.damage-dashboard .billing-audit {
  border-color: var(--bill-line);
}

.damage-dashboard .billing-settings-form fieldset {
  border-color: var(--bill-line);
  background: var(--bill-input);
}
.damage-dashboard .billing-settings-form legend {
  color: #cfe8b3;
}
.damage-dashboard .billing-logo-preview-wrap img {
  border-color: var(--bill-line);
  background: #f7f8fa;
}
.damage-dashboard .billing-reward-option,
.damage-dashboard .billing-reward-card {
  border-color: var(--bill-line);
  background: var(--bill-input);
}

.damage-dashboard .billing dialog {
  width: min(900px, calc(100vw - 32px));
  border: 1px solid #3a4a5f;
  border-radius: 12px;
  background: var(--bill-panel);
  color: var(--bill-ink);
  box-shadow: 0 24px 90px #000a;
  color-scheme: dark;
}
.damage-dashboard .billing dialog::backdrop {
  background: #050a14bf;
  backdrop-filter: blur(2px);
}
.damage-dashboard .billing dialog footer {
  border-top: 1px solid var(--bill-line);
  margin-top: 18px;
  padding-top: 14px;
}

@media (max-width: 1100px) {
  .damage-dashboard .billing-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 700px) {
  .damage-dashboard .billing-header {
    align-items: flex-start;
  }
  .damage-dashboard .billing > section[data-billing-content] {
    padding: 14px;
  }
  .damage-dashboard .billing-overview {
    grid-template-columns: 1fr;
  }
  .damage-dashboard .billing-commandbar {
    align-items: flex-start;
  }
  .damage-dashboard .billing-commandbar .billing-header-actions,
  .damage-dashboard .billing-header > .billing-header-actions {
    width: 100%;
  }
  .damage-dashboard .billing-commandbar .billing-header-actions button {
    flex: 1 1 auto;
  }
  .damage-dashboard .billing .billing-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: thin;
  }
  .damage-dashboard .billing .billing-nav button {
    flex: 0 0 auto;
  }
  .damage-dashboard .billing-toolbar {
    align-items: stretch;
  }
  .damage-dashboard .billing-toolbar label {
    flex: 1 1 180px;
  }
  .damage-dashboard .billing table {
    min-width: 720px;
  }
}
