/* =======================================================
   SEI – Stock Engine Intelligence
   Design System v2 — Professional Fintech UI
   ======================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* -------------------------------------------------------
   CSS Custom Properties
------------------------------------------------------- */
:root {
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;

    /* Neutral palette */
    --slate-950: #020617;
    --slate-900: #0f172a;
    --slate-800: #1e293b;
    --slate-700: #334155;
    --slate-600: #475569;
    --slate-500: #64748b;
    --slate-400: #94a3b8;
    --slate-300: #cbd5e1;
    --slate-200: #e2e8f0;
    --slate-100: #f1f5f9;
    --slate-50:  #f8fafc;
    --white:     #ffffff;

    /* Accent — electric blue */
    --blue-700: #1d4ed8;
    --blue-600: #2563eb;
    --blue-500: #3b82f6;
    --blue-400: #60a5fa;
    --blue-300: #93c5fd;
    --blue-100: #dbeafe;
    --blue-50:  #eff6ff;

    /* Signal badge palette */
    --badge-buy-bg:       #dcfce7; --badge-buy-text:       #15803d; --badge-buy-ring:       #86efac;
    --badge-increase-bg:  #bbf7d0; --badge-increase-text:  #14532d; --badge-increase-ring:  #4ade80;
    --badge-hold-bg:      #e0f2fe; --badge-hold-text:      #0369a1; --badge-hold-ring:      #7dd3fc;
    --badge-reduce-bg:    #fff7ed; --badge-reduce-text:    #c2410c; --badge-reduce-ring:    #fdba74;
    --badge-sell-bg:      #fee2e2; --badge-sell-text:      #b91c1c; --badge-sell-ring:      #fca5a5;
    --badge-avoid-bg:     #fef3c7; --badge-avoid-text:     #92400e; --badge-avoid-ring:     #fcd34d;
    --badge-neutral-bg:   #f1f5f9; --badge-neutral-text:   #475569; --badge-neutral-ring:   #cbd5e1;

    /* Status / risk */
    --color-success: #16a34a;
    --color-warning: #d97706;
    --color-danger:  #dc2626;
    --color-extreme: #7f1d1d;

    /* Elevation / shadow */
    --shadow-xs: 0 1px 2px rgba(15,23,42,0.07);
    --shadow-sm: 0 1px 4px rgba(15,23,42,0.08), 0 1px 2px rgba(15,23,42,0.05);
    --shadow-md: 0 4px 16px rgba(15,23,42,0.09), 0 2px 6px rgba(15,23,42,0.05);
    --shadow-lg: 0 12px 40px rgba(15,23,42,0.12), 0 4px 12px rgba(15,23,42,0.06);

    /* Radius */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    /* Layout */
    --header-h: 64px;
    --nav-h:    46px;
    --container-max: 1640px;
    --page-pad: 32px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--slate-100);
    color: var(--slate-800);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--blue-600);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* -------------------------------------------------------
   Header
------------------------------------------------------- */
.main-header {
    background: linear-gradient(135deg, var(--slate-950) 0%, #1a2a4a 100%);
    color: var(--white);
    height: var(--header-h);
    padding: 0 var(--page-pad);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    position: sticky;
    top: 0;
    z-index: 200;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 2px 24px rgba(0, 0, 0, 0.35);
}

.main-header::before {
    content: '';
    display: block;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--blue-500), var(--blue-400));
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='22 7 13.5 15.5 8.5 10.5 2 17'/%3E%3Cpolyline points='16 7 22 7 22 13'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 18px;
}

/* The div wrapping h1+p inside the header */
.main-header > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.main-header h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--white);
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.main-header p {
    font-size: 12px;
    color: var(--slate-400);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    line-height: 1;
}

/* Live dot after subtitle */
.main-header p::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 2px rgba(34,197,94,0.3);
    animation: pulse-dot 2.5s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 2px rgba(34,197,94,0.3); }
    50%       { box-shadow: 0 0 0 5px rgba(34,197,94,0.1); }
}

/* -------------------------------------------------------
   Navigation
------------------------------------------------------- */
.main-nav {
    background: var(--slate-800);
    height: var(--nav-h);
    padding: 0 var(--page-pad);
    display: flex;
    align-items: center;
    gap: var(--space-1);
    position: sticky;
    top: var(--header-h);
    z-index: 199;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.main-nav::-webkit-scrollbar { display: none; }

.main-nav a {
    display: inline-flex;
    align-items: center;
    color: var(--slate-400);
    font-size: 13px;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: color 0.15s, background 0.15s;
    position: relative;
    text-decoration: none;
    letter-spacing: 0.1px;
}

.main-nav a:hover {
    background: rgba(255,255,255,0.07);
    color: var(--white);
    text-decoration: none;
}

.main-nav a.active {
    color: var(--blue-400);
    background: rgba(59,130,246,0.12);
    font-weight: 600;
}

.main-nav a.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 10px;
    right: 10px;
    height: 2px;
    background: var(--blue-400);
    border-radius: 999px;
}

/* Nav divider */
.main-nav-sep {
    width: 1px;
    height: 18px;
    background: rgba(255,255,255,0.1);
    margin: 0 var(--space-2);
    flex-shrink: 0;
}

/* -------------------------------------------------------
   Page Container
------------------------------------------------------- */
.container {
    padding: var(--space-6) var(--page-pad);
    max-width: var(--container-max);
    margin: 0 auto;
}

/* -------------------------------------------------------
   KPI Grid
------------------------------------------------------- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

/* -------------------------------------------------------
   Card (KPI tile)
------------------------------------------------------- */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 18px 22px 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--slate-200);
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* Colored top accent bar */
.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--blue-500), var(--blue-400));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.card h2 {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--slate-500);
    text-transform: uppercase;
    letter-spacing: 0.9px;
    margin-bottom: var(--space-2);
    margin-top: 0;
}

.card .value {
    font-size: 28px;
    font-weight: 800;
    color: var(--slate-900);
    line-height: 1.1;
    letter-spacing: -0.8px;
    font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------
   Section (content panel)
------------------------------------------------------- */
.section {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--slate-200);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-6);
    overflow: hidden;
}

.section > h2 {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--slate-800);
    padding: 16px 22px 14px;
    border-bottom: 1px solid var(--slate-100);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--slate-50);
}

/* Left accent line on h2 */
.section > h2::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 16px;
    background: var(--blue-500);
    border-radius: 999px;
    flex-shrink: 0;
}

/* Non-table inner content gets padding */
.section > p,
.section > .legend-grid,
.section > .notes-grid,
.section > ul,
.section > ol {
    padding: var(--space-5) var(--space-6);
}

/* Section overflow for wide tables */
.section-scroll {
    overflow-x: auto;
}

/* -------------------------------------------------------
   Tables
------------------------------------------------------- */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    background: var(--slate-50);
    color: var(--slate-500);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--slate-200);
    white-space: nowrap;
}

thead th[title] {
    cursor: help;
    text-decoration: underline dotted var(--slate-400);
    text-underline-offset: 3px;
}

tbody td {
    padding: 9px 16px;
    border-bottom: 1px solid var(--slate-100);
    color: var(--slate-700);
    vertical-align: middle;
    white-space: nowrap;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover td {
    background: var(--blue-50);
}

/* Numeric columns use monospace */
td.num,
th.num {
    font-family: var(--font-mono);
    font-size: 12.5px;
    text-align: right;
}

/* Strong text in tables */
td strong {
    color: var(--slate-900);
    font-weight: 600;
}

/* P&L coloring helpers */
.pnl-pos { color: var(--color-success); font-weight: 600; font-family: var(--font-mono); font-size: 12.5px; }
.pnl-neg { color: var(--color-danger);  font-weight: 600; font-family: var(--font-mono); font-size: 12.5px; }

/* Asset row with missing data */
tr.row-warning td {
    background: #fffbeb;
}

tr.row-warning:hover td {
    background: #fef3c7;
}

/* -------------------------------------------------------
   Badges (signal types)
------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.2px;
    white-space: nowrap;
    line-height: 1.5;
    cursor: default;
}

.buy      { background: var(--badge-buy-bg);      color: var(--badge-buy-text);      border: 1px solid var(--badge-buy-ring); }
.increase { background: var(--badge-increase-bg); color: var(--badge-increase-text); border: 1px solid var(--badge-increase-ring); }
.hold     { background: var(--badge-hold-bg);     color: var(--badge-hold-text);     border: 1px solid var(--badge-hold-ring); }
.reduce   { background: var(--badge-reduce-bg);   color: var(--badge-reduce-text);   border: 1px solid var(--badge-reduce-ring); }
.sell     { background: var(--badge-sell-bg);     color: var(--badge-sell-text);     border: 1px solid var(--badge-sell-ring); }
.avoid    { background: var(--badge-avoid-bg);    color: var(--badge-avoid-text);    border: 1px solid var(--badge-avoid-ring); }
.neutral  { background: var(--badge-neutral-bg);  color: var(--badge-neutral-text);  border: 1px solid var(--badge-neutral-ring); }

/* Status badges (jobs, logs) */
.badge-status-pending   { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.badge-status-running   { background: var(--blue-100); color: var(--blue-700); border: 1px solid var(--blue-300); }
.badge-status-completed { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.badge-status-failed    { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }

/* Log level badges */
.badge-debug    { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.badge-info     { background: var(--blue-100); color: var(--blue-700); border: 1px solid var(--blue-300); }
.badge-warning  { background: #fff7ed; color: #c2410c; border: 1px solid #fdba74; }
.badge-error    { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.badge-critical { background: #fdf2f8; color: #86198f; border: 1px solid #f0abfc; }

/* Verdict badges */
.badge-robust   { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.badge-fragile  { background: #fff7ed; color: #c2410c; border: 1px solid #fdba74; }
.badge-overfitted { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.badge-too-risky  { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }

/* -------------------------------------------------------
   Risk levels
------------------------------------------------------- */
.risk-low     { color: var(--color-success); font-weight: 600; }
.risk-medium  { color: var(--color-warning); font-weight: 600; }
.risk-high    { color: var(--color-danger);  font-weight: 600; }
.risk-extreme { color: var(--color-extreme); font-weight: 700; letter-spacing: 0.3px; }

/* -------------------------------------------------------
   Filter Form
------------------------------------------------------- */
form.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
    gap: var(--space-4);
    align-items: end;
    padding: var(--space-5) var(--space-6);
    background: var(--slate-50);
    border-bottom: 1px solid var(--slate-200);
}

label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--slate-600);
    margin-bottom: var(--space-1);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

input,
select {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 11px;
    border: 1px solid var(--slate-300);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: var(--font-sans);
    color: var(--slate-800);
    background: var(--white);
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
    -webkit-appearance: none;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

input::placeholder {
    color: var(--slate-400);
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3E%3Cpath stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    padding-right: 30px;
    cursor: pointer;
}

/* -------------------------------------------------------
   Buttons
------------------------------------------------------- */
button,
input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    width: 100%;
    box-sizing: border-box;
    padding: 9px 18px;
    background: var(--slate-900);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: var(--font-sans);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    letter-spacing: 0.1px;
}

button:hover,
input[type="submit"]:hover {
    background: var(--slate-700);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

button:active,
input[type="submit"]:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--blue-600);
}

.btn-primary:hover {
    background: var(--blue-700);
}

.btn-danger {
    background: var(--color-danger);
}

.btn-danger:hover {
    background: #b91c1c;
}

.button-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    padding: 9px 18px;
    background: var(--white);
    color: var(--slate-700);
    border: 1px solid var(--slate-300);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: var(--font-sans);
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.button-secondary:hover {
    background: var(--slate-100);
    border-color: var(--slate-400);
    text-decoration: none;
}

/* -------------------------------------------------------
   Legend Grid & Note Boxes
------------------------------------------------------- */
.legend-grid,
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
    gap: var(--space-3);
}

.legend-item {
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    padding: 14px 15px;
    background: var(--slate-50);
    transition: box-shadow 0.15s, border-color 0.15s;
}

.legend-item:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--slate-300);
}

.legend-item strong {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-1);
    font-size: 12.5px;
    color: var(--slate-800);
}

.legend-item span {
    font-size: 12px;
    color: var(--slate-500);
    line-height: 1.5;
    display: block;
}

/* Note boxes */
.note-box {
    border: 1px solid var(--slate-200);
    border-left: 4px solid var(--slate-700);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    background: var(--slate-50);
    line-height: 1.5;
}

.note-box h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--slate-800);
    margin-bottom: 6px;
}

.note-box p {
    font-size: 12.5px;
    color: var(--slate-600);
    line-height: 1.55;
}

.note-box ul {
    margin: 6px 0 0 0;
    padding-left: 18px;
    font-size: 12.5px;
    color: var(--slate-600);
    line-height: 1.6;
}

.note-warning {
    border-left-color: var(--color-warning);
    background: #fffbeb;
    border-color: #fde68a;
    border-left-color: var(--color-warning);
}

.note-warning h3 { color: #92400e; }

.note-good {
    border-left-color: var(--color-success);
    background: #f0fdf4;
    border-color: #bbf7d0;
    border-left-color: var(--color-success);
}

.note-good h3 { color: var(--color-success); }

.note-risk {
    border-left-color: var(--color-danger);
    background: #fef2f2;
    border-color: #fecaca;
    border-left-color: var(--color-danger);
}

.note-risk h3 { color: var(--color-danger); }

/* -------------------------------------------------------
   Misc utilities
------------------------------------------------------- */
.details {
    max-width: 440px;
    white-space: normal;
    color: var(--slate-600);
    line-height: 1.5;
    font-size: 12.5px;
}

.muted {
    color: var(--slate-500);
    font-size: 12.5px;
}

.small-help {
    display: block;
    margin-top: var(--space-1);
    color: var(--slate-500);
    font-size: 11.5px;
    font-weight: 400;
    white-space: normal;
    line-height: 1.45;
}

.tooltip-help {
    cursor: help;
}

/* Monospace numbers (prices, pct) */
.mono {
    font-family: var(--font-mono);
    font-size: 12.5px;
}

/* Text align helpers */
.text-right  { text-align: right; }
.text-center { text-align: center; }

/* -------------------------------------------------------
   SVG / Chart containers
------------------------------------------------------- */
.chart-wrap {
    padding: var(--space-5) var(--space-6);
    overflow-x: auto;
}

.chart-wrap svg {
    display: block;
    background: linear-gradient(180deg, var(--slate-50) 0%, var(--white) 100%);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    width: 100%;
    height: auto;
}

/* -------------------------------------------------------
   Feature importance bar
------------------------------------------------------- */
.feat-bar-track {
    background: var(--slate-200);
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
    min-width: 120px;
}

.feat-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue-600), var(--blue-400));
    border-radius: 999px;
    transition: width 0.4s ease;
}

/* -------------------------------------------------------
   Details / Summary (expandable log context)
------------------------------------------------------- */
details > summary {
    cursor: pointer;
    color: var(--blue-600);
    font-size: 12.5px;
    font-weight: 500;
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    user-select: none;
    transition: color 0.15s;
}

details > summary::before {
    content: '▶';
    font-size: 9px;
    transition: transform 0.15s;
}

details[open] > summary::before {
    transform: rotate(90deg);
}

details > summary:hover {
    color: var(--blue-700);
    text-decoration: underline;
}

details[open] > summary {
    margin-bottom: var(--space-2);
}

pre {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--slate-900);
    color: #a5f3fc;
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    overflow-x: auto;
    white-space: pre-wrap;
    line-height: 1.6;
    border: 1px solid var(--slate-700);
}

/* -------------------------------------------------------
   Form inside section (strategy / comandi selectors)
------------------------------------------------------- */
.section > form:not(.filters) {
    padding: var(--space-5) var(--space-6);
}

.form-group {
    margin-bottom: var(--space-4);
}

/* Strategy edit textarea */
textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 11px;
    border: 1px solid var(--slate-300);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: var(--font-sans);
    color: var(--slate-800);
    background: var(--white);
    transition: border-color 0.15s, box-shadow 0.15s;
    resize: vertical;
    min-height: 80px;
}

textarea:focus {
    outline: none;
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

/* Inline checkbox label */
.label-inline {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--slate-700);
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
    margin-right: var(--space-5);
}

.label-inline input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: var(--blue-600);
    cursor: pointer;
    padding: 0;
}

/* -------------------------------------------------------
   Command buttons (comandi.php)
------------------------------------------------------- */
.cmd-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-4);
    padding: var(--space-5) var(--space-6);
}

.cmd-card {
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    transition: box-shadow 0.15s, border-color 0.15s;
}

.cmd-card:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--slate-300);
}

.cmd-card h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--slate-800);
    margin: 0;
}

.cmd-card p {
    font-size: 12.5px;
    color: var(--slate-500);
    line-height: 1.5;
    margin: 0;
}

/* -------------------------------------------------------
   PIN / Auth form
------------------------------------------------------- */
.auth-wrap {
    max-width: 360px;
    margin: var(--space-8) auto;
    padding: var(--space-8);
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--slate-200);
    text-align: center;
}

.auth-wrap h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--slate-900);
    margin-bottom: var(--space-2);
}

.auth-wrap p {
    font-size: 13.5px;
    color: var(--slate-500);
    margin-bottom: var(--space-6);
}

/* -------------------------------------------------------
   Footer
------------------------------------------------------- */
.footer {
    color: var(--slate-400);
    font-size: 12px;
    padding: var(--space-5) var(--page-pad) var(--space-8);
    max-width: var(--container-max);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: var(--space-4);
    border-top: 1px solid var(--slate-200);
    margin-top: var(--space-2);
}

.footer::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    flex-shrink: 0;
}

/* -------------------------------------------------------
   Scrollbar (Webkit)
------------------------------------------------------- */
::-webkit-scrollbar             { width: 6px; height: 6px; }
::-webkit-scrollbar-track       { background: transparent; }
::-webkit-scrollbar-thumb       { background: var(--slate-300); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--slate-400); }

/* -------------------------------------------------------
   Responsive
------------------------------------------------------- */
@media (max-width: 1024px) {
    :root {
        --page-pad: 24px;
    }
}

@media (max-width: 768px) {
    :root {
        --header-h:  56px;
        --page-pad:  16px;
        --container-max: 100%;
    }

    .main-header h1 {
        font-size: 16px;
    }

    .main-header p {
        display: none;
    }

    .main-nav a {
        font-size: 12.5px;
        padding: 4px 9px;
    }

    .grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-3);
    }

    .card .value {
        font-size: 22px;
    }

    thead th,
    tbody td {
        padding: 8px 12px;
        font-size: 12.5px;
    }

    form.filters {
        grid-template-columns: 1fr 1fr;
        padding: var(--space-4) var(--space-4);
        gap: var(--space-3);
    }

    .legend-grid,
    .notes-grid {
        grid-template-columns: 1fr;
    }

    .section > h2 {
        padding: 14px 16px 12px;
        font-size: 14px;
    }

    .cmd-grid {
        grid-template-columns: 1fr;
        padding: var(--space-4);
    }
}

@media (max-width: 480px) {
    .grid {
        grid-template-columns: 1fr;
    }

    form.filters {
        grid-template-columns: 1fr;
    }

    .main-header::before {
        width: 26px;
        height: 26px;
    }
}
