/* =====================================================================
   Community Services — mobile-first HTML5 application design system
   Senior-friendly: large text, big touch targets, high contrast
   Prebuilt stack: Bootstrap 5.3 + Bootstrap Icons + Chart.js (CDN)
   ===================================================================== */

:root {
  --paper: #ffffff;
  --wash: #f5f7fb;
  --ink: #0f172a;
  --muted: #4a5568;
  --line: #d2d6dc;

  --brand: #0e7490;
  --brand-2: #14b8a6;
  --brand-soft: #e2f3f7;
  --brand-deep: #0a4f63;

  --accent: #f59e0b;
  --accent-soft: #fef3d9;

  --good: #059669;
  --good-soft: #e3f6ef;
  --bad: #dc2626;
  --bad-soft: #fdeaea;
  --warn: #d97706;
  --warn-soft: #fdf1df;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 7px;

  --shadow-sm: 0 1px 2px rgb(15 23 42 / .05), 0 1px 3px rgb(15 23 42 / .07);
  --shadow-md: 0 6px 20px -6px rgb(15 23 42 / .14);
  --shadow-lg: 0 16px 40px -12px rgb(15 23 42 / .2);

  --mono: "SFMono-Regular", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
  --display: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* mobile-first sizing */
  --fs-base: 18px;
  --fs-lg: 22px;
  --fs-xl: 28px;
  --fs-2xl: 36px;
  --fs-stat: 2.2rem;
  --tap-min: 52px;
  --gap: 16px;
}

/* ---------- base (mobile first) ---------- */

html { scroll-behavior: smooth; }

body {
  font-family: var(--display);
  font-size: var(--fs-base);
  line-height: 1.6;
  background: var(--wash);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4, .h1, .h2, .h3, .h4 { letter-spacing: -.02em; color: var(--ink); }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-deep); }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.small-caps { text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; font-weight: 700; }
.muted { color: var(--muted); }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- app chrome ---------- */

.app-nav {
  background: rgb(255 255 255 / .92);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1030;
}
.app-nav .navbar-brand { font-weight: 800; letter-spacing: -.02em; font-size: 1.1rem; }
.app-nav .brand-dot {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  margin-right: .45rem; vertical-align: 1px;
}
.app-nav .nav-link { font-weight: 600; color: var(--muted); min-height: var(--tap-min); display: inline-flex; align-items: center; }
.app-nav .nav-link.active, .app-nav .nav-link:hover { color: var(--brand); }

.wrap { max-width: 1180px; margin-inline: auto; padding-inline: clamp(16px, 4vw, 32px); }

/* ---------- mobile nav toggle ---------- */

.navbar-toggler {
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  border: 2px solid var(--line);
  border-radius: var(--radius-xs);
  padding: .5rem;
}
.navbar-toggler:focus { box-shadow: 0 0 0 3px var(--brand-soft); }

/* ---------- panels & surfaces ---------- */

.panel {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel-pad { padding: clamp(16px, 4vw, 24px); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px;
  border-bottom: 2px solid var(--line);
  flex-wrap: wrap;
}
.panel-head .small-caps { margin: 0; }
.panel-title { font-size: var(--fs-lg); font-weight: 700; margin: 0; }

.section-label {
  font-size: .82rem; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}

/* ---------- stats / chips ---------- */

.stat {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.stat .stat-label {
  font-size: .82rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted);
}
.stat .stat-value { font-size: var(--fs-stat); font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }
.stat .stat-foot { font-size: .88rem; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.stat .stat-ico {
  position: absolute; right: 16px; top: 16px;
  width: 40px; height: 40px; border-radius: var(--radius-xs);
  display: grid; place-items: center; font-size: 1.2rem;
}

.badge-soft { font-weight: 700; border-radius: 999px; padding: .4em .85em; font-size: .82rem; }
.bge-brand { background: var(--brand-soft); color: var(--brand-deep); }
.bge-good  { background: var(--good-soft);  color: var(--good); }
.bge-bad   { background: var(--bad-soft);   color: var(--bad); }
.bge-warn  { background: var(--warn-soft);  color: var(--warn); }
.bge-accent{ background: var(--accent-soft);color: #92400e; }
.bge-line  { background: var(--wash); color: var(--muted); border: 2px solid var(--line); }

.pill-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .4rem; vertical-align: 1px; }
.pill-dot.on { background: var(--good); box-shadow: 0 0 0 4px var(--good-soft); }
.pill-dot.off { background: var(--muted); }
.pill-dot.alert { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }

/* ---------- progress / gauges ---------- */

.meter { background: var(--wash); border: 2px solid var(--line); border-radius: 999px; height: 12px; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand-2), var(--brand)); }
.meter.good > span { background: linear-gradient(90deg, #34d399, var(--good)); }
.meter.warn > span { background: linear-gradient(90deg, #fbbf24, var(--warn)); }

/* ---------- ticket / contract cards ---------- */

.ticket {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.ticket:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: #cbd7e6; }
.ticket .t-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 0; }
.ticket .t-body { padding: 12px 16px 16px; }
.ticket .t-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin-top: 10px; }
.ticket .t-field { font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.ticket .t-val { font-size: 1rem; font-weight: 650; word-break: break-word; }
.ticket .t-val.mono { font-size: .92rem; }

/* ---------- node cards (CCasHC) ---------- */

.node { position: relative; }
.node .node-badge { position: absolute; top: 14px; right: 14px; }
.node .node-ico {
  width: 48px; height: 48px; border-radius: var(--radius-xs);
  display: grid; place-items: center; font-size: 1.4rem;
  background: var(--brand-soft); color: var(--brand-deep);
}
.node.hub .node-ico { background: var(--brand-deep); color: #fff; }
.node.spoke .node-ico { background: var(--accent-soft); color: #92400e; }
.node.micro .node-ico { background: var(--good-soft); color: var(--good); }

/* ---------- data table ---------- */

.app-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.app-table th {
  text-align: left; font-size: .78rem; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
  padding: 12px 16px; border-bottom: 2px solid var(--line); white-space: nowrap;
}
.app-table td { padding: 14px 16px; border-bottom: 2px solid var(--line); vertical-align: middle; }
.app-table tbody tr:hover { background: #fafcfe; }
.app-table tbody tr:last-child td { border-bottom: 0; }

/* ---------- forms (mobile-optimized, senior-friendly) ---------- */

.form-label { font-size: var(--fs-base); font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.form-control, .form-select {
  border-color: var(--line); border-radius: var(--radius-xs); font-size: var(--fs-base);
  padding: .65rem .85rem; min-height: var(--tap-min);
}
.form-control:focus, .form-select:focus { border-color: var(--brand-2); box-shadow: 0 0 0 .25rem rgb(20 184 166 / .2); }
.input-group-text { background: var(--wash); border-color: var(--line); color: var(--muted); font-size: var(--fs-base); min-height: var(--tap-min); }

.btn {
  border-radius: var(--radius-xs); font-weight: 700; padding: .6rem 1.2rem;
  font-size: var(--fs-base); min-height: var(--tap-min); display: inline-flex; align-items: center; gap: .5rem;
}
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-deep); border-color: var(--brand-deep); color: #fff; }
.btn-ghost { background: transparent; border: 2px solid var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.btn-lg2 { padding: .75rem 1.5rem; font-size: var(--fs-lg); border-radius: var(--radius-sm); }

/* mobile: full-width buttons by default */
.d-grid .btn, .btn-block { width: 100%; justify-content: center; }

/* ---------- footer ---------- */

.app-foot {
  border-top: 2px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  font-size: .88rem;
}

/* ---------- CTA hero band ---------- */

.hero-band {
  background: linear-gradient(120deg, var(--brand-deep), var(--brand) 55%, var(--brand-2));
  color: #fff; border-radius: var(--radius);
}
.hero-band h1, .hero-band h2 { color: #fff; }
.hero-band .muted { color: rgb(255 255 255 / .75); }

/* =====================================================================
   TRADING-TERMINAL THEME (UMG)
   Scoped via <body class="theme-trade">
   ===================================================================== */

body.theme-trade {
  --paper: #10172b;
  --wash: #0b1120;
  --ink: #e6edf7;
  --muted: #8b9bb8;
  --line: #1e2b45;
  --brand: #22d3ee;
  --brand-2: #2dd4bf;
  --brand-soft: rgb(34 211 238 / .12);
  --brand-deep: #67e8f9;
  --good: #34d399;
  --good-soft: rgb(52 211 153 / .12);
  --bad: #fb7185;
  --bad-soft: rgb(251 113 133 / .12);
  --warn: #fbbf24;
  --warn-soft: rgb(251 191 36 / .12);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
  --shadow-md: 0 8px 24px -8px rgb(0 0 0 / .55);
  --shadow-lg: 0 18px 44px -14px rgb(0 0 0 / .6);
  background: var(--wash);
}
body.theme-trade h1, body.theme-trade h2, body.theme-trade h3, body.theme-trade h4,
body.theme-trade .h1, body.theme-trade .h2, body.theme-trade .h3, body.theme-trade .h4 { color: var(--ink); }
body.theme-trade .panel, body.theme-trade .stat, body.theme-trade .ticket {
  background: var(--paper); border-color: var(--line);
}
body.theme-trade .app-nav { background: rgb(11 17 32 / .92); border-color: var(--line); }
body.theme-trade .app-nav .nav-link { color: var(--muted); }
body.theme-trade .app-nav .nav-link.active, body.theme-trade .app-nav .nav-link:hover { color: var(--brand); }
body.theme-trade .app-table tbody tr:hover { background: rgb(34 211 238 / .04); }
body.theme-trade .app-table td { border-color: var(--line); }
body.theme-trade .form-control, body.theme-trade .form-select {
  background: #0d1526; border-color: var(--line); color: var(--ink);
}
body.theme-trade .form-control::placeholder { color: #54627d; }
body.theme-trade .meter { background: #0d1526; border-color: var(--line); }
body.theme-trade .app-foot { background: var(--paper); border-color: var(--line); }
body.theme-trade .bge-line { background: #0d1526; color: var(--muted); border-color: var(--line); }

/* ---------- order book flash rows ---------- */

td.pos, .pos { color: var(--good); font-weight: 700; }
td.neg, .neg { color: var(--bad); font-weight: 700; }
.flatline { color: var(--muted); }

/* =====================================================================
   RESPONSIVE — tablet and up (mobile styles are the default)
   ===================================================================== */

@media (min-width: 768px) {
  :root {
    --fs-base: 17px;
    --fs-lg: 20px;
    --fs-xl: 26px;
    --fs-2xl: 34px;
    --fs-stat: 2rem;
    --gap: 24px;
  }
}

@media (min-width: 1024px) {
  :root {
    --fs-base: 16px;
    --fs-lg: 19px;
    --fs-xl: 24px;
    --fs-2xl: 32px;
    --fs-stat: 1.8rem;
  }
  .stat .stat-value { font-size: var(--fs-stat); }
}
