/* =====================================================================
   Streama Finance - stylesheet
   Flat, crimson-accented UI matching the Streama logo.
   ===================================================================== */
:root {
    --brand:         #EC003F;
    --brand-soft:    rgba(236, 0, 63, 0.10);
    --brand-border:  rgba(236, 0, 63, 0.25);
    --text:          #0a0a0a;
    --text-muted:    #6b6b6b;
    --text-dim:      #9a9a9a;
    --bg:            #f7f7f5;
    --surface:       #ffffff;
    --surface-2:     #f1efe8;
    --border:        rgba(0, 0, 0, 0.10);
    --border-strong: rgba(0, 0, 0, 0.18);
    --success:       #27500A;
    --success-bg:    #EAF3DE;
    --danger:        #791F1F;
    --danger-bg:     #FCEBEB;
    --warn:          #854F0B;
    --warn-bg:       #FAEEDA;
    --info:          #0C447C;
    --info-bg:       #E6F1FB;
    --radius-sm:     6px;
    --radius-md:     8px;
    --radius-lg:     12px;
    --shadow-focus:  0 0 0 3px var(--brand-soft);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}
h1 { font-size: 22px; font-weight: 500; letter-spacing: -0.01em; margin: 0 0 4px; }
h2 { font-size: 18px; font-weight: 500; margin: 0 0 8px; }
h3 { font-size: 15px; font-weight: 500; margin: 0 0 4px; }
h4 { font-size: 13px; font-weight: 500; margin: 16px 0 8px; }
p  { margin: 0 0 8px; }
a  { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--text-muted); font-size: 12px; }
.hidden { display: none !important; }
.r { text-align: right; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: 12px; }

/* ---------- Auth page ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center;
             background: linear-gradient(180deg, #f7f7f5 0%, #efece5 100%); }
.auth-wrapper { max-width: 900px; margin: 40px auto; padding: 20px;
                display: grid; grid-template-columns: 1fr 1fr; gap: 32px; width: 100%; }
.auth-card { background: var(--surface); border: 1px solid var(--border);
             border-radius: var(--radius-lg); padding: 32px; }
.auth-card h1 { margin-top: 24px; }
.auth-aside { padding: 32px; }
.auth-aside h2 { margin-bottom: 16px; }
.auth-aside ul { list-style: none; padding: 0; }
.auth-aside li { padding: 8px 0 8px 24px; position: relative; color: var(--text-muted); }
.auth-aside li::before { content: "→"; position: absolute; left: 0; color: var(--brand); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-name { font-size: 18px; font-weight: 500; letter-spacing: -0.01em; }
.brand-sub  { font-size: 10px; color: var(--text-muted);
              text-transform: uppercase; letter-spacing: 0.14em; }
.demo-note  { margin-top: 16px; padding: 10px 12px; background: var(--info-bg);
              border-radius: var(--radius-sm); font-size: 12px; color: var(--info); }

@media (max-width: 700px) {
    .auth-wrapper { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
}

/* ---------- Top navigation ---------- */
.topnav { background: var(--surface); border-bottom: 1px solid var(--border);
          padding: 10px 20px; display: flex; justify-content: space-between;
          align-items: center; gap: 16px; flex-wrap: wrap; }
.topnav-left { display: flex; align-items: center; gap: 24px; }
.topnav-right { display: flex; align-items: center; gap: 12px; }
.brand-small { display: flex; align-items: center; gap: 8px; color: var(--text);
               font-size: 15px; font-weight: 500; }
.brand-small:hover { text-decoration: none; }
.topnav nav { display: flex; gap: 2px; font-size: 13px; }
.topnav nav a { padding: 6px 12px; border-radius: var(--radius-sm);
                color: var(--text-muted); }
.topnav nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.topnav nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.company-select { padding: 6px 10px; border: 1px solid var(--border);
                  border-radius: var(--radius-sm); background: var(--surface);
                  font-size: 12px; max-width: 180px; }
.currency-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm);
                   overflow: hidden; font-size: 12px; }
.currency-toggle button { border: 0; background: transparent; padding: 5px 10px;
                          color: var(--text-muted); cursor: pointer; }
.currency-toggle button.active { background: var(--text); color: var(--surface); font-weight: 500; }
.user-menu { display: flex; align-items: center; gap: 8px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--info-bg);
          color: var(--info); display: flex; align-items: center; justify-content: center;
          font-size: 11px; font-weight: 500; }
.user-info { line-height: 1.2; font-size: 12px; }
.user-info div:last-child { color: var(--text-muted); font-size: 10px; }

/* ---------- Page & cards ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 20px; display: flex;
        flex-direction: column; gap: 14px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end;
               gap: 16px; flex-wrap: wrap; }
.rate-pill { font-size: 12px; padding: 6px 12px; background: var(--surface);
             border: 1px solid var(--border); border-radius: var(--radius-sm); }
.card { background: var(--surface); border: 1px solid var(--border);
        border-radius: var(--radius-md); padding: 16px 18px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start;
             margin-bottom: 12px; gap: 12px; }
.warn-card { background: var(--warn-bg); border-color: #EF9F27; }
.warn-card h3 { color: var(--warn); }

/* ---------- KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border);
            border-radius: var(--radius-md); padding: 12px 14px; }
.kpi-label { font-size: 10px; color: var(--text-muted);
             text-transform: uppercase; letter-spacing: 0.08em; }
.kpi-value { font-size: 20px; font-weight: 500; margin-top: 4px; letter-spacing: -0.02em; }
.kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Two-column layouts ---------- */
.grid-2-1 { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 10px; }
@media (max-width: 900px) { .grid-2-1 { grid-template-columns: 1fr; } }

/* ---------- Charts & legend ---------- */
.chart-legend { display: flex; gap: 12px; font-size: 11px; color: var(--text-muted); }
.chart-legend span { display: flex; align-items: center; gap: 5px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.donut-row { display: flex; align-items: center; gap: 16px; margin-top: 12px; }
.donut-row svg { width: 90px; height: 90px; flex-shrink: 0; }
.legend-list { list-style: none; padding: 0; margin: 0; flex: 1; font-size: 12px; }
.legend-list li { display: flex; justify-content: space-between; padding: 3px 0; }
.legend-list li span { display: flex; align-items: center; gap: 6px; }
.legend-list li i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

/* ---------- AI alert banner ---------- */
.ai-alert { display: flex; gap: 12px; padding: 12px 14px; background: var(--surface);
            border: 1px solid var(--border); border-left: 3px solid var(--brand);
            border-radius: var(--radius-md); align-items: center; }
.ai-alert-icon { width: 32px; height: 32px; background: var(--brand-soft);
                 border-radius: 8px; display: flex; align-items: center;
                 justify-content: center; flex-shrink: 0; }
.ai-alert-body { flex: 1; }
.ai-alert-title { font-size: 13px; font-weight: 500; }
.ai-alert-text { margin-top: 2px; }

/* ---------- Tables ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; padding: 8px 8px; font-weight: 500;
                 color: var(--text-muted); border-bottom: 1px solid var(--border);
                 font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; }
.data-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--surface-2); }
.pos { color: var(--success); font-weight: 500; }
.neg { color: var(--danger); font-weight: 500; }
.badge-pos { background: var(--success-bg); color: var(--success); padding: 2px 6px;
             border-radius: 4px; font-size: 11px; font-weight: 500; }
.badge-neg { background: var(--danger-bg); color: var(--danger); padding: 2px 6px;
             border-radius: 4px; font-size: 11px; font-weight: 500; }
.badge-info { background: var(--info-bg); color: var(--info); padding: 2px 6px;
              border-radius: 4px; font-size: 11px; font-weight: 500; }

/* ---------- Filters row ---------- */
.filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.filters label { display: flex; flex-direction: column; gap: 4px;
                 font-size: 11px; color: var(--text-muted); }

/* ---------- Forms ---------- */
form label { display: flex; flex-direction: column; gap: 4px; margin: 10px 0;
             font-size: 12px; color: var(--text-muted); }
input, select, textarea {
    font: inherit; font-size: 14px; padding: 8px 10px; color: var(--text);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); width: 100%;
    transition: border 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand);
                                             box-shadow: var(--shadow-focus); }
textarea { resize: vertical; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Buttons ---------- */
button { font: inherit; font-size: 13px; padding: 7px 14px; cursor: pointer;
         border-radius: var(--radius-sm); border: 1px solid var(--border);
         background: var(--surface); color: var(--text); transition: all 0.15s; }
button:hover { border-color: var(--border-strong); background: var(--surface-2); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand);
               font-weight: 500; padding: 8px 16px; }
.btn-primary:hover { background: #c4002f; border-color: #c4002f; }
.btn-secondary { background: var(--surface); }
.link-btn { border: 0; background: transparent; color: var(--brand); padding: 4px 8px; }
.link-btn:hover { background: var(--brand-soft); }

/* ---------- Dialogs ---------- */
.dialog { border: 0; padding: 0; border-radius: var(--radius-lg);
          box-shadow: 0 20px 40px rgba(0,0,0,0.15); max-width: 540px; width: 90%; }
.dialog::backdrop { background: rgba(0,0,0,0.35); }
.dialog form { padding: 24px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- Errors ---------- */
.error { background: var(--danger-bg); color: var(--danger); padding: 8px 12px;
         border-radius: var(--radius-sm); font-size: 13px; margin: 8px 0; }

/* ---------- AI insights ---------- */
.insight-item { padding: 12px 14px; border-radius: var(--radius-md);
                background: var(--surface); border: 1px solid var(--border);
                margin-bottom: 8px; display: flex; gap: 12px; }
.insight-item.critical { border-left: 3px solid var(--danger); }
.insight-item.warning  { border-left: 3px solid var(--warn); }
.insight-item.info     { border-left: 3px solid var(--info); }
.insight-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
