/* ---------- Colours and sizes (change these to restyle the whole app) ---------- */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --border: #e3e8ec;
  --text: #17202a;
  --muted: #64707d;
  --primary: #0f766e;
  --primary-hover: #0b5f58;
  --primary-soft: #e6f4f2;
  --danger: #c2322b;
  --danger-soft: #fdecea;
  --warning: #b45309;
  --warning-soft: #fef3e2;
  --success: #15803d;
  --success-soft: #e8f6ed;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --sidebar-w: 232px;
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
svg.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Layout ---------- */
.shell { min-height: 100vh; display: flex; }
.sidebar {
  width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 30;
  transition: transform .2s ease;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; font-weight: 700; font-size: 1.05rem; }
.brand-logo { width: 32px; height: 32px; border-radius: 8px; background: var(--primary); color: #fff; display: grid; place-items: center; }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-weight: 500; margin-bottom: 2px;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.sidebar-foot { border-top: 1px solid var(--border); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.me { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(244, 246, 248, .92); backdrop-filter: blur(6px);
  display: flex; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid transparent;
}
.topbar h1 { flex: 1; }
.topbar .menu-btn { display: none; }
.content { padding: 8px 24px 40px; max-width: 1200px; width: 100%; }
.backdrop { display: none; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0, 0, 0, .15); }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 25; }
  .main { margin-left: 0; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; border-bottom-color: var(--border); }
  .content { padding: 12px 16px 32px; }
}

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  min-height: 38px;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: .88rem; }
.btn-block { width: 100%; }
.lang-btn { font-size: .85rem; min-width: 48px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: .9rem; }
.field .hint { font-size: .82rem; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); width: 100%;
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; min-height: 40px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.error-text { color: var(--danger); font-size: .9rem; min-height: 1.2em; margin: 0 0 10px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
td.actions { text-align: right; white-space: nowrap; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge-green { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-red { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-amber { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-teal { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

/* ---------- Login screen ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { padding: 0 0 6px; justify-content: center; }
.auth-top { display: flex; justify-content: flex-end; margin-bottom: 8px; }

/* ---------- Empty / coming soon ---------- */
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty svg.icon { width: 40px; height: 40px; margin-bottom: 8px; color: var(--primary); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .4); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto; padding: 20px; box-shadow: 0 20px 50px rgba(0, 0, 0, .2); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: #17202a; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); font-weight: 500; }
.toast.error { background: var(--danger); }

/* ---------- Toolbar (search + buttons above lists) ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.search-box { position: relative; flex: 1; min-width: 200px; }
.search-box svg.icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box input { padding-left: 36px; }
.toolbar-select { width: auto; min-width: 160px; }
@media (max-width: 600px) {
  .toolbar > .btn { flex: 1; }
  .toolbar-select { flex: 1; }
}

/* ---------- Lists of cards ---------- */
.card-list { display: flex; flex-direction: column; gap: 10px; }
.card-list .card { margin-bottom: 0; }
.item-card { display: flex; gap: 14px; align-items: center; cursor: pointer; padding: 14px 16px; }
.item-card:hover, .pcard:hover { border-color: #c9d3da; }
.item-card:focus-visible, .pcard:focus-visible { outline: 2px solid var(--primary); }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.item-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.item-title { font-weight: 650; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); }
.plain-list { margin: 0; padding-left: 18px; }
.plain-list li { margin: 3px 0; }
@media (max-width: 600px) {
  .item-card { flex-direction: column; align-items: stretch; }
  .item-side { flex-direction: row; align-items: center; justify-content: space-between; }
}

/* ---------- Product cards ---------- */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
@media (max-width: 400px) { .product-grid { grid-template-columns: 1fr; } }
.pcard { display: flex; gap: 14px; margin: 0; cursor: pointer; padding: 14px; }
.pthumb { width: 84px; height: 84px; flex: none; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; color: var(--muted); }
.pthumb img { width: 100%; height: 100%; object-fit: cover; }
.pbody { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.pstats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 6px 0 0; }
.pstats dt { font-size: .75rem; color: var(--muted); }
.pstats dd { margin: 0; font-size: .92rem; }
.pos { color: var(--success); }
.neg { color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.chip { font-size: .78rem; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); }
.chip-low { background: var(--warning-soft); border-color: transparent; color: var(--warning); font-weight: 600; }

/* ---------- Product form ---------- */
.modal-wide { max-width: 720px; }
.photo-row { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.photo-preview { width: 96px; height: 96px; border-radius: 12px; border: 1px dashed var(--border); background: var(--surface-2); display: grid; place-items: center; overflow: hidden; color: var(--muted); flex: none; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.input-group { display: flex; }
.input-group input { border-top-right-radius: 0; border-bottom-right-radius: 0; flex: 1; min-width: 0; }
.input-group select { width: auto; border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: none; background: var(--surface-2); }
.profit-box { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; background: var(--primary-soft); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.profit-box div { display: flex; flex-direction: column; gap: 2px; }
.profit-box span { font-size: .78rem; color: var(--muted); }
@media (max-width: 500px) { .profit-box { grid-template-columns: 1fr; } .profit-box div { flex-direction: row; justify-content: space-between; } }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; margin: 4px 0 12px; cursor: pointer; }
.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--primary); }
.variant-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.variant-row { display: grid; grid-template-columns: 1fr 90px 130px 40px; gap: 8px; align-items: center; }
.variant-head { font-size: .8rem; color: var(--muted); font-weight: 600; }
#variants { margin-bottom: 14px; }
@media (max-width: 500px) { .variant-row { grid-template-columns: 1fr 64px 96px 34px; gap: 6px; } }

/* ---------- Product ideas ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 2px; }
.tab { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .88rem; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tab .count { opacity: .75; margin-left: 4px; }
.idea-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
@media (max-width: 400px) { .idea-grid { grid-template-columns: 1fr; } }
.idea-card { margin: 0; display: flex; flex-direction: column; gap: 8px; cursor: pointer; }
.idea-card.rejected { opacity: .7; }
.idea-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }

/* ---------- Roles & permissions ---------- */
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.perm-table input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--primary); cursor: pointer; }
.role-select { width: auto; min-height: 34px; padding: 5px 8px; }

/* ---------- Orders ---------- */
.badge-blue { background: #e8f0fe; color: #1d4ed8; border-color: transparent; }
.ch-shopee { background: #fff1ec; color: #d9480f; border-color: transparent; }
.ch-tiktok { background: #17202a; color: #fff; border-color: transparent; }
.ch-facebook { background: #e7f0ff; color: #1864ab; border-color: transparent; }
.ch-instagram { background: #fdeef6; color: #c2255c; border-color: transparent; }
.order-card { margin: 0; display: flex; flex-direction: column; gap: 6px; cursor: pointer; padding: 14px 16px; }
.order-card.cancelled, .order-card.returned { opacity: .72; }
.order-card:hover { border-color: #c9d3da; }
.order-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.order-customer { font-weight: 600; }
.order-bottom { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 2px; }
.status-select { width: auto; min-height: 32px; padding: 4px 8px; font-size: .85rem; font-weight: 600; border-radius: 999px; }
.status-select.badge-teal { background: var(--primary-soft); color: var(--primary); }
.status-select.badge-amber { background: var(--warning-soft); color: var(--warning); }
.status-select.badge-blue { background: #e8f0fe; color: #1d4ed8; }
.status-select.badge-green { background: var(--success-soft); color: var(--success); }
.status-select.badge-red { background: var(--danger-soft); color: var(--danger); }
.form-section { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 6px 0 10px; padding-top: 6px; border-top: 1px solid var(--border); }
.modal-body > .form-section:first-child { border-top: none; padding-top: 0; }
.item-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.order-item { display: grid; grid-template-columns: 1fr 72px 120px 36px; gap: 8px; align-items: center; }
.order-item .warn { grid-column: 1 / -1; color: var(--warning); margin-top: -4px; }
.fixed-item { padding: 9px 11px; background: var(--surface-2); border-radius: 8px; border: 1px solid var(--border); }
.item-head-hint { margin-bottom: 8px; }
#items { margin-bottom: 14px; }
@media (max-width: 560px) {
  .order-item { grid-template-columns: 1fr 1fr 34px; }
  .order-item select, .order-item .fixed-item { grid-column: 1 / -1; }
}
.summary-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 4px; }
.summary-box > div { display: flex; justify-content: space-between; gap: 12px; }
.summary-box .total { border-top: 1px solid var(--border); padding-top: 6px; margin-top: 2px; }
.fee-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0 12px; }
.input-suffix { display: flex; align-items: center; gap: 6px; }
.input-suffix span { color: var(--muted); }

/* ---------- Customers ---------- */
.stat-row { display: flex; gap: 24px; margin: 4px 0 14px; }
.stat-row > div { display: flex; flex-direction: column; }
.history { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.history-row { display: flex; justify-content: space-between; gap: 10px; text-align: left; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font: inherit; color: inherit; cursor: pointer; }
.history-row:hover { background: var(--surface-2); }
.history-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }

/* ---------- Customer search & merge ---------- */
.cust-search { position: relative; }
.suggest { position: absolute; top: 68px; left: 0; right: 0; z-index: 5; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12); max-height: 320px; overflow-y: auto; }
.suggest-row { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; padding: 9px 12px; border: none; border-bottom: 1px solid var(--border); background: none; font: inherit; color: inherit; cursor: pointer; }
.suggest-row:hover { background: var(--surface-2); }
.suggest-new { padding: 8px 12px; }
.small-badge { font-size: .7rem; padding: 1px 6px; }
.link-btn { background: none; border: none; color: var(--primary); font: inherit; font-size: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
.merge-option { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; cursor: pointer; }
.merge-option:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.merge-option input { width: 18px; height: 18px; min-height: 0; margin-top: 2px; accent-color: var(--primary); }

/* ---------- Several phones / emails / addresses ---------- */
.contact-rows { display: flex; flex-direction: column; gap: 6px; }
.contact-row { display: grid; grid-template-columns: 1fr auto 36px; gap: 8px; align-items: center; }
.main-pick { display: flex; align-items: center; gap: 4px; font-size: .82rem; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.main-pick input { width: 16px; height: 16px; min-height: 0; accent-color: var(--primary); }
.main-pick:has(input:checked) { color: var(--primary); }
.add-contact { align-self: flex-start; margin-top: 2px; }

/* ---------- Note (manual), log & trace (system) ---------- */
.note-box { background: #fff8db; border: 1px solid #f1e3a4; border-radius: 10px; padding: 10px 12px 12px; margin-bottom: 14px; }
.note-box label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: 6px; color: #7a5b00; }
.note-box textarea { background: #fffdf0; border-color: #efe1a0; }
.log-box { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 10px 0 4px; background: var(--surface-2); }
.log-box summary { cursor: pointer; font-weight: 650; }
.timeline { list-style: none; margin: 10px 0 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.timeline li { position: relative; display: flex; flex-direction: column; }
.timeline li::before { content: ''; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid var(--surface-2); }
.tl-time { font-size: .75rem; color: var(--muted); }
.tl-text { font-size: .9rem; }
.match-box { background: var(--warning-soft); border: 1px solid #f3d19c; border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.match-box p { margin: 0 0 10px; }
.match-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dup-intro p { margin: 4px 0 10px; }
.dup-card { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.dup-people { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dup-people > div { padding: 10px; border: 1px solid var(--border); border-radius: 10px; }
@media (max-width: 600px) { .dup-people { grid-template-columns: 1fr; } }

/* ---------- Money ---------- */
.month-pick { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.month-pick input { width: auto; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 14px; }
.tile { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.tile-label { font-size: .85rem; color: var(--muted); font-weight: 600; }
.tile-value { font-size: 1.5rem; line-height: 1.2; }
.tile-sub { font-size: .78rem; color: var(--muted); }
.expected-note { display: flex; gap: 8px; align-items: center; background: var(--primary-soft); border-color: transparent; color: var(--primary); font-weight: 500; padding: 12px 16px; }
.pnl { display: flex; flex-direction: column; gap: 6px; }
.pnl > div { display: flex; justify-content: space-between; gap: 12px; }
.pnl .sub { border-top: 1px dashed var(--border); padding-top: 6px; font-weight: 600; }
.pnl .total { border-top: 1px solid var(--text); padding-top: 8px; margin-top: 2px; font-size: 1.05rem; }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: 150px 1fr auto; gap: 10px; align-items: center; font-size: .9rem; }
.hbar-track { height: 10px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: #257de0; border-radius: 4px; }
.hbar-fill.hbar-stock { background: repeating-linear-gradient(45deg, #257de0 0 4px, #8fbcf0 4px 8px); }
@media (max-width: 500px) { .hbar { grid-template-columns: 1fr auto; } .hbar-track { grid-column: 1 / -1; grid-row: 2; } }
.chart-wrap { position: relative; height: 300px; }
.table-toggle { margin-top: 12px; }
.table-toggle summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: .9rem; }
.entry-list { display: flex; flex-direction: column; }
.entry-row { display: grid; grid-template-columns: 90px 1fr auto; gap: 10px; align-items: center; padding: 10px 4px; border: none; border-bottom: 1px solid var(--border); background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.entry-row:hover { background: var(--surface-2); }
.entry-row:last-child { border-bottom: none; }
.entry-main { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; min-width: 0; }
.entry-amount { font-weight: 650; }
@media (max-width: 500px) { .entry-row { grid-template-columns: 1fr auto; } .entry-date { grid-column: 1 / -1; } }

/* ---------- Tasks ---------- */
.person { display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 700; flex: none; }
.person-sm { width: 22px; height: 22px; font-size: .7rem; }
.person-md { width: 30px; height: 30px; font-size: .85rem; }
.person-lg { width: 44px; height: 44px; font-size: 1.1rem; }
.person-none { background: transparent; color: var(--muted); border: 2px dashed var(--border); }
.task-list { padding: 4px 0; display: flex; flex-direction: column; }
.card.task-list { padding: 4px 6px; margin-bottom: 0; }
.task { display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 10px; border-left: 3px solid transparent; }
.task + .task { border-top: 1px solid var(--border); }
.task:hover { background: var(--surface-2); }
.task-mine { border-left-color: var(--primary); }
.task-compact { padding: 6px 4px; gap: 8px; }
.tick { width: 24px; height: 24px; flex: none; border-radius: 50%; border: 2px solid #b6c2cb; background: var(--surface); color: #fff; font-weight: 800; font-size: .8rem; cursor: pointer; display: grid; place-items: center; padding: 0; }
.tick:hover:not(:disabled) { border-color: var(--success); }
.task-done .tick { background: var(--success); border-color: var(--success); }
.task-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; cursor: pointer; }
.task-title { font-weight: 550; }
.task-done .task-title { text-decoration: line-through; color: var(--muted); }
.task-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.due { font-size: .76rem; font-weight: 600; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.due.due-over { background: var(--danger-soft); color: var(--danger); }
.due.due-today { background: var(--warning-soft); color: var(--warning); }
.link-chip { display: inline-flex; align-items: center; gap: 3px; font-size: .74rem; padding: 1px 7px; border-radius: 6px; border: 1px solid var(--border); color: var(--muted); }
.link-chip svg.icon { width: 12px; height: 12px; }
.task-group { margin-bottom: 18px; }
.task-group-title { font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 8px 4px; cursor: default; }
.task-group-title .count { font-weight: 500; opacity: .8; margin-left: 4px; }
.group-overdue .task-group-title { color: var(--danger); }
.group-today .task-group-title { color: var(--warning); }
details.task-group > summary { cursor: pointer; }
.tab-alert:not(.active) { border-color: #f3b5b2; color: var(--danger); }
.legend-line { margin-top: 4px; }
.task-owner { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface-2); border-radius: 12px; margin-bottom: 14px; }
.task-owner > div { flex: 1; }
/* panel inside an order / client profile */
.task-slot { margin: 4px 0 12px; }
.task-panel { border: 1px solid #cfe3df; background: #f5fbfa; border-radius: 12px; padding: 8px 10px; }
.task-panel-head { display: flex; justify-content: space-between; align-items: center; font-weight: 650; font-size: .9rem; color: var(--primary); }
.task-panel-head span { display: inline-flex; gap: 6px; align-items: center; }
.add-task-mini { border-style: dashed; color: var(--primary); }

/* ---------- Dashboard ---------- */
.dash-hello { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.dash-hello h2 { font-size: 1.25rem; }
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pill-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 7px 14px; font: inherit; font-weight: 600; cursor: pointer; color: var(--text); }
.pill-btn:hover { border-color: var(--primary); color: var(--primary); }
.dash-top { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; margin-bottom: 14px; }
@media (max-width: 800px) { .dash-top { grid-template-columns: 1fr; } }
.hero-tile { background: linear-gradient(135deg, #0f766e, #0b5f58); color: #fff; border-radius: 16px; padding: 20px 22px; display: flex; flex-direction: column; gap: 4px; box-shadow: 0 6px 20px rgba(15, 118, 110, .25); }
.hero-label { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; opacity: .85; font-weight: 700; }
.hero-value { font-size: 2.3rem; line-height: 1.1; }
.hero-sub { opacity: .8; font-size: .85rem; }
.hero-row { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .2); font-size: .9rem; }
.mini-tiles { display: grid; gap: 10px; }
.mini-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column; }
.mini-tile span { font-size: .78rem; color: var(--muted); font-weight: 600; }
.mini-tile strong { font-size: 1.2rem; }
.mini-tile em { font-style: normal; font-size: .75rem; color: var(--muted); }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
@media (max-width: 400px) { .dash-grid { grid-template-columns: 1fr; } }
.dash-card { margin: 0; }
.status-strip { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.status-chip { flex: 1; min-width: 90px; text-decoration: none; padding: 10px; border-radius: 10px; display: flex; flex-direction: column; font-size: .8rem; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.status-chip b { font-size: 1.4rem; }
.status-chip.badge-teal { background: var(--primary-soft); color: var(--primary); }
.status-chip.badge-amber { background: var(--warning-soft); color: var(--warning); }
.status-chip.badge-blue { background: #e8f0fe; color: #1d4ed8; }
.handle-list { display: flex; flex-direction: column; }
.handle-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 8px 4px; border: none; border-top: 1px solid var(--border); background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.handle-row:hover { background: var(--surface-2); }
@media (max-width: 500px) { .handle-row { grid-template-columns: auto 1fr auto; } .handle-row .muted { display: none; } }
.all-clear { color: var(--success); font-weight: 600; background: var(--success-soft); border-radius: 10px; padding: 12px; margin: 0; }
.task-counters { display: flex; gap: 12px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin: -6px 0 8px; }
.warn-text { color: var(--warning); font-weight: 600; }
.channel-bars { display: flex; flex-direction: column; gap: 12px; }
.ch-row { display: grid; grid-template-columns: 100px 1fr 120px; gap: 10px; align-items: center; }
.ch-name { font-weight: 600; font-size: .9rem; }
.ch-track { height: 14px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.ch-fill { display: block; height: 100%; background: #257de0; border-radius: 4px; }
.ch-value { display: flex; flex-direction: column; align-items: flex-end; font-size: .88rem; }
.ch-value em { font-style: normal; font-size: .74rem; color: var(--muted); }
.stock-list { display: flex; flex-direction: column; gap: 6px; }
.stock-row { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 10px; text-decoration: none; color: inherit; }
.stock-row:hover { background: var(--surface-2); }
.stock-thumb { width: 36px; height: 36px; border-radius: 8px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); flex: none; }
.stock-thumb img { width: 100%; height: 100%; object-fit: cover; }
.stock-name { flex: 1; min-width: 0; font-size: .9rem; }
.stock-pill { font-size: .75rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--warning-soft); color: var(--warning); white-space: nowrap; }
.stock-pill.out { background: var(--danger-soft); color: var(--danger); }

/* ---------- Task form: compact person picker & link pickers ---------- */
.task-info { margin: -6px 0 12px; }
.task-props { display: grid; grid-template-columns: 170px 1fr; gap: 0 16px; align-items: start; }
@media (max-width: 500px) { .task-props { grid-template-columns: 1fr; } }
.assignee-name { font-weight: 500; color: var(--muted); }
.person-picker { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 40px; }
.pick { padding: 2px; border: 2px solid transparent; border-radius: 50%; background: none; cursor: pointer; line-height: 0; }
.pick:hover:not(:disabled) { border-color: var(--border); }
.pick.picked { border-color: var(--text); }
.pick:disabled { cursor: default; }
.person-picker .link-btn { margin-left: 6px; font-size: .82rem; }
.link-pickers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 500px) { .link-pickers { grid-template-columns: 1fr; } }
.link-picker { position: relative; display: flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 8px; padding: 0 8px; min-height: 40px; background: var(--surface); }
.lp-icon { color: var(--muted); display: inline-flex; }
.lp-input { border: none; padding: 6px 0; min-height: 36px; }
.lp-input:focus { outline: none; }
.lp-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .88rem; background: var(--primary-soft); color: var(--primary); border-radius: 6px; padding: 3px 4px 3px 8px; }
.chip-x { border: none; background: none; color: inherit; font-size: 1rem; cursor: pointer; line-height: 1; padding: 0 4px; }
.link-picker .suggest { top: 42px; }
/* Results open inside the box (a pop-up would be cut off at the bottom of the window). */
.link-picker { flex-wrap: wrap; }
.link-picker .suggest { position: static; flex-basis: 100%; box-shadow: none; border: none; border-top: 1px solid var(--border); border-radius: 0; margin: 0 -8px; max-height: 220px; }
.link-pickers { align-items: start; }
.lp-input { width: auto; flex: 1 1 0; min-width: 0; }
.lp-chip { flex: 0 1 auto; margin: 6px 0; }
.link-pickers { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.link-picker { min-width: 0; }
@media (max-width: 500px) { .link-pickers { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Coloured pop-up header (task) ---------- */
.modal-accent .modal-head { background: var(--primary); color: #fff; margin: -20px -20px 14px; padding: 14px 16px 14px 20px; border-radius: var(--radius) var(--radius) 0 0; gap: 12px; }
.modal-accent .modal-head h2 { flex: 1; }
.modal-accent .modal-head [data-close] { color: #fff; }
.modal-accent .modal-head [data-close]:hover { background: rgba(255, 255, 255, .15); }
.modal-head-extra { display: flex; align-items: center; }
.head-person { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.head-person .assignee-name { font-size: .75rem; color: rgba(255, 255, 255, .85); font-weight: 600; }
.modal-accent .person-picker { min-height: 0; gap: 2px; }
.modal-accent .pick.picked { border-color: #fff; }
.modal-accent .pick:hover:not(:disabled) { border-color: rgba(255, 255, 255, .5); }
.modal-accent .person-none { color: #fff; border-color: rgba(255, 255, 255, .6); }
@media (max-width: 500px) { .modal-accent .modal-head { flex-wrap: wrap; } .modal-head-extra { order: 3; flex-basis: 100%; } .head-person { align-items: flex-start; } }

/* ---------- Linked to: ORDER + / CLIENT + ---------- */
.link-row { display: flex; gap: 8px; flex-wrap: wrap; min-height: 40px; align-items: center; }
.link-item { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 500; letter-spacing: .04em; color: var(--muted); border: 1px dashed var(--border); border-radius: 8px; padding: 4px 4px 4px 10px; }
.link-item.linked { border-style: solid; border-color: #b9dcd6; background: var(--primary-soft); color: var(--primary); padding-left: 2px; }
.link-open { border: none; background: none; color: inherit; font: inherit; font-size: .82rem; cursor: pointer; padding: 2px 6px; text-align: left; letter-spacing: normal; }
.link-open b { letter-spacing: .04em; font-weight: 800; margin-right: 2px; }
.link-open:hover { text-decoration: underline; }
.plus-btn { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--primary); font-weight: 800; font-size: 1rem; line-height: 1; cursor: pointer; }
.plus-btn:hover { border-color: var(--primary); }
.pick-results { margin-top: 10px; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; min-height: 60px; }
.pick-results > p { padding: 12px; margin: 0; }
.profile-card { display: flex; flex-direction: column; gap: 12px; }
.profile-name { display: flex; gap: 8px; align-items: center; font-size: 1.1rem; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.profile-grid > div { display: flex; flex-direction: column; gap: 2px; }
.profile-card .btn { align-self: flex-start; }
.assignee-line { display: flex; gap: 8px; align-items: baseline; }
.head-link { border: none; background: none; color: #fff; font: inherit; font-size: .75rem; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 0; }

/* ---------- Text links line (OPERA-style): bold = has something, dim = empty ---------- */
.text-links { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; padding: 8px 0 4px; border-top: 1px solid var(--border); margin-top: 4px; }
.text-link { border: none; background: none; font: inherit; font-size: .9rem; padding: 4px 6px; border-radius: 6px; cursor: pointer; color: var(--text); }
.text-link.has { font-weight: 750; color: var(--primary); }
.text-link.empty { color: #a3adb7; font-weight: 400; }
.text-link:hover { background: var(--surface-2); text-decoration: underline; }
.tl-count { font-weight: 500; }
.tl-sep { color: #c5cdd4; }
.tasks-window .task-panel { border: none; background: none; padding: 0; }

/* Header extras: meta text + small button */
.head-meta { font-size: .8rem; color: rgba(255, 255, 255, .85); font-weight: 600; white-space: nowrap; }
.head-btn { display: inline-flex; align-items: center; gap: 4px; border: 1px solid rgba(255, 255, 255, .5); background: transparent; color: #fff; border-radius: 6px; padding: 3px 8px; font: inherit; font-size: .78rem; font-weight: 700; cursor: pointer; margin-left: 10px; }
.head-btn:hover { background: rgba(255, 255, 255, .15); }
.head-btn svg.icon { width: 14px; height: 14px; }
.modal-accent .modal-head-extra { gap: 0; flex-wrap: wrap; justify-content: flex-end; }

/* Delete confirmation: red header */
.modal-danger .modal-head { background: var(--danger); }

/* Task window: ORDER / CLIENT bold when linked, dim when not */
.link-item { border: none; padding: 2px 0; background: none; gap: 2px; font-size: .82rem; letter-spacing: .04em; color: #a3adb7; }
.link-item.linked { border: none; background: none; padding: 2px 0; color: var(--primary); }
.link-row { gap: 4px 14px; }
.plus-btn { width: 22px; height: 22px; font-size: .9rem; border-color: #d5dce2; }
