/* =========================================================
   FRAUD DETECTION CONSOLE
   Design system inherited from credit-risk dashboard.
   ========================================================= */

/* =========================================================
   TOKENS
   ========================================================= */
:root {
    --sidebar-w: 232px;
    --header-h: 56px;

    --bg:          #ffffff;
    --bg-sidebar:  #fcfcfc;
    --bg-hover:    #f5f5f5;
    --bg-active:   #f2f2f2;

    --border:      #ebebeb;

    --text:        #141414;
    --text-muted:  #6b6b6b;
    --text-faint:  #a3a3a3;

    --success:     #16803c;
    --warning:     #8b6b00;
    --danger:      #c0392b;

    /* Fraud risk band colours */
    --band-low:       #16803c;
    --band-low-bg:    #f4fdf6;
    --band-low-bdr:   #cfefd9;

    --band-medium:    #a16207;
    --band-medium-bg: #fdf9ec;
    --band-medium-bdr:#f5e5b3;

    --band-high:      #c2410c;
    --band-high-bg:   #fdf3ea;
    --band-high-bdr:  #f7c9a9;

    --band-critical:    #c0392b;
    --band-critical-bg: #fdf0f0;
    --band-critical-bdr:#f3bcbc;

    --radius-sm: 5px;
    --radius:    7px;
    --radius-lg: 9px;
}

/* =========================================================
   RESET
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }

/* =========================================================
   SIDEBAR
   ========================================================= */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 40;
}

.brand {
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px;
    flex-shrink: 0;
}

.brand__mark {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: var(--text);
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 10px;
    flex-shrink: 0;
}

.brand__name {
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
}

.brand__name span { color: var(--text-faint); font-weight: 400; margin-left: 3px; }

.nav {
    flex: 1;
    overflow-y: auto;
    padding: 4px 10px 16px;
}

.nav__section {
    padding: 18px 10px 6px;
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-faint);
}
.nav__section:first-child { padding-top: 8px; }

.nav__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    margin-bottom: 1px;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 13px;
    transition: background .12s, color .12s;
}

.nav__item i {
    width: 15px;
    font-size: 12px;
    text-align: center;
    color: var(--text-faint);
    transition: color .12s;
    flex-shrink: 0;
}

.nav__item:hover { background: var(--bg-hover); color: var(--text); }
.nav__item:hover i { color: var(--text-muted); }

.nav__item.active {
    background: var(--bg-active);
    color: var(--text);
    font-weight: 500;
}
.nav__item.active i { color: var(--text); }

/* =========================================================
   MAIN
   ========================================================= */
.main {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--header-h);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 14px;
}

.topbar__title {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
}

.topbar__sep { width: 1px; height: 14px; background: var(--border); }
.topbar__crumb { font-size: 12.5px; color: var(--text-faint); white-space: nowrap; }

.content {
    flex: 1;
    padding: 40px 28px 64px;
    max-width: 1240px;
    width: 100%;
}

/* =========================================================
   PAGE HEAD
   ========================================================= */
.page-head { margin-bottom: 40px; }

.page-head h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.025em;
    color: var(--text);
    line-height: 1.25;
}

.page-head p {
    font-size: 13px;
    color: var(--text-faint);
    margin-top: 5px;
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius);
    background: var(--text);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: -0.005em;
    transition: background .12s, transform .05s;
}

.btn:hover { background: #2a2a2a; }
.btn:active { transform: translateY(1px); }

.btn--ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn--ghost:hover { background: var(--bg-hover); }

/* =========================================================
   CARDS
   ========================================================= */
.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
}

.card + .card { margin-top: 24px; }

.card__title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.card__sub {
    font-size: 12.5px;
    color: var(--text-faint);
    margin-bottom: 20px;
}

/* =========================================================
   FORM
   ========================================================= */
.form-section {
    margin-bottom: 40px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border);
}
.form-section:last-of-type { border-bottom: none; }

.form-section__title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
}

.form-section__sub {
    font-size: 12px;
    color: var(--text-faint);
    margin-bottom: 20px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px 20px;
}

.form-field { display: flex; flex-direction: column; gap: 6px; }

.form-field label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: -0.005em;
}

.form-field input,
.form-field select {
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color .12s;
    width: 100%;
}

.form-field input:focus,
.form-field select:focus { border-color: #b8b8b8; }

.form-field input::placeholder { color: var(--text-faint); }

.form-field .error {
    font-size: 11.5px;
    color: var(--danger);
    margin-top: 2px;
}

/* Checkbox fields sit on their own line, not stretched vertically */
.form-field input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--text);
    margin-top: 10px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

/* =========================================================
   RESULT HERO
   ========================================================= */
.result-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
    gap: 24px;
    margin-bottom: 32px;
}

/* ---------- Probability panel ---------- */
.result-prob {
    padding: 32px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg);
}

.result-prob__label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 12px;
}

.result-prob__value {
    font-size: 54px;
    font-weight: 500;
    letter-spacing: -0.04em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    transition: color .3s;
}

.band-low      .result-prob__value { color: var(--band-low); }
.band-medium   .result-prob__value { color: var(--band-medium); }
.band-high     .result-prob__value { color: var(--band-high); }
.band-critical .result-prob__value { color: var(--band-critical); }

/* Probability gauge */
.result-prob__gauge {
    position: relative;
    height: 8px;
    margin-top: 22px;
    background: var(--bg-hover);
    border-radius: 4px;
    overflow: visible;
}

.result-prob__gauge-fill {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    border-radius: 4px;
    transition: width .6s cubic-bezier(.22,.61,.36,1);
}

.band-low      .result-prob__gauge-fill { background: var(--band-low); }
.band-medium   .result-prob__gauge-fill { background: #d9a406; }
.band-high     .result-prob__gauge-fill { background: #e26b0a; }
.band-critical .result-prob__gauge-fill { background: var(--band-critical); }

.result-prob__gauge-threshold {
    position: absolute;
    top: -4px;
    width: 2px;
    height: 16px;
    background: var(--text);
    border-radius: 1px;
    transform: translateX(-1px);
}

/* Band chip */
.result-prob__band {
    display: inline-block;
    margin-top: 20px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 500;
    letter-spacing: -0.005em;
}

.band-low      .result-prob__band { background: var(--band-low-bg);      color: var(--band-low); }
.band-medium   .result-prob__band { background: var(--band-medium-bg);   color: var(--band-medium); }
.band-high     .result-prob__band { background: var(--band-high-bg);     color: var(--band-high); }
.band-critical .result-prob__band { background: var(--band-critical-bg); color: var(--band-critical); }

/* ---------- Summary panel ---------- */
.result-summary {
    padding: 32px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg);
}

.result-summary h3 {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 12px;
}

.result-summary p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.65;
    margin-bottom: 12px;
}

/* ---------- Decision block ---------- */
.decision {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 20px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.decision--inline {
    margin: 0;
    padding: 16px 18px;
    align-items: flex-start;
}

.decision--low      { border-color: var(--band-low-bdr);      background: var(--band-low-bg); }
.decision--medium   { border-color: var(--band-medium-bdr);   background: var(--band-medium-bg); }
.decision--high     { border-color: var(--band-high-bdr);     background: var(--band-high-bg); }
.decision--critical { border-color: var(--band-critical-bdr); background: var(--band-critical-bg); }

.decision__left { flex-shrink: 0; }

.decision__label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 4px;
}

.decision__action {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.decision--low      .decision__action { color: var(--band-low); }
.decision--medium   .decision__action { color: var(--band-medium); }
.decision--high     .decision__action { color: var(--band-high); }
.decision--critical .decision__action { color: var(--band-critical); }

.decision__note {
    font-size: 12.5px;
    color: var(--text-muted);
    max-width: 480px;
    line-height: 1.55;
}

/* ---------- Factor list (SHAP contributors) ---------- */
.factor-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.factor {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 90px;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.factor:last-child { border-bottom: none; }

.factor__name {
    font-size: 13px;
    color: var(--text);
    font-weight: 500;
    letter-spacing: -0.005em;
}

.factor__value {
    font-size: 11.5px;
    color: var(--text-faint);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

.factor__impact {
    font-size: 12.5px;
    font-weight: 500;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.factor__impact--up   { color: var(--danger); }
.factor__impact--down { color: var(--success); }

.factor-note {
    font-size: 11.5px;
    color: var(--text-faint);
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.factor-note .up   { color: var(--danger); font-weight: 500; }
.factor-note .down { color: var(--success); font-weight: 500; }

/* ---------- Computed grid (transaction summary) ---------- */
.computed-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px 24px;
}

.computed-item {
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.computed-item__label {
    font-size: 11.5px;
    color: var(--text-faint);
    margin-bottom: 4px;
}

.computed-item__value {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

/* =========================================================
   MODEL PERFORMANCE
   ========================================================= */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.metric {
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.metric__label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.metric__value {
    font-size: 22px;
    font-weight: 500;
    letter-spacing: -0.03em;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.metric__sub {
    font-size: 11.5px;
    color: var(--text-faint);
    margin-top: 4px;
}

/* ---------- Figures (charts) ---------- */
.figure {
    margin-top: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    background: #fff;
}

.figure img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius-sm);
}

.figure__caption {
    font-size: 12px;
    color: var(--text-faint);
    margin-top: 12px;
    text-align: center;
    line-height: 1.5;
}

.figure__caption strong {
    color: var(--text-muted);
    font-weight: 500;
}

.figure-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    margin-top: 24px;
}

/* =========================================================
   TABLE
   ========================================================= */
.dtable { width: 100%; border-collapse: collapse; }

.dtable th {
    padding: 0 16px 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-faint);
    text-align: left;
    white-space: nowrap;
}

.dtable td {
    padding: 14px 16px 14px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
    color: var(--text-muted);
    white-space: nowrap;
}

.dtable tbody tr:last-child td { border-bottom: none; }
.dtable td:first-child { color: var(--text); }
.dtable .num { text-align: right; font-variant-numeric: tabular-nums; }
.dtable th.num { text-align: right; }
.dtable td.strong { color: var(--text); font-weight: 500; }

/* =========================================================
   HERO
   ========================================================= */
.hero {
    padding: 60px 0 40px;
    max-width: 720px;
}

.hero h1 {
    font-size: 32px;
    font-weight: 600;
    letter-spacing: -0.035em;
    line-height: 1.15;
    margin-bottom: 16px;
}

.hero p {
    font-size: 14.5px;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 28px;
}

.hero__actions { display: flex; gap: 12px; flex-wrap: wrap; }

.pill {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--bg-hover);
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 20px;
    letter-spacing: -0.005em;
}

/* =========================================================
   PROSE (methodology / about)
   ========================================================= */
.prose p {
    font-size: 13.5px;
    line-height: 1.75;
    color: var(--text-muted);
    margin-bottom: 16px;
    max-width: 720px;
}

.prose h3 {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    margin: 32px 0 12px;
}
.prose h3:first-child { margin-top: 0; }

.prose ul {
    list-style: none;
    max-width: 720px;
    margin-bottom: 16px;
}

.prose li {
    font-size: 13.5px;
    color: var(--text-muted);
    padding-left: 18px;
    position: relative;
    margin-bottom: 8px;
    line-height: 1.7;
}

.prose li::before {
    content: "·";
    position: absolute;
    left: 4px;
    color: var(--text-faint);
    font-weight: 700;
}

.prose li strong { color: var(--text); font-weight: 500; }

.prose code {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 12.5px;
    background: var(--bg-hover);
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--text);
}

/* =========================================================
   MISC
   ========================================================= */
.divider {
    height: 1px;
    background: var(--border);
    margin: 32px 0;
}

.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }

/* =========================================================
   MOBILE MENU
   ========================================================= */
.topbar__menu {
    display: none;
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    align-items: center;
    justify-content: center;
    color: var(--text);
    font-size: 14px;
    transition: background .12s;
    flex-shrink: 0;
}
.topbar__menu:hover { background: var(--bg-hover); }

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 20, 0.32);
    z-index: 35;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}

.sidebar-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1100px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .result-hero { grid-template-columns: minmax(0, 1fr); }
    .computed-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .22s cubic-bezier(.22,.61,.36,1);
        box-shadow: 0 0 40px rgba(0, 0, 0, 0);
    }

    .sidebar.is-open {
        transform: translateX(0);
        box-shadow: 0 8px 40px rgba(0, 0, 0, 0.10);
    }

    .main { margin-left: 0; }
    .topbar__menu { display: inline-flex; }
}

@media (max-width: 700px) {
    .figure-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
    .topbar { padding: 0 18px; }
    .topbar__crumb { display: none; }
    .content { padding: 28px 18px 48px; }
    .metric-grid { grid-template-columns: minmax(0, 1fr); }
    .computed-grid { grid-template-columns: minmax(0, 1fr); }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .hero h1 { font-size: 24px; }
    .hero { padding: 40px 0 28px; }
    .result-prob__value { font-size: 42px; }
    .decision--inline { flex-direction: column; align-items: flex-start; }
    .factor { grid-template-columns: minmax(0, 1fr) 70px; }
}

/* =========================================================
   ANIMATIONS
   ========================================================= */
@keyframes growWidth {
    from { width: 0; }
}

.result-prob__gauge-fill {
    animation: growWidth .6s cubic-bezier(.22,.61,.36,1) both;
}