:root {
  --bg: #0d1117;
  --panel: #151b23;
  --panel-2: #1c2430;
  --border: #2a3441;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #3fb950;
  --buy: #2ea043;
  --sell: #da3633;
  --hold: #6e7681;
  --both: #d29922;
  --danger: #f85149;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(circle at top, #101720 0%, #0a0e14 70%);
  color: var(--text);
  min-height: 100vh;
}

.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}
.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
.brand h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0;
}
.brand span.tag {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: 4px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 12px;
}

.login-card {
  max-width: 380px;
  margin: 8vh auto 0;
}

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type="email"],
input[type="password"],
input[type="number"] {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  font-size: 16px;
  min-height: 44px;
  margin-bottom: 16px;
}
input:focus {
  outline: 1px solid var(--accent);
}

button,
.btn {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  min-height: 44px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  transition: filter 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
button:hover,
.btn:hover {
  filter: brightness(1.1);
}
.btn-secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

/* Market chart card — TradingView embed above the gate-status card. */
.chart-card {
  padding: 18px 18px 0;
  overflow: hidden;
}
.chart-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding-bottom: 14px;
}
.chart-card-note {
  font-size: 11px;
  color: var(--muted);
}
.chart-embed {
  height: 420px;
  margin: 0 -18px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.status-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.03em;
}
.status-pill.buy {
  background: rgba(46, 160, 67, 0.15);
  color: var(--buy);
  border: 1px solid var(--buy);
}
.status-pill.sell {
  background: rgba(218, 54, 51, 0.15);
  color: var(--sell);
  border: 1px solid var(--sell);
}
.status-pill.hold {
  background: rgba(110, 118, 129, 0.15);
  color: var(--muted);
  border: 1px solid var(--hold);
}
.status-pill.buy_sell {
  background: rgba(210, 153, 34, 0.15);
  color: var(--both);
  border: 1px solid var(--both);
}

.meta-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
}
.meta-row strong {
  color: var(--text);
}

.countdown {
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  color: var(--text);
}

/* Two-trip-wire race display — replaces the old single .countdown line
   when the gate is active; falls back to the same muted "no instruction"
   messaging when it's HOLD. */
.race-legs {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.race-leg {
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  color: var(--text);
}
.race-leg.muted {
  color: var(--muted);
  font-variant-numeric: normal;
}
.race-leg.invalidation {
  color: var(--danger);
  font-weight: 700;
}

.trigger-fired {
  margin-top: 14px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--both);
  background: rgba(210, 153, 34, 0.12);
  border: 1px solid var(--both);
  display: inline-block;
}
.trigger-fired.invalidation {
  color: var(--danger);
  background: rgba(248, 81, 73, 0.12);
  border: 1px solid var(--danger);
}

/* Stop-condition toggles — one row per trip-wire, each independently
   enable/disable-able. Unchecked = input is `disabled`, which is what
   actually keeps it out of the form POST (see dashboard.html's JS). */
.trigger-block {
  margin-bottom: 18px;
}
.trigger-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 10px;
}
.trigger-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.trigger-toggle-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.toggle-switch {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
  flex-shrink: 0;
}
.toggle-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition:
    transform 0.15s ease,
    background 0.15s ease;
}
.trigger-toggle input[type="checkbox"]:checked + .toggle-switch {
  background: rgba(63, 185, 80, 0.18);
  border-color: var(--accent);
}
.trigger-toggle input[type="checkbox"]:checked + .toggle-switch::after {
  transform: translateX(16px);
  background: var(--accent);
}

.price-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.price-row input[type="number"] {
  max-width: 220px;
  margin-bottom: 0;
}
.price-hint {
  font-size: 12px;
  color: var(--muted);
}

.duration-row.disabled,
.price-row.disabled {
  opacity: 0.4;
}

.trigger-note {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 20px;
}
.trigger-note.invalidation-note {
  color: var(--danger);
  margin: 8px 0 4px;
}
.trigger-note.invalidation-note strong {
  color: var(--danger);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0 20px;
}
.action-option {
  position: relative;
}
.action-option input {
  position: absolute;
  opacity: 0;
}
.action-option label {
  display: block;
  cursor: pointer;
  text-align: center;
  padding: 16px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel-2);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
}
.action-option input:checked + label.buy {
  border-color: var(--buy);
  background: rgba(46, 160, 67, 0.12);
  color: var(--buy);
}
.action-option input:checked + label.sell {
  border-color: var(--sell);
  background: rgba(218, 54, 51, 0.12);
  color: var(--sell);
}
.action-option input:checked + label.hold {
  border-color: var(--hold);
  background: rgba(110, 118, 129, 0.18);
  color: var(--text);
}
.action-option input:checked + label.buy_sell {
  border-color: var(--both);
  background: rgba(210, 153, 34, 0.12);
  color: var(--both);
}

.duration-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.duration-row input[type="range"] {
  flex: 1;
}
.duration-value {
  min-width: 64px;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.flash {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}
.flash.success {
  background: rgba(46, 160, 67, 0.12);
  border: 1px solid var(--buy);
  color: var(--buy);
}
.flash.error {
  background: rgba(248, 81, 73, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.history {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 13px;
}
table.history th,
table.history td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}
table.history th {
  color: var(--text);
  font-weight: 600;
}
table.history tr:last-child td {
  border-bottom: none;
}

/* =========================================================================
   App navigation — sticky top bar (brand + tabs + user menu) on wide
   screens; top bar collapses to brand + avatar and a fixed bottom tab bar
   takes over primary navigation under the mobile breakpoint (see the
   max-width: 700px rules further down). Both pieces share the same
   `active_page` state from _nav.html so exactly one tab is ever marked
   current in either layout.
   ========================================================================= */

.app-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(21, 27, 35, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.app-nav-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.app-nav-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}
.app-nav-brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse-dot 2s ease-in-out infinite;
  flex-shrink: 0;
}
.app-nav-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* Tab row — a segmented control, not a row of loose links. The active
   tab gets a filled pill; inactive tabs are quiet until hovered, so the
   row reads as "here's where you are" at a glance rather than a list of
   equally-weighted options. */
.app-nav-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  margin: 0 auto;
}
.app-nav-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 16px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}
.app-nav-tab svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.app-nav-tab:hover {
  color: var(--text);
}
.app-nav-tab.active {
  background: var(--accent);
  color: #06280f;
}

/* User avatar + dropdown menu — collapses email/sign-out into a single
   affordance instead of two loose items competing with the tabs for
   space in the bar. */
.app-nav-user {
  position: relative;
  flex-shrink: 0;
  margin-left: auto;
}
.app-nav-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  min-height: 0;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}
.app-nav-avatar:hover {
  border-color: var(--accent);
}
.app-nav-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 220px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
  z-index: 45;
}
.app-nav-menu.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.app-nav-menu-email {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 6px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  word-break: break-all;
}
.app-nav-menu-signout {
  width: 100%;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--border);
  font-weight: 600;
}
.app-nav-menu-signout:hover {
  border-color: var(--danger);
  background: rgba(248, 81, 73, 0.1);
  filter: none;
}

/* Mobile-only duplicate of the dropdown menu, opened from the bottom tab
   bar's "Account" tab instead of the top bar's avatar (which is hidden
   on narrow screens — see the responsive rules below). */
.app-nav-menu-mobile {
  position: fixed;
  top: auto;
  bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 10px);
  right: 12px;
  left: 12px;
  min-width: 0;
  z-index: 61;
}
.app-nav-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.app-nav-menu-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* Bottom tab bar — hidden by default (desktop primary nav lives in
   .app-nav-tabs instead); shown under the mobile breakpoint below. */
.app-bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background: rgba(21, 27, 35, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
}
.app-bottom-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: transparent;
  border: none;
  min-height: 0;
  -webkit-tap-highlight-color: transparent;
}
.app-bottom-tab svg {
  width: 21px;
  height: 21px;
}
.app-bottom-tab.active {
  color: var(--accent);
}
.app-bottom-tab:active {
  background: var(--panel-2);
}

/* =========================================================================
   Live Logs page
   ========================================================================= */

@keyframes pulse-dot {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.8);
  }
}

.conn-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.conn-status.live {
  color: var(--buy);
  border-color: var(--buy);
  background: rgba(46, 160, 67, 0.1);
}
.conn-status.down {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(248, 81, 73, 0.1);
}
.conn-status .conn-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}
.conn-status.live .conn-led {
  animation: pulse-dot 1.6s ease-in-out infinite;
}

.logs-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.logs-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-chip {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  user-select: none;
  transition: all 0.15s ease;
}
.filter-chip:hover {
  color: var(--text);
  border-color: var(--muted);
}
.filter-chip.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(63, 185, 80, 0.1);
}

.log-feed-frame {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #080b10;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.4);
}
.log-feed-frame::before {
  /* top fade mask — signals older lines have scrolled away above */
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 36px;
  background: linear-gradient(to bottom, #080b10 0%, rgba(8, 11, 16, 0) 100%);
  z-index: 2;
  pointer-events: none;
}
.log-feed-frame.flash-trade::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  box-shadow:
    0 0 0 1px var(--buy),
    0 0 24px 2px rgba(46, 160, 67, 0.35) inset;
  animation: frame-flash 900ms ease-out;
  pointer-events: none;
  z-index: 3;
}
.log-feed-frame.flash-error::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  box-shadow:
    0 0 0 1px var(--danger),
    0 0 24px 2px rgba(248, 81, 73, 0.35) inset;
  animation: frame-flash 900ms ease-out;
  pointer-events: none;
  z-index: 3;
}
@keyframes frame-flash {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.log-feed {
  height: 420px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 14px 16px;
  font-family:
    "SF Mono", "Fira Code", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
}

.log-line {
  display: grid;
  grid-template-columns: 72px 88px 96px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 3px 6px;
  border-radius: 6px;
  animation: line-in 320ms ease-out;
  white-space: pre-wrap;
  word-break: break-word;
}
@keyframes line-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.log-line .lt-time {
  color: #4d5a68;
  font-variant-numeric: tabular-nums;
}
.log-line .lt-bot {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 8px;
  border-radius: 999px;
  text-align: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  justify-self: start;
}
.log-line .lt-level {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
}
.log-line .lt-msg {
  color: #c9d1d9;
}

.log-line.level-info .lt-level {
  color: #58a6ff;
}
.log-line.level-warning .lt-level {
  color: var(--both);
}
.log-line.level-warning .lt-msg {
  color: #f0d78c;
}
.log-line.level-error .lt-level,
.log-line.level-critical .lt-level {
  color: var(--danger);
}
.log-line.level-error .lt-msg,
.log-line.level-critical .lt-msg {
  color: #ffb3ae;
}

.log-line.tone-trade .lt-msg {
  color: var(--buy);
  font-weight: 600;
}
.log-line.tone-block .lt-msg {
  color: var(--sell);
}
.log-line.tone-gate .lt-msg {
  color: var(--both);
  font-weight: 600;
}

.log-feed .cursor {
  display: inline-block;
  width: 8px;
  height: 14px;
  background: var(--accent);
  margin-left: 2px;
  animation: caret-blink 1s steps(1) infinite;
  vertical-align: text-bottom;
}
@keyframes caret-blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

.log-feed-empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
}

/* MT5 test-account credentials card */
.cred-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 16px;
}
.cred-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.cred-item {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-width: 0;
}
.cred-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}
.cred-value-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.cred-value {
  font-family:
    "SF Mono", "Fira Code", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  color: var(--text);
  overflow-wrap: anywhere;
  flex: 1;
  min-width: 0;
}
.cred-btn {
  flex-shrink: 0;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 6px 10px;
  border-radius: 6px;
  min-height: 30px;
  transition: all 0.15s ease;
}
.cred-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  filter: none;
  background: rgba(63, 185, 80, 0.08);
}
.cred-note {
  color: var(--danger);
  font-size: 12px;
  margin: 14px 0 0;
}
.cred-value-hidden {
  color: var(--muted);
  font-style: italic;
  font-size: 13px;
}

.bot-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.bot-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.bot-chip.seen {
  color: var(--text);
  border-color: var(--accent);
}

/* =========================================================================
   Gold News page
   ========================================================================= */

.gold-news-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.gold-news-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gn-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 24px 4px;
  text-align: center;
}

.gn-hero {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
}
@media (max-width: 640px) {
  .gn-hero {
    grid-template-columns: 1fr;
  }
}

.gn-hero-image {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel-2);
}
.gn-hero-image-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: var(--muted);
}

.gn-hero-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.gn-hero-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
}
.gn-hero-post {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: #c9d1d9;
  white-space: pre-wrap;
}
.gn-hero-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: auto;
  font-size: 12px;
  color: var(--muted);
}
.gn-source-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.gn-source-link:hover {
  text-decoration: underline;
}

.gn-history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.gn-history-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-2);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease;
}
.gn-history-card:hover {
  border-color: var(--accent);
}
.gn-history-thumb {
  height: 100px;
  background-size: cover;
  background-position: center;
  background-color: #0d1117;
}
.gn-history-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--muted);
}
.gn-history-body {
  padding: 10px 12px;
}
.gn-history-title {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gn-history-time {
  font-size: 11px;
  color: var(--muted);
}

/* =========================================================================
   User Management System
   Nav: bell + notification dropdown, role pill. Shared: modal, role
   pills, status dots. Account page: profile grid, permission list,
   pending banner. Manage Users: user cards, inline management forms.
   ========================================================================= */

/* ── Nav: icon buttons (bell), right-side grouping, notification dropdown */
.app-nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.app-nav-user {
  position: relative;
  flex-shrink: 0;
}
.app-nav-icon-btn {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  padding: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    border-color 0.15s ease,
    color 0.15s ease;
}
.app-nav-icon-btn svg {
  width: 17px;
  height: 17px;
}
.app-nav-icon-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}
.app-nav-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 2px solid var(--panel);
}

.app-nav-menu-notifs {
  min-width: 300px;
  max-width: 92vw;
  padding: 0;
  overflow: hidden;
}
.notif-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.notif-mark-all {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  padding: 0;
  min-height: 0;
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}
.notif-list {
  max-height: 320px;
  overflow-y: auto;
}
.notif-item {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: default;
}
.notif-item:last-child {
  border-bottom: none;
}
.notif-item.unread {
  cursor: pointer;
  background: rgba(63, 185, 80, 0.05);
}
.notif-item.unread:hover {
  background: rgba(63, 185, 80, 0.09);
}
.notif-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
  background: transparent;
}
.notif-item.unread .notif-dot {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}
.notif-body p {
  margin: 0 0 3px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
}
.notif-time {
  font-size: 10.5px;
  color: var(--muted);
}
.notif-empty {
  padding: 24px 14px;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}
.notif-menu-header-mobile {
  padding: 10px 2px 6px;
  border-bottom: none;
}
.notif-list-mobile {
  max-height: 220px;
  margin-bottom: 8px;
}
.notif-list-mobile .notif-item {
  padding: 10px 2px;
}

.app-nav-menu-link {
  display: block;
  width: 100%;
  padding: 9px 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
}
.app-nav-menu-link:hover {
  background: var(--panel-2);
}

.app-bottom-badge {
  top: 2px;
  right: 22%;
}

/* ── Role pills — used in the nav, account page, and Manage Users ────── */
.role-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  margin-left: 8px;
  vertical-align: middle;
}
.role-super_admin {
  color: #f0b429;
  border-color: #f0b429;
  background: rgba(240, 180, 41, 0.1);
}
.role-admin {
  color: #58a6ff;
  border-color: #58a6ff;
  background: rgba(88, 166, 255, 0.1);
}
.role-user {
  color: var(--muted);
}

.status-dot-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.status-dot-ok,
.status-dot-pending,
.status-dot-bad {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot-ok {
  background: var(--accent);
  box-shadow: 0 0 5px var(--accent);
}
.status-dot-pending {
  background: #d29922;
  box-shadow: 0 0 5px #d29922;
}
.status-dot-bad {
  background: var(--danger);
  box-shadow: 0 0 5px var(--danger);
}

/* ── Modal — permission-denied popup, reusable for future confirms ───── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -46%);
  width: min(360px, 90vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px 24px 22px;
  text-align: center;
  z-index: 95;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.modal.open {
  opacity: 1;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}
.modal-icon {
  font-size: 30px;
  margin-bottom: 10px;
}
.modal h3 {
  margin: 0 0 10px;
  font-size: 16px;
}
.modal p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  margin: 0 0 20px;
}
.modal .btn,
.modal button {
  width: 100%;
}

/* ── Pending-approval notice (login/register/account pages) ──────────── */
.pending-notice {
  background: rgba(210, 153, 34, 0.1);
  border: 1px solid rgba(210, 153, 34, 0.35);
  color: #d29922;
  font-size: 12.5px;
  line-height: 1.6;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 18px;
}
.pending-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  border-color: rgba(210, 153, 34, 0.35);
}
.pending-icon {
  font-size: 24px;
  line-height: 1;
}

/* ── Account page ──────────────────────────────────────────────────────── */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.profile-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.profile-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.profile-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.access-summary {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  margin: 0;
}
.access-summary code {
  background: var(--panel-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}
.access-summary a {
  color: var(--accent);
}
.permission-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.permission-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
}
.permission-list li.not-granted {
  opacity: 0.5;
}
.perm-check {
  font-size: 13px;
  font-weight: 800;
  color: var(--accent);
  width: 16px;
  flex-shrink: 0;
  text-align: center;
}
.not-granted .perm-check {
  color: var(--muted);
}
.perm-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.perm-desc {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.5;
}

.stacked-form {
  display: flex;
  flex-direction: column;
  max-width: 380px;
}
.stacked-form button[type="submit"] {
  margin-top: 6px;
}

/* ── Manage Users page ─────────────────────────────────────────────────── */
.admin-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.pending-count-badge {
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}
.user-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--panel-2);
}
.user-card-pending {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.user-card-suspended {
  opacity: 0.6;
}
.user-card-main {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.user-card-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.user-card-email {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}
.user-card-meta {
  font-size: 11.5px;
  color: var(--muted);
}
.user-card-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.btn-approve {
  background: var(--accent);
  color: #06280f;
}
.btn-reject {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}
.btn-reject:hover {
  background: rgba(248, 81, 73, 0.1);
  filter: none;
}

.user-card-details {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.user-card-details summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  list-style: none;
  user-select: none;
}
.user-card-details summary::-webkit-details-marker {
  display: none;
}
.user-card-details summary::before {
  content: "▸ ";
}
.user-card-details[open] summary::before {
  content: "▾ ";
}
.user-card-detail-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 12px;
}
.inline-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.inline-form label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.inline-form select,
.inline-form input[type="text"],
.inline-form input[type="number"] {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
  min-height: 38px;
}
.permission-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.perm-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text);
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
}
.perm-checkbox input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}
.mt5-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
.inline-form-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.inline-form-row form {
  flex: 1;
  min-width: 120px;
}
.inline-form-row button {
  width: 100%;
}
.create-user-form select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  min-height: 44px;
  margin-bottom: 16px;
}

/* =========================================================================
   Responsive breakpoints
   Mobile-first touch targets, no horizontal scroll on the page itself
   (individual data tables/log lines opt into their own scroll containers),
   16px inputs to stop iOS auto-zoom, and progressively simplified layouts
   as space shrinks.
   ========================================================================= */

/* Tablet and small laptops */
@media (max-width: 768px) {
  .wrap {
    padding: 24px 16px 48px;
  }
  .card {
    padding: 18px;
  }
  .cred-grid {
    grid-template-columns: 1fr;
  }
  .action-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }
  .meta-row {
    gap: 12px 20px;
  }
  table.history {
    min-width: 560px;
  }
  .chart-embed {
    height: 360px;
  }
}

/* Primary nav breakpoint — top bar loses its inline tab row and avatar
   menu; the fixed bottom tab bar (hidden until now) takes over as the
   primary way to move between pages, with an "Account" tab standing in
   for the avatar dropdown. */
@media (max-width: 700px) {
  .app-nav-tabs,
  .app-nav-user {
    display: none;
  }
  .app-nav-inner {
    height: 52px;
    padding: 0 16px;
  }
  .app-bottom-nav {
    display: flex;
  }
  .wrap {
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }
}

/* Phones */
@media (max-width: 640px) {
  .brand h1 {
    font-size: 16px;
  }
  .app-nav-name {
    font-size: 14px;
  }
  .status-hero {
    align-items: flex-start;
  }
  .pending-card {
    flex-direction: column;
  }
  .user-card-pending {
    flex-direction: column;
    align-items: flex-start;
  }
  .user-card-actions {
    width: 100%;
  }
  .user-card-actions form {
    flex: 1;
  }
  .user-card-actions button {
    width: 100%;
  }
  .app-nav-menu-notifs {
    min-width: 0;
    width: 92vw;
  }
  .status-pill {
    font-size: 17px;
    padding: 8px 14px;
  }
  .action-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .price-row input[type="number"] {
    max-width: none;
    width: 100%;
  }
  .duration-row {
    flex-wrap: wrap;
  }
  .duration-row input[type="range"] {
    width: 100%;
    flex: none;
  }
  .duration-value {
    text-align: left;
  }
  button[type="submit"],
  #gate-form button {
    width: 100%;
  }
  .logs-toolbar {
    align-items: stretch;
  }
  .logs-filters {
    width: 100%;
  }
  .filter-chip {
    flex: 1 1 auto;
    text-align: center;
  }
  .log-feed {
    height: 340px;
    font-size: 12px;
    padding: 12px;
  }
  /* Stack each log line into two rows instead of a rigid 4-column grid —
     the fixed column widths don't leave enough room for the message on a
     phone-width screen. */
  .log-line {
    grid-template-columns: auto auto 1fr;
    grid-template-areas:
      "time bot level"
      "msg  msg  msg";
    row-gap: 2px;
  }
  .log-line .lt-time {
    grid-area: time;
  }
  .log-line .lt-bot {
    grid-area: bot;
  }
  .log-line .lt-level {
    grid-area: level;
    justify-self: end;
  }
  .log-line .lt-msg {
    grid-area: msg;
  }
  .cred-value-row {
    flex-wrap: wrap;
  }
  .cred-btn {
    padding: 8px 12px;
  }
  .chart-card {
    padding: 14px 14px 0;
  }
  .chart-embed {
    height: 300px;
    margin: 0 -14px;
  }
}

/* Small phones */
@media (max-width: 420px) {
  .wrap {
    padding: 16px 12px 40px;
  }
  .card {
    padding: 14px;
  }
  .brand .tag {
    display: none;
  }
  .action-grid {
    grid-template-columns: 1fr;
  }
  .meta-row {
    flex-direction: column;
    gap: 8px;
  }
  .login-card {
    margin-top: 4vh;
  }
  .gn-history-grid {
    grid-template-columns: 1fr;
  }
  .log-feed {
    height: 300px;
  }
  .app-bottom-tab {
    font-size: 9px;
  }
  .app-bottom-tab svg {
    width: 19px;
    height: 19px;
  }
  .app-nav-menu-mobile {
    right: 8px;
    left: 8px;
  }
  .chart-embed {
    height: 240px;
  }
}
