/* ============================================================
   DeepSuggest — modern UI theme
   ============================================================ */
:root {
    --bg: #eef1f8;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --line: #e7eaf3;
    --brand: #4f46e5;
    --brand-2: #7c3aed;
    --brand-dark: #4338ca;
    --brand-soft: #eef2ff;
    --ok: #059669;     --ok-soft: #d1fae5;
    --err: #e11d48;    --err-soft: #ffe4e6;
    --warn: #d97706;   --warn-soft: #fef3c7;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.05);
    --shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px -8px rgba(15,23,42,.12);
    --shadow-lg: 0 20px 48px -16px rgba(31,27,74,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app { display: flex; min-height: 100vh; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: 236px; flex-shrink: 0;
    background: linear-gradient(180deg, #211c54 0%, #312a7a 60%, #3b2f8f 100%);
    color: #c7cdf0;
    padding: 22px 16px;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.brand { font-size: 23px; font-weight: 800; letter-spacing: -.02em; color: #fff; padding: 4px 10px 22px; }
.brand span { background: linear-gradient(90deg,#a5b4fc,#c4b5fd); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.sidebar nav { display: flex; flex-direction: column; gap: 3px; }
.sidebar nav a {
    color: #c0c6ee; text-decoration: none; padding: 10px 13px; border-radius: 10px;
    font-weight: 500; font-size: 14px; display: flex; align-items: center;
    transition: background .15s ease, color .15s ease;
}
.sidebar nav a .nav-ic { width: 18px; height: 18px; margin-right: 11px; flex-shrink: 0; opacity: .85; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.sidebar nav a.active .nav-ic { opacity: 1; }
.sidebar nav a.active {
    background: linear-gradient(90deg, rgba(255,255,255,.16), rgba(255,255,255,.06));
    color: #fff; box-shadow: inset 3px 0 0 #a5b4fc;
}
.sidebar-user {
    margin-top: auto; padding: 14px 10px 2px; border-top: 1px solid rgba(255,255,255,.1);
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.user-name { font-size: 13px; color: #e6e9fb; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #9aa3d8; font-weight: 600; }
.logout-btn { background: none; border: none; color: #9aa3d8; cursor: pointer; font-size: 13px; padding: 0; }
.logout-btn:hover { color: #fff; text-decoration: underline; }

/* ---------- Content ---------- */
.content { flex: 1; padding: 28px 36px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.page-head h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 0; }

.panel {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 22px; margin-bottom: 20px; box-shadow: var(--shadow-sm);
}
.panel h2 { margin: 0 0 14px; font-size: 16px; font-weight: 700; letter-spacing: -.01em;
    color: var(--brand-dark); display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.panel h2::before { content: ''; width: 4px; height: 17px; border-radius: 3px; flex-shrink: 0;
    background: linear-gradient(180deg, var(--brand), var(--brand-2)); }

/* Colored card accents (top border + matching title) */
.accent-amber  { border-top: 3px solid #f59e0b; }
.accent-blue   { border-top: 3px solid #2563eb; }
.accent-green  { border-top: 3px solid #059669; }
.accent-red    { border-top: 3px solid #e11d48; }
.accent-purple { border-top: 3px solid #7c3aed; }
.accent-teal   { border-top: 3px solid #0d9488; }
.accent-amber  > h2 { color: #b45309; } .accent-amber  > h2::before { background: #f59e0b; }
.accent-blue   > h2 { color: #1d4ed8; } .accent-blue   > h2::before { background: #2563eb; }
.accent-green  > h2 { color: #047857; } .accent-green  > h2::before { background: #059669; }
.accent-red    > h2 { color: #be123c; } .accent-red    > h2::before { background: #e11d48; }
.accent-purple > h2 { color: #6d28d9; } .accent-purple > h2::before { background: #7c3aed; }
.accent-teal   > h2 { color: #0f766e; } .accent-teal   > h2::before { background: #0d9488; }
.panel-highlight { border: 1px solid #c7d2fe; background: linear-gradient(180deg,#f5f7ff, #ffffff); box-shadow: var(--shadow); }
.panel-highlight h2 { color: var(--brand-dark); }

.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- Hero banner ---------- */
.hero {
    position: relative; overflow: hidden; border-radius: var(--radius); margin-bottom: 22px;
    padding: 30px 32px; color: #fff;
    background: linear-gradient(120deg, #4f46e5 0%, #6d28d9 55%, #7c3aed 100%);
    box-shadow: var(--shadow);
    display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
}
.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 240px; height: 240px;
    background: radial-gradient(circle, rgba(255,255,255,.18), transparent 70%); }
.hero-eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: 11px; font-weight: 700; opacity: .85; }
.hero-title { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0 6px; }
.hero-sub { margin: 0; opacity: .9; font-size: 14.5px; max-width: 520px; }
.hero-actions { margin-top: 14px; }
.hero .btn-ghost { background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.3); backdrop-filter: blur(4px); }
.hero .btn-ghost:hover { background: rgba(255,255,255,.26); }
.hero-stats { display: flex; gap: 14px; flex-wrap: wrap; position: relative; z-index: 1; }
.hero-stat { background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22); border-radius: 14px;
    padding: 14px 18px; min-width: 130px; backdrop-filter: blur(4px); }
.hs-num { display: block; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.hs-label { display: block; font-size: 11.5px; opacity: .9; margin-top: 2px; }

/* ---------- Stat cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card {
    position: relative; overflow: hidden;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow-sm);
    transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: linear-gradient(180deg, var(--brand), var(--brand-2)); }
.card-num { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.card-label { color: var(--muted); font-size: 12.5px; font-weight: 500; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th {
    font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
    font-weight: 600; background: var(--surface-2); border-bottom: 1px solid var(--line);
}
thead th:first-child { border-top-left-radius: 10px; }
thead th:last-child { border-top-right-radius: 10px; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #fafbff; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; }
table.compact th, table.compact td { padding: 9px 10px; font-size: 13.5px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    background: linear-gradient(180deg, #5b53ea, var(--brand)); color: #fff; border: none;
    padding: 10px 18px; border-radius: 10px; font-size: 14px; font-weight: 600; font-family: inherit;
    cursor: pointer; text-decoration: none; box-shadow: 0 1px 2px rgba(79,70,229,.35), 0 6px 16px -6px rgba(79,70,229,.5);
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover { background: linear-gradient(180deg, #5048e0, var(--brand-dark)); transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-ghost { background: #fff; color: var(--ink-2); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { background: var(--surface-2); border-color: #cbd5e1; }
.btn-block { width: 100%; margin-top: 12px; padding: 12px; }
.btn-row { display: flex; gap: 10px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

/* Colored button variants */
.btn-info    { background: linear-gradient(180deg, #3b82f6, #2563eb); box-shadow: 0 6px 14px -6px rgba(37,99,235,.6); }
.btn-info:hover    { background: linear-gradient(180deg, #2f78f0, #1d4ed8); }
.btn-success { background: linear-gradient(180deg, #10b981, #059669); box-shadow: 0 6px 14px -6px rgba(5,150,105,.6); }
.btn-success:hover { background: linear-gradient(180deg, #0fa876, #047857); }
.btn-warn    { background: linear-gradient(180deg, #f59e0b, #d97706); box-shadow: 0 6px 14px -6px rgba(217,119,6,.6); }
.btn-warn:hover    { background: linear-gradient(180deg, #ed940a, #b45309); }
.btn-danger  { background: linear-gradient(180deg, #f43f5e, #e11d48); box-shadow: 0 6px 14px -6px rgba(225,29,72,.6); }
.btn-danger:hover  { background: linear-gradient(180deg, #ef2e50, #be123c); }

/* ---------- Tags / badges ---------- */
.tag { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
    font-size: 11.5px; font-weight: 600; background: #eef1f8; color: var(--muted); white-space: nowrap; }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-err { background: var(--err-soft); color: var(--err); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-pos, .tag-quickbooks { background: var(--brand-soft); color: var(--brand); }

/* ---------- Flash ---------- */
.flash { padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; border: 1px solid transparent; }
.flash-success { background: var(--ok-soft); color: #065f46; border-color: #a7f3d0; }
.flash-error { background: var(--err-soft); color: #9f1239; border-color: #fecdd3; }
.flash-info { background: var(--brand-soft); color: var(--brand-dark); border-color: #c7d2fe; }
.status-ok { color: var(--ok); font-weight: 600; }

/* ---------- Forms ---------- */
.input, select.input {
    width: 100%; padding: 11px 13px; border: 1px solid #d7dceb; border-radius: 10px;
    font-size: 14px; background: #fff; color: var(--ink); font-family: inherit; transition: border-color .12s, box-shadow .12s;
}
.input:focus, select.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; align-items: end; }
.field-action span { visibility: hidden; }
.row-sub td { padding-top: 0; border-bottom: 2px solid var(--line); }
.link-danger { background: none; border: none; color: var(--err); cursor: pointer; font-size: 13px; padding: 0; font-family: inherit; }
.link-danger:hover { text-decoration: underline; }

/* ---------- Suggestions layout ---------- */
.suggest-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
.suggest-col { display: flex; flex-direction: column; gap: 20px; }
.suggest-col .panel { margin-bottom: 0; }
.suggest-side { display: flex; flex-direction: column; gap: 20px; }
.suggest-side .panel { margin-bottom: 0; }
.suggest-main { min-height: 110px; }

/* Searchable client dropdown */
.combo { position: relative; }
.combo::after { content: '▾'; position: absolute; right: 14px; top: 12px; color: var(--muted); pointer-events: none; }
.combo #client-search { padding-right: 30px; cursor: pointer; }
.combo-list { list-style: none; margin: 6px 0 0; padding: 6px; position: absolute; z-index: 40;
    left: 0; right: 0; max-height: 340px; overflow-y: auto; background: #fff;
    border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); display: none; }
.combo.open .combo-list { display: block; }
.combo-list li { border-radius: 8px; }
.combo-list li a { display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
    padding: 9px 12px; text-decoration: none; color: var(--ink); border-radius: 8px; }
.combo-list li a:hover { background: var(--brand-soft); text-decoration: none; }
.combo-list li a.active { background: var(--brand); color: #fff; }
.combo-list li a.active .combo-meta { color: #dbe0ff; }
.combo-meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.combo-empty { padding: 10px 12px; }

/* Client summary header */
.client-header h2 { margin: 0 0 14px; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.client-stats { display: flex; flex-wrap: wrap; gap: 14px; }
.client-stats .stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
    padding: 10px 16px; display: flex; flex-direction: column; gap: 3px; min-width: 120px; }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.stat-val { font-weight: 700; font-size: 15px; }

/* Trend arrows */
.trend-up { color: var(--ok); font-weight: 700; }
.trend-down { color: var(--err); font-weight: 700; }

/* Avatars */
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
    background: var(--av, var(--brand)); color: #fff; font-weight: 700; flex-shrink: 0;
    box-shadow: 0 2px 6px -1px rgba(15,23,42,.25); vertical-align: middle; }
.client-header h2 .avatar { margin-right: 4px; }
.name-cell { display: inline-flex; align-items: center; gap: 9px; }

/* Sparkline */
.spark { display: block; }
.spark-wrap { display: flex; flex-direction: column; gap: 2px; }

/* Brand logo */
.brand-logo { max-height: 40px; max-width: 100%; display: block; }

/* Status-tinted table rows */
tr.row-danger td { background: #fff1f2 !important; box-shadow: inset 3px 0 0 #e11d48; }
tr.row-warn   td { background: #fffbeb !important; box-shadow: inset 3px 0 0 #f59e0b; }
tr.row-ok     td { background: #f0fdf4 !important; }
tr.row-danger:hover td, tr.row-warn:hover td, tr.row-ok:hover td { filter: brightness(.985); }

/* Dashboard monthly-sales bars */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; max-width: 38px; border-radius: 7px 7px 0 0;
    background: linear-gradient(180deg, #6366f1, #4f46e5); min-height: 3px; transition: height .3s ease; }
.bar-val { font-size: 10.5px; color: var(--muted); font-weight: 600; }
.bar-lbl { font-size: 11px; color: var(--muted); }

/* KPI hero tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi-icon { width: 48px; height: 48px; border-radius: 13px; display: flex; align-items: center; justify-content: center;
    font-size: 24px; flex-shrink: 0; }
.kpi-num { font-size: 23px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi-amber  .kpi-icon { background: #fef3c7; } .kpi-blue .kpi-icon { background: #dbeafe; }
.kpi-green  .kpi-icon { background: #d1fae5; } .kpi-red  .kpi-icon { background: #ffe4e6; }
.kpi-purple .kpi-icon { background: #ede9fe; } .kpi-teal .kpi-icon { background: #ccfbf1; }

/* Toast notifications */
#toast-stack { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 13px 15px; border-radius: 12px;
    background: #fff; box-shadow: var(--shadow-lg); border-left: 4px solid var(--brand); font-size: 14px;
    animation: toast-in .25s ease; cursor: pointer; }
.toast.hide { animation: toast-out .25s ease forwards; }
.toast-success { border-left-color: var(--ok); }
.toast-error   { border-left-color: var(--err); }
.toast-info    { border-left-color: var(--brand); }
.toast-ico { font-size: 16px; }
@keyframes toast-in  { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(40px); } }

/* Clickable product links */
.prod-link { color: var(--ink); text-decoration: none; border-bottom: 1px dotted var(--brand); cursor: pointer; }
.prod-link:hover { color: var(--brand); text-decoration: none; }

/* Order-sheet editor */
.sheet-input { padding: 6px 8px; }
#sheet-table td { padding: 5px 6px; }
.drag-handle { cursor: grab; color: #b6bed0; user-select: none; text-align: center; }
.drag-handle:active { cursor: grabbing; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 100;
    display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: #fff; border-radius: 14px; width: 720px; max-width: 100%; max-height: 86vh;
    display: flex; flex-direction: column; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 14px 18px; background: var(--brand); color: #fff; }
.modal-close { background: none; border: none; color: #fff; font-size: 18px; cursor: pointer; }
.modal-body { overflow-y: auto; padding: 0 4px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); }

/* Follow-up + re-order */
.followup-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px;
    padding-top: 14px; border-top: 1px solid var(--line); }
.followup-bar form { display: inline; }
.pick-col { width: 92px; white-space: nowrap; }
.pick-qty { width: 50px; padding: 5px 6px; border: 1px solid #d7dceb; border-radius: 7px; margin-left: 6px; text-align: center; font-family: inherit; }
.reorder-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    background: linear-gradient(180deg,#f5f7ff,#fff); border: 1px solid #c7d2fe; border-radius: 12px; padding: 14px 16px; }

/* Re-order sheet */
.order-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; gap: 20px; }
.order-client { text-align: right; }

/* Invoice detail */
.invoice-meta { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
.invoice-meta div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; display: flex; flex-direction: column; gap: 3px; }
.invoice-totals { margin-top: 16px; margin-left: auto; width: 300px; }
.invoice-totals div { display: flex; justify-content: space-between; padding: 7px 0; }
.invoice-totals .grand { font-weight: 800; font-size: 17px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }

/* Import / Export */
.data-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.data-head { min-width: 180px; }
.data-head h2 { margin: 0 0 2px; }
.data-import { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 260px; }
.file-input { padding: 8px; flex: 1; }
.data-actions { display: flex; gap: 8px; }

/* ---------- Auth pages ---------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: radial-gradient(1200px 600px at 50% -10%, #3b2f8f, #1a1640); padding: 20px; }
.auth-card { background: #fff; border-radius: 18px; padding: 34px; width: 380px; max-width: 92vw; box-shadow: var(--shadow-lg); }
.auth-card .brand { color: var(--ink); padding: 0 0 18px; }
.auth-card .brand span { -webkit-text-fill-color: initial; background: none; color: var(--brand); }
.auth-title { font-size: 21px; font-weight: 800; margin: 0 0 18px; letter-spacing: -.02em; }

/* ---------- Print ---------- */
@media print {
    .sidebar, .no-print, .page-head .btn { display: none !important; }
    .content { padding: 0; max-width: none; }
    .app { display: block; }
    .panel { border: none; box-shadow: none; padding: 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
    .suggest-layout { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .content { padding: 20px; }
}
