/*
  Options Dashboard - FIX9 CSS
  =================================

  Ten plik jest celowo mocno opisany, żeby łatwo było ręcznie stroić dashboard.

  Najczęściej zmieniane miejsca:
  - prawa kolumna:        sekcja "RIGHT COLUMN"
  - wysokość górnego wykresu: .chart-main w sekcji "CHARTS"
  - wysokość heatmapy:    .heat-wrap w sekcji "HEATMAP"
  - wielkość komórek:     #heatTable th, #heatTable td
  - spacing opisów osi X: nie CSS, tylko JS: frontend/app.js -> AXIS_LABELS_MAIN / AXIS_LABELS_SMALL
*/

:root{
  --bg:#0b1220;
  --panel:#111827;
  --panel2:#0f172a;
  --border:#263244;
  --text:#e5eef9;
  --muted:#9fb0c3;
  --accent:#60a5fa;
}

*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--text);font-family:Inter,Arial,sans-serif}

/* MAIN LAYOUT
   Zmień grid-template-columns, jeśli chcesz szerszą/lewą albo węższą/prawą kolumnę. */
.wrap{padding:14px;display:grid;grid-template-columns:2.25fr .95fr;gap:14px;min-height:100vh}
.left,.side{display:grid;gap:14px;align-content:start}

/* PANELS */
.panel{background:linear-gradient(180deg,var(--panel),var(--panel2));border:1px solid var(--border);border-radius:16px;padding:14px;box-shadow:0 10px 30px rgba(0,0,0,.22)}
.title{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-bottom:10px;flex-wrap:wrap}
.title h2{margin:0;font-size:18px}.muted{color:var(--muted)}.small{font-size:12px}.headline{font-size:15px;font-weight:700}
.topbar{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.chip,select,input,button{padding:7px 10px;border-radius:999px;border:1px solid var(--border);background:#0c1423;color:var(--text);font-size:12px}
button{cursor:pointer}.chip{white-space:nowrap}

/* TOP METRIC CARDS */
.grid4{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}
.metric{border:1px solid var(--border);border-radius:12px;padding:10px;background:#0b1322;cursor:pointer}
.metric:hover{border-color:var(--accent)}
.metric .k{font-size:12px;color:var(--muted);margin-bottom:4px}.metric .v{font-size:20px;font-weight:700}

/* RIGHT COLUMN
   Fix4: panele po prawej są celowo bardziej zbite, żeby nie było dużych pustych przestrzeni.
   Strojenie:
   - .side .panel padding -> większe/mniejsze panele
   - .side .kv padding/margin/font-size -> gęstość listy poziomów
*/
.side{gap:10px}
.side .panel{padding:10px 12px;border-radius:14px}
.side .section-label{font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);margin-bottom:6px}
.kv{display:grid;grid-template-columns:1fr auto;gap:8px;border:1px solid var(--border);border-radius:10px;background:#0b1322;cursor:pointer}
.side .kv{padding:4px 7px;font-size:12px;margin-bottom:4px}
.left .kv{padding:10px;font-size:14px;margin-bottom:7px}
.kv:hover{border-color:var(--accent)}

/* CHARTS
   .chart-main = górny wykres. Zmień height, jeśli jest za wysoki/niski.
   .chart-gamma = środkowy wykres gamma.
   .chart-detail = trzeci wykres, domyślnie ukryty do czasu kliknięcia.
*/
.chart{width:100%;height:340px;display:block;background:#0b1322;border:1px solid var(--border);border-radius:12px}
.chart-main{height:900px}
.chart-gamma{height:380px}
.chart-detail{height:430px}
.hidden{display:none}

/* LEGEND */
.legend{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}
.legend-item{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--muted);padding:4px 8px;border:1px solid var(--border);border-radius:999px;background:#0c1423}
.sw{width:12px;height:12px;border-radius:3px;display:inline-block}

/* HEATMAP
   .heat-wrap max-height -> wysokość tabeli heatmapy.
   #heatTable th/td padding/font-size -> wielkość komórek.
*/
.heat-wrap{overflow:auto;max-height:680px;border:1px solid var(--border);border-radius:12px}
table{width:100%;border-collapse:collapse;font-size:13px}
thead th{position:sticky;top:0;background:#111827;z-index:2}
tfoot td{position:sticky;bottom:0;background:#111827;font-weight:800}
#heatTable th,#heatTable td{padding:9px 12px;border-bottom:1px solid rgba(255,255,255,.06);text-align:right}
th:first-child,td:first-child{text-align:right;position:sticky;left:0;background:#111827;z-index:1}
td.hm{cursor:pointer}

/* SVG CHART ELEMENTS */
.axis-label{fill:#9fb0c3;font-size:11px}
.axis-label-x{fill:#9fb0c3;font-size:10px}
.axis-title{fill:#cbd5e1;font-size:12px;font-weight:700}
.price-line{stroke-width:3}.regular-line{stroke-width:1.8}
.series-label{font-size:11px;font-weight:700;paint-order:stroke;stroke:#0b1322;stroke-width:2.0px;stroke-linejoin:round}

/* TOOLTIP */
.tooltip{position:fixed;pointer-events:none;background:#020617;border:1px solid var(--border);border-radius:10px;padding:8px 10px;color:var(--text);font-size:12px;box-shadow:0 10px 30px rgba(0,0,0,.45);z-index:20}

@media (max-width:1100px){.wrap{grid-template-columns:1fr}.grid4{grid-template-columns:repeat(2,1fr)}.chart-main{height:620px}}


/* ============================
   FIX5 LICENSE PANEL STYLES
   ============================
   Change these classes when you want to tune the license panel:
   - .license-panel.license-ok      green normal state
   - .license-panel.license-warning orange expiring soon / grace period
   - .license-panel.license-error   red expired / invalid / client limit
*/
.license-panel{border-width:2px}
.license-panel.license-ok{border-color:#22c55e}
.license-panel.license-warning{border-color:#f59e0b}
.license-panel.license-error{border-color:#ef4444}
.license-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}
.license-grid .metric{min-height:64px}
.hidden{display:none!important}
button{background:#1f2937;color:var(--text);border:1px solid var(--border);border-radius:10px;padding:7px 10px;cursor:pointer}
button:hover{filter:brightness(1.2)}

/* ============================
   FIX9 RIGHT-SIDE LICENSE PANEL
   ============================ */
.compact-title {
  margin-bottom: 8px;
}

.side .license-panel {
  padding: 10px 12px;
}

.side-license-grid {
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.side-license-grid .metric {
  min-height: auto;
  padding: 7px;
  cursor: default;
}

.side-license-grid .metric:hover {
  border-color: var(--border);
}

.side-license-grid .metric .k {
  font-size: 10px;
  margin-bottom: 2px;
}

.side-license-grid .metric .v {
  font-size: 12px;
  line-height: 1.2;
  word-break: break-word;
}

/* ============================
   FIX9 LICENSE MESSAGE STYLES
   ============================
   Typ komunikatu ustawiasz po stronie serwera licencji w polu message_type.
   Obsługiwane wartości: info, warning, error, success, promo, critical.
*/
.license-message-panel {
  overflow: hidden;
}

.license-message-body {
  font-size: 13px;
  line-height: 1.45;
  color: inherit;
}

.license-message-body a {
  color: var(--accent);
}

.license-message-body p:first-child {
  margin-top: 0;
}

.license-message-body p:last-child {
  margin-bottom: 0;
}

.msg-info {
  background: #e7f3ff;
  border-left: 4px solid #2196F3;
  color: #0b1220;
}

.msg-warning {
  background: #fff8e1;
  border-left: 4px solid #ff9800;
  color: #0b1220;
}

.msg-error {
  background: #fdecea;
  border-left: 4px solid #f44336;
  color: #0b1220;
}

.msg-success {
  background: #e8f5e9;
  border-left: 4px solid #4caf50;
  color: #0b1220;
}

.msg-promo {
  background: #f3e5f5;
  border-left: 4px solid #9c27b0;
  color: #0b1220;
}

.msg-critical {
  background: #000;
  border-left: 4px solid red;
  color: #fff;
}

/* ============================
   FIX8 BRANDING, MENU LABELS AND CLIENT LIMIT OVERLAY
   ============================ */
.brand-link {
  color: var(--accent);
  text-decoration: none;
}
.brand-link:hover { text-decoration: underline; }

.menu-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #0c1423;
  color: var(--muted);
  font-size: 11px;
}
.menu-field select,
.menu-field input {
  border: none;
  background: transparent;
  padding: 4px 6px;
  min-width: 72px;
}
.menu-field input { width: 96px; }
.menu-field span { white-space: nowrap; }

.client-limit-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(2, 6, 23, 0.88);
  backdrop-filter: blur(5px);
  padding: 20px;
}
.client-limit-card {
  width: min(720px, 96vw);
  border: 1px solid var(--border);
  border-radius: 20px;
  background: linear-gradient(180deg, #111827, #0f172a);
  box-shadow: 0 25px 80px rgba(0,0,0,.55);
  padding: 24px;
}
.client-limit-card h1 {
  margin: 0 0 8px;
  color: #fecaca;
}
.client-limit-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0;
}
.client-limit-grid div {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #0b1322;
  padding: 12px;
}
.client-limit-grid span {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 6px;
}
.client-limit-grid strong {
  font-size: 16px;
}
.client-limit-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.overlay-license-message {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #0b1322;
  font-size: 13px;
  line-height: 1.45;
}
@media (max-width: 700px) {
  .client-limit-grid { grid-template-columns: 1fr; }
  .menu-field { width: 100%; justify-content: space-between; }
}

/* FIX18a authentication and user management */
.auth-body{min-height:100vh;background:radial-gradient(circle at top left,#233b75 0,#111827 38%,#080b12 100%);color:#111827;display:flex;align-items:center;justify-content:center;padding:24px}.auth-card{width:min(460px,100%);background:#fff;border:1px solid rgba(255,255,255,.22);border-radius:24px;box-shadow:0 28px 90px rgba(0,0,0,.35);padding:30px}.auth-card h1{margin:10px 0 8px;font-size:32px}.auth-brand a{font-weight:900;color:#2563eb;text-decoration:none}.muted{color:#667085}.auth-form{display:grid;gap:12px;margin-top:18px}.auth-form input,.auth-form select,.user-panel input,.user-panel select{border:1px solid #d0d5dd;border-radius:14px;padding:12px 14px;font:inherit}.auth-form button,.user-panel button,.small-button{border:0;border-radius:14px;background:#2563eb;color:#fff;font-weight:900;padding:12px 16px;cursor:pointer;text-decoration:none;display:inline-flex;align-items:center;justify-content:center}.auth-msg{min-height:20px;font-size:14px}.auth-msg.err{color:#fca5a5}.auth-msg.ok{color:#86efac}.admin-users-body{align-items:flex-start;justify-content:stretch;padding:0;color:var(--text)}.users-shell{width:100%;max-width:none;margin:0;padding:24px}.users-header{display:flex;align-items:center;justify-content:space-between;gap:18px;color:#fff;margin-bottom:20px}.users-header h1{margin:0 0 8px}.users-header .muted{color:#cbd5e1}.users-actions{display:flex;gap:10px}.users-grid{display:grid;grid-template-columns:340px minmax(0,1fr);gap:20px;align-items:start}.user-panel{background:linear-gradient(180deg,var(--panel),var(--panel2));border:1px solid var(--border);color:var(--text);border-radius:22px;padding:22px;box-shadow:0 20px 70px rgba(0,0,0,.22);display:grid;gap:12px}.user-panel h2{margin-top:0}.user-panel .muted{color:var(--muted)}.user-panel.wide{overflow:hidden;min-width:0}.table-scroll{overflow:auto;width:100%;border:1px solid var(--border);border-radius:14px;background:#07111f}.users-table{width:100%;min-width:1180px;border-collapse:collapse;font-size:14px;color:var(--text);background:#07111f}.users-table th,.users-table td{border-bottom:1px solid rgba(255,255,255,.08);padding:12px;text-align:left;vertical-align:top}.users-table th{position:sticky;top:0;background:#111827;z-index:2;font-size:12px;color:#bfdbfe;text-transform:uppercase;letter-spacing:.08em}.users-table tr:nth-child(even) td{background:#0b1322}.users-table tr:hover td{background:#122039}.user-row-actions{display:flex;gap:6px;flex-wrap:wrap}.user-row-actions button{padding:8px 10px;border-radius:999px;background:#1f2937;color:var(--text);border:1px solid var(--border)}.field-label{display:grid;gap:6px;font-weight:700;color:var(--text)}.user-edit{width:100%;box-sizing:border-box;border:1px solid var(--border);border-radius:10px;padding:8px 10px;font:inherit;background:#0c1423;color:var(--text)}.users-table td{min-width:100px}.users-table td:nth-child(2){min-width:150px}.users-table td:nth-child(3){min-width:240px}.users-table td:nth-child(6){min-width:190px}@media(max-width:900px){.users-grid{grid-template-columns:1fr}.users-header{display:grid}.auth-body{align-items:flex-start}.users-shell{padding:16px}}

/* FIX18a: dashboard menu buttons use the same style as Download analysis ZIP */
#exportBtn,.admin-users-link,#logoutDashboardBtn{background:#1f2937 !important;color:var(--text,#e5e7eb) !important;border:1px solid var(--border,#334155) !important;border-radius:10px !important;padding:7px 10px !important;font-size:12px !important;font-weight:800 !important;line-height:1.2 !important;cursor:pointer;text-decoration:none;display:inline-flex;align-items:center;justify-content:center;min-height:32px}
#exportBtn:hover,.admin-users-link:hover,#logoutDashboardBtn:hover{filter:brightness(1.2)}
.auth-help a{color:#2563eb;font-weight:800;text-decoration:none}.auth-help a:hover{text-decoration:underline}
