/* VA Command — modern light SAAS admin theme */
:root {
    --bg: #f5f7fb;
    --card: #ffffff;
    --text: #1a2333;
    --muted: #6b7689;
    --border: #e6eaf2;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --navy: #0f1b2d;
    --navy-2: #16263f;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .05);
    --danger: #dc2626;
    --success: #16a34a;
    --warn: #d97706;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: Inter, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code { background: #eef2f7; padding: 1px 6px; border-radius: 6px; font-size: 12.5px; }
.pos { color: var(--success); }
.neg { color: var(--danger); }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; background: var(--navy); color: #c7d2e4;
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0;
}
.side-logo { display: flex; align-items: center; gap: 10px; padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.logo-mark {
    width: 36px; height: 36px; border-radius: 10px; background: var(--primary);
    color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0;
}
.logo-text { font-weight: 700; font-size: 16px; color: #fff; }
.nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
    color: #aebdd3; font-weight: 500;
}
.nav-item:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-icon { width: 20px; text-align: center; opacity: .9; }
.nav-disabled { opacity: .45; cursor: not-allowed; }
.phase-badge {
    font-style: normal; font-size: 10px; font-weight: 700; background: #e0e9ff; color: var(--primary-dark);
    border-radius: 20px; padding: 2px 8px; margin-left: auto; white-space: nowrap;
}
.nav-disabled .phase-badge { background: rgba(255,255,255,.12); color: #9fb0c9; }
.side-foot { padding: 16px 18px; border-top: 1px solid rgba(255,255,255,.08); }
.role-badge { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; padding: 4px 10px; border-radius: 20px; }
.role-admin { background: rgba(37,99,235,.25); color: #bcd0ff; }
.role-client { background: rgba(22,163,74,.22); color: #a7e6bd; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    background: var(--card); border-bottom: 1px solid var(--border);
    padding: 14px 24px; display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 10;
}
.topbar-title h1 { font-size: 20px; font-weight: 700; }
.topbar-title p { color: var(--muted); font-size: 13px; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-name { font-weight: 600; }
.menu-btn { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 16px; cursor: pointer; }
.content { padding: 24px; max-width: 1200px; width: 100%; margin: 0 auto; }

/* ---------- Cards / KPI ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h3 { font-size: 15px; font-weight: 700; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 4px; border-top: 3px solid var(--primary); }
.kpi-soon { border-top-color: #c3cede; }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.kpi-value { font-size: 26px; font-weight: 800; }
.kpi-sub { color: var(--muted); font-size: 12.5px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; padding: 10px 12px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; border-bottom: 2px solid var(--border); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafd; }
td.actions { white-space: nowrap; text-align: right; }
.link-sm { font-size: 12.5px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: 13px; }
.field input[type=text], .field input[type=password], .field input[type=email],
.field input[type=number], .field input[type=url], .field select {
    padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: #fff; width: 100%;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.field-check { justify-content: flex-end; padding-bottom: 10px; }
.field-check label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.inline-form { display: inline; }

/* ---------- Buttons ---------- */
.btn { display: inline-block; padding: 10px 18px; border-radius: 8px; border: 1px solid transparent; font-weight: 600; font-size: 14px; cursor: pointer; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger-ghost { background: #fff; border-color: #f3c2c2; color: var(--danger); }
.btn-danger-ghost:hover { background: #fef2f2; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.badge-active { background: #e6f6ec; color: var(--success); }
.badge-blocked { background: #fdecec; color: var(--danger); }
.badge-paused { background: #fef4e2; color: var(--warn); }
.badge-new { background: #e8f0fe; color: #1a56db; }
.badge-sent_to_supplier { background: #fef4e2; color: #b45309; }
.badge-dispatched { background: #ede9fe; color: #6d28d9; }
.badge-delivered { background: #e6f6ec; color: #15803d; }
.badge-cancelled { background: #f1f5f9; color: #64748b; }
.badge-deposit { background: #e6f6ec; color: #15803d; }
.badge-deduction { background: #fdecec; color: #b91c1c; }
.badge-adjustment { background: #fef4e2; color: #b45309; }
.badge-refund { background: #e8f0fe; color: #1a56db; }
.badge-open { background: #fef4e2; color: #b45309; }
.badge-settled { background: #e6f6ec; color: #15803d; }
.status-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.status-tab { padding: 7px 14px; border-radius: 20px; background: #f1f5f9; color: #475569; font-size: 13px; font-weight: 600; text-decoration: none; }
.status-tab.active { background: #0f1b2d; color: #fff; }
.status-tab .cnt { opacity: .7; font-weight: 700; margin-left: 4px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filters .field { margin: 0; min-width: 150px; }
.cost-table td:last-child, .cost-table th:last-child { text-align: right; }


/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab { padding: 10px 16px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Client header / KV ---------- */
.client-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.client-head h3 { font-size: 18px; }
.client-head-right { display: flex; align-items: center; gap: 10px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.kv div { display: flex; flex-direction: column; gap: 2px; }
.kv span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }

/* ---------- Activity ---------- */
.activity { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.activity li { display: flex; gap: 10px; }
.act-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.act-admin { background: var(--primary); }
.act-client { background: var(--success); }
.act-system { background: var(--muted); }
.act-time { font-size: 12px; color: var(--muted); }

/* ---------- Quick links ---------- */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.quick-link { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; padding: 16px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-weight: 600; }
.quick-link:hover { border-color: var(--primary); text-decoration: none; }
.quick-icon { font-size: 20px; }
.quick-disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Placeholder cards ---------- */
.placeholder-card { border-style: dashed; text-align: center; padding: 40px 20px; }
.placeholder-card h3 { margin-bottom: 8px; }

/* ---------- Toasts / alerts ---------- */
.toast-wrap { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.toast-wrap:empty { display: none; }
.toast { padding: 12px 16px; border-radius: 10px; font-weight: 500; box-shadow: var(--shadow); }
.toast-success { background: #e6f6ec; color: #14532d; border: 1px solid #bfe6cc; }
.toast-error { background: #fdecec; color: #7f1d1d; border: 1px solid #f3c2c2; }
.toast-info { background: #e8effe; color: #1e3a8a; border: 1px solid #c9d9fb; }
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.alert-error { background: #fdecec; color: #7f1d1d; border: 1px solid #f3c2c2; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--navy); }
.login-card { background: #fff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25); padding: 36px; width: 100%; max-width: 400px; }
.login-card h2 { text-align: center; font-size: 22px; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.login-logo { display: flex; justify-content: center; margin-bottom: 14px; }
.login-logo .logo-mark { width: 48px; height: 48px; font-size: 18px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn-block { margin-top: 6px; }
.login-hint { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 16px; }

/* ---------- Installer ---------- */
.install-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--navy); }
.install-card { background: #fff; border-radius: 16px; padding: 36px; width: 100%; max-width: 520px; }
.install-card h2 { margin-bottom: 6px; }
.install-steps { margin: 14px 0 20px 18px; color: var(--muted); font-size: 13px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .25s ease; z-index: 50; }
    body.nav-open .sidebar { transform: translateX(0); }
    .menu-btn { display: inline-block; }
    .content { padding: 16px; }
    .topbar { padding: 12px 16px; }
    .user-name { display: none; }
}
