/* =====================================================================
   FTV Sostera · SAP Fiori-inspired design system
   ===================================================================== */

:root {
    --sap-brand:        #0a6ed1;
    --sap-brand-dark:   #0854a0;
    --sap-brand-light:  #e8f1fb;
    --sap-accent:       #ee8208;
    --sap-positive:     #107e3e;
    --sap-positive-bg:  #e8f5ee;
    --sap-critical:     #df6e0c;
    --sap-critical-bg:  #fef3e2;
    --sap-negative:     #bb0000;
    --sap-negative-bg:  #fdeaea;
    --sap-info:         #0a6ed1;
    --sap-info-bg:      #e8f1fb;
    --sap-neutral:      #6a6d70;
    --sap-neutral-bg:   #eef0f2;

    --sap-bg:           #f5f6f7;
    --sap-bg-alt:       #edeff1;
    --sap-shell:        #354a5f;
    --sap-shell-dark:   #2b3e50;
    --sap-card:         #ffffff;
    --sap-line:         #d9d9d9;
    --sap-text:         #32363a;
    --sap-text-muted:   #6a6d70;
    --sap-text-light:   #89919a;

    --sap-radius:       4px;
    --sap-radius-lg:    8px;
    --sap-shadow-1:     0 1px 2px rgba(0,0,0,.06);
    --sap-shadow-2:     0 4px 12px rgba(0,40,80,.08);
    --sap-shadow-3:     0 12px 32px rgba(0,40,80,.12);
    --sap-font:         "72", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--sap-font);
    color: var(--sap-text);
    background: var(--sap-bg);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--sap-brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { color: var(--sap-text); font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 24px; margin: 0 0 8px; }
h2 { font-size: 20px; margin: 0 0 6px; }
h3 { font-size: 16px; margin: 0 0 6px; }
.muted { color: var(--sap-text-muted); font-size: 13px; }
hr { border: 0; border-top: 1px solid var(--sap-line); margin: 18px 0; }

/* ---------- SHELL ---------- */
.sap-shell { display: grid; grid-template-columns: 240px 1fr; grid-template-rows: 48px 1fr; min-height: 100vh; }
.sap-topbar {
    grid-column: 1 / -1;
    background: var(--sap-shell-dark);
    color: #fff;
    display: flex; align-items: center; padding: 0 20px;
    box-shadow: 0 1px 0 rgba(0,0,0,.2);
    position: sticky; top: 0; z-index: 50;
}
.sap-topbar .brand { font-weight: 700; font-size: 15px; letter-spacing: .03em; }
.sap-topbar .brand span { color: var(--sap-accent); font-weight: 400; margin-left: 6px; font-size: 13px; }
.sap-topbar .spacer { flex: 1; }
.sap-topbar .breadcrumb { color: #c1c9d2; font-size: 13px; margin-left: 28px; }
.sap-topbar .user { color: #d9e1ea; font-size: 13px; display: flex; align-items: center; gap: 12px; }
.sap-topbar .user .avatar { width: 32px; height: 32px; background: var(--sap-brand); color: #fff; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; }
.sap-topbar .user a { color: #d9e1ea; }
.sap-topbar .user a:hover { color: #fff; text-decoration: none; }

.sap-sidebar {
    background: var(--sap-shell);
    color: #d9e1ea;
    padding: 12px 0;
    border-right: 1px solid rgba(0,0,0,.15);
}
.sap-sidebar .group { padding: 14px 18px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8d9aab; }
.sap-sidebar a {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 18px; color: #d9e1ea; font-size: 14px; line-height: 1.2;
    border-left: 3px solid transparent;
    text-decoration: none; transition: background .15s, border-color .15s;
}
.sap-sidebar a:hover { background: rgba(255,255,255,.05); }
.sap-sidebar a.active { background: rgba(10,110,209,.18); border-left-color: var(--sap-brand); color: #fff; font-weight: 600; }
.sap-sidebar .ic { width: 18px; text-align: center; opacity: .85; }

.sap-main { padding: 20px 28px 60px; min-width: 0; }
.sap-page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.sap-page-header .title h1 { line-height: 1.2; }

/* ---------- CARDS / TILES ---------- */
.sap-card {
    background: var(--sap-card);
    border: 1px solid var(--sap-line);
    border-radius: var(--sap-radius);
    box-shadow: var(--sap-shadow-1);
    padding: 18px;
}
.sap-card.padded-lg { padding: 24px; }
.sap-card-title { font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--sap-text-muted); margin-bottom: 12px; }
.sap-card-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--sap-bg-alt); }
.sap-card-row:last-child { border-bottom: 0; }

.sap-tile {
    background: var(--sap-card);
    border: 1px solid var(--sap-line);
    border-radius: var(--sap-radius);
    padding: 16px;
    box-shadow: var(--sap-shadow-1);
    display: flex; flex-direction: column; gap: 6px;
    min-height: 110px;
    transition: transform .12s, box-shadow .12s;
}
.sap-tile:hover { box-shadow: var(--sap-shadow-2); transform: translateY(-1px); }
.sap-tile .label { color: var(--sap-text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.sap-tile .value { font-size: 28px; font-weight: 700; color: var(--sap-text); line-height: 1.1; }
.sap-tile .delta { font-size: 12px; color: var(--sap-text-muted); }
.sap-tile.brand { background: linear-gradient(135deg, var(--sap-brand) 0%, var(--sap-brand-dark) 100%); color: #fff; border: 0; }
.sap-tile.brand .label, .sap-tile.brand .delta, .sap-tile.brand .value { color: #fff; }
.sap-tile.positive .value { color: var(--sap-positive); }
.sap-tile.critical .value { color: var(--sap-critical); }
.sap-tile.negative .value { color: var(--sap-negative); }

.sap-grid { display: grid; gap: 14px; }
.sap-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.sap-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.sap-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.sap-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1100px) {
    .sap-grid.cols-3, .sap-grid.cols-4, .sap-grid.cols-5 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
    .sap-grid.cols-2, .sap-grid.cols-3, .sap-grid.cols-4, .sap-grid.cols-5 { grid-template-columns: 1fr; }
    .sap-shell { grid-template-columns: 1fr; }
    .sap-sidebar { display: none; }
}

/* ---------- BADGES / STATUS ---------- */
.sap-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600; line-height: 1.5;
    background: var(--sap-neutral-bg); color: var(--sap-neutral);
}
.sap-badge.tone-success  { background: var(--sap-positive-bg); color: var(--sap-positive); }
.sap-badge.tone-info     { background: var(--sap-info-bg); color: var(--sap-info); }
.sap-badge.tone-warning  { background: var(--sap-critical-bg); color: var(--sap-critical); }
.sap-badge.tone-danger   { background: var(--sap-negative-bg); color: var(--sap-negative); }
.sap-badge.tone-neutral  { background: var(--sap-neutral-bg); color: var(--sap-neutral); }

/* ---------- TABLES ---------- */
.sap-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--sap-card); border: 1px solid var(--sap-line); border-radius: var(--sap-radius); overflow: hidden; }
.sap-table thead th {
    background: var(--sap-bg-alt);
    color: var(--sap-text-muted);
    text-align: left; font-weight: 600; font-size: 12px;
    text-transform: uppercase; letter-spacing: .04em;
    padding: 10px 14px; border-bottom: 1px solid var(--sap-line);
    position: sticky; top: 0;
}
.sap-table tbody td { padding: 11px 14px; border-bottom: 1px solid var(--sap-bg-alt); vertical-align: middle; }
.sap-table tbody tr:hover td { background: rgba(10,110,209,.04); }
.sap-table tbody tr:last-child td { border-bottom: 0; }
.sap-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.sap-table .actions { white-space: nowrap; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 8px 12px; border-bottom: 1px solid var(--sap-line); text-align: left; font-size: 13px; }

/* ---------- FORMS ---------- */
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--sap-text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=number], .field input[type=date],
.field select, .field textarea, input.sap-input, select.sap-input, textarea.sap-input {
    width: 100%;
    border: 1px solid var(--sap-line);
    background: #fff;
    padding: 8px 10px;
    border-radius: var(--sap-radius);
    font-family: inherit;
    font-size: 14px;
    color: var(--sap-text);
    transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus,
input.sap-input:focus, select.sap-input:focus, textarea.sap-input:focus {
    outline: 0;
    border-color: var(--sap-brand);
    box-shadow: 0 0 0 2px rgba(10,110,209,.18);
}
.field textarea, textarea.sap-input { min-height: 90px; resize: vertical; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 720px) {
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

/* ---------- BUTTONS ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px;
    border-radius: var(--sap-radius);
    border: 1px solid var(--sap-line);
    background: #fff;
    color: var(--sap-text);
    font-family: inherit; font-size: 13px; font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { border-color: var(--sap-brand); color: var(--sap-brand); text-decoration: none; }
.btn.primary { background: var(--sap-brand); border-color: var(--sap-brand); color: #fff; }
.btn.primary:hover { background: var(--sap-brand-dark); border-color: var(--sap-brand-dark); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--sap-text-muted); }
.btn.ghost:hover { color: var(--sap-brand); border-color: transparent; }
.btn.danger { background: #fff; border-color: var(--sap-negative); color: var(--sap-negative); }
.btn.danger:hover { background: var(--sap-negative); color: #fff; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.block { display: flex; justify-content: center; width: 100%; }

/* ---------- PROGRESS / ALERTS ---------- */
.sap-progress { background: var(--sap-bg-alt); height: 8px; border-radius: 999px; overflow: hidden; }
.sap-progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--sap-brand), var(--sap-positive)); border-radius: 999px; transition: width .4s; }
.alert { padding: 12px 14px; border-radius: var(--sap-radius); border-left: 4px solid; background: #fff; margin-bottom: 16px; }
.alert.info     { border-color: var(--sap-info);     background: var(--sap-info-bg); }
.alert.success  { border-color: var(--sap-positive); background: var(--sap-positive-bg); }
.alert.warning  { border-color: var(--sap-critical); background: var(--sap-critical-bg); }
.alert.danger   { border-color: var(--sap-negative); background: var(--sap-negative-bg); }
.alert.error    { border-color: var(--sap-negative); background: var(--sap-negative-bg); }

/* ---------- LOGIN ---------- */
.sap-login {
    min-height: 100vh;
    background: linear-gradient(135deg, #1b3a5e 0%, #0a6ed1 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 30px;
}
.sap-login .card {
    background: #fff;
    border-radius: var(--sap-radius-lg);
    box-shadow: 0 24px 60px rgba(0,0,0,.18);
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
}
.sap-login .logo { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.sap-login .logo .dot { width: 36px; height: 36px; border-radius: 8px; background: linear-gradient(135deg, var(--sap-brand) 0%, var(--sap-accent) 100%); }
.sap-login .logo .name { font-weight: 700; font-size: 20px; }
.sap-login .logo .name span { color: var(--sap-text-muted); font-weight: 400; }

/* ---------- KPI / SCORE ---------- */
.score-ring {
    width: 130px; height: 130px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center; flex-direction: column;
    background: conic-gradient(var(--sap-brand) calc(var(--p, 0) * 1%), var(--sap-bg-alt) 0);
    position: relative;
    margin: 0 auto;
}
.score-ring::before { content: ''; position: absolute; inset: 8px; background: #fff; border-radius: 50%; }
.score-ring .v { position: relative; font-size: 28px; font-weight: 700; color: var(--sap-brand); }
.score-ring .l { position: relative; font-size: 12px; color: var(--sap-text-muted); }

/* ---------- TABS / PILLS ---------- */
.sap-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--sap-line); margin-bottom: 18px; flex-wrap: wrap; }
.sap-tabs a {
    padding: 10px 16px;
    color: var(--sap-text-muted); font-weight: 600; font-size: 13px;
    border-bottom: 2px solid transparent;
    text-decoration: none;
}
.sap-tabs a:hover { color: var(--sap-brand); text-decoration: none; }
.sap-tabs a.active { color: var(--sap-brand); border-bottom-color: var(--sap-brand); }

/* ---------- MATERIALITY MATRIX ---------- */
.matrix {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 560px;
    background:
        linear-gradient(to right, transparent calc(50% - 1px), rgba(0,0,0,.08) 50%, transparent calc(50% + 1px)),
        linear-gradient(to top, transparent calc(50% - 1px), rgba(0,0,0,.08) 50%, transparent calc(50% + 1px)),
        linear-gradient(135deg, #f9fafb 0%, #eef1f5 100%);
    border: 1px solid var(--sap-line);
    border-radius: var(--sap-radius);
    margin: 0 auto;
}
.matrix .dot {
    position: absolute;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--sap-brand);
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,.18);
    transform: translate(-50%, 50%);
    cursor: pointer;
}
.matrix .dot.E { background: var(--sap-positive); }
.matrix .dot.S { background: var(--sap-accent); }
.matrix .dot.G { background: var(--sap-brand); }
.matrix .axis-x, .matrix .axis-y { position: absolute; font-size: 11px; color: var(--sap-text-muted); }
.matrix .axis-x { bottom: -22px; left: 0; right: 0; text-align: center; }
.matrix .axis-y { top: 0; bottom: 0; left: -42px; display: flex; align-items: center; transform: rotate(-90deg); transform-origin: right center; }

/* ---------- MISC ---------- */
.btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spaced > * + * { margin-top: 14px; }
.kbd { font-family: monospace; background: var(--sap-bg-alt); padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.empty { padding: 30px; text-align: center; color: var(--sap-text-muted); }
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; }
.pillar-E { color: var(--sap-positive); font-weight: 700; }
.pillar-S { color: var(--sap-accent); font-weight: 700; }
.pillar-G { color: var(--sap-brand); font-weight: 700; }
