/* Trading Bot Dashboard — TradingView-inspired dark theme */
:root {
  --bg: #131722;
  --panel: #1e222d;
  --panel-2: #262b38;
  --border: #2a2e39;
  --text: #d1d4dc;
  --text-strong: #f0f3fa;
  --muted: #787b86;
  --accent: #2962ff;
  --accent-hover: #3d74ff;
  --up: #26a69a;
  --down: #ef5350;
  --warn: #f5a623;
  --radius: 6px;
  --radius-lg: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --bottom-nav-height: 56px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  min-height: 100dvh;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

[hidden] { display: none !important; }
h1, h2, h3 { color: var(--text-strong); margin: 0; font-weight: 600; }
h2 { font-size: 18px; }
p { margin: 0; }
code { font-family: var(--mono); background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
a { color: var(--accent-hover); }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------- Buttons */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 8px 14px;
  min-height: 38px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-strong);
  background: var(--panel-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: background .12s, border-color .12s, opacity .12s, transform .08s;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--panel-2); }
.btn-danger { background: var(--down); }
.btn-danger-ghost { background: transparent; border-color: var(--border); color: var(--down); }
.btn-danger-ghost:hover:not(:disabled) { background: rgba(239, 83, 80, .12); border-color: var(--down); }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- Forms */
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
input[type="text"], input[type="password"], input[type="number"], .select {
  width: 100%;
  background: var(--bg);
  color: var(--text-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  min-height: 38px;
  font: inherit;
  touch-action: manipulation;
}
input:focus, .select:focus { border-color: var(--accent); outline: none; }
input.is-invalid, .select.is-invalid { border-color: var(--down); }
.form-error { color: var(--down); font-size: 13px; margin: 6px 0 10px; }

/* ---------------------------------------------------------------- Login */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: clamp(16px, 4vw, 28px);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(20px, 5vw, 28px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .4);
}
.login-subtitle { margin: 6px 0 22px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-large h1 { font-size: 20px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--up) 0 50%, var(--down) 50% 100%);
}
.brand-name { font-weight: 700; color: var(--text-strong); }

/* --------------------------------------------------------------- Shell */
.app-body { display: flex; flex-direction: column; min-height: 100%; min-height: 100dvh; }
.topbar {
  display: flex; align-items: center; gap: 24px;
  height: 52px; padding: 0 16px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.tabs { display: flex; gap: 4px; height: 100%; }
.tab {
  appearance: none; background: none; border: none; color: var(--muted);
  font: inherit; font-weight: 600; padding: 0 14px; cursor: pointer;
  border-bottom: 2px solid transparent;
  display: inline-flex; align-items: center; gap: 8px;
  touch-action: manipulation;
  transition: color .12s, border-color .12s, background .12s;
}
.tab-icon { flex-shrink: 0; }
.tab-label { white-space: nowrap; }
.tab:hover { color: var(--text-strong); }
.tab.is-active { color: var(--text-strong); border-bottom-color: var(--accent); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-name { font-size: 13px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.view { flex: 1; display: flex; flex-direction: column; padding: 12px 16px 16px; min-height: 0; }

/* -------------------------------------------------------------- Market */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 10px; }
.toolbar-group { display: flex; align-items: center; gap: 8px; }
.toolbar-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.toolbar-spacer { flex: 1; }
.toolbar .select { width: auto; min-width: 150px; }

.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.segmented button {
  appearance: none; border: none; background: var(--panel); color: var(--text);
  font: inherit; padding: 7px 12px; cursor: pointer; border-right: 1px solid var(--border);
  min-height: 36px; display: inline-flex; align-items: center; justify-content: center;
  touch-action: manipulation; transition: background .12s, color .12s;
}
.segmented button:last-child { border-right: none; }
.segmented button:hover { background: var(--panel-2); }
.segmented button.is-active { background: var(--accent); color: #fff; font-weight: 600; }
.segmented button:disabled { opacity: .5; cursor: not-allowed; }

.statusbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px;
  padding: 8px 12px; margin-bottom: 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 12.5px;
}
.statusbar-main { display: contents; }
.statusbar-details { display: contents; }
.statusbar-toggle { display: none; }
.meta { display: inline-flex; align-items: baseline; gap: 6px; }
.meta-label { color: var(--muted); }
.meta-value { display: inline-flex; align-items: baseline; gap: 6px; }
.meta b { color: var(--text-strong); font-weight: 600; font-variant-numeric: tabular-nums; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-weight: 600; font-size: 12px;
  background: var(--panel-2); border: 1px solid var(--border); flex-shrink: 0;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill-ok { color: var(--up); }
.pill-warn { color: var(--warn); }
.pill-bad { color: var(--down); }
.pill-muted { color: var(--muted); }
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; background: var(--panel-2); color: var(--muted);
}
.tag-open { color: var(--warn); }
.tag-closed { color: var(--up); }

.chart-card {
  position: relative; flex: 1; min-height: 420px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.chart { position: absolute; inset: 0; }
.legend {
  position: absolute; left: 12px; top: 10px; z-index: 5; pointer-events: none;
  display: flex; flex-wrap: wrap; gap: 4px 14px; max-width: calc(100% - 90px);
  font: 12px/1.3 var(--mono); color: var(--text);
  background: rgba(19, 23, 34, .82); padding: 6px 8px; border-radius: 4px;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.legend .lg-title { color: var(--text-strong); font-weight: 700; font-family: var(--font); }
.legend .lg-key { color: var(--muted); margin-right: 3px; }
.legend .up { color: var(--up); }
.legend .down { color: var(--down); }

.overlay {
  position: absolute; inset: 0; z-index: 8; display: grid; place-items: center;
  background: rgba(19, 23, 34, .94); text-align: center; padding: 20px;
}
.overlay-light { background: rgba(19, 23, 34, .55); }
.overlay-box { max-width: 460px; display: flex; flex-direction: column; gap: 8px; }
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.footnote { margin-top: 8px; font-size: 12px; }

/* ------------------------------------------------------------ Settings */
.settings-header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.settings-header p { max-width: 640px; margin-top: 4px; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }

.status-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 9px 12px; margin-bottom: 12px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--border); font-size: 13px;
}
.status-banner .chip { font-weight: 600; color: var(--text-strong); }
.status-banner .ok { color: var(--up); }
.status-banner .pending { color: var(--warn); }
.status-error { border-color: var(--down); color: var(--down); }

.settings-sections { display: flex; flex-direction: column; gap: 16px; }
.section-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.section-card > header { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.section-card > header h3 { font-size: 15px; }
.section-card > header p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.setup-subgroup-title { padding: 14px 16px 4px 16px; font-size: 13.5px; font-weight: 700; color: var(--primary, #3b82f6); letter-spacing: 0.3px; display: flex; align-items: center; gap: 8px; border-bottom: 1px dashed var(--border); margin: 0 16px; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px 20px; padding: 16px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.span-all { grid-column: 1 / -1; }
.field-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.field-label { font-weight: 600; color: var(--text-strong); }
.field-desc { font-size: 12px; color: var(--muted); }
.field-key { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.field-hint { font-size: 11.5px; color: var(--muted); }
.field-error { font-size: 12px; color: var(--down); min-height: 0; }
.field.is-dirty .field-label::after {
  content: "modified"; margin-left: 8px; font-size: 10px; font-weight: 700; text-transform: uppercase;
  color: var(--warn); border: 1px solid var(--warn); border-radius: 4px; padding: 0 5px;
}
.icon-btn {
  appearance: none; background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 12px; padding: 2px 6px; border-radius: 4px;
  touch-action: manipulation;
}
.icon-btn:hover { color: var(--text-strong); background: var(--panel-2); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-item {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px;
  font-family: var(--mono); font-size: 12.5px; color: var(--text-strong);
}
.chip-item button { appearance: none; border: none; background: none; color: var(--muted); cursor: pointer; border-radius: 50%; width: 22px; height: 22px; line-height: 1; touch-action: manipulation; }
.chip-item button:hover { color: #fff; background: var(--down); }
.chip-add { display: flex; gap: 8px; margin-top: 6px; max-width: 360px; }

.audit { margin-top: 18px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.audit summary { cursor: pointer; padding: 12px 16px; font-weight: 600; color: var(--text-strong); touch-action: manipulation; }
.audit-body { padding: 0 16px 14px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.audit table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.audit th, .audit td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.audit th { color: var(--muted); font-weight: 600; }
.audit td.diff { font-family: var(--mono); color: var(--text); word-break: break-word; }

/* ------------------------------------------------- Dialog & notifications */
.dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; max-width: 420px; width: calc(100% - 32px);
}
.dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog h3 { margin-bottom: 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast {
  background: var(--panel-2); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius); padding: 10px 14px; max-width: 360px; box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
}
.toast-success { border-left-color: var(--up); }
.toast-error { border-left-color: var(--down); }

/* ------------------------------------------------- Observability & Logs */
.logs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
}
.logs-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.grafana-frame-container {
  width: 100%;
  height: calc(100vh - 180px);
  min-height: 550px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}
.grafana-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
}

/* ========================================================================= */
/* Responsive Mobile & Touch Optimizations                                  */
/* ========================================================================= */

@media (max-width: 768px) {
  .view { padding: 10px 12px 14px; }
}

@media (max-width: 680px) {
  /* Prevent iOS zoom jumps on focus */
  input[type="text"], input[type="password"], input[type="number"], .select {
    font-size: 16px;
    min-height: 42px;
  }

  /* Safe area aware topbar with Brand and User/Logout only */
  .topbar {
    height: calc(52px + var(--safe-top));
    padding: var(--safe-top) 12px 0 12px;
    gap: 12px;
  }
  .brand-name { font-size: 15px; }
  .user-name { display: none; }
  .btn-ghost { padding: 6px 10px; }

  /* Ergonomic mobile bottom navigation bar */
  .tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--panel);
    border-top: 1px solid var(--border);
    border-bottom: none;
    z-index: 40;
    display: flex;
    gap: 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, .45);
  }
  .tab {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px 2px;
    font-size: 11px;
    font-weight: 500;
    border-bottom: none;
    border-top: 2px solid transparent;
    color: var(--muted);
  }
  .tab.is-active {
    color: var(--accent-hover);
    border-top-color: var(--accent);
    background: rgba(41, 98, 255, 0.08);
  }
  .tab-icon {
    width: 20px;
    height: 20px;
  }
  .tab-label {
    font-size: 11px;
    line-height: 1;
  }

  /* Content clearance above fixed bottom navigation */
  .content {
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 14px);
  }

  /* Toasts positioned above bottom navigation */
  .toasts {
    bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 12px);
    left: 12px;
    right: 12px;
    max-width: none;
  }
  .toast {
    max-width: 100%;
  }

  /* Market view responsive mobile toolbar */
  .toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
  }
  .toolbar-group:first-child {
    flex: 1 1 120px;
    min-width: 0;
  }
  .toolbar-group:first-child .select {
    width: 100%;
    min-width: 0;
  }
  .toolbar-group:last-child {
    margin-left: auto;
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
  }
  .toolbar-group:last-child .btn {
    min-height: 42px;
    padding: 0 14px;
  }
  .toolbar-spacer {
    display: none;
  }
  .toolbar-group:nth-child(2) {
    order: 3;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .toolbar-group:nth-child(2) .toolbar-label {
    font-size: 11px;
  }
  #timeframe-group {
    width: 100%;
    display: flex;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-radius: var(--radius);
  }
  #timeframe-group::-webkit-scrollbar {
    display: none;
  }
  #timeframe-group button {
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 40px;
    padding: 8px 12px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
  }

  /* Mobile statusbar: compact bar by default, expandable details drawer */
  .statusbar {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 6px 10px;
    margin-bottom: 8px;
    font-size: 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  .statusbar-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 28px;
  }

  .statusbar-main .pill {
    padding: 2px 8px;
    font-size: 11.5px;
  }

  .statusbar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    min-height: 28px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    user-select: none;
    -webkit-user-select: none;
    margin-left: auto;
  }

  .statusbar-toggle:hover,
  .statusbar-toggle:active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
  }

  .statusbar-toggle[aria-expanded="true"] {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
  }

  .statusbar-toggle .toggle-icon {
    transition: transform 0.2s ease;
  }

  .statusbar-toggle[aria-expanded="true"] .toggle-icon {
    transform: rotate(180deg);
  }

  .statusbar-details {
    display: none;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    width: 100%;
  }

  .statusbar.is-expanded .statusbar-details,
  .statusbar-toggle[aria-expanded="true"] ~ .statusbar-details {
    display: flex;
  }

  .statusbar-details .meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    padding: 7px 10px;
    background: var(--panel-2);
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.04);
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
  }

  .statusbar-details .meta-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--muted);
    font-weight: 600;
  }

  .statusbar-details .meta-value {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    width: 100%;
  }

  .statusbar-details .meta b {
    font-size: 12px;
    font-family: var(--mono);
    color: var(--text-strong);
    white-space: normal;
    word-break: break-word;
    overflow: visible;
    text-overflow: clip;
    max-width: 100%;
    line-height: 1.4;
  }

  /* Chart card mobile height & legend */
  .chart-card {
    min-height: 340px;
    height: clamp(340px, 52vh, 560px);
  }
  .legend {
    left: 8px;
    top: 8px;
    max-width: calc(100% - 16px);
    font-size: 11px;
    gap: 3px 8px;
    padding: 4px 6px;
    background: rgba(19, 23, 34, 0.88);
  }

  /* Settings view mobile layout */
  .settings-header {
    flex-direction: column;
    gap: 12px;
  }
  .settings-header h2 {
    font-size: 17px;
  }
  .settings-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }
  #settings-save {
    grid-column: 1 / -1;
    min-height: 44px;
    font-size: 15px;
    order: -1;
  }
  #settings-discard, #settings-reset {
    min-height: 40px;
    font-size: 13px;
    padding: 6px 8px;
  }
  .field-grid {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 12px;
  }
  .setup-subgroup-title {
    margin: 0 12px;
    padding: 10px 0 4px 0;
    font-size: 13px;
  }
  .icon-btn {
    min-width: 32px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--panel-2);
  }
  .chips {
    gap: 8px;
  }
  .chip-item {
    font-size: 13px;
    padding: 5px 8px 5px 12px;
  }
  .chip-item button {
    width: 26px;
    height: 26px;
    line-height: 26px;
    font-size: 15px;
  }
  .chip-add {
    max-width: 100%;
    width: 100%;
  }
  .chip-add input {
    font-size: 16px;
    min-height: 42px;
  }
  .chip-add .btn {
    min-height: 42px;
    padding: 0 16px;
  }

  /* Observability & Logs mobile layout */
  .logs-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .logs-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }
  .logs-actions .segmented {
    grid-column: 1 / -1;
    width: 100%;
    display: flex;
  }
  .logs-actions .segmented .btn {
    flex: 1;
    min-height: 40px;
  }
  #btn-open-explore, #btn-open-dashboard {
    min-height: 40px;
    font-size: 13px;
    padding: 6px 10px;
  }
  .grafana-frame-container {
    height: calc(100dvh - 240px);
    min-height: 380px;
  }

  /* Dialog actions full width */
  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }
  .dialog-actions .btn {
    min-height: 44px;
  }
}

/* Landscape mobile optimization: full chart screen */
@media (max-height: 500px) and (orientation: landscape) {
  .topbar {
    height: calc(42px + var(--safe-top));
    padding: var(--safe-top) 12px 0 12px;
  }
  .tabs {
    display: none;
  }
  .content {
    padding-bottom: 0;
  }
  .toolbar {
    margin-bottom: 4px;
    gap: 8px;
  }
  .statusbar {
    display: none;
  }
  .chart-card {
    min-height: 220px;
    height: calc(100dvh - 75px);
  }
  .footnote {
    display: none;
  }
  .grafana-frame-container {
    height: calc(100dvh - 110px);
    min-height: 220px;
  }
}
