/* LFAIT Range Master — shared theme.
 *
 * Before this file every template carried its own <style> block redefining
 * .sidebar and .main, so a layout change meant editing twelve files and the
 * pages drifted apart. Everything visual now lives here; pages keep only the
 * rules unique to them.
 *
 * Dark is the default. Light is opt-in via <html data-theme="light">, set by
 * the toggle in _head.html before first paint so there is no flash.
 */

:root {
  /* Backgrounds, back to front. */
  --bg:            #0b0d10;
  --bg-elevated:   #12151a;
  --bg-raised:     #171b21;
  --bg-hover:      #1d222a;

  --border:        #242a33;
  --border-strong: #323a45;

  --text:          #e6e9ef;
  --text-muted:    #9aa4b2;
  --text-faint:    #6b7480;

  --accent:        #f7931a;  /* Bitcoin orange, the one brand colour here */
  --accent-hover:  #ffa733;
  --accent-soft:   rgba(247, 147, 26, 0.12);

  --ok:            #3fb950;
  --ok-soft:       rgba(63, 185, 80, 0.12);
  --warn:          #d29922;
  --warn-soft:     rgba(210, 153, 34, 0.12);
  --danger:        #f85149;
  --danger-soft:   rgba(248, 81, 73, 0.12);
  --info:          #58a6ff;
  --info-soft:     rgba(88, 166, 255, 0.12);

  --radius:        10px;
  --radius-sm:     7px;
  --shadow:        0 1px 2px rgba(0,0,0,.28), 0 8px 24px rgba(0,0,0,.22);

  --sidebar-w:     236px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
}

[data-theme="light"] {
  --bg:            #f6f7f9;
  --bg-elevated:   #ffffff;
  --bg-raised:     #ffffff;
  --bg-hover:      #eef0f3;
  --border:        #e1e4e8;
  --border-strong: #cfd4da;
  --text:          #14171c;
  --text-muted:    #5c6570;
  --text-faint:    #858e99;
  --shadow:        0 1px 2px rgba(16,24,40,.05), 0 8px 24px rgba(16,24,40,.06);
}

* { box-sizing: border-box; }

/* The canvas is set inline in _head.html so it survives a slow CDN; this repeats
   it so the stylesheet is correct on its own, and so scrollbars and form
   controls get the right rendering without depending on Bootstrap's
   [data-bs-theme] rule, which is what was supplying color-scheme before. */
html { background: var(--bg); color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

code, pre, .mono, .hex { font-family: var(--mono); font-size: .86em; }

/* Long hex keyspace bounds are the most common cell in this app. They must be
   able to wrap mid-string or a slices table forces horizontal scrolling. */
.hex { word-break: break-all; color: var(--text-muted); }

/* ---------- Layout ---------- */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 18px 12px 24px;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 18px;
  font-weight: 600; font-size: 15px; letter-spacing: -.01em;
}
.sidebar-brand img { width: 28px; height: 28px; border-radius: 6px; }

.sidebar a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  transition: background .12s ease, color .12s ease;
}
.sidebar a:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.sidebar a.active { background: var(--accent-soft); color: var(--accent); }
.sidebar a .ico { width: 18px; text-align: center; flex: none; opacity: .9; }

.nav-group {
  margin: 18px 0 8px; padding: 14px 10px 0;
  border-top: 1px solid var(--border);
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-faint);
}

.sidebar .danger-link { color: var(--text-muted); }
.sidebar .danger-link:hover { background: var(--danger-soft); color: var(--danger); }

.main { margin-left: var(--sidebar-w); padding: 24px 28px 64px; }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.page-title { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -.02em; }
.page-sub { margin: 2px 0 0; color: var(--text-muted); font-size: 13px; }

/* ---------- Cards and stats ---------- */

.card, .panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel { padding: 18px; margin-bottom: 18px; }
.panel-title {
  margin: 0 0 14px; font-size: 13px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint);
}

.stat-grid {
  display: grid; gap: 12px; margin-bottom: 20px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-faint); margin-bottom: 6px;
}
.stat-value {
  font-size: 22px; font-weight: 650; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.stat-value.accent { color: var(--accent); }
.stat-value.ok     { color: var(--ok); }
.stat-value.danger { color: var(--danger); }

/* ---------- Tables ---------- */

.table-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-faint); white-space: nowrap;
}
table.tbl tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: var(--bg-hover); }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Sortable headers, driven by ui.js */
table.tbl thead th.sortable { cursor: pointer; user-select: none; }
table.tbl thead th.sortable:hover { color: var(--text); }
table.tbl thead th.sortable::after {
  content: "↕"; opacity: .3; margin-left: 6px; font-size: 10px;
}
table.tbl thead th.sort-asc::after  { content: "↑"; opacity: 1; color: var(--accent); }
table.tbl thead th.sort-desc::after { content: "↓"; opacity: 1; color: var(--accent); }

/* ---------- Badges ---------- */

.badge-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-ok      { background: var(--ok-soft);     color: var(--ok);     border-color: rgba(63,185,80,.3); }
.badge-warn    { background: var(--warn-soft);   color: var(--warn);   border-color: rgba(210,153,34,.3); }
.badge-danger  { background: var(--danger-soft); color: var(--danger); border-color: rgba(248,81,73,.3); }
.badge-info    { background: var(--info-soft);   color: var(--info);   border-color: rgba(88,166,255,.3); }
.badge-muted   { background: var(--bg-hover);    color: var(--text-muted); border-color: var(--border); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.dot.pulse { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* ---------- Forms and buttons ---------- */

label.fld { display: block; margin-bottom: 14px; }
label.fld > span {
  display: block; margin-bottom: 6px;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
}

input[type=text], input[type=password], input[type=number],
input[type=search], select, textarea {
  width: 100%; padding: 9px 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: var(--text-faint); }

/* File inputs get their own rule because ::file-selector-button is drawn by the
 * browser in its own light chrome, and nothing you set on the <input> reaches
 * it. Until this existed the wallet upload form was a grey "Choose File" slab
 * sitting in the middle of a dark panel. */
/* Slice Stats "Range" cell. The window name leads, the hex bounds are evidence
   rather than the headline, and the keyspace figure is separated from the work
   -queue percentage beside it so the two are not read as the same number. */
.range-cell { min-width: 340px; line-height: 1.45; }
.range-title { font-weight: 600; color: var(--text); }
.range-note { font-weight: 400; color: var(--text-muted); font-size: 12px; }
.range-bounds {
  display: block; margin: 2px 0 3px;
  font-size: 11.5px; color: var(--text-muted);
  white-space: nowrap; cursor: help;
}
.range-scanned { font-size: 12px; color: var(--text-muted); }
.range-scanned strong { color: var(--text); font-weight: 600; }

input[type=file] {
  width: 100%; padding: 7px 10px;
  background: var(--bg); color: var(--text-muted);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px;
}
input[type=file]::file-selector-button {
  margin: -7px 11px -7px -10px;
  padding: 8px 13px;
  background: var(--bg-raised); color: var(--text);
  border: 0; border-right: 1px solid var(--border-strong);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  font: inherit; font-weight: 550; cursor: pointer;
}
input[type=file]::file-selector-button:hover { background: var(--bg-hover); }

/* The :not([class]) selectors are a safety net, not the intended way to write a
 * button. A <button> with no class renders in the user agent's control chrome,
 * which is light grey -- the "Add Wallet(s)" submit shipped exactly that way and
 * was the one white block on an otherwise dark page. Catching the unclassed
 * case means forgetting `class="btn"` degrades to plain rather than to broken. */
.btn,
button:not([class]),
input[type=submit]:not([class]) {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-raised); color: var(--text);
  font-family: inherit; font-size: 13px; font-weight: 550;
  cursor: pointer; white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
}
.btn:hover,
button:not([class]):hover,
input[type=submit]:not([class]):hover { background: var(--bg-hover); border-color: var(--text-faint); text-decoration: none; color: var(--text); }
.btn:active,
button:not([class]):active { transform: translateY(1px); }
.btn:disabled, .btn.is-busy { opacity: .55; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #1a1205; font-weight: 650; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #1a1205; }
.btn-danger  { background: var(--danger-soft); border-color: rgba(248,81,73,.35); color: var(--danger); }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ok      { background: var(--ok-soft); border-color: rgba(63,185,80,.35); color: var(--ok); }
.btn-ok:hover { background: var(--ok); border-color: var(--ok); color: #06210c; }
.btn-warn    { background: var(--warn-soft); border-color: rgba(210,153,34,.35); color: var(--warn); }
.btn-warn:hover { background: var(--warn); border-color: var(--warn); color: #241a02; }
.btn-info    { background: var(--info-soft); border-color: rgba(88,166,255,.35); color: var(--info); }
.btn-info:hover { background: var(--info); border-color: var(--info); color: #041427; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Square icon-only buttons for dense table rows.
 *
 * These carry their semantic tint AT REST, not only on hover. An earlier
 * version used Bootstrap's .btn-outline-* on the dark theme, which renders a
 * 1px grey outline around a transparent box -- five of those in a row read as
 * empty pills, and since the icon font was never loaded they literally were.
 * Hence also: the icons here are inline SVG, so a blocked CDN cannot empty
 * them again. Every one needs a title AND an aria-label; there is no text. */
.btn-icon {
  width: 30px; height: 30px; padding: 0;
  flex: none; border-radius: var(--radius-sm);
}
.btn-icon svg { width: 15px; height: 15px; display: block; }
.btn-icon:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

/* Sits in a table cell, so it must not wrap or stretch the row height. */
.action-group { display: inline-flex; gap: 5px; align-items: center; white-space: nowrap; }

/* ---------- Alerts ---------- */

.note {
  padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-elevated);
  margin-bottom: 14px; font-size: 13px;
}
.note-ok     { background: var(--ok-soft);     border-color: rgba(63,185,80,.3);  color: var(--ok); }
.note-warn   { background: var(--warn-soft);   border-color: rgba(210,153,34,.3); color: var(--warn); }
.note-danger { background: var(--danger-soft); border-color: rgba(248,81,73,.3);  color: var(--danger); }
.note-info   { background: var(--info-soft);   border-color: rgba(88,166,255,.3); color: var(--info); }

/* ---------- Toasts (ui.js) ---------- */

#toasts {
  position: fixed; bottom: 20px; right: 20px; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast-item {
  background: var(--bg-raised); border: 1px solid var(--border-strong);
  border-left: 3px solid var(--info);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 11px 15px; font-size: 13px; max-width: 380px;
  animation: toast-in .18s ease-out;
}
.toast-item.ok     { border-left-color: var(--ok); }
.toast-item.danger { border-left-color: var(--danger); }
.toast-item.warn   { border-left-color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }

/* ---------- Utilities ---------- */

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.tabnum { font-variant-numeric: tabular-nums; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.mt0 { margin-top: 0 } .mb0 { margin-bottom: 0 }

.theme-toggle {
  background: none; border: 1px solid var(--border-strong);
  color: var(--text-muted); border-radius: var(--radius-sm);
  width: 32px; height: 32px; cursor: pointer; font-size: 14px; line-height: 1;
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--text); }

/* Small inline meter. Named .meter, not .bar: range_map.html defines its own
   24px .bar for the scanner/cracker/hit legend, and Bootstrap owns
   .progress-bar. */
.meter { height: 6px; border-radius: 3px; background: var(--bg-hover); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* ---------- Mobile ---------- */

@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: none; }
  .main { margin-left: 0; padding: 16px 14px 56px; }
  .nav-toggle { display: inline-flex !important; }
  /* Cheap scrim so a tap outside the drawer closes it. */
  body.nav-open::after {
    content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 99;
  }
}
.nav-toggle { display: none; }
