/* ============================================================
   Customer Hub — design system
   Calm and neutral: white surfaces, hairline borders, one accent.
   Colour is kept for meaning only (overdue, done, partly done).
   ============================================================ */

:root {
    --bg:            #f7f7f8;
    --surface:       #ffffff;
    --subtle:        #f2f3f5;
    --border:        #e6e7eb;
    --border-strong: #d5d8de;
    --text:          #16181d;
    --text-2:        #555c69;
    --text-3:        #8a909c;
    --accent:        #2b4a8b;
    --accent-hover:  #213a6e;
    --accent-soft:   #eef2fa;
    --red:           #b42318;
    --red-soft:      #fef3f2;
    --amber:         #b54708;
    --amber-soft:    #fffaeb;
    --green:         #067647;
    --green-soft:    #ecfdf3;
    --blue:          #175cd3;
    --radius:        10px;
    --radius-sm:     8px;
    --shadow-sm:     0 1px 2px rgba(16, 24, 40, .05);
    --shadow-pop:    0 10px 30px rgba(16, 24, 40, .14);
    --sidebar-w:     240px;
}

* { -webkit-tap-highlight-color: transparent; }

html { font-size: 16px; }
body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: .9375rem;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { font-weight: 600; letter-spacing: -.01em; color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
.text-muted { color: var(--text-3) !important; }
.small, small { font-size: .8125rem; }
code { color: var(--text-2); background: var(--subtle); padding: 1px 5px; border-radius: 4px; font-size: .8125rem; }

/* ---------- Mobile top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; gap: 8px;
    height: calc(56px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 12px 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.topbar-brand {
    display: inline-flex; align-items: center; gap: 8px;
    font-weight: 600; font-size: 1rem; color: var(--text);
}
.topbar-brand:hover { color: var(--text); }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px;
    border: 0; border-radius: var(--radius-sm);
    background: transparent; color: var(--text-2);
    font-size: 1.25rem;
}
.icon-btn:hover, .icon-btn:active { background: var(--subtle); color: var(--text); }

.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 7px;
    background: var(--accent); color: #fff; font-size: .85rem;
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 16px 12px;
    display: flex; flex-direction: column;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform .2s ease;
}
.sidebar-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-pop); }
.sidebar-overlay {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(16, 24, 40, .35);
    opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
}
.sidebar-open .sidebar-overlay { opacity: 1; pointer-events: auto; }

.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 8px 16px;
    font-weight: 600; font-size: 1rem; color: var(--text);
}
.sidebar-brand:hover { color: var(--text); }
.sidebar-new { margin: 0 4px 12px; }
.sidebar-new .btn { width: 100%; justify-content: center; }
.sidebar-search { position: relative; margin: 0 4px 14px; }
.sidebar-search .bi {
    position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
    color: var(--text-3); font-size: .85rem;
}
.sidebar-search input {
    width: 100%; height: 34px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--subtle);
    padding: 0 10px 0 31px;
    font-size: .875rem; color: var(--text);
}
.sidebar-search input::placeholder { color: var(--text-3); }
.sidebar-search input:focus { outline: none; background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.nav-label {
    padding: 14px 10px 4px;
    font-size: .6875rem; font-weight: 600; color: var(--text-3);
    text-transform: uppercase; letter-spacing: .06em;
}
.sidebar-link {
    display: flex; align-items: center; gap: 10px;
    height: 34px; padding: 0 10px; margin-bottom: 1px;
    border-radius: var(--radius-sm);
    color: var(--text-2); font-size: .875rem; font-weight: 500;
}
.sidebar-link .bi { font-size: 1rem; color: var(--text-3); width: 18px; text-align: center; }
.sidebar-link:hover { background: var(--subtle); color: var(--text); }
.sidebar-link.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-link.active .bi { color: var(--accent); }
.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }

/* ---------- Content area ---------- */
.has-sidebar .content { padding: 20px 16px 96px; }

@media (min-width: 992px) {
    .sidebar { transform: none; }
    .sidebar-toggle, .sidebar-overlay { display: none; }
    .has-sidebar .topbar { display: none; }
    .has-sidebar .content { margin-left: var(--sidebar-w); padding: 32px 40px 72px; max-width: calc(1160px + var(--sidebar-w)); }
}

/* ---------- Quick add (phones only; desktop uses the sidebar "New" button) ---------- */
.quick-add {
    position: fixed; z-index: 45;
    right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
}
.quick-add-btn {
    width: 52px; height: 52px;
    border: 0; border-radius: 50%;
    background: var(--accent); color: #fff;
    font-size: 1.4rem;
    box-shadow: var(--shadow-pop);
}
.quick-add-btn:hover, .quick-add-btn:active { background: var(--accent-hover); }
@media (min-width: 992px) { .quick-add { display: none; } }

.dropdown-menu {
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-pop); padding: 6px; min-width: 210px;
    font-size: .875rem;
}
.dropdown-item { border-radius: 6px; padding: 7px 10px; color: var(--text); }
.dropdown-item .bi { width: 20px; color: var(--text-3); margin-right: 6px; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--subtle); color: var(--text); }
.dropdown-header { font-size: .75rem; color: var(--text-3); padding: 6px 10px; }
.dropdown-divider { border-color: var(--border); margin: 4px 0; }

/* ---------- Alerts ---------- */
.app-alert {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; margin-bottom: 16px;
    border: 1px solid; border-radius: var(--radius-sm);
    font-size: .875rem; font-weight: 500;
    transition: opacity .6s ease;
}
.app-alert.fade-out { opacity: 0; }
.app-alert-success { background: var(--green-soft); border-color: #b7ebc9; color: var(--green); }
.app-alert-danger  { background: var(--red-soft);   border-color: #f9cdc8; color: var(--red); }
.app-alert a { color: inherit; text-decoration: underline; }

/* ---------- Sign-in ---------- */
.login-page {
    display: flex; align-items: center; justify-content: center;
    padding: 24px 16px;
    background: var(--bg);
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border); border-radius: 14px;
    box-shadow: var(--shadow-sm);
    padding: 32px 28px;
    width: 100%; max-width: 380px;
}
.login-logo { margin-bottom: 18px; }
.login-logo .brand-mark { width: 40px; height: 40px; border-radius: 10px; font-size: 1.2rem; }
.login-card h1 { font-size: 1.25rem; margin-bottom: 2px; }
.login-sub { color: var(--text-2); font-size: .875rem; margin-bottom: 22px; }
.remember-row {
    display: flex; align-items: center; gap: 8px;
    margin: 14px 0 18px;
    color: var(--text-2); font-size: .875rem; cursor: pointer;
}
.remember-row input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- Buttons ----------
   primary = the one main action; secondary = everything else.
   Older class names map onto these two so all pages stay consistent. */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font-size: .875rem; font-weight: 500; line-height: 1.25;
    padding: .5rem .875rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}
.btn .bi { font-size: .95em; }
.btn-sm { font-size: .8125rem; padding: .3125rem .625rem; border-radius: 7px; }
.btn-lg { font-size: .9375rem; padding: .65rem 1rem; }

.btn-primary, .btn-brand {
    background: var(--accent); border: 1px solid var(--accent); color: #fff;
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active,
.btn-brand:hover, .btn-brand:focus, .btn-brand:active {
    background: var(--accent-hover); border-color: var(--accent-hover); color: #fff;
}

.btn-secondary, .btn-soft, .btn-outline-brand, .btn-soft-green, .btn-soft-red,
.btn-call, .btn-whatsapp, .btn-email {
    background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
    box-shadow: var(--shadow-sm);
}
.btn-secondary:hover, .btn-soft:hover, .btn-outline-brand:hover, .btn-soft-green:hover, .btn-soft-red:hover,
.btn-call:hover, .btn-whatsapp:hover, .btn-email:hover,
.btn-secondary:focus, .btn-soft:focus, .btn-outline-brand:focus {
    background: var(--subtle); border-color: var(--border-strong); color: var(--text);
}
.btn-soft-red, .btn-soft-red:hover { color: var(--red); }
.btn-whatsapp .bi { color: #1f9d55; }
.btn-icon { width: 34px; padding-left: 0; padding-right: 0; }
.btn-icon.btn-sm { width: 30px; }

.btn-link-danger {
    background: none; border: 0; padding: 0;
    color: var(--red); font-size: .875rem; font-weight: 500;
}
.btn-link-danger:hover { text-decoration: underline; color: var(--red); }

/* ---------- Page header ---------- */
.page-head {
    display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
    gap: 12px 16px;
    margin-bottom: 20px;
}
.page-title { font-size: 1.375rem; margin: 0; }
.page-sub { color: var(--text-2); font-size: .875rem; margin: 2px 0 0; }
.page-sub a { color: var(--text-2); text-decoration: underline; text-underline-offset: 2px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Panels ---------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}
.panel h2 { font-size: 1rem; margin: 0 0 12px; }
.panel h2 .bi { color: var(--text-3); margin-right: 4px; }
.panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    margin-bottom: 4px;
}
.panel-head h2 { margin: 0; }
.panel-head a { font-size: .8125rem; font-weight: 500; color: var(--text-2); }
.panel-head a:hover { color: var(--accent); }

/* ---------- Stats ---------- */
.stat-row {
    display: grid; gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    margin-bottom: 20px;
}
.stat-tile {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    color: inherit;
}
a.stat-tile:hover { border-color: var(--border-strong); color: inherit; }
.stat-label { color: var(--text-2); font-size: .8125rem; font-weight: 500; }
.stat-value { font-size: 1.625rem; font-weight: 600; letter-spacing: -.02em; margin-top: 2px; }
.tile-red .stat-value   { color: var(--red); }
.tile-amber .stat-value { color: var(--amber); }

.dash-grid { display: grid; gap: 0 20px; grid-template-columns: 1fr; }
@media (min-width: 1200px) { .dash-grid { grid-template-columns: 1fr 1fr; } }

/* ---------- Tabs (underlined) ---------- */
.tab-pills {
    display: flex; gap: 22px;
    overflow-x: auto; scrollbar-width: none;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.tab-pills::-webkit-scrollbar { display: none; }
.tab-pill {
    flex: 0 0 auto;
    padding: 10px 0;
    margin-bottom: -1px;
    border-bottom: 2px solid transparent;
    color: var(--text-2); font-size: .875rem; font-weight: 500;
    white-space: nowrap;
}
.tab-pill:hover { color: var(--text); }
.tab-pill.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-pill .bi { color: var(--text-3); }
.tab-pill .count {
    display: inline-block; min-width: 18px; margin-left: 4px;
    padding: 0 6px; border-radius: 999px;
    background: var(--subtle); color: var(--text-2);
    font-size: .75rem; font-weight: 500; text-align: center;
}

/* ---------- Filters ---------- */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 10px 12px;
    align-items: flex-end;
    padding-bottom: 16px; margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
}
.filter-bar > div { flex: 1 1 150px; min-width: 0; }
.filter-bar > .filter-actions { flex: 0 0 auto; display: flex; gap: 8px; }
.result-count { color: var(--text-2); font-size: .8125rem; margin: 12px 0 4px; }
.result-count strong { color: var(--text); font-weight: 600; }

/* ---------- Form controls ---------- */
.form-label { font-size: .8125rem; font-weight: 500; color: var(--text-2); margin-bottom: 5px; }
.form-control, .form-select {
    font-size: .9375rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: .45rem .75rem;
    color: var(--text);
    box-shadow: var(--shadow-sm);
}
.form-select { padding-right: 2rem; }
.form-control-sm { font-size: .8125rem; padding: .3rem .6rem; border-radius: 7px; }
.form-control-lg { font-size: 1rem; padding: .6rem .85rem; }
.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-control::placeholder { color: var(--text-3); }
.form-text { font-size: .8125rem; color: var(--text-3); margin-top: 5px; }
.input-group-text { font-size: .875rem; background: var(--subtle); border-color: var(--border-strong); color: var(--text-2); }

.form-panel { max-width: 760px; }
.field-grid {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    margin-bottom: 16px;
}
.field-grid .full { grid-column: 1 / -1; }
.form-actions {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
    padding-top: 16px; margin-top: 4px;
    border-top: 1px solid var(--border);
}

/* Pill choices (channel, direction, type …) */
.choice-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.choice-pills input { position: absolute; opacity: 0; pointer-events: none; }
.choice-pills label {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border-strong); border-radius: 999px;
    background: var(--surface); color: var(--text-2);
    font-size: .8125rem; font-weight: 500;
    cursor: pointer; user-select: none;
}
.choice-pills label .bi { color: var(--text-3); }
.choice-pills input:checked + label { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.choice-pills input:checked + label .bi { color: var(--accent); }
.choice-pills input:focus-visible + label { box-shadow: 0 0 0 3px var(--accent-soft); }

/* Segmented control (commitment "what happened") */
.segmented {
    display: inline-flex; flex-wrap: wrap; gap: 2px;
    padding: 3px;
    background: var(--subtle); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
    padding: 5px 11px; border-radius: 6px;
    font-size: .8125rem; font-weight: 500; color: var(--text-2);
    cursor: pointer; user-select: none;
}
.segmented input:checked + label { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .1); }
.segmented input:focus-visible + label { outline: 2px solid var(--accent); }

.check-row { display: flex; align-items: center; gap: 8px; font-size: .875rem; cursor: pointer; }
.check-row input, .big-check { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ---------- Status: a dot and a word, not a coloured block ---------- */
.badge-soft {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .8125rem; font-weight: 500; color: var(--text-2);
    white-space: nowrap;
}
.badge-soft::before {
    content: ''; width: 7px; height: 7px; border-radius: 50%;
    background: var(--dot, var(--text-3));
}
.badge-amber { --dot: #f79009; }
.badge-green { --dot: #17b26a; }
.badge-red   { --dot: #f04438; }
.badge-blue  { --dot: #2e90fa; }
.badge-grey  { --dot: #c2c6cd; }
/* Labels such as "Customer" or a tag: a quiet outlined chip */
.badge-brand {
    padding: 1px 8px; border: 1px solid var(--border); border-radius: 6px;
    background: var(--surface); color: var(--text-2); font-size: .75rem;
}
.badge-brand::before { display: none; }

.due-tag { font-size: .8125rem; font-weight: 500; color: var(--text-2); white-space: nowrap; }
.due-tag.due-overdue { color: var(--red); }
.due-tag.due-today   { color: var(--amber); }

/* ---------- List rows ---------- */
.item-list { display: flex; flex-direction: column; }
.item {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.item:last-child { border-bottom: 0; }
.item-icon {
    flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--subtle); color: var(--text-3);
    font-size: .9rem; font-weight: 600;
}
.item-icon.ic-green { color: var(--green); }
.item-icon.ic-amber { color: var(--amber); }
.item-icon.ic-red   { color: var(--red); }
.item-icon.ic-blue  { color: var(--blue); }
.item-main { flex: 1 1 0; min-width: 0; }
.item-title { font-weight: 500; overflow-wrap: anywhere; }
.item-title a { color: var(--text); }
.item-title a:hover { color: var(--accent); }
.item-title .badge-soft, .item-title .badge-brand { margin-left: 6px; vertical-align: 1px; }
.item-meta {
    display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px;
    margin-top: 2px;
    color: var(--text-2); font-size: .8125rem;
}
.item-meta .bi { color: var(--text-3); margin-right: 2px; }
.item-meta a { color: var(--text-2); }
.item-meta a:hover { color: var(--accent); }
.item-body {
    margin-top: 6px; font-size: .875rem; color: var(--text);
    white-space: pre-line; overflow-wrap: anywhere;
}
.item-update {
    margin-top: 8px; padding-left: 10px;
    border-left: 2px solid var(--border-strong);
    font-size: .8125rem; color: var(--text-2);
    overflow-wrap: anywhere;
}
.item-update strong { color: var(--text); font-weight: 500; }
.item-update a { margin-left: 6px; color: var(--text-2); text-decoration: underline; text-underline-offset: 2px; }
.item-right {
    flex: 0 0 auto;
    display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
    text-align: right;
}
.item-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; margin-top: 10px; }
.item-actions .btn { font-size: .8125rem; padding: .25rem .6rem; border-radius: 7px; box-shadow: none; }
.item.is-done .item-title, .item.is-done .item-title a { color: var(--text-2); }
.item.is-projected { opacity: .55; }
.item.is-projected .item-title { font-style: italic; }

@media (max-width: 576px) {
    .item { flex-wrap: wrap; }
    .item-right { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 12px; width: 100%; padding-left: 44px; margin-top: -6px; text-align: left; }
}

.progress-mini { width: 72px; height: 4px; background: var(--subtle); border-radius: 999px; overflow: hidden; }
.progress-mini > span { display: block; height: 100%; background: #17b26a; border-radius: 999px; }

.empty-state { text-align: center; color: var(--text-3); padding: 28px 12px; font-size: .875rem; }
.empty-state .bi { font-size: 1.5rem; display: block; margin-bottom: 6px; }
.empty-state p { margin: 0; }

/* ---------- Date groups ---------- */
.day-group { margin-top: 6px; }
.day-heading {
    position: sticky; top: 0; z-index: 2;
    background: var(--surface);
    padding: 14px 0 6px;
    border-bottom: 1px solid var(--border);
    font-size: .6875rem; font-weight: 600; color: var(--text-3);
    text-transform: uppercase; letter-spacing: .06em;
}
@media (max-width: 991px) { .day-heading { top: 56px; } }

/* ---------- Commitment "Update" box ---------- */
details.progress-box > summary, details.inline-form > summary { list-style: none; cursor: pointer; display: inline-flex; }
details.progress-box > summary::-webkit-details-marker, details.inline-form > summary::-webkit-details-marker { display: none; }
details.progress-box[open] { flex-basis: 100%; }
details.progress-box[open] > summary { background: var(--subtle); }
.progress-form, .inline-form-body {
    margin-top: 8px; padding: 12px;
    background: var(--subtle); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.inline-form-body { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.progress-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-top: 10px; }
.pf-field { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.pf-field[hidden] { display: none; }
.pf-field span { font-size: .75rem; font-weight: 500; color: var(--text-2); }
.pf-field input[type=date] { width: 150px; }
.pf-note { flex: 1 1 220px; }
.progress-log .item-icon { width: 28px; height: 28px; font-size: .85rem; }

/* ---------- Party header ---------- */
.party-head { display: flex; flex-wrap: wrap; gap: 14px 16px; align-items: flex-start; }
.party-avatar {
    flex: 0 0 auto;
    width: 48px; height: 48px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--subtle); color: var(--text-2);
    font-size: 1.1rem; font-weight: 600;
}
.party-info { flex: 1 1 260px; min-width: 0; }
.party-info h1 { font-size: 1.375rem; margin: 0; overflow-wrap: anywhere; }
.party-company { color: var(--text-2); font-size: .875rem; }
.party-facts {
    display: flex; flex-wrap: wrap; gap: 4px 18px;
    margin-top: 8px; color: var(--text-2); font-size: .8125rem;
}
.party-facts .bi { margin-right: 5px; color: var(--text-3); }
.contact-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.party-notes {
    margin-top: 16px; padding: 10px 14px;
    background: var(--subtle); border-radius: var(--radius-sm);
    font-size: .875rem; color: var(--text-2); white-space: pre-line;
}
.party-stats {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    margin-top: 18px; padding-top: 16px;
    border-top: 1px solid var(--border);
}
.party-stat { padding: 0 12px 0 0; }
.party-stat b { display: block; font-size: 1.0625rem; font-weight: 600; }
.party-stat span { color: var(--text-2); font-size: .75rem; }

.contact-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); margin-top: 8px; }
.contact-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.contact-card .name { font-weight: 500; }
.contact-card .role { color: var(--text-2); font-size: .8125rem; }
.contact-card .links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; font-size: .8125rem; }

/* ---------- Tags ---------- */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 9px; border-radius: 6px;
    background: var(--subtle); border: 1px solid transparent;
    color: var(--text-2); font-size: .8125rem; font-weight: 500;
}
.tag-chip:hover { border-color: var(--border-strong); color: var(--text); }
.tag-chip.active { background: var(--accent); color: #fff; }
.tag-chip.active:hover { color: #fff; }
.tag-chip .count { color: var(--text-3); font-size: .75rem; }
.tag-chip.active .count { color: rgba(255, 255, 255, .75); }
button.tag-chip { cursor: pointer; }

/* ---------- Order line editor ---------- */
.lines { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.line-row { display: grid; gap: 8px; grid-template-columns: 1fr 110px 110px 38px; align-items: end; }
.line-row .form-label { display: none; }
.lines .line-row:first-child .form-label { display: block; }
.line-remove {
    width: 38px; height: 38px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text-3);
}
.line-remove:hover { color: var(--red); }
.line-note { grid-column: 1 / -1; font-size: .75rem; color: var(--text-3); margin-top: -2px; }
@media (max-width: 576px) {
    .line-row { grid-template-columns: 1fr 1fr 38px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
    .line-row .line-desc { grid-column: 1 / -1; }
    .line-row .form-label { display: block; }
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.app-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.app-table th {
    text-align: left; color: var(--text-3); font-weight: 600;
    font-size: .6875rem; text-transform: uppercase; letter-spacing: .06em;
    padding: 8px 10px; border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.app-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.app-table tr:last-child td { border-bottom: 0; }
.app-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.app-table .qty-input { width: 100px; margin-left: auto; text-align: right; }

@media (max-width: 576px) {
    .stack-table thead { display: none; }
    .stack-table, .stack-table tbody, .stack-table tr, .stack-table td { display: block; width: 100%; }
    .stack-table tr { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 8px; padding: 12px 0; border-bottom: 1px solid var(--border); }
    .stack-table tr:last-child { border-bottom: 0; }
    .stack-table td { border: 0; padding: 0; text-align: left !important; }
    .stack-table td[data-label]::before {
        content: attr(data-label); display: block;
        font-size: .6875rem; font-weight: 600; color: var(--text-3);
        text-transform: uppercase; letter-spacing: .05em;
    }
    .stack-table .cell-title { grid-column: 1 / -1; font-weight: 500; }
    .stack-table .cell-input { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; }
    .stack-table .qty-input { margin: 0; width: 120px; }
}

/* ---------- Misc pages ---------- */
.settings-grid { display: grid; gap: 0 20px; grid-template-columns: 1fr; }
@media (min-width: 1200px) { .settings-grid { grid-template-columns: 1fr 1fr; } }
.search-big { display: flex; gap: 8px; margin-bottom: 20px; max-width: 640px; }
.agenda-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.agenda-nav .label { font-weight: 600; margin: 0 6px; }
mark { background: #fff3b0; padding: 0 2px; border-radius: 3px; }

@media (max-width: 576px) {
    .panel { padding: 16px; }
    .page-title { font-size: 1.25rem; }
}

/* ---------- Print ---------- */
@media print {
    .sidebar, .topbar, .sidebar-overlay, .no-print, .quick-add, .item-actions, .filter-bar { display: none !important; }
    body { background: #fff; }
    .has-sidebar .content { margin: 0; padding: 0; max-width: none; }
    .panel { border: 0; padding: 0; }
    .day-heading { position: static; }
}
.item-actions .btn-icon { width: 30px; padding-left: 0; padding-right: 0; }
/* In list rows only the main action keeps a border; Edit / Files etc. are quiet */
.item-actions .btn-soft { background: transparent; border-color: transparent; color: var(--text-2); }
.item-actions .btn-soft:hover { background: var(--subtle); color: var(--text); border-color: transparent; }
@media (max-width: 576px) {
    .party-avatar { display: none; }
    .party-head { flex-wrap: nowrap; }
    .party-info { flex: 1 1 0; }
    .party-info h1 { font-size: 1.25rem; }
}
@media (max-width: 576px) {
    .progress-log .item { flex-wrap: nowrap; }
    .progress-log .item-right { width: auto; padding-left: 0; margin-top: 0; }
}

/* Notes */
.note-preview { color: var(--text-2); }
.note-body-input { min-height: 320px; font-size: .9375rem; line-height: 1.6; }
