/* ==========================================================================
   CRM design system - built on Bootstrap 5.3 variables. Light + dark themes.
   ========================================================================== */
:root, [data-bs-theme=light] {
  --ink: #0c1a2b; --brand: #0e7c86; --brand-2: #12a3a0; --accent: #ff7a45;
  --bg: #f3f5f9; --surface: #ffffff; --surface-2: #f8fafc; --line: #e6eaf1; --text: #17212f; --muted: #6b7789;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 6px 20px -8px rgba(16,24,40,.10);
  --radius: 16px;
  --bs-primary: #0e7c86; --bs-primary-rgb: 14,124,134; --bs-link-color: #0e7c86; --bs-link-hover-color: #0a5f67;
  --bs-body-bg: var(--bg); --bs-body-color: var(--text); --bs-border-color: var(--line);
  --bs-body-font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-font-size: .9rem;
}
[data-bs-theme=dark] {
  --bg: #0a121d; --surface: #111c2b; --surface-2: #162336; --line: #22324a; --text: #e6edf6; --muted: #8b9ab0;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -10px rgba(0,0,0,.6);
  --bs-body-bg: var(--bg); --bs-body-color: var(--text); --bs-border-color: var(--line);
  --bs-link-color: #4fd1cb; --bs-link-hover-color: #7ee0db;
}
* { -webkit-tap-highlight-color: transparent; }
body { min-height: 100vh; letter-spacing: -.005em; }
a { text-decoration: none; }
h1, h2, h3, h4, h5 { font-weight: 700; letter-spacing: -.02em; }
.muted { color: var(--muted); } .small-caps { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #c9d4e3; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; }
.side .brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 1.05rem; padding: 4px 8px 16px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--brand-2), var(--accent)); display: grid; place-items: center; color: #fff; font-size: 1rem; flex: none; }
.side .sec { font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; color: #63738a; padding: 14px 10px 4px; font-weight: 700; }
.side a.nav-i { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 10px; color: #c9d4e3; font-weight: 500; }
.side a.nav-i i { font-size: 1.05rem; opacity: .85; width: 20px; text-align: center; }
.side a.nav-i:hover { background: rgba(255,255,255,.06); color: #fff; }
.side a.nav-i.active { background: rgba(18,163,160,.18); color: #fff; box-shadow: inset 3px 0 0 var(--brand-2); }
.side .count { margin-left: auto; background: var(--accent); color: #fff; font-size: .68rem; font-weight: 700; border-radius: 20px; padding: 1px 7px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 1020; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(10px); display: flex; align-items: center; gap: 10px; padding: 12px 24px; border-bottom: 1px solid var(--line); }
.top .search { flex: 1; max-width: 460px; position: relative; }
.top .search input { border-radius: 12px; padding-left: 38px; background: var(--surface); border-color: var(--line); height: 40px; }
.top .search i { position: absolute; left: 13px; top: 10px; color: var(--muted); }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); display: inline-grid; place-items: center; position: relative; flex: none; }
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.icon-btn .dot { position: absolute; top: -5px; right: -5px; background: var(--accent); color: #fff; font-size: .62rem; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 700; font-size: .78rem; display: inline-grid; place-items: center; flex: none; }
.avatar.sm { width: 26px; height: 26px; font-size: .62rem; } .avatar.lg { width: 54px; height: 54px; font-size: 1.1rem; }
.avatar.alt { background: linear-gradient(135deg, #64748b, #94a3b8); }
.content { padding: 22px 24px 96px; max-width: 1500px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 1.45rem; margin: 0; } .page-head .sub { color: var(--muted); margin-top: 2px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- surfaces ---------- */
.cardx { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.cardx .hd { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 700; }
.cardx .bd { padding: 18px; } .cardx .bd.tight { padding: 0; }
.kpi { padding: 16px 18px; display: flex; gap: 14px; align-items: center; height: 100%; }
.kpi .ic { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; font-size: 1.2rem; flex: none; }
.kpi .v { font-size: 1.5rem; font-weight: 800; line-height: 1.1; letter-spacing: -.03em; } .kpi .l { color: var(--muted); font-size: .78rem; font-weight: 600; }
a.kpi { color: inherit; transition: transform .15s; } a.kpi:hover { transform: translateY(-2px); }
.t-teal { background: rgba(14,124,134,.12); color: #0e7c86; } .t-orange { background: rgba(255,122,69,.14); color: #e8590c; }
.t-blue { background: rgba(37,99,235,.12); color: #2563eb; } .t-green { background: rgba(22,163,74,.13); color: #15803d; }
.t-red { background: rgba(220,38,38,.12); color: #dc2626; } .t-violet { background: rgba(124,58,237,.12); color: #7c3aed; } .t-amber { background: rgba(217,119,6,.14); color: #b45309; }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: .72rem; font-weight: 700; white-space: nowrap; line-height: 1.5; }
.chip-secondary, .chip-dark { background: rgba(100,116,139,.14); color: #56657a; } .chip-info { background: rgba(2,132,199,.12); color: #0369a1; }
.chip-primary { background: rgba(37,99,235,.12); color: #1d4ed8; } .chip-success { background: rgba(22,163,74,.14); color: #15803d; }
.chip-danger { background: rgba(220,38,38,.12); color: #b91c1c; } .chip-warning { background: rgba(217,119,6,.15); color: #b45309; }
.chip-violet { background: rgba(124,58,237,.12); color: #6d28d9; } .chip-teal { background: rgba(14,124,134,.13); color: #0e7c86; }
.chip-orange { background: rgba(255,122,69,.15); color: #c2410c; } .chip-pink { background: rgba(219,39,119,.12); color: #be185d; }
[data-bs-theme=dark] .chip { filter: brightness(1.55) saturate(.9); }
.dotc { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.bg-c-secondary, .bg-c-dark { background: #94a3b8; } .bg-c-info { background: #0ea5e9; } .bg-c-primary { background: #3b82f6; } .bg-c-success { background: #22c55e; }
.bg-c-danger { background: #ef4444; } .bg-c-warning { background: #f59e0b; } .bg-c-violet { background: #8b5cf6; } .bg-c-teal { background: #14b8a6; } .bg-c-orange { background: #fb923c; } .bg-c-pink { background: #ec4899; }

/* ---------- forms & buttons ---------- */
.btn { border-radius: 11px; font-weight: 600; font-size: .86rem; padding: .5rem .95rem; }
.btn-sm { border-radius: 9px; padding: .3rem .65rem; font-size: .78rem; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: #0a5f67; --bs-btn-hover-border-color: #0a5f67; --bs-btn-active-bg: #0a5f67; --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-accent { background: var(--accent); color: #fff; border: 0; } .btn-accent:hover { background: #f2622b; color: #fff; }
.btn-soft { background: var(--surface); border: 1px solid var(--line); color: var(--text); } .btn-soft:hover { border-color: var(--brand); color: var(--brand); background: var(--surface); }
.form-control, .form-select { border-radius: 11px; border-color: var(--line); background-color: var(--surface); font-size: .9rem; padding: .52rem .8rem; }
.form-control:focus, .form-select:focus { border-color: var(--brand-2); box-shadow: 0 0 0 .2rem rgba(18,163,160,.15); }
.form-label { font-size: .76rem; font-weight: 700; color: var(--muted); margin-bottom: .3rem; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; background: var(--surface-2); border: 1px solid var(--line); padding: 5px; border-radius: 14px; }
.seg input { display: none; } .seg label { text-align: center; padding: 9px 6px; border-radius: 10px; font-weight: 700; font-size: .8rem; cursor: pointer; color: var(--muted); margin: 0; }
.seg input:checked + label { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
.drop { border: 2px dashed var(--line); border-radius: 14px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; transition: .15s; background: var(--surface-2); }
.drop.over, .drop:hover { border-color: var(--brand-2); color: var(--brand); } .drop input { display: none; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; } .filters .form-select, .filters .form-control { width: auto; min-width: 130px; flex: 1 1 130px; max-width: 220px; }
.tabsx { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabsx a { padding: 9px 14px; font-weight: 700; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-size: .85rem; }
.tabsx a.active { color: var(--brand); border-color: var(--brand); } .tabsx a .n { background: var(--surface-2); border: 1px solid var(--line); border-radius: 20px; padding: 0 7px; font-size: .7rem; margin-left: 4px; }

/* ---------- tables that fold into cards on phones ---------- */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
.tbl th { font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: left; background: var(--surface-2); }
.tbl th:first-child { border-top-left-radius: var(--radius); } .tbl th:last-child { border-top-right-radius: var(--radius); }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; } .tbl tbody tr:hover { background: var(--surface-2); }
.tbl .ttl { font-weight: 700; color: var(--text); display: block; } .tbl .ttl:hover { color: var(--brand); }
.empty { text-align: center; padding: 44px 16px; color: var(--muted); } .empty i { font-size: 2.2rem; display: block; margin-bottom: 8px; opacity: .5; }
.pager { display: flex; gap: 5px; align-items: center; padding: 14px 16px; flex-wrap: wrap; } .pager a { min-width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; border: 1px solid var(--line); color: var(--text); font-weight: 600; background: var(--surface); }
.pager a.active { background: var(--brand); color: #fff; border-color: var(--brand); } .pager a.disabled { opacity: .4; pointer-events: none; } .pager .muted { margin-left: 8px; font-size: .8rem; }

/* ---------- timeline ---------- */
.tl { position: relative; padding-left: 0; margin: 0; list-style: none; }
.tl li { position: relative; padding: 0 0 20px 46px; } .tl li:last-child { padding-bottom: 0; }
.tl li::before { content: ""; position: absolute; left: 16px; top: 34px; bottom: 0; width: 2px; background: var(--line); } .tl li:last-child::before { display: none; }
.tl .ico { position: absolute; left: 0; top: 0; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); color: var(--brand); font-size: .9rem; }
.tl .ico.sys { color: var(--muted); } .tl .ico.cust { background: rgba(255,122,69,.14); color: var(--accent); border-color: transparent; }
.tl .meta { font-size: .74rem; color: var(--muted); } .tl .sum { font-weight: 700; } .tl .body { white-space: pre-line; margin-top: 3px; }
.tl .resp { background: var(--surface-2); border-left: 3px solid var(--brand-2); border-radius: 0 10px 10px 0; padding: 7px 11px; margin-top: 7px; white-space: pre-line; font-size: .85rem; }
.vis { font-size: .66rem; font-weight: 700; border-radius: 6px; padding: 1px 6px; } .vis.internal { background: rgba(100,116,139,.15); color: var(--muted); } .vis.customer { background: rgba(22,163,74,.14); color: #15803d; }

/* ---------- progress steps (orders / shipments) ---------- */
.steps { display: flex; overflow-x: auto; gap: 0; padding: 6px 2px 10px; scrollbar-width: thin; }
.steps .st { flex: 1 0 96px; text-align: center; position: relative; font-size: .7rem; font-weight: 600; color: var(--muted); padding-top: 30px; }
.steps .st::before { content: ""; position: absolute; top: 10px; left: -50%; width: 100%; height: 3px; background: var(--line); } .steps .st:first-child::before { display: none; }
.steps .st::after { content: ""; position: absolute; top: 3px; left: 50%; margin-left: -9px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 3px solid var(--line); z-index: 1; }
.steps .st.done::before, .steps .st.now::before { background: var(--brand-2); } .steps .st.done::after { background: var(--brand-2); border-color: var(--brand-2); }
.steps .st.now::after { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 5px rgba(255,122,69,.2); } .steps .st.now { color: var(--text); font-weight: 800; }
button.st { background: none; border: 0; cursor: pointer; }

/* ---------- pipeline board ---------- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 14px; scroll-snap-type: x proximity; align-items: flex-start; }
.col-b { flex: 0 0 272px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); scroll-snap-align: start; max-height: calc(100vh - 230px); display: flex; flex-direction: column; }
.col-b .ch { padding: 12px 14px; display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .84rem; } .col-b .ch .n { margin-left: auto; color: var(--muted); font-weight: 600; }
.col-b .cb { padding: 0 8px 8px; overflow-y: auto; min-height: 60px; flex: 1; } .col-b.over { outline: 2px dashed var(--brand-2); outline-offset: -3px; }
.lcard { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; margin-bottom: 8px; color: var(--text); box-shadow: 0 1px 2px rgba(16,24,40,.04); cursor: grab; }
.lcard:hover { border-color: var(--brand-2); color: var(--text); } .lcard.dragging { opacity: .4; }
.lcard .p { font-weight: 700; line-height: 1.25; } .lcard .c { color: var(--muted); font-size: .78rem; margin-top: 2px; } .lcard .f { display: flex; align-items: center; gap: 6px; margin-top: 9px; font-size: .72rem; color: var(--muted); }
.due-over { color: #dc2626 !important; font-weight: 700; } .due-today { color: #d97706 !important; font-weight: 700; }

/* ---------- misc ---------- */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px 18px; } .kv .k { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; } .kv .v { font-weight: 600; word-break: break-word; }
.bar { height: 8px; border-radius: 6px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); } .bar > span { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.rowbar { display: grid; grid-template-columns: minmax(90px, 150px) 1fr 44px; gap: 10px; align-items: center; padding: 6px 0; font-size: .84rem; } .rowbar .n { text-align: right; font-weight: 700; }
.file { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); } .file:last-child { border: 0; } .file .fi { width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; color: var(--brand); flex: none; }
.file .nm { font-weight: 600; word-break: break-all; line-height: 1.2; } .quick { display: flex; gap: 8px; flex-wrap: wrap; }
.quick a { flex: 1 1 0; min-width: 84px; text-align: center; padding: 10px 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 700; font-size: .78rem; } .quick a i { display: block; font-size: 1.15rem; margin-bottom: 2px; }
.quick a.wa { color: #128c4b; } .quick a:hover { border-color: var(--brand-2); }
.alert { border-radius: 12px; border: 0; font-weight: 600; font-size: .86rem; }
.toasts { position: fixed; top: 74px; right: 18px; z-index: 2000; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 36px)); }
.toasts .alert { box-shadow: var(--shadow); margin: 0; animation: slide .25s ease-out; } @keyframes slide { from { transform: translateY(-8px); opacity: 0; } }
.dropdown-menu { border-radius: 14px; border-color: var(--line); box-shadow: var(--shadow); padding: 6px; font-size: .88rem; } .dropdown-item { border-radius: 9px; padding: 8px 12px; font-weight: 500; }
.modal-content, .offcanvas { border-radius: 18px; border: 0; background: var(--surface); } .offcanvas-bottom { border-radius: 20px 20px 0 0; height: auto; max-height: 92vh; }
.items td { padding: 4px; vertical-align: top; } .items .form-control { padding: .4rem .55rem; }
.bottom, .fab { display: none; }

/* auth screens */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth .art { background: radial-gradient(1200px 600px at 10% 10%, #12a3a033, transparent), linear-gradient(150deg, #0c1a2b, #0b3540 60%, #0e7c86); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth .art h2 { font-size: 2.3rem; line-height: 1.1; max-width: 460px; } .auth .art .route { display: flex; gap: 10px; align-items: center; font-weight: 600; opacity: .85; flex-wrap: wrap; }
.auth .panel { display: grid; place-items: center; padding: 28px; background: var(--surface); } .auth form { width: 100%; max-width: 380px; }

/* ---------- phones & tablets ---------- */
@media (max-width: 991px) {
  .shell { grid-template-columns: 1fr; } .side { display: none; }
  .top { padding: 10px 14px; } .content { padding: 16px 14px 110px; }
  .page-head h1 { font-size: 1.25rem; }
  .bottom { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 1030; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom a, .bottom button { background: none; border: 0; text-align: center; color: var(--muted); font-size: .64rem; font-weight: 700; padding: 4px 0; position: relative; } .bottom i { display: block; font-size: 1.25rem; }
  .bottom a.active { color: var(--brand); } .bottom .count { position: absolute; top: 0; left: 54%; background: var(--accent); color: #fff; border-radius: 10px; font-size: .58rem; padding: 0 5px; }
  .bottom .plus { width: 50px; height: 50px; border-radius: 17px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; display: grid; place-items: center; margin: -22px auto 0; box-shadow: 0 8px 18px -6px rgba(14,124,134,.7); } .bottom .plus i { font-size: 1.5rem; }
  .auth { grid-template-columns: 1fr; } .auth .art { display: none; }
  .tbl.fold thead { display: none; } .tbl.fold, .tbl.fold tbody, .tbl.fold tr, .tbl.fold td { display: block; width: 100%; }
  .tbl.fold tr { padding: 12px 14px; border-bottom: 1px solid var(--line); position: relative; } .tbl.fold tr:last-child { border: 0; }
  .tbl.fold td { padding: 2px 0; border: 0; } .tbl.fold td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: .74rem; font-weight: 600; }
  .tbl.fold td.hide-m { display: none; } .tbl.fold td.pin { position: absolute; top: 12px; right: 14px; width: auto; }
  .col-b { flex-basis: 82vw; max-height: none; } .hide-m { display: none !important; }
  .filters .form-select, .filters .form-control { max-width: none; flex-basis: 44%; }
}
@media (min-width: 992px) { .hide-d { display: none !important; } }
@media print { .side, .top, .bottom, .no-print, .toasts { display: none !important; } .shell { display: block; } .content { padding: 0; } body { background: #fff; } .cardx { box-shadow: none; border: 0; } }
