/* ══════════════════════════════════════════════════════════
   Pi Stock Ticker — stylesheet
   Dark/light theme via [data-theme] on <html>
   ══════════════════════════════════════════════════════════ */

/* ── CSS variables ─────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:       #0f1117;
  --surface:  #1a1d2e;
  --surface2: #252840;
  --border:   #2e3150;
  --text:     #e2e4f0;
  --muted:    #8b8faa;
  --accent:   #6c63ff;
  --accent2:  #3b82f6;
  --green:    #22c55e;
  --red:      #ef4444;
  --header-bg:#13152b;
  --shadow:   0 4px 24px rgba(0,0,0,.45);
  --row-alt:  rgba(255,255,255,.03);
}
[data-theme="light"] {
  --bg:       #f4f6fb;
  --surface:  #ffffff;
  --surface2: #eef0f8;
  --border:   #d1d5e0;
  --text:     #1a1d2e;
  --muted:    #6b7280;
  --accent:   #6c63ff;
  --accent2:  #3b82f6;
  --green:    #16a34a;
  --red:      #dc2626;
  --header-bg:#1a1d2e;
  --shadow:   0 4px 24px rgba(0,0,0,.10);
  --row-alt:  rgba(0,0,0,.025);
}

/* ── Global utility ────────────────────────────────────────────────── */
/* .hidden must be defined globally — compound rules like .foo.hidden
   only work for elements that have the compound rule; a bare .hidden
   class on any other element would be ignored without this rule. */
.hidden { display: none !important; }

/* ── Reset & base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background .25s, color .25s;
}

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

/* ── Navbar ────────────────────────────────────────────────────────── */
.navbar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; height: 56px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.navbar-brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.navbar-icon  { font-size: 22px; }
.navbar-title { font-weight: 700; font-size: 1.05rem; color: #fff; }
.navbar-subtitle { font-size: .75rem; color: #8b8faa; display: none; }
@media (min-width: 600px) { .navbar-subtitle { display: inline; } }
.navbar-tabs { display: flex; gap: 4px; flex: 1; justify-content: center; }
.navbar-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Tabs ──────────────────────────────────────────────────────────── */
.tab-btn {
  padding: 6px 14px; border-radius: 8px; border: none; cursor: pointer;
  background: transparent; color: #8b8faa; font-size: .9rem; font-weight: 500;
  transition: background .15s, color .15s;
}
.tab-btn:hover   { background: rgba(255,255,255,.07); color: #fff; }
.tab-btn.active  { background: var(--accent); color: #fff; }

.tab-content        { display: none; padding: 20px; max-width: 1200px; margin: 0 auto; }
.tab-content.active { display: block; }

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
  padding: 7px 16px; border-radius: 8px; border: none; cursor: pointer;
  font-size: .88rem; font-weight: 500; transition: opacity .15s, transform .1s;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover   { opacity: .85; }
.btn:active  { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost   { background: rgba(255,255,255,.08); color: var(--text); border: 1px solid var(--border); }
.btn-danger  { background: var(--red); color: #fff; }

/* ── Summary bar ───────────────────────────────────────────────────── */
.summary-bar {
  display: flex; gap: 12px; padding: 12px 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.summary-bar.hidden { display: none; }
.summary-card {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--surface2); border-radius: 10px;
  padding: 10px 18px; flex-shrink: 0; min-width: 120px;
}
.summary-label { font-size: .73rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.summary-value { font-size: 1.1rem; font-weight: 700; }
.pos { color: var(--green); }
.neg { color: var(--red);   }

/* ── Section header ────────────────────────────────────────────────── */
.section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px;
}
.section-header h2 { font-size: 1.2rem; font-weight: 700; }

/* ── Asset table ───────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }

.asset-table {
  width: 100%; border-collapse: collapse;
  background: var(--surface); font-size: .83rem;
}
.asset-table thead tr { background: var(--surface2); }
.asset-table th, .asset-table td {
  padding: 8px 10px; text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.asset-table tbody tr:hover { background: var(--row-alt); }
.asset-table tbody tr:last-child td { border-bottom: none; }

/* Name column: truncate long names */
.col-name-cell {
  max-width: 130px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.col-name { max-width: 130px; }

.badge {
  display: inline-block; padding: 2px 7px; border-radius: 20px;
  font-size: .72rem; font-weight: 600; text-transform: uppercase;
}
.badge-stock  { background: rgba(59,130,246,.18); color: #60a5fa; }
.badge-crypto { background: rgba(250,189,0,.18);  color: #fbbf24; }
.badge-forex  { background: rgba(34,197,94,.18);  color: #4ade80; }

.pnl-positive { color: var(--green); font-weight: 600; }
.pnl-negative { color: var(--red);   font-weight: 600; }

.indicator { font-size: 1rem; }

.empty-state { text-align: center; padding: 48px; color: var(--muted); }

.action-btns { display: flex; gap: 6px; }
.btn-icon {
  background: none; border: none; cursor: pointer; font-size: 1rem;
  padding: 4px; border-radius: 6px; transition: background .15s;
  color: var(--muted);
}
.btn-icon:hover { background: var(--surface2); color: var(--text); }

/* ── Display tab ───────────────────────────────────────────────────── */
.page-switcher { display: flex; gap: 6px; }
.page-btn {
  padding: 5px 12px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--muted); cursor: pointer;
  font-size: .85rem; transition: background .15s;
}
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.display-container {
  display: flex; gap: 32px; align-items: flex-start;
  flex-wrap: wrap;
}
.eink-frame {
  position: relative; border-radius: 12px; overflow: hidden;
  border: 3px solid var(--border);
  box-shadow: var(--shadow);
  background: #ddd;
  /* Actual display: 176×264 → show at 2× scale (portrait default).
     JS overrides width/height inline for landscape orientation. */
  width: 352px; height: 528px;
  flex-shrink: 0;
  transition: width .25s ease, height .25s ease;
}
.eink-img { width: 100%; height: 100%; object-fit: fill; image-rendering: auto; }
.subpage-nav {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; margin-top: 10px;
  font-size: .95rem; font-weight: 600; color: var(--text);
}
.subpage-btn { padding: 4px 14px; font-size: 1rem; }
.eink-loading {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; background: rgba(0,0,0,.5); color: #fff;
  font-size: 1rem;
}
.eink-loading.hidden { display: none; }

.display-info { flex: 1; min-width: 240px; }
.info-row { margin-bottom: 10px; font-size: .9rem; color: var(--muted); }
.info-row strong { color: var(--text); }
.display-actions { display: flex; flex-direction: column; gap: 10px; margin: 18px 0; }
.auto-preview-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }

.select-sm {
  padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text); font-size: .85rem;
}

/* ── Settings ──────────────────────────────────────────────────────── */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.settings-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px;
}
.settings-card h3 { margin-bottom: 18px; font-size: 1rem; }
.field-label {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px;
  font-size: .88rem; color: var(--muted);
}
.field-input {
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text); font-size: .9rem;
  width: 100%; transition: border-color .15s;
}
.field-input:focus { outline: none; border-color: var(--accent); }
.field-hint { font-size: .78rem; color: var(--muted); }
.field-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.toggle-label { flex-direction: row !important; align-items: center; gap: 10px; cursor: pointer; }
.toggle-label input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }

/* ── Modal ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 1.2rem; color: var(--muted); }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 22px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 22px; border-top: 1px solid var(--border);
}
.modal-divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

/* Asset type selector */
.type-selector { display: flex; gap: 8px; margin-bottom: 18px; }
.type-btn {
  flex: 1; padding: 8px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--muted); cursor: pointer;
  font-size: .88rem; transition: all .15s;
}
.type-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Search results */
.search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.search-row .field-input { flex: 1; }
.search-results {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; max-height: 160px; overflow-y: auto;
  margin-bottom: 12px;
}
.search-results.hidden { display: none; }
.search-item {
  padding: 8px 14px; cursor: pointer; font-size: .88rem;
  border-bottom: 1px solid var(--border);
  display: flex; gap: 12px; align-items: center;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--border); }
.search-sym { font-weight: 700; min-width: 60px; }
.search-name { color: var(--muted); }

/* ── Toast ─────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  padding: 12px 20px; border-radius: 10px; font-size: .9rem;
  box-shadow: var(--shadow); color: #fff; max-width: 320px;
  animation: slide-in .3s ease;
}
.toast-success { background: var(--green); }
.toast-error   { background: var(--red); }
.toast-info    { background: var(--accent2); }

@keyframes slide-in {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Spinner ───────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinning { display: inline-block; animation: spin .8s linear infinite; }

/* ── Screen orientation selector ───────────────────────────────────── */
.orient-selector {
  display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap;
}
.orient-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 12px; border-radius: 10px; border: 2px solid var(--border);
  background: var(--surface2); color: var(--muted); cursor: pointer;
  font-size: .78rem; text-align: center; min-width: 72px;
  transition: all .15s;
}
.orient-btn:hover { border-color: var(--accent); color: var(--text); }
.orient-btn.active { border-color: var(--accent); background: rgba(108,99,255,.15); color: var(--text); }
.orient-icon {
  font-size: 1.6rem; line-height: 1; display: inline-block;
  transition: transform .25s;
}
.orient-rot90  { transform: rotate(90deg);  }
.orient-rot180 { transform: rotate(180deg); }
.orient-rot270 { transform: rotate(270deg); }
.orient-label  { line-height: 1.3; color: var(--muted); }
.orient-btn.active .orient-label { color: var(--text); }

/* ── Hardware tab ───────────────────────────────────────────────────── */
.hw-loading {
  text-align: center; padding: 60px; color: var(--muted); font-size: 1rem;
}
.hw-banner {
  padding: 14px 20px; border-radius: 12px; margin-bottom: 18px;
  font-weight: 600; font-size: 1rem;
}
.hw-banner.ok       { background: rgba(34,197,94,.15);  color: var(--green); border: 1px solid rgba(34,197,94,.3); }
.hw-banner.degraded { background: rgba(234,179,8,.15);  color: #ca8a04;      border: 1px solid rgba(234,179,8,.3); }
.hw-banner.error    { background: rgba(239,68,68,.15);  color: var(--red);   border: 1px solid rgba(239,68,68,.3); }
.hw-banner.mock     { background: rgba(59,130,246,.15); color: var(--accent2); border: 1px solid rgba(59,130,246,.3); }

.hw-notes {
  display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px;
}
.hw-note {
  padding: 10px 14px; border-radius: 8px;
  font-size: .88rem; background: var(--surface2);
  border-left: 3px solid var(--border);
}
.hw-note.warn { border-color: #ca8a04; }
.hw-note.ok   { border-color: var(--green); }
.hw-note.info { border-color: var(--accent2); }

.hw-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px; margin-bottom: 16px;
}

.hw-status-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 0;
  font-size: .9rem;
}
.hw-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.hw-dot.ok      { background: var(--green); box-shadow: 0 0 6px var(--green); }
.hw-dot.warn    { background: #ca8a04; }
.hw-dot.error   { background: var(--red); }
.hw-dot.missing { background: var(--muted); }

.hw-detail { font-size: .8rem; color: var(--muted); margin-top: 2px; }

.hw-cmd-hint {
  margin-top: 12px; padding: 10px; border-radius: 8px;
  background: var(--bg); font-size: .8rem; color: var(--muted);
  border: 1px solid var(--border);
}
.hw-cmd-hint code {
  display: inline-block; margin-top: 4px; font-size: .78rem;
  background: rgba(0,0,0,.2); padding: 2px 6px; border-radius: 4px;
  color: #89dceb; font-family: monospace;
}

.hw-sysinfo {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 16px;
  font-size: .88rem;
}
.hw-sysinfo dt { color: var(--muted); }
.hw-sysinfo dd { color: var(--text); font-family: monospace; font-size: .82rem; }

/* ── Per-page rotation config table ────────────────────────────────── */
.page-cfg-table {
  display: grid;
  grid-template-columns: 1fr 72px 36px;
  gap: 4px 8px;
  align-items: center;
  margin-top: 4px;
}
.page-cfg-hdr {
  display: contents;
}
.page-cfg-hdr > span {
  font-size: .72rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; padding-bottom: 2px;
}
.page-cfg-row {
  display: contents;
}
.page-cfg-row > span {
  font-size: .88rem; color: var(--text);
}
.page-cfg-row .page-dur {
  padding: 4px 6px; font-size: .83rem; text-align: center;
}
.page-cfg-row .page-ena {
  justify-self: center; width: 16px; height: 16px; cursor: pointer;
  accent-color: var(--accent);
}

/* ── History period checkboxes ──────────────────────────────────────── */
.hist-period-label {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 6px; font-size: .82rem;
  border: 1px solid var(--border); cursor: pointer;
  user-select: none; color: var(--text);
}
.hist-period-label:has(input:checked) {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.hist-period { display: none; }

/* ── Sortable table headers ─────────────────────────────────────────── */
th.sortable {
  cursor: pointer; user-select: none; position: relative;
  padding-right: 22px;
}
th.sortable::after {
  content: "⇅"; position: absolute; right: 6px; top: 50%;
  transform: translateY(-50%); font-size: .75rem; color: var(--muted);
  opacity: .45;
}
th.sortable.sort-asc::after  { content: "▲"; opacity: 1; color: var(--accent); }
th.sortable.sort-desc::after { content: "▼"; opacity: 1; color: var(--accent); }

/* ── Symbol hint (ticker under display label) ───────────────────────── */
.sym-hint {
  font-size: .72rem; color: var(--muted); font-weight: 400;
  font-family: monospace; letter-spacing: .02em;
}

/* ── Privacy / allocation styles ────────────────────────────────────── */
.alloc-pct {
  font-size: .9rem; font-weight: 600; color: var(--accent2);
}
.summary-alloc {
  min-width: 200px;
}
.alloc-text {
  font-size: .82rem; font-weight: 500; letter-spacing: .01em;
  white-space: normal; line-height: 1.5;
}

/* ── Sleep schedule grid ────────────────────────────────────────────── */
.schedule-grid { width: 100%; }
.schedule-hdr,
.schedule-row {
  display: grid;
  grid-template-columns: 38px 1fr 1fr 28px;
  gap: 6px;
  align-items: center;
  margin-bottom: 5px;
}
.schedule-hdr {
  font-size: .75rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 7px;
}
.schedule-row > span {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
}
.schedule-row .field-input {
  padding: 3px 6px;
  font-size: .8rem;
}

/* ── Cash badge ─────────────────────────────────────────────────────── */
.badge-cash     { background: rgba(156,163,175,.18); color: #9ca3af; }
.badge-currency { background: rgba(52,211,153,.18);  color: #34d399; }

/* ── History badge & pill buttons ───────────────────────────────────── */
.hist-badge { font-size: 12px; }
.hist-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.hist-pill {
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.hist-pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Live ticker banner ─────────────────────────────────────────────── */
.ticker-banner {
  position: relative;
  overflow: hidden;
  height: 34px;
  background: #060b06;
  border-bottom: 1px solid #0d1f0d;
  /* Subtle scanline texture */
  background-image: repeating-linear-gradient(
    0deg, transparent, transparent 3px,
    rgba(0,0,0,.18) 3px, rgba(0,0,0,.18) 4px
  );
  display: flex;
  align-items: center;
  cursor: default;
}
.ticker-banner.hidden { display: none; }

/* Fade edges */
.ticker-banner::before,
.ticker-banner::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 48px;
  z-index: 2;
  pointer-events: none;
}
.ticker-banner::before { left: 0;  background: linear-gradient(to right, #060b06, transparent); }
.ticker-banner::after  { right: 0; background: linear-gradient(to left,  #060b06, transparent); }

.ticker-track {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  will-change: transform;
  animation: ticker-scroll 40s linear infinite;
}
.ticker-banner:hover .ticker-track { animation-play-state: paused; }

@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

.ticker-inner {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.ticker-item {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 0 6px 0 16px;
  font-family: "Courier New", "Lucida Console", monospace;
  font-size: 12.5px;
  letter-spacing: .08em;
}

.ticker-sym {
  color: #7aaa7a;
  font-weight: 700;
  letter-spacing: .12em;
}
.ticker-price { color: #4d7a4d; font-size: 11.5px; }

.ticker-up   { color: #00e844; text-shadow: 0 0 7px rgba(0,232,68,.55); }
.ticker-down { color: #ff4040; text-shadow: 0 0 7px rgba(255,64,64,.55); }
.ticker-flat { color: #3d5a3d; }

.ticker-sep {
  color: #0f2810;
  font-size: 9px;
  padding: 0 4px 0 10px;
  letter-spacing: 0;
  vertical-align: middle;
}

/* ── Login overlay ─────────────────────────────────────────────────── */
.login-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-overlay.hidden { display: none; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 40px 36px;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-logo   { font-size: 3rem; margin-bottom: 12px; }
.login-title  { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }
.login-subtitle { color: var(--muted); font-size: .9rem; margin-bottom: 28px; }
.login-card .field-label { text-align: left; }
.login-btn { width: 100%; justify-content: center; padding: 10px; font-size: 1rem; margin-top: 8px; }
.login-error {
  color: var(--red); font-size: .85rem;
  padding: 8px 12px; border-radius: 8px; margin-top: 4px;
  background: rgba(239,68,68,.1);
}

/* ── Responsive ────────────────────────────────────────────────────── */

/* Tablet / narrow desktop: collapse navbar to 2 rows */
@media (max-width: 768px) {
  .navbar {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 14px 0;
    column-gap: 8px;
    row-gap: 0;
  }
  .navbar-brand { flex: 1; padding-bottom: 8px; }
  .navbar-actions { gap: 4px; padding-bottom: 8px; }

  /* Hide "Refresh" label, keep icon */
  .btn-label { display: none; }
  #btn-refresh { padding: 7px 10px; }

  /* Tabs: full-width second row, horizontal scroll */
  .navbar-tabs {
    order: 10;
    width: 100%;
    flex: none;
    overflow-x: auto;
    overflow-y: hidden;
    justify-content: flex-start;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 6px 0 8px;
    border-top: 1px solid var(--border);
    gap: 4px;
  }
  .navbar-tabs::-webkit-scrollbar { display: none; }
  .navbar-tabs .tab-btn {
    white-space: nowrap;
    padding: 5px 13px;
    font-size: .85rem;
  }
}

/* Mobile phone */
@media (max-width: 640px) {
  /* Section header: stack vertically */
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  /* Page switcher: horizontal scroll, no wrap */
  .page-switcher {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .page-switcher::-webkit-scrollbar { display: none; }
  .page-btn { white-space: nowrap; }

  /* Tab content: tighter padding */
  .tab-content { padding: 14px 12px; }

  /* Summary bar: narrower cards */
  .summary-card { min-width: 88px; padding: 8px 10px; }
  .summary-value { font-size: .95rem; }

  /* Display tab: stack frame above info */
  .display-container { flex-direction: column; gap: 20px; }
  .display-info { min-width: 0; }
  .display-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  /* Settings: single column */
  .settings-grid { grid-template-columns: 1fr; }
  .field-row-2   { grid-template-columns: 1fr; }

  /* Orient buttons: compact */
  .orient-selector { gap: 6px; }
  .orient-btn { min-width: 60px; padding: 8px; font-size: .72rem; }

  /* Modal: slide up from bottom edge */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    max-height: 95vh;
    border-radius: 20px 20px 0 0;
  }
  .modal-body   { padding: 16px; }
  .modal-header { padding: 14px 16px; }
  .modal-footer { padding: 12px 16px; }

  /* Table: slightly smaller text */
  .asset-table th,
  .asset-table td { padding: 7px 8px; font-size: .8rem; }
}
