/* Sales Outlook design system. No external fonts/CDNs (strict CSP). */

:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --border: #e4e8f1;
    --text: #16203a;
    --text-muted: #64708c;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --accent: #06b6d4;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --success: #059669;
    --success-soft: #ecfdf5;
    --warning-soft: #fffbeb;
    --sidebar-bg: #0f172a;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #1e293b;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(22, 32, 58, .06), 0 8px 24px -12px rgba(22, 32, 58, .12);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
p { margin: 0 0 1rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-size: .85em; background: var(--primary-soft); padding: .1em .4em; border-radius: 5px; }
small, .small { font-size: .85rem; }
.muted { color: var(--text-muted); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.empty { color: var(--text-muted); font-style: italic; }

/* ---- App shell --------------------------------------------------------- */
body.app { display: flex; min-height: 100vh; }

.sidebar {
    display: flex;
    flex-direction: column;
    width: 264px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; }
.brand-mark {
    width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    box-shadow: 0 4px 12px -2px rgba(79, 70, 229, .5);
}
.brand-mark-lg { width: 44px; height: 44px; border-radius: 12px; }
.brand-name { font-weight: 700; font-size: 1.05rem; color: #fff; letter-spacing: .01em; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-section {
    margin: 18px 10px 6px;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #64748b;
}
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--sidebar-text);
    font-weight: 500;
}
.nav-link svg { width: 18px; height: 18px; opacity: .8; }
.nav-link:hover { background: var(--sidebar-active); color: #fff; text-decoration: none; }
.nav-link.is-active { background: var(--sidebar-active); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }

.sidebar-footer { border-top: 1px solid #1e293b; padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff; font-weight: 700; font-size: .9rem; flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-name { color: #fff; font-weight: 600; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { color: #64748b; font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; min-width: 0; padding: 28px 36px 48px; }
.topbar { margin-bottom: 20px; }
.page-title { font-size: 1.45rem; font-weight: 700; }
.content { display: flex; flex-direction: column; gap: 20px; }

/* ---- Cards, grids ------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    margin-bottom: 20px;
}
.content > .card { margin-bottom: 0; }
.card-title { font-size: 1.05rem; font-weight: 650; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card-head .card-title { margin: 0; }
.card-narrow { max-width: 480px; }
.card-accent { border-left: 4px solid var(--accent); }
.stat { display: flex; flex-direction: column; gap: 2px; margin-bottom: 0; }
.stat-label { font-size: .8rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }
.stat-value { font-size: 1.9rem; font-weight: 750; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 1000px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---- Forms -------------------------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-weight: 600; font-size: .88rem; }
.field-label small { color: var(--text-muted); font-weight: 400; }
input[type="text"], input[type="email"], input[type="password"] {
    font: inherit;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    width: 100%;
}
input:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .18);
}
fieldset.field { border: 0; padding: 0; margin: 0; }
.check { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.form-error { color: var(--danger); font-size: .88rem; margin: 0; }
.notice { background: var(--warning-soft); border: 1px solid #fde68a; border-radius: 8px; padding: 10px 14px; }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
    font: inherit;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease, transform .05s ease;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(79, 70, 229, .3); }
.btn-icon { width: 18px; height: 18px; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: inherit; border-color: transparent; }
.sidebar .btn-ghost { color: var(--sidebar-text); border-color: #1e293b; }
.sidebar .btn-ghost:hover { background: var(--sidebar-active); color: #fff; }
.btn-ghost:hover { background: var(--primary-soft); color: var(--primary); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: var(--danger); color: #fff; }

/* ---- Tables, lists, badges ---------------------------------------------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left;
    font-size: .76rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.row-muted td { opacity: .55; }

.list { list-style: none; margin: 0 0 16px; padding: 0; }
.list-item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: 0; }
.list-item > div { display: flex; flex-direction: column; }

.badge {
    display: inline-block;
    font-size: .74rem;
    font-weight: 650;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    margin-right: 4px;
}
.badge-admin { background: #fdf2f8; color: #be185d; }
.badge-ok { background: var(--success-soft); color: var(--success); }
.badge-off { background: #f1f5f9; color: var(--text-muted); }

/* ---- Flash messages ------------------------------------------------------ */
.flash {
    display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
    border-radius: 8px;
    padding: 11px 14px;
    margin-bottom: 16px;
    border: 1px solid;
    overflow-wrap: anywhere;
}
.flash-success { background: var(--success-soft); border-color: #a7f3d0; color: #065f46; }
.flash-error { background: var(--danger-soft); border-color: #fecaca; color: #991b1b; }
.flash-close {
    background: none; border: 0; cursor: pointer;
    font-size: 1.1rem; line-height: 1; color: inherit; opacity: .6; padding: 0;
}
.flash-close:hover { opacity: 1; }

/* ---- Auth (sign-in) pages ------------------------------------------------ */
body.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(800px 400px at 85% -10%, rgba(6, 182, 212, .18), transparent 60%),
        radial-gradient(900px 500px at 10% 110%, rgba(79, 70, 229, .16), transparent 60%),
        var(--sidebar-bg);
    padding: 24px;
}
.auth-wrap { width: 100%; max-width: 420px; }
.auth-brand {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    margin-bottom: 22px;
}
.auth-brand .brand-name { font-size: 1.3rem; }
.auth-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 30px 32px;
    box-shadow: 0 20px 60px -20px rgba(0, 0, 0, .55);
}
.auth-title { font-size: 1.3rem; font-weight: 720; margin-bottom: 2px; }
.auth-sub { color: var(--text-muted); margin-bottom: 20px; }
.auth-foot { text-align: center; color: #64748b; font-size: .82rem; margin-top: 18px; }

.divider {
    display: flex; align-items: center; gap: 12px;
    color: var(--text-muted); font-size: .8rem;
    margin: 18px 0;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

@media (max-width: 820px) {
    body.app { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; }
    .main { padding: 20px 16px 40px; }
}
