/* ============================================================
   Ломбард — design system (Finova style)
   Brand: #55B2C9 / #CAE7EE / #122C32 / #E3E8EF on #F7F9FB.
   Typography: Public Sans (self-hosted, latin) + system fallback for Cyrillic.
   Radii: halved vs previous spec.
   ============================================================ */

@font-face { font-family: "Public Sans"; font-style: normal; font-weight: 400;
    font-display: swap; src: url("/static/fonts/public-sans-400.60715978fab2.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-style: normal; font-weight: 500;
    font-display: swap; src: url("/static/fonts/public-sans-500.38c037ffedf4.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-style: normal; font-weight: 600;
    font-display: swap; src: url("/static/fonts/public-sans-600.6b1fe1f62892.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-style: normal; font-weight: 700;
    font-display: swap; src: url("/static/fonts/public-sans-700.3c0eda7c2982.woff2") format("woff2"); }

:root {
    /* Brand (Finova teal) */
    --brand:      #55B2C9;
    --brand-dark: #3F9BB3;
    --brand-100:  #CAE7EE;
    --brand-50:   #EAF4F8;
    --ink:        #122C32;

    /* Surfaces */
    --bg:        #F7F9FB;
    --surface:   #FFFFFF;
    --surface-2: #F2F5F8;

    /* Text */
    --text:      #122C32;
    --text-soft: #56666D;
    --muted:     #8A99A0;

    /* Lines */
    --border:    #E3E8EF;
    --border-2:  #D7DEE7;

    /* Semantic */
    --success:   #16A37B;
    --success-bg:#E3F6EF;
    --danger:    #E5567A;
    --danger-bg: #FCEBF0;
    --warning:   #E59A3C;

    /* Radius (halved) & shadow */
    --r-sm: 4px;
    --r:    4px;
    --r-lg: 4px;
    --r-xl: 4px;
    --shadow-sm: 0 1px 2px rgba(18, 44, 50, .04);
    --shadow:    0 8px 28px rgba(18, 44, 50, .07);

    --sidebar-w: 248px;
    --font: "Public Sans", "Inter", -apple-system, "Segoe UI", Roboto,
            system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { color: var(--brand); }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }

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

/* ---------------- App shell ---------------- */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 6px 8px 16px;
}
.brand .logo {
    width: 34px; height: 34px;
    border-radius: var(--r);
    background: linear-gradient(150deg, var(--brand-100), var(--brand));
    display: grid; place-items: center;
    color: #fff; font-size: 17px; font-weight: 700;
}
.brand .name { font-weight: 700; font-size: 18px; line-height: 1.1; color: var(--ink); }

.menu-label {
    font-size: 11px; letter-spacing: .09em; text-transform: uppercase;
    color: var(--muted); padding: 16px 10px 8px; font-weight: 600;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 11px;
    border-radius: var(--r);
    color: var(--text-soft);
    font-weight: 500;
    transition: background .15s, color .15s;
}
.nav a .ico { width: 18px; text-align: center; opacity: .8; font-size: 15px; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active {
    background: var(--brand-50);
    color: var(--brand-dark);
    font-weight: 600;
}
.nav a.active .ico { opacity: 1; color: var(--brand); }
.nav a .badge-count {
    margin-left: auto;
    background: var(--brand-50); color: var(--brand-dark);
    font-size: 12px; font-weight: 600;
    border-radius: 999px; padding: 1px 8px;
}

.sidebar .spacer { flex: 1; }

.user-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 9px; border-radius: var(--r);
    border: 1px solid var(--border);
}
.user-chip .avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(150deg, var(--brand-100), var(--brand));
    color: #fff; display: grid; place-items: center; font-weight: 600;
}
.user-chip .who { line-height: 1.25; min-width: 0; }
.user-chip .who .nm { font-weight: 600; font-size: 14px; color: var(--ink);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .who .em { font-size: 12px; color: var(--muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- Topbar ---------------- */
.topbar {
    display: flex; align-items: center; gap: 16px;
    margin-bottom: 26px;
}
.search {
    flex: 1; max-width: 380px;
    display: flex; align-items: center; gap: 10px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); padding: 10px 14px; color: var(--muted);
    font-size: 14px;
}
.search input {
    border: none; background: transparent; outline: none; flex: 1;
    font-family: var(--font); font-size: 14px; color: var(--text);
}
.topbar .actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn {
    width: 38px; height: 38px; border-radius: var(--r);
    border: 1px solid var(--border); background: var(--surface);
    display: grid; place-items: center; cursor: pointer; color: var(--text-soft);
}
.icon-btn:hover { background: var(--surface-2); }

/* ---------------- Main ---------------- */
.main { padding: 24px 30px 40px; min-width: 0; }

.page-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; margin-bottom: 22px;
}
.page-head h1 { font-size: 24px; }
.page-head .sub { color: var(--muted); margin-top: 3px; font-size: 14px; }

.pill {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); padding: 9px 13px; font-size: 14px;
    color: var(--text-soft);
}

/* ---------------- Grid & cards ---------------- */
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
}
.card.pad-lg { padding: 24px 26px; }
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
}
.card-head h2 { font-size: 16px; }
.card-head .link { font-size: 13px; font-weight: 500; }

/* Featured (teal) card */
.card-feature {
    background: linear-gradient(140deg, var(--brand), var(--ink));
    color: #EAF6FA; border: none;
}
.card-feature h2 { color: #fff; }

/* Stat tiles */
.stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); padding: 16px 18px;
    box-shadow: var(--shadow-sm);
}
.stat .ico-box {
    width: 38px; height: 38px; border-radius: var(--r);
    background: var(--brand-50); color: var(--brand-dark);
    display: grid; place-items: center; font-size: 17px; margin-bottom: 12px;
}
.stat .label { font-size: 13px; color: var(--muted); }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 4px;
    letter-spacing: -0.02em; color: var(--ink); }
.stat .value.placeholder { color: var(--border-2); }

/* Balance */
.balance .amount { font-size: 38px; font-weight: 700; letter-spacing: -0.03em;
    color: var(--ink); }
.delta {
    display: inline-flex; align-items: center; gap: 5px;
    background: var(--success-bg); color: var(--success);
    font-size: 13px; font-weight: 600; border-radius: 999px; padding: 3px 10px;
}

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 16px; border-radius: var(--r); border: 1px solid transparent;
    font-family: var(--font); font-size: 14px; font-weight: 600;
    cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-soft { background: var(--brand-50); color: var(--brand-dark); }
.btn-soft:hover { background: var(--brand-100); }
.btn-ghost { background: var(--surface); border-color: var(--border-2); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-light { background: #fff; color: var(--brand-dark); }
.btn-block { width: 100%; }

/* Badges */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600; border-radius: 999px; padding: 4px 10px;
}
.badge-blue { background: var(--brand-50); color: var(--brand-dark); }
.badge-green { background: var(--success-bg); color: var(--success); }
.badge-red { background: var(--danger-bg); color: var(--danger); }
.badge-soon { background: #FFF1E2; color: #B5701B; }

/* List rows */
.row {
    display: flex; align-items: center; gap: 14px;
    padding: 13px 0; border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: none; }
.row .ava {
    width: 40px; height: 40px; border-radius: var(--r); flex: none;
    background: var(--surface-2); color: var(--text-soft);
    display: grid; place-items: center; font-weight: 600; font-size: 14px;
}
.row .meta { flex: 1; min-width: 0; }
.row .meta .t { font-weight: 600; font-size: 14px; color: var(--ink); }
.row .meta .s { font-size: 13px; color: var(--muted); }
.row .amt { font-weight: 600; font-size: 14px; }

/* Table */
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .04em;
    text-transform: uppercase; color: var(--muted); padding: 0 12px 12px;
    border-bottom: 1px solid var(--border);
}
.table td { padding: 14px 12px; border-bottom: 1px solid var(--border);
    font-size: 14px; }
.table tr:last-child td { border-bottom: none; }

/* Forms */
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 13px; color: var(--text-soft);
    margin-bottom: 7px; font-weight: 500; }
.field input, .field textarea, .field select {
    width: 100%; padding: 11px 13px; font-size: 15px; font-family: var(--font);
    border: 1px solid var(--border-2); border-radius: var(--r);
    background: var(--surface); color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 4px var(--brand-50);
}
.field .help { font-size: 12px; color: var(--muted); margin-top: 5px; }
.field .err { font-size: 12.5px; color: var(--danger); margin-top: 5px; }
.form-error {
    background: var(--danger-bg); color: var(--danger);
    border: 1px solid #F4C9D7; border-radius: var(--r);
    padding: 11px 13px; font-size: 13.5px; margin-bottom: 15px;
}

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
    width: 100%; max-width: 400px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-xl); padding: 32px 32px 28px;
    box-shadow: var(--shadow);
}
.auth-card .brand { padding: 0 0 18px; }

@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
    .main { padding: 18px; }
    .topbar .search { max-width: none; }
}
