/* Chuck's CRM -- stylesheet */

:root {
    --sidebar-width: 210px;
    --topbar-height: 50px;
    --sidebar-bg: #1c2333;
    --sidebar-hover: #2a3347;
    --sidebar-active-bg: #2d3f5e;
    --sidebar-active-bar: #4a90d9;
    --sidebar-text: #c9d1e0;
    --sidebar-text-muted: #6b7a99;
    --brand-text: #ffffff;

    --content-bg: #f4f6fb;
    --surface: #ffffff;
    --border: #e2e6ef;
    --border-light: #eef0f6;

    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;

    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #eff6ff;

    --danger: #dc2626;
    --danger-light: #fef2f2;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --success: #16a34a;
    --success-light: #f0fdf4;

    --priority-high: #dc2626;
    --priority-normal: #2563eb;
    --priority-low: #6b7280;

    --radius: 6px;
    --radius-sm: 4px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow: 0 2px 8px rgba(0,0,0,.10);

    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', 'Fira Mono', 'Consolas', monospace;
    --font-size-base: 14px;
    --line-height: 1.5;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: var(--font-size-base); }

body {
    font-family: var(--font);
    font-size: var(--font-size-base);
    line-height: var(--line-height);
    color: var(--text-primary);
    background: var(--content-bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout ---- */

.layout {
    display: flex;
    min-height: 100vh;
    padding-top: var(--topbar-height);
}

/* ---- Top bar ---- */

.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 200;
    border-bottom: 1px solid rgba(255,255,255,.07);
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
}

.topbar-brand {
    font-size: 15px;
    font-weight: 700;
    color: var(--brand-text);
    letter-spacing: .01em;
    white-space: nowrap;
}

.topbar-search {
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 340px;
    margin-left: 24px;
}

.topbar .topbar-search-input {
    width: 100%;
    padding: 7px 12px;
    font-size: 13px;
    border: 1px solid rgba(255,255,255,.30);
    border-radius: var(--radius);
    background: rgba(255,255,255,.15);
    color: #e8ecf4;
    font-family: var(--font);
    outline: none;
    box-shadow: none;
    transition: border-color .12s, background .12s;
}

.topbar .topbar-search-input::placeholder { color: #a0aec0; }

.topbar .topbar-search-input:focus {
    border-color: rgba(255,255,255,.55);
    background: rgba(255,255,255,.20);
    box-shadow: none;
}

/* ---- Sidebar ---- */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-brand {
    padding: 20px 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
}

.brand-name {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: var(--brand-text);
    letter-spacing: .01em;
}

.nav-list {
    list-style: none;
    padding: 10px 0;
    flex: 1;
}

.nav-item { position: relative; }

.nav-link {
    display: block;
    padding: 9px 18px;
    color: var(--sidebar-text);
    font-size: 13.5px;
    font-weight: 500;
    border-radius: 0;
    transition: background .12s, color .12s;
    text-decoration: none;
}

.nav-link:hover {
    background: var(--sidebar-hover);
    color: #ffffff;
    text-decoration: none;
}

.nav-item.active .nav-link {
    background: var(--sidebar-active-bg);
    color: #ffffff;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--sidebar-active-bar);
    border-radius: 0 2px 2px 0;
}

.sidebar-footer {
    padding: 12px 0;
    border-top: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
}

.nav-logout {
    color: var(--sidebar-text-muted);
    font-size: 13px;
}

.nav-logout:hover { color: #ffffff; }

/* ---- Content area ---- */

.content-wrap {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.content {
    flex: 1;
    padding: 28px 32px;
}

.page-footer {
    padding: 14px 32px;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-light);
    background: var(--surface);
}

/* ---- Page headings ---- */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 12px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.page-subtitle {
    margin-top: 2px;
    font-size: 13px;
    color: var(--text-muted);
}

/* ---- Cards / panels ---- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.card-header {
    padding: 14px 18px 12px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: .01em;
    text-transform: uppercase;
    font-size: 11.5px;
    color: var(--text-secondary);
}

.card-body {
    padding: 16px 18px;
}

.card-body-flush {
    padding: 0;
}

/* ---- Dashboard grid ---- */

.dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.dash-grid .card { margin-bottom: 0; }

/* ---- Tables ---- */

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

thead th {
    padding: 9px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    background: var(--content-bg);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--border-light); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8f9ff; }

tbody td {
    padding: 9px 14px;
    color: var(--text-primary);
    vertical-align: middle;
}

.td-muted { color: var(--text-muted); font-size: 13px; }

/* ---- Badges ---- */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.6;
}

.badge-high    { background: var(--danger-light);  color: var(--danger); }
.badge-normal  { background: var(--accent-light);  color: var(--accent); }
.badge-low     { background: #f3f4f6;              color: var(--text-muted); }
.badge-overdue { background: var(--danger-light);  color: var(--danger); }
.badge-today   { background: var(--warning-light); color: var(--warning); }

/* ---- Buttons ---- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 16px;
    font-size: 13.5px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background .12s, border-color .12s, color .12s;
    line-height: 1.4;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
    text-decoration: none;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-secondary:hover {
    background: var(--content-bg);
    color: var(--text-primary);
    text-decoration: none;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
    color: #fff;
    text-decoration: none;
}

.btn-sm { padding: 4px 11px; font-size: 12.5px; }

/* ---- Forms ---- */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group.full-width { grid-column: 1 / -1; }

label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: .01em;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="password"],
select,
textarea {
    padding: 7px 10px;
    font-size: 13.5px;
    font-family: var(--font);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color .12s, box-shadow .12s;
    width: 100%;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

textarea { resize: vertical; min-height: 80px; }

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
}

/* ---- Alerts ---- */

.alert {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    margin-bottom: 18px;
    border: 1px solid transparent;
}

.alert-error   { background: var(--danger-light);  color: var(--danger);  border-color: #fecaca; }
.alert-success { background: var(--success-light); color: var(--success); border-color: #bbf7d0; }
.alert-warning { background: var(--warning-light); color: var(--warning); border-color: #fde68a; }

/* ---- Empty state ---- */

.empty-state {
    padding: 32px 18px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13.5px;
}

/* ---- Login page ---- */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sidebar-bg);
}

.login-box {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 36px 40px 32px;
    width: 100%;
    max-width: 360px;
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo-name {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -.01em;
}

.login-logo-sub {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 2px;
}

.login-box .form-group { margin-bottom: 14px; }

.login-box .btn { width: 100%; justify-content: center; margin-top: 6px; }

/* ---- Misc utilities ---- */

.text-muted  { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-right  { text-align: right; }

.mt-0  { margin-top: 0; }
.mb-0  { margin-bottom: 0; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.stat-row {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow-sm);
}

.stat-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.stat-value.danger { color: var(--danger); }
.stat-value.warning { color: var(--warning); }

/* ---- Typeahead ---- */

.typeahead-wrap { position: relative; }

.typeahead-list {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    z-index: 200;
    list-style: none;
    display: none;
    max-height: 220px;
    overflow-y: auto;
}

.typeahead-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13.5px;
    line-height: 1.4;
    border-bottom: 1px solid var(--border-light);
}

.typeahead-item:last-child { border-bottom: none; }
.typeahead-item:hover { background: var(--accent-light); }

.ta-name { font-weight: 600; color: var(--text-primary); }
.ta-sub  { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* ---- Form sections ---- */

.form-section {
    margin-bottom: 28px;
}

.form-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 16px;
}

/* ---- Checkbox grid (for groups, property types) ---- */

.check-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    color: var(--text-primary);
    cursor: pointer;
}

.check-item input[type="checkbox"] {
    width: 15px;
    height: 15px;
    min-width: 15px;
    accent-color: var(--accent);
    cursor: pointer;
    border: none;
    padding: 0;
}

/* ---- Filter bar (contact list) ---- */

.filter-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}

.filter-bar .form-group {
    flex: 0 0 auto;
    min-width: 160px;
}

.filter-bar .form-group.filter-search {
    flex: 1 1 220px;
}

.filter-bar input[type="text"],
.filter-bar select {
    padding: 6px 9px;
    font-size: 13px;
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    padding-bottom: 1px;
}

/* ---- Pagination ---- */

.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 0 4px;
    font-size: 13.5px;
    color: var(--text-muted);
}

.pagination a {
    display: inline-block;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    text-decoration: none;
}

.pagination a:hover {
    background: var(--content-bg);
    text-decoration: none;
}

.pagination .page-info { flex: 1; text-align: center; }

/* ---- DNC badge ---- */

.badge-dnc {
    background: var(--danger-light);
    color: var(--danger);
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    letter-spacing: .04em;
    vertical-align: middle;
    margin-left: 4px;
}

/* ---- Last-contact age coloring ---- */

.lc-stale  { color: var(--warning); }
.lc-cold   { color: var(--danger); }

/* ---- Multi-select control ---- */

.ms-control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    min-height: 38px;
    cursor: text;
    transition: border-color .12s, box-shadow .12s;
}

.ms-control:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.ms-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}

.ms-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px 2px 10px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.ms-tag-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--accent);
    font-size: 15px;
    line-height: 1;
    padding: 0;
    margin: 0;
    opacity: .6;
    width: 16px;
    height: 16px;
}

.ms-tag-remove:hover { opacity: 1; }

/* Override global select styles inside the ms-control */
.ms-control select.ms-add {
    border: none;
    background: transparent;
    box-shadow: none;
    padding: 2px 4px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    width: auto;
    min-width: 130px;
    flex: 0 0 auto;
}

.ms-control select.ms-add:focus {
    outline: none;
    box-shadow: none;
    border: none;
}

/* ---- Modal ---- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.modal-box {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, .18);
    padding: 28px 32px 24px;
    max-width: 400px;
    width: calc(100% - 48px);
}

.modal-body {
    font-size: 15px;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 22px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ---- Contact view: two-column grid ---- */

.view-grid {
    display: grid;
    grid-template-columns: 55fr 45fr;
    gap: 24px;
    align-items: start;
    margin-bottom: 24px;
}

/* ---- Detail list (key/value pairs on view pages) ---- */

.detail-list {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 10px 16px;
    font-size: 13.5px;
    align-items: baseline;
}

.detail-list dt {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    padding-top: 1px;
    white-space: nowrap;
}

.detail-list dd {
    color: var(--text-primary);
    word-break: break-word;
    line-height: 1.5;
}

/* ---- Description block below detail list ---- */

.view-description {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border-light);
}

.view-description-label {
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.view-description-body {
    font-size: 13.5px;
    color: var(--text-primary);
    line-height: 1.65;
    white-space: pre-wrap;
}

/* ---- Tag pills (property types, groups) ---- */

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 1px;
}

.tag {
    display: inline-block;
    padding: 2px 9px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
}

/* Groups get a slightly different tint to distinguish from property types */
.tag-group {
    background: #f0fdf4;
    color: var(--success);
}

/* ---- Tabs ---- */

.tab-bar {
    display: flex;
    border-bottom: 1px solid var(--border-light);
    padding: 0 4px;
    gap: 0;
    background: var(--content-bg);
    border-radius: var(--radius) var(--radius) 0 0;
}

.tab-btn {
    padding: 11px 18px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    margin-bottom: -1px;
    transition: color .12s, border-color .12s;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-count {
    display: inline-block;
    background: var(--border);
    color: var(--text-muted);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    padding: 0 6px;
    line-height: 1.7;
    min-width: 20px;
    text-align: center;
}

.tab-btn.active .tab-count {
    background: var(--accent-light);
    color: var(--accent);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- Inline add form (notes, tasks) ---- */

.inline-form-bar {
    padding: 14px 18px 16px;
    border-bottom: 1px solid var(--border-light);
    background: var(--content-bg);
}

.inline-form-bar textarea {
    width: 100%;
    min-height: 72px;
}

/* ---- Note items ---- */

.note-item {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-light);
}

.note-item:last-child { border-bottom: none; }

.note-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 7px;
}

.note-date {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.note-body {
    font-size: 13.5px;
    color: var(--text-primary);
    line-height: 1.65;
}

.note-link {
    margin-top: 5px;
    font-size: 12px;
}

.note-link a {
    color: var(--accent);
    text-decoration: none;
}

.note-link a:hover { text-decoration: underline; }

/* ---- Inline text-link buttons (delete note, etc.) ---- */

.btn-link {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12.5px;
    color: var(--accent);
    padding: 0;
    text-decoration: none;
    font-family: var(--font);
}

.btn-link:hover { text-decoration: underline; }
.btn-link-danger { color: var(--danger); }
.btn-link-danger:hover { color: #b91c1c; text-decoration: underline; }

/* ---- Overdue task row ---- */

tr.task-overdue td {
    background: var(--danger-light);
}

/* ---- Email direction badges ---- */

.badge-inbound  { background: var(--success-light); color: var(--success); }
.badge-outbound { background: var(--accent-light);  color: var(--accent); }

/* ---- Larger AI modal variant ---- */

.modal-box-lg {
    max-width: 620px;
    width: calc(100% - 48px);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.ai-modal-body {
    font-size: 14px;
    line-height: 1.75;
    color: var(--text-primary);
    white-space: pre-wrap;
    overflow-y: auto;
    flex: 1;
}

/* ---- Linked contacts list (companies/view.php right column) ---- */

.contact-list {
    display: flex;
    flex-direction: column;
}

.contact-list-item {
    padding: 11px 18px;
    border-bottom: 1px solid var(--border-light);
}

.contact-list-item:last-child { border-bottom: none; }

.contact-list-name {
    font-size: 13.5px;
    font-weight: 600;
}

.contact-list-name a {
    color: var(--accent);
    text-decoration: none;
}

.contact-list-name a:hover { text-decoration: underline; }

.contact-list-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ---- Note attribution (contact name in company unified notes stream) ---- */

.note-attribution {
    font-size: 12px;
    color: var(--text-muted);
}

.note-attribution a {
    color: var(--accent);
    text-decoration: none;
}

.note-attribution a:hover { text-decoration: underline; }

/* ---- Note type badges ---- */

.note-type-badge {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    letter-spacing: .03em;
    text-transform: uppercase;
    vertical-align: middle;
    line-height: 1.6;
}

.note-type-call           { background: #dbeafe; color: #1d4ed8; }
.note-type-email          { background: #dcfce7; color: #15803d; }
.note-type-meeting        { background: #f3e8ff; color: #7e22ce; }
.note-type-voicemail      { background: #f3f4f6; color: #6b7280; }
.note-type-task-completed { background: #fff7ed; color: #c2410c; }

/* ---- Email direction badges ---- */

.direction-badge {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    letter-spacing: .03em;
    text-transform: uppercase;
    vertical-align: middle;
    line-height: 1.6;
}

.direction-outbound { background: #dbeafe; color: #1d4ed8; }
.direction-inbound  { background: #dcfce7; color: #15803d; }

/* ---- Email note truncation (show more / show less) ---- */

.note-body-truncatable .note-body-inner {
    position: relative;
}
.note-body-truncatable.collapsed .note-body-inner {
    max-height: 22.5em; /* 15 lines × 1.5 line-height */
    overflow: hidden;
}
.note-body-fade {
    display: none;
}
.note-body-truncatable.collapsed .note-body-fade {
    display: block;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3em;
    background: linear-gradient(to bottom, transparent, #ffffff);
    pointer-events: none;
}
.note-show-more {
    display: inline-block;
    background: none;
    border: none;
    padding: 3px 0 0;
    font-size: 12.5px;
    color: var(--accent);
    cursor: pointer;
    line-height: 1;
}
.note-show-more:hover { text-decoration: underline; }

/* ---- Page back link ---- */

.page-back {
    display: inline-block;
    font-size: 12.5px;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 4px;
}

.page-back:hover { color: var(--accent); text-decoration: underline; }

/* ---- Admin panel ---- */

/* Clickable section header -- card-header used as a toggle */
.admin-section-hdr:hover {
    background: var(--content-bg);
}

/* Save bar at the bottom of each section form */
.admin-save-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    border-top: 1px solid var(--border-light);
    background: var(--content-bg);
}

.admin-save-hint {
    font-size: 12px;
    color: var(--text-muted);
}

/* Add-option / add-group form strip */
.admin-add-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-top: 2px solid var(--border-light);
    background: var(--surface);
}

/* Drag-and-drop states for option rows */
tr.row-dragging {
    opacity: 0.4;
}

tr.row-drag-over td {
    background: var(--accent-light);
}

/* ---- Import wizard step indicator ---- */

.import-steps {
    display: flex;
    align-items: center;
    margin-bottom: 24px;
}

.import-step {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}

.import-step-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    background: var(--surface);
    color: var(--text-muted);
    flex-shrink: 0;
}

.import-step.done .import-step-num {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.import-step.active .import-step-num {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.import-step.active .import-step-label {
    color: var(--text-primary);
    font-weight: 600;
}

.import-step-sep {
    flex: 0 0 40px;
    height: 2px;
    background: var(--border);
    margin: 0 6px;
}

/* ---- Import mapping table (steps 2 and 3) ---- */

.import-map-table {
    width: 100%;
    border-collapse: collapse;
}

.import-map-table th {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding: 8px 16px;
    border-bottom: 2px solid var(--border);
    text-align: left;
    background: var(--surface);
}

.import-map-table td {
    padding: 7px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 13.5px;
    vertical-align: middle;
}

.import-map-table tr:last-child td {
    border-bottom: none;
}

.import-map-col-header {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--content-bg);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    display: inline-block;
}

.import-map-arrow {
    color: var(--text-muted);
    text-align: center;
    font-size: 15px;
}

/* ---- Import results grid ---- */

.import-results-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.import-result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}

.import-result-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.import-result-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.import-result-value.success { color: var(--success); }
.import-result-value.danger  { color: var(--danger); }
.import-result-value.warning { color: var(--warning); }

/* ---- Quick search dropdown ---- */

.qs-dropdown {
    position: fixed;
    z-index: 300;
    min-width: 300px;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,.14);
    display: none;
    overflow: hidden;
}

.qs-section-label {
    padding: 5px 12px 4px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    background: var(--content-bg);
    border-bottom: 1px solid var(--border-light);
}

.qs-item {
    display: block;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    text-decoration: none;
    transition: background .1s;
}

.qs-item:last-child { border-bottom: none; }

.qs-item:hover {
    background: var(--accent-light);
    text-decoration: none;
}

.qs-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
}

.qs-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
}

.qs-empty {
    padding: 14px 12px;
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}

/* ---- Advanced search page ---- */

.adv-filter-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px 20px;
    margin-bottom: 16px;
}

.adv-filter-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.adv-filter-row > label:first-child {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.adv-filter-pt-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: .01em;
    margin-bottom: 8px;
}

.adv-filter-radios {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding-top: 2px;
}

.adv-filter-radios label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 400;
    font-size: 13.5px;
    color: var(--text-primary);
    cursor: pointer;
    white-space: nowrap;
}

.adv-filter-radios input[type="radio"] {
    width: 14px;
    height: 14px;
    min-width: 14px;
    accent-color: var(--accent);
    border: none;
    padding: 0;
    cursor: pointer;
}

.adv-filter-radios input[type="number"] {
    width: 64px;
    padding: 4px 6px;
    font-size: 13px;
    display: inline-block;
}

.adv-results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 12px;
}

.adv-results-count {
    font-size: 13.5px;
    color: var(--text-muted);
    font-weight: 500;
}
