:root {
  color-scheme: dark;
  --bg: #060708;
  --panel: #0a0c0f;
  --panel-2: #0d1014;
  --line: #242a32;
  --line-soft: #171c22;
  --text: #c9d1d9;
  --muted: #727b86;
  --accent: #8a919e;
  --warn: #c99b3a;
  --good: #2fbf71;
  --bad: #d95a64;
}

* { box-sizing: border-box; }
html { background: var(--bg); font-size: 11px; min-height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  overflow-x: auto;
  background: #060708;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  line-height: 1.25;
}

.shell {
  width: min(1680px, 100%);
  min-width: 1180px;
  margin: 0 auto;
  padding: 8px 10px 14px;
}

.topbar {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  background: #07090c;
  padding: 0 10px;
  margin-bottom: 6px;
}

.brand-block { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
h1, h2, p { margin: 0; }
h1 { font-size: 14px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; color: #d6dde7; }
.eyebrow, .panel-title small, label, .fee-grid span, .link-list small, .data-row span, .metric-line span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.top-meta { display: flex; align-items: center; gap: 6px; }

.status-pill, .terminal-button {
  height: 24px;
  border: 1px solid var(--line);
  background: #0b0e12;
  color: var(--muted);
  padding: 0 8px;
  font: 750 10px/22px ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.status-pill.good { color: var(--good); border-color: #1e5b3d; }
.status-pill.danger { color: var(--bad); border-color: #66313a; }
.terminal-button { cursor: pointer; }
.terminal-button:hover, .quick-row button:hover, .chart-controls button:hover, .link-list a:hover, .link-action:hover, .settlement-button:hover { border-color: var(--accent); color: #e5e7eb; }

.terminal-grid {
  display: grid;
  grid-template-columns: 1.12fr .84fr 1.22fr;
  grid-template-areas:
    "price tape converter"
    "price fees links";
  gap: 6px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 9px;
  min-height: 0;
}
.price-panel { grid-area: price; }
.tape-panel { grid-area: tape; }
.converter-panel { grid-area: converter; }
.fees-panel { grid-area: fees; }
.links-panel { grid-area: links; }
.panel-title {
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line-soft);
  margin: -2px 0 8px;
  padding-bottom: 6px;
}
.panel-title span { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }

.mega {
  font: 850 58px/.9 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: -.075em;
  margin: 22px 0 20px;
  color: #e7edf5;
}
.data-row, .metric-line {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--line-soft);
  min-height: 28px;
}
.data-row strong, .metric-line strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 12px;
}
.metric-stack { display: grid; gap: 0; }
.tone.good, .good { color: var(--good) !important; }
.tone.warn, .warn { color: var(--warn) !important; }
.tone.danger, .danger { color: var(--bad) !important; }

.price-chart {
  margin-top: 8px;
  border-top: 1px solid var(--line-soft);
  padding-top: 8px;
}
.chart-head, .chart-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font: 750 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.chart-head strong, .chart-foot span:last-child { color: var(--accent); font-weight: 800; }
#priceChart {
  display: block;
  width: 100%;
  height: 180px;
  margin: 7px 0;
  border: 1px solid var(--line-soft);
  background: #07090c;
}
.chart-gridline {
  fill: none;
  stroke: #171c22;
  stroke-width: 1;
}
#priceChartLine {
  fill: none;
  stroke: var(--warn);
  stroke-width: 1.6;
}
.chart-controls {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
  margin-top: 7px;
}
.chart-controls button {
  height: 22px;
  border: 1px solid var(--line-soft);
  border-radius: 0;
  background: #0d1014;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
  font: 800 9px/20px ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .04em;
}
.chart-controls button.active {
  border-color: #5d4820;
  color: var(--warn);
  background: #11100b;
}

.converter-grid {
  display: grid;
  grid-template-columns: .9fr 1fr 1fr;
  gap: 6px;
}
label { display: grid; gap: 4px; }
input {
  width: 100%;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #060708;
  color: #e5e7eb;
  padding: 0 7px;
  font: 750 12px/26px ui-monospace, SFMono-Regular, Menlo, monospace;
  outline: none;
}
input:focus { border-color: var(--warn); }
.quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 7px 0;
}
.quick-row button {
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #0d1014;
  color: var(--accent);
  padding: 0 8px;
  cursor: pointer;
  font: 800 10px/20px ui-monospace, SFMono-Regular, Menlo, monospace;
}
.result-strip {
  border: 1px solid var(--line-soft);
  background: #07090c;
  color: var(--text);
  padding: 7px;
  min-height: 29px;
  font: 750 11px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.fee-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}
.fee-grid div {
  border: 1px solid var(--line-soft);
  background: #07090c;
  padding: 7px;
}
.fee-grid strong {
  display: block;
  margin-top: 4px;
  font: 850 18px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #d6dde7;
}

.link-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.link-list a, .link-action {
  min-height: 42px;
  border: 1px solid var(--line-soft);
  background: #07090c;
  color: var(--text);
  display: grid;
  gap: 3px;
  padding: 7px;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  border-radius: 0;
  font: inherit;
}
.link-action { color: var(--warn); border-color: #3a321f; }
.link-list span { font-size: 11px; font-weight: 850; letter-spacing: .08em; }
.link-action span { color: var(--warn); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(0, 0, 0, .78);
}
.modal-backdrop[hidden] { display: none; }
.lightning-modal {
  width: min(760px, 100%);
  max-height: calc(100dvh - 28px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #07090c;
  color: var(--text);
  padding: 10px;
}
.modal-head {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 8px;
  margin-bottom: 8px;
}
h2 {
  margin: 2px 0 0;
  color: #d6dde7;
  font: 850 13px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .1em;
}
.lightning-grid {
  display: grid;
  grid-template-columns: .9fr 1fr;
  gap: 8px;
}
.lightning-form { display: grid; gap: 7px; align-content: start; }
.converter-grid.compact { grid-template-columns: 1fr 1fr; }
.settlement-button {
  height: 30px;
  border: 1px solid #5d4820;
  border-radius: 0;
  background: #11100b;
  color: var(--warn);
  cursor: pointer;
  font: 850 10px/28px ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .1em;
}
.invoice-panel { display: grid; gap: 7px; }
.qr-frame {
  min-height: 270px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-soft);
  background: #060708;
  color: var(--muted);
  text-align: center;
  overflow: hidden;
}
.qr-frame svg, .qr-frame img { width: min(256px, 100%); height: auto; display: block; image-rendering: pixelated; }
#lightningInvoice {
  width: 100%;
  min-height: 86px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #060708;
  color: #d6dde7;
  padding: 7px;
  font: 700 10px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;
  outline: none;
}
.modal-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}
.modal-actions .terminal-button { display: block; text-align: center; text-decoration: none; }

@media (max-width: 1180px) {
  .shell { min-width: 0; width: 100%; }
  .terminal-grid {
    grid-template-columns: 1fr;
    grid-template-areas: "price" "tape" "converter" "fees" "links";
  }
  .mega { font-size: clamp(34px, 12vw, 52px); }
  .converter-grid, .link-list { grid-template-columns: 1fr; }
  .lightning-grid, .converter-grid.compact, .modal-actions { grid-template-columns: 1fr; }
  .lightning-modal { width: 100%; max-height: calc(100dvh - 16px); padding: 8px; }
  .modal-backdrop { padding: 8px; align-items: start; }
  .qr-frame { min-height: 220px; }
  .chart-controls { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #priceChart { height: 150px; }
  .topbar { height: auto; min-height: 42px; align-items: flex-start; padding: 8px; }
  .brand-block, .topbar { flex-direction: column; }
  .top-meta { width: 100%; }
  .status-pill, .terminal-button { flex: 1; text-align: center; }
}
