@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@500;600;700;800&display=swap');

:root {
    --primary: hsl(212,100%,26%);
    --primary-light: hsl(212,100%,36%);
    --primary-dark: hsl(212,100%,18%);
    --sidebar-bg: hsl(212,100%,20%);
    --sidebar-border: hsl(212,100%,15%);
    --sidebar-active: hsl(212,100%,30%);
    --accent: #0ea5e9;
    --sidebar-width: 256px;
    --topbar-height: 60px;
    --bg: hsl(210,20%,98%);
    --card-bg: #ffffff;
    --text: hsl(222,47%,11%);
    --text-muted: hsl(215,16%,47%);
    --border: hsl(214,32%,91%);
    --muted: hsl(210,40%,96%);
    --radius: 0.75rem;
    --radius-sm: 0.5rem;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.1),0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05);
}
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 14px; }
body { margin: 0; font-family: 'Inter', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ── Login / Auth ─────────────────────────────────────────────────────────── */
.auth-root { min-height: 100vh; display: flex; background: var(--bg); }
.auth-hero {
    display: none;
    position: relative;
    width: 50%;
    background: linear-gradient(135deg, hsl(222,47%,18%) 0%, hsl(212,100%,26%) 50%, hsl(232,80%,45%) 100%);
    overflow: hidden;
    align-items: center;
    justify-content: center;
    padding: 48px;
}
@media (min-width: 992px) { .auth-hero { display: flex; } }
.auth-hero-dots {
    position: absolute; inset: 0;
    background-image: radial-gradient(circle at 25px 25px, rgba(255,255,255,.12) 2px, transparent 0);
    background-size: 50px 50px;
}
.auth-hero-content { position: relative; z-index: 1; color: #fff; max-width: 480px; }
.auth-hero-logo { display: flex; align-items: center; gap: 16px; margin-bottom: 40px; }
.auth-hero-logo-icon { width: 56px; height: 56px; border-radius: 16px; background: rgba(255,255,255,.15); backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.auth-hero-logo-name { font-family: 'Outfit', sans-serif; font-weight: 800; font-size: 2rem; letter-spacing: -0.5px; }
.auth-hero h2 { font-family: 'Outfit', sans-serif; font-size: 1.9rem; font-weight: 700; line-height: 1.25; margin: 0 0 16px; }
.auth-hero p { font-size: .95rem; color: rgba(255,255,255,.75); margin: 0; line-height: 1.6; }
.auth-hero-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 32px; }
.auth-hero-badge { padding: 5px 14px; border-radius: 100px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18); font-size: .75rem; color: rgba(255,255,255,.85); font-weight: 500; }
.auth-form-panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px 24px; background: var(--card-bg); }
.auth-form-wrap { width: 100%; max-width: 440px; }
.auth-mobile-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 32px; justify-content: center; }
@media (min-width: 992px) { .auth-mobile-logo { display: none; } }
.auth-mobile-logo-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; color: #fff; }
.auth-mobile-logo-name { font-family: 'Outfit', sans-serif; font-weight: 800; font-size: 1.5rem; color: var(--text); }
.auth-card-inner { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 36px; box-shadow: var(--shadow-lg); }
.auth-heading { font-family: 'Outfit', sans-serif; font-size: 1.6rem; font-weight: 700; color: var(--text); margin: 0 0 6px; }
.auth-subheading { color: var(--text-muted); font-size: .875rem; margin: 0 0 28px; }
.auth-field label { display: block; font-size: .78rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.auth-input-wrap { position: relative; }
.auth-input-wrap .auth-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: .85rem; pointer-events: none; }
.auth-input-wrap input { width: 100%; padding: 10px 14px 10px 36px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: .9rem; background: #fff; color: var(--text); transition: border-color .15s, box-shadow .15s; outline: none; }
.auth-input-wrap input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px hsl(212,100%,26%,.12); }
.auth-input-wrap .toggle-pwd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; padding: 4px 6px; color: var(--text-muted); }
.auth-btn { width: 100%; padding: 12px; background: var(--primary); color: #fff; border: none; border-radius: var(--radius-sm); font-size: .9rem; font-weight: 600; font-family: inherit; transition: background .15s; margin-top: 8px; }
.auth-btn:hover { background: var(--primary-light); }
.auth-btn:disabled { opacity: .7; cursor: not-allowed; }
.auth-divider { margin: 24px 0; text-align: center; position: relative; }
.auth-divider::before { content: ''; position: absolute; inset: 50% 0 auto; height: 1px; background: var(--border); }
.auth-divider span { position: relative; background: #fff; padding: 0 12px; font-size: .7rem; font-weight: 700; letter-spacing: .08em; color: var(--text-muted); text-transform: uppercase; }
.demo-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 10px; }
.demo-chip { padding: 5px 14px; border: 1.5px solid var(--border); border-radius: 100px; background: #fff; font-size: .78rem; font-weight: 500; color: var(--text); transition: all .15s; cursor: pointer; }
.demo-chip:hover { border-color: var(--primary); color: var(--primary); background: hsl(212,100%,26%,.05); }
.auth-footer { text-align: center; margin-top: 18px; font-size: .8rem; color: var(--text-muted); }
.auth-footer a { color: var(--primary); font-weight: 600; }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.p365-sidebar {
    position: fixed; top: 0; left: 0; width: var(--sidebar-width);
    height: 100vh; background: var(--sidebar-bg); color: rgba(255,255,255,.85);
    display: flex; flex-direction: column; z-index: 200;
    overflow-y: auto; overflow-x: hidden;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.1) transparent;
}
.sidebar-header { height: var(--topbar-height); display: flex; align-items: center; padding: 0 16px; border-bottom: 1px solid rgba(255,255,255,.08); gap: 10px; flex-shrink: 0; }
.sidebar-logo-icon { width: 32px; height: 32px; border-radius: 8px; background: rgba(255,255,255,.15); display: flex; align-items: center; justify-content: center; font-size: .85rem; flex-shrink: 0; }
.sidebar-logo-text { font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 1.15rem; color: #fff; white-space: nowrap; letter-spacing: -0.3px; }
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: var(--radius-sm);
    font-size: .82rem; font-weight: 500; color: rgba(255,255,255,.7);
    cursor: pointer; border: none; background: none; width: 100%;
    text-align: left; transition: all .15s;
    text-decoration: none; white-space: nowrap;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.13); color: #fff; }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-icon { width: 18px; text-align: center; font-size: .85rem; flex-shrink: 0; color: rgba(255,255,255,.5); }
.sidebar-footer { padding: 12px 10px; border-top: 1px solid rgba(255,255,255,.08); flex-shrink: 0; }
.sidebar-footer .nav-item { color: rgba(255,150,150,.8); }
.sidebar-footer .nav-item:hover { background: rgba(255,100,100,.08); color: #ff9999; }

/* ── Main layout ──────────────────────────────────────────────────────────── */
.p365-main { margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; }
.p365-topbar {
    height: var(--topbar-height); background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 24px; gap: 12px;
    position: sticky; top: 0; z-index: 100;
    box-shadow: var(--shadow-sm);
}
.topbar-title { font-size: 1rem; font-weight: 600; flex: 1; color: var(--text); }
.topbar-title small { display: block; font-size: .7rem; font-weight: 400; color: var(--text-muted); }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.topbar-btn { width: 36px; height: 36px; border-radius: var(--radius-sm); border: none; background: none; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: .9rem; cursor: pointer; transition: all .15s; position: relative; }
.topbar-btn:hover { background: var(--muted); color: var(--text); }
.topbar-notif-dot { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: #ef4444; border: 1.5px solid #fff; }
.topbar-divider { width: 1px; height: 24px; background: var(--border); margin: 0 6px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: var(--radius-sm); background: var(--muted); cursor: default; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: hsl(212,100%,26%,.15); border: 1.5px solid hsl(212,100%,26%,.25); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .72rem; color: var(--primary); flex-shrink: 0; }
.user-info-name { font-size: .78rem; font-weight: 600; color: var(--text); line-height: 1.1; }
.user-info-role { font-size: .65rem; color: var(--text-muted); line-height: 1.1; text-transform: capitalize; }
.topbar-logout { display: flex; align-items: center; gap: 5px; padding: 7px 12px; border-radius: var(--radius-sm); border: none; background: none; font-size: .8rem; font-weight: 500; color: var(--text-muted); cursor: pointer; transition: all .15s; }
.topbar-logout:hover { background: #fee2e2; color: #dc2626; }
.p365-content { flex: 1; padding: 24px 28px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.p365-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.p365-card-header { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.p365-card-header h2, .p365-card-header h3 { margin: 0; font-size: .9rem; font-weight: 600; color: var(--text); }
.p365-card-body { padding: 20px; }

/* ── KPI Cards ────────────────────────────────────────────────────────────── */
.kpi-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); transition: box-shadow .15s; }
.kpi-card:hover { box-shadow: var(--shadow); }
.kpi-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
.kpi-label { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; }
.kpi-value { font-family: 'Outfit', sans-serif; font-size: 1.65rem; font-weight: 700; color: var(--text); line-height: 1.15; margin-bottom: 4px; }
.kpi-sub { font-size: .72rem; color: var(--text-muted); }
.kpi-trend { display: inline-flex; align-items: center; gap: 3px; font-size: .7rem; font-weight: 600; padding: 2px 6px; border-radius: 4px; margin-top: 3px; }
.kpi-trend.up { background: #d1fae5; color: #065f46; }
.kpi-trend.down { background: #fee2e2; color: #991b1b; }

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.p365-tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.p365-tab { padding: 10px 16px; font-size: .8rem; font-weight: 500; color: var(--text-muted); background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; transition: all .15s; margin-bottom: -2px; display: flex; align-items: center; gap: 5px; }
.p365-tab:hover { color: var(--text); background: var(--muted); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.p365-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ── Badges / Status ──────────────────────────────────────────────────────── */
.badge-p365, .p365-badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 100px; font-size: .7rem; font-weight: 600; border: 1px solid transparent; }
.badge-draft     { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.badge-pending   { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.badge-approved  { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.badge-rejected  { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.badge-active    { background: #ccfbf1; color: #065f46; border-color: #5eead4; }
.badge-cancelled { background: #f1f5f9; color: #94a3b8; border-color: #cbd5e1; }
.badge-confirmed { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.badge-published { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.badge-awarded   { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.badge-sent      { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }
.badge-submitted { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.badge-in_transit,.badge-in-transit { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }
.badge-delivered { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.badge-paid      { background: #ccfbf1; color: #065f46; border-color: #5eead4; }
.badge-po_raised { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.badge-under_review { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.badge-registered { background: #f1f5f9; color: #64748b; border-color: #cbd5e1; }
.badge-gr_completed { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.badge-evaluated { background: #fdf4ff; color: #7e22ce; border-color: #d8b4fe; }
.badge-validation_failed { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.badge-payment_initiated { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }
.badge-partial   { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.badge-completed { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.badge-flagged   { background: #ffedd5; color: #9a3412; border-color: #fdba74; }
.badge-ocr_processing { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }
.badge-validated { background: #ccfbf1; color: #065f46; border-color: #5eead4; }
.badge-pending_approval { background: #fef3c7; color: #92400e; border-color: #fcd34d; }

.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-approved,.dot-active,.dot-delivered,.dot-paid,.dot-gr_completed,.dot-awarded { background:#22c55e; }
.dot-pending,.dot-submitted,.dot-under_review,.dot-pending_approval { background:#f59e0b; }
.dot-rejected,.dot-cancelled,.dot-flagged { background:#ef4444; }
.dot-draft,.dot-registered { background:#94a3b8; }
.dot-confirmed,.dot-published,.dot-sent,.dot-in_transit { background:#3b82f6; }
.dot-po_raised,.dot-completed { background:#10b981; }
.dot-evaluated,.dot-payment_initiated,.dot-ocr_processing { background:#8b5cf6; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.p365-table-wrap { overflow-x: auto; }
.p365-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.p365-table thead th { padding: 10px 16px; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); background: #f8fafc; border-bottom: 1px solid var(--border); white-space: nowrap; text-align: left; }
.p365-table tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; cursor: pointer; }
.p365-table tbody tr:last-child { border-bottom: none; }
.p365-table tbody tr:hover { background: #f8fafc; }
.p365-table td { padding: 11px 16px; vertical-align: middle; color: var(--text); }
.p365-table .td-mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: .75rem; font-weight: 700; color: var(--primary); }
.p365-table .td-muted { color: var(--text-muted); }
.p365-table .td-value { font-weight: 700; color: #16a34a; }

/* ── Action Bar ───────────────────────────────────────────────────────────── */
.p365-action-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.p365-search { display: flex; align-items: center; gap: 0; border: 1.5px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.p365-search i { padding: 0 10px; color: var(--text-muted); font-size: .8rem; }
.p365-search input { border: none; outline: none; font-size: .82rem; padding: 7px 10px 7px 0; background: transparent; width: 200px; color: var(--text); }
.p365-select { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 7px 12px; font-size: .82rem; background: #fff; color: var(--text); outline: none; cursor: pointer; font-family: inherit; }
.p365-select:focus { border-color: var(--primary); }
.btn-p365 { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm); font-size: .82rem; font-weight: 600; font-family: inherit; border: none; cursor: pointer; transition: all .15s; }
.btn-primary-p365 { background: var(--primary); color: #fff; }
.btn-primary-p365:hover { background: var(--primary-light); }
.btn-secondary-p365 { background: var(--muted); color: var(--text); }
.btn-secondary-p365:hover { background: var(--border); }
.btn-outline-p365 { background: #fff; color: var(--text); border: 1.5px solid var(--border); }
.btn-outline-p365:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm-p365 { padding: 5px 10px; font-size: .75rem; gap: 4px; }
.btn-danger-p365 { background: #fee2e2; color: #dc2626; border: 1px solid #fca5a5; }
.btn-danger-p365:hover { background: #fecaca; }
.btn-success-p365 { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.btn-success-p365:hover { background: #a7f3d0; }
.btn-icon-p365 { width: 32px; height: 32px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: #fff; display: flex; align-items: center; justify-content: center; font-size: .8rem; color: var(--text-muted); cursor: pointer; transition: all .15s; padding: 0; }
.btn-icon-p365:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger-icon { border-color: #fca5a5; color: #dc2626; }
.btn-danger-icon:hover { background: #fee2e2; border-color: #ef4444; color: #991b1b; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.p365-modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1040; display: none; align-items: center; justify-content: center; padding: 16px; }
.p365-modal-backdrop.show { display: flex; }
.p365-modal { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 100%; max-width: 680px; max-height: 90vh; display: flex; flex-direction: column; animation: modal-in .18s ease; }
.p365-modal.modal-lg { max-width: 900px; }
.p365-modal.modal-xl { max-width: 1100px; }
@keyframes modal-in { from { opacity:0; transform:translateY(-12px) scale(.98); } to { opacity:1; transform:none; } }
.p365-modal-header { background: var(--primary); color: #fff; padding: 14px 20px; border-radius: var(--radius) var(--radius) 0 0; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.p365-modal-header h3 { margin: 0; font-size: .9rem; font-weight: 600; flex: 1; }
.p365-modal-close { width: 28px; height: 28px; border-radius: 6px; border: none; background: rgba(255,255,255,.15); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: .8rem; }
.p365-modal-close:hover { background: rgba(255,255,255,.25); }
.p365-modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.p365-modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0; }

/* ── Form elements ────────────────────────────────────────────────────────── */
.p365-label { display: block; font-size: .7rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 5px; }
.p365-input, .p365-select-f, .p365-textarea {
    width: 100%; padding: 8px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: .85rem; background: #fff; color: var(--text); outline: none;
    font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
.p365-input:focus, .p365-select-f:focus, .p365-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px hsl(212,100%,26%,.1); }
.p365-textarea { resize: vertical; }
.p365-input-group { display: grid; gap: 14px; }
.p365-input-group.g2 { grid-template-columns: 1fr 1fr; }
.p365-input-group.g3 { grid-template-columns: 1fr 1fr 1fr; }
.p365-input-group.g4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
@media (max-width: 600px) { .p365-input-group.g2,.p365-input-group.g3,.p365-input-group.g4 { grid-template-columns: 1fr; } }

/* ── Line items table ─────────────────────────────────────────────────────── */
.li-table { width: 100%; border-collapse: collapse; font-size: .78rem; }
.li-table thead th { padding: 7px 8px; font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); border-bottom: 1.5px solid var(--border); background: #f8fafc; text-align: left; white-space: nowrap; }
.li-table tbody tr { border-bottom: 1px solid var(--border); }
.li-table td { padding: 5px 6px; vertical-align: middle; }
.li-table .li-input { width: 100%; padding: 5px 8px; border: 1px solid var(--border); border-radius: 5px; font-size: .78rem; background: #fff; outline: none; font-family: inherit; }
.li-table .li-input:focus { border-color: var(--primary); }
.li-total-bar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 10px; padding: 10px 12px; background: #f8fafc; border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: .85rem; font-weight: 700; }

/* ── Empty states ─────────────────────────────────────────────────────────── */
.p365-empty { text-align: center; padding: 56px 24px; color: var(--text-muted); }
.p365-empty i { font-size: 2.2rem; margin-bottom: 14px; opacity: .3; display: block; }
.p365-empty p { font-size: .85rem; margin: 0; }
.p365-empty small { font-size: .75rem; opacity: .7; }

/* ── Lifecycle bar ────────────────────────────────────────────────────────── */
.lifecycle-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.lifecycle-step { display: flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: var(--radius-sm); font-size: .7rem; font-weight: 600; white-space: nowrap; }
.lifecycle-step.done { background: #d1fae5; color: #065f46; }
.lifecycle-step.current { background: var(--primary); color: #fff; }
.lifecycle-step.todo { background: var(--muted); color: var(--text-muted); }
.lifecycle-arrow { color: var(--text-muted); font-size: .7rem; }

/* ── Detail panel (view modal) ────────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-field label { font-size: .65rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); display: block; margin-bottom: 3px; }
.detail-field span { font-size: .85rem; color: var(--text); font-weight: 500; }
.detail-section-title { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); margin: 16px 0 10px; border-bottom: 1px solid var(--border); padding-bottom: 5px; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
#p365-toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.p365-toast { min-width: 260px; max-width: 380px; padding: 12px 16px; border-radius: var(--radius-sm); background: #1e293b; color: #fff; font-size: .82rem; font-weight: 500; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; animation: toast-in .2s ease; }
.p365-toast.success { background: #065f46; }
.p365-toast.error { background: #991b1b; }
.p365-toast.warning { background: #92400e; }
@keyframes toast-in { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:none; } }

/* ── Progress / Stat bars ─────────────────────────────────────────────────── */
.stat-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.stat-bar-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s ease; }
.stat-bar-fill.green { background: #22c55e; }
.stat-bar-fill.amber { background: #f59e0b; }
.stat-bar-fill.red { background: #ef4444; }

/* ── Priority badges ──────────────────────────────────────────────────────── */
.priority-low { background: #f0fdf4; color: #16a34a; border: 1px solid #86efac; }
.priority-medium { background: #fffbeb; color: #d97706; border: 1px solid #fcd34d; }
.priority-high { background: #fef2f2; color: #dc2626; border: 1px solid #fca5a5; }
.priority-critical { background: #fdf2f8; color: #9d174d; border: 1px solid #f9a8d4; animation: pulse-border 1.5s infinite; }
@keyframes pulse-border { 0%,100% { border-color: #f9a8d4; } 50% { border-color: #ec4899; } }

/* ── Chat ─────────────────────────────────────────────────────────────────── */
.chat-wrap { display: flex; height: calc(100vh - var(--topbar-height) - 48px); gap: 0; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.chat-sidebar { width: 280px; border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.chat-sidebar-header { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: .85rem; font-weight: 600; }
.chat-rooms { flex: 1; overflow-y: auto; }
.chat-room-item { padding: 12px 16px; display: flex; align-items: flex-start; gap: 10px; cursor: pointer; border-bottom: 1px solid #f8fafc; transition: background .1s; }
.chat-room-item:hover { background: var(--muted); }
.chat-room-item.active { background: hsl(212,100%,26%,.06); border-left: 3px solid var(--primary); }
.chat-room-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; flex-shrink: 0; }
.chat-room-name { font-size: .82rem; font-weight: 600; }
.chat-room-last { font-size: .72rem; color: var(--text-muted); margin-top: 2px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 160px; }
.chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chat-main-header { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { display: flex; gap: 10px; }
.chat-msg.mine { flex-direction: row-reverse; }
.chat-msg-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--muted); border: 1.5px solid var(--border); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .7rem; color: var(--text-muted); flex-shrink: 0; }
.chat-bubble { max-width: 68%; padding: 9px 13px; border-radius: 12px; font-size: .82rem; line-height: 1.5; }
.chat-bubble.theirs { background: var(--muted); color: var(--text); border-bottom-left-radius: 3px; }
.chat-bubble.mine-b { background: var(--primary); color: #fff; border-bottom-right-radius: 3px; }
.chat-bubble-meta { font-size: .65rem; color: var(--text-muted); margin-top: 3px; }
.chat-mine .chat-bubble-meta { text-align: right; color: rgba(255,255,255,.7); }
.chat-input-area { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.chat-input { flex: 1; border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 9px 14px; font-size: .85rem; outline: none; font-family: inherit; }
.chat-input:focus { border-color: var(--primary); }

/* ── Audit ────────────────────────────────────────────────────────────────── */
.audit-entry { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.audit-entry:last-child { border-bottom: none; }
.audit-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: .8rem; flex-shrink: 0; }
.audit-text { flex: 1; }
.audit-title { font-size: .82rem; font-weight: 600; color: var(--text); }
.audit-meta { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }
.audit-time { font-size: .7rem; color: var(--text-muted); white-space: nowrap; }

/* ── Vendor card ──────────────────────────────────────────────────────────── */
.vendor-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; transition: box-shadow .15s, transform .15s; cursor: pointer; }
.vendor-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.vendor-logo { width: 44px; height: 44px; border-radius: 10px; background: var(--muted); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1rem; color: var(--primary); border: 1px solid var(--border); flex-shrink: 0; }
.vendor-rating { color: #f59e0b; font-size: .75rem; }

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Spin ─────────────────────────────────────────────────────────────────── */
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Loading overlay ──────────────────────────────────────────────────────── */
.p365-loading { text-align: center; padding: 48px; color: var(--text-muted); }
.p365-loading i { font-size: 1.5rem; margin-bottom: 8px; display: block; }
