/* TP Portal design system — Phase 4.5, Echo CI palette (CI manual 2026-07).
   Primary: white, green #a6ce39, grey #514b49 (foundation).
   Supporting accents: navy #004991, teal #01b5b7, orange #ff751f.
   Orange is reserved for titles/headings/key messages per marketing. */

:root {
  --green: #a6ce39;
  --green-hover: #93b830;
  --grey: #514b49;
  --navy: #004991;
  --teal: #01b5b7;
  --orange: #ff751f;

  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #efeeec;
  --text: #514b49;
  --muted: #857d79;
  --line: #e2dfdd;
  --btn-text: #2e2b29;
  --link: var(--navy);
  --link-hover: #016f70;
  --heading: var(--orange);
  --header-bg: var(--grey);
  --chart: var(--teal);
  --chart-hover: var(--navy);

  --ok-bg: #f3f8e2;    --ok-line: #c4dd82;   --ok-text: #4a6212;
  --warn-bg: #fdeee2;  --warn-line: #f3bd93; --warn-text: #9c4a09;
  --err-bg: #fdeaea;   --err-line: #e3a6a6;  --err-text: #8a1f1f;
  --note-bg: #e2f5f5;  --note-line: #8ed8d9; --note-text: #0d6162;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #181614;
    --surface: #221f1d;
    --surface-2: #2c2927;
    --text: #e9e6e3;
    --muted: #a39c98;
    --line: #3c3835;
    --btn-text: #23211f;
    --link: var(--teal);
    --link-hover: #45d4d6;
    --header-bg: #37332f;
    --chart: var(--teal);
    --chart-hover: var(--green);

    --ok-bg: #2a3313;    --ok-line: #5a6f28;   --ok-text: #c8e178;
    --warn-bg: #3a2410;  --warn-line: #7a4c1e; --warn-text: #f3bd93;
    --err-bg: #351a1a;   --err-line: #6b2f2f;  --err-text: #e3a6a6;
    --note-bg: #10312f;  --note-line: #1e5f60; --note-text: #7edfe0;
  }
}

* { box-sizing: border-box; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0; background: var(--bg); color: var(--text);
  line-height: 1.45; font-size: 0.95rem;
}
main { max-width: 74rem; margin: 1.4rem auto 4rem; padding: 0 1.2rem; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }
h2 { margin: 0.4rem 0 0.6rem; font-size: 1.35rem; font-weight: 700;
     color: var(--heading); }
h3 { margin: 1.1rem 0 0.4rem; font-size: 1.02rem; font-weight: 700;
     color: var(--heading); }
small, .hint { color: var(--muted); }
p.hint { max-width: 44rem; }

/* header / nav */
.site-header {
  background: var(--header-bg); color: #fff;
  padding: 0.55rem 1.2rem;
  display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; align-items: center;
}
.site-header .brand { font-weight: 650; font-size: 1.05rem; color: #fff; }
.site-header .brand small { color: var(--green); font-weight: 400; margin-left: 0.5rem; }
.site-header nav { display: flex; flex-wrap: wrap; gap: 0.15rem; }
.site-header nav a {
  color: #f0ede9; padding: 0.25rem 0.65rem; border-radius: 6px;
}
.site-header nav a:hover { background: rgba(255,255,255,0.13); text-decoration: none; }
.site-header .who {
  margin-left: auto; display: flex; align-items: center; gap: 0.6rem;
  color: #d8d3cf; font-size: 0.85rem;
}
.site-header .who form { margin: 0; }
.site-header .who button {
  background: transparent; border: 1px solid rgba(255,255,255,0.4);
  color: #fff; border-radius: 6px; padding: 0.2rem 0.6rem; cursor: pointer;
  font-size: 0.8rem;
}
.site-header .who button:hover { background: rgba(255,255,255,0.13); }

/* breadcrumbs / page context line */
.crumbs { color: var(--muted); margin: 0 0 0.6rem; }

/* messages */
.msg {
  padding: 0.65rem 0.9rem; border-radius: var(--radius);
  border: 1px solid var(--line); margin: 0.5rem 0; max-width: 46rem;
}
.msg-error { background: var(--err-bg); border-color: var(--err-line); color: var(--err-text); }
.msg-warn  { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-text); }
.msg-ok    { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-text); }
.msg-note  { background: var(--note-bg); border-color: var(--note-line); color: var(--note-text); }

/* cards */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.2rem; max-width: 46rem;
  margin: 0.7rem 0; box-shadow: 0 1px 2px rgba(16, 32, 48, 0.05);
}
.card-sm { max-width: 24rem; }
.card-confirm { border-color: var(--note-line); background: var(--note-bg); }
.card h3:first-child { margin-top: 0; }

/* tables */
.tbl { border-collapse: collapse; background: var(--surface);
       border: 1px solid var(--line); border-radius: var(--radius); }
.tbl-full { width: 100%; }
.tbl th {
  text-align: left; padding: 0.45rem 0.9rem; font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
  border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.tbl td { padding: 0.45rem 0.9rem; border-bottom: 1px solid var(--line); }
.tbl tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; }
.tbl tr:hover td { background: var(--surface-2); }

/* forms & buttons */
button, .btn {
  display: inline-block; background: var(--green); color: var(--btn-text);
  font-weight: 600;
  border: none; border-radius: 6px; padding: 0.45rem 0.95rem;
  font-size: 0.92rem; cursor: pointer; text-decoration: none;
}
button:hover, .btn:hover { background: var(--green-hover); text-decoration: none;
  color: var(--btn-text); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--teal); outline-offset: 2px;
}
input, select {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 0.38rem 0.55rem;
  font-size: 0.92rem; max-width: 100%;
}
label { margin-right: 0.6rem; }
form.inline { display: inline; }

/* badges */
.badge {
  display: inline-block; padding: 0.05rem 0.5rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
  vertical-align: middle; border: 1px solid transparent;
}
.badge-sandbox { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-text); }
.badge-ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-text); }
.badge-muted { background: var(--surface-2); border-color: var(--line); color: var(--muted); }

/* action link rows (solution detail) */
.actions a { margin-right: 0.35rem; }
.danger { color: var(--err-text); }

/* raw JSON blocks */
pre.raw {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.7rem 0.9rem;
  overflow: auto; max-height: 22rem; font-size: 0.8rem;
}

/* responsive: tables scroll rather than break the page */
.tbl-wrap { overflow-x: auto; }
@media (max-width: 640px) {
  main { padding: 0 0.7rem; }
  .site-header { padding: 0.5rem 0.7rem; }
  .site-header .who { flex-basis: 100%; margin-left: 0; }
}

/* print: audit/result pages print clean */
@media print {
  .site-header, .crumbs, form, button { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .msg, .tbl { border-color: #999; box-shadow: none; }
}

/* landing: account picker */
ul.accounts { list-style: none; padding: 0; max-width: 34rem; }
ul.accounts li {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.8rem 1rem; margin: 0.5rem 0;
}
ul.accounts li a { font-weight: 600; font-size: 1.05rem; display: block; }
ul.accounts li small { color: var(--muted); }

/* daily usage bar chart (solution detail) */
.usage-chart {
  display: flex; align-items: flex-end; gap: 2px;
  height: 9rem; max-width: 46rem; padding: 0.6rem 0.6rem 0.2rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.uc-col { flex: 1 1 0; height: 100%; display: flex; align-items: flex-end; min-width: 4px; }
.uc-bar { width: 100%; background: var(--chart); border-radius: 2px 2px 0 0; min-height: 2px; }
.uc-col:hover .uc-bar { background: var(--chart-hover); }

/* solution-detail action bar */
.action-bar {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.6rem; align-items: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.6rem 0.9rem; max-width: 60rem;
  margin: 0.7rem 0;
}
.action-group { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.ag-label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin-right: 0.25rem;
}
.chip {
  display: inline-block; padding: 0.28rem 0.7rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text); font-size: 0.85rem;
}
.chip:hover { border-color: var(--teal); color: var(--link-hover);
              text-decoration: none; }
.action-bar .btn { padding: 0.28rem 0.8rem; font-size: 0.85rem; border-radius: 999px; }

/* service facts card */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
         gap: 0.55rem 1.4rem; max-width: 60rem; }
.fact { display: flex; flex-direction: column; }
.f-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
           color: var(--muted); }
.f-value { font-weight: 550; overflow-wrap: anywhere; }

/* ---- Phase 4.6: balance tiles + wallet panels --------------------------- */
/* Two expandable tiles (Neil 2026-07-23): face = headline balance, panel =
   per-part bars/auto-topup/ledger, lazy-loaded as an HTMX fragment. */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
         gap: 0.7rem; max-width: 46rem; align-items: start; }
details.tile { padding: 0; margin: 0; overflow: hidden; }
details.tile summary { list-style: none; cursor: pointer; padding: 0.85rem 1.1rem;
                       position: relative; display: block; }
details.tile summary::-webkit-details-marker { display: none; }
details.tile summary::after { content: "▾"; position: absolute; right: 1rem;
                              top: 0.85rem; color: var(--muted);
                              transition: transform 0.15s; }
details.tile[open] summary::after { transform: rotate(180deg); }
details.tile summary:hover { background: var(--surface-2); }
details.tile summary:focus-visible { outline: 2px solid var(--teal); outline-offset: -2px; }
.tile .t-big { display: block; font-size: 1.7rem; font-weight: 700;
               letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.tile .t-cap { display: block; font-size: 0.8rem; color: var(--muted);
               text-transform: uppercase; letter-spacing: 0.05em; }
.tile .t-sub { display: block; font-size: 0.8rem; color: var(--muted);
               margin-top: 0.25rem; }
.tile-panel { border-top: 1px solid var(--line); padding: 0.8rem 1.1rem 1rem; }

/* wallet bundle rows (no charts — kept simple for support, Neil 2026-07-23) */
.w-part { padding: 0.45rem 0; border-top: 1px solid var(--line); }
.w-part:first-of-type { border-top: none; padding-top: 0; }
.w-part-head { display: flex; justify-content: space-between; gap: 0.3rem 1rem;
               flex-wrap: wrap; }
.w-part-name { font-weight: 600; }
.w-part-meta { color: var(--muted); font-size: 0.85rem;
               font-variant-numeric: tabular-nums; }
/* nested progressive-disclosure block inside a tile panel */
details.more { margin-top: 0.7rem; }
details.more summary { cursor: pointer; color: var(--link); font-size: 0.85rem; }
details.more summary:hover { color: var(--link-hover); }
details.more summary:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
details.more[open] summary { margin-bottom: 0.35rem; }

.panel-h { margin: 0.9rem 0 0.25rem; font-size: 0.75rem; text-transform: uppercase;
           letter-spacing: 0.05em; color: var(--muted); }
.at-line { margin: 0.15rem 0; }
.mini-ledger { width: 100%; border-collapse: collapse; font-size: 0.85rem;
               font-variant-numeric: tabular-nums; }
.mini-ledger td { padding: 0.25rem 0.4rem 0.25rem 0; border-bottom: 1px solid var(--line); }
.mini-ledger tr:last-child td { border-bottom: none; }
.mini-ledger .num { text-align: right; }

/* loading skeletons + progress (fragments must always show progress) */
.skel { color: var(--muted); }
.spinner { display: inline-block; width: 0.9em; height: 0.9em; margin-right: 0.45rem;
           border: 2px solid var(--line); border-top-color: var(--teal);
           border-radius: 50%; vertical-align: -0.15em;
           animation: tp-spin 0.8s linear infinite; }
@keyframes tp-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  details.tile summary::after { transition: none; }
}
/* htmx: dim a retry link while its request is in flight */
.htmx-request { opacity: 0.6; pointer-events: none; }