:root {
    --page-bg: #e9ebf0;
    --bg: #f6f7f9;
    --sidebar-bg: #fbfbfc;
    --card-bg: #ffffff;
    --column-bg: #edeff3;
    --border: #e6e8eb;
    --field-bg: #ffffff;
    --field-border: #d7dae0;
    --text: #17181a;
    --text-muted: #6b6f76;
    --accent: #5e6ad2;
    --accent-hover: #515dc4;
    --accent-text: #ffffff;
    --nav-active-bg: #eef0f8;
    --danger: #e5484d;
    --success: #3f9e6f;
    --glow: rgba(23, 24, 28, 0.06);
    --glow-strong: rgba(23, 24, 28, 0.10);

    --pastel-blue: #e8edfb;
    --pastel-purple: #efeafe;
    --pastel-green: #e2f3ea;
    --pastel-yellow: #f9f1da;
    --dash-card-text: #17181a;
    --dash-card-label: rgba(23, 24, 28, 0.55);

    --radius-lg: 12px;
    --radius-md: 8px;
    --radius-sm: 6px;
}

[data-theme="dark"] {
    --page-bg: #08090a;
    --bg: #0f1011;
    --sidebar-bg: #0a0b0c;
    --card-bg: #16171a;
    --column-bg: #131416;
    --border: rgba(255, 255, 255, 0.08);
    --field-bg: #1b1d20;
    --field-border: rgba(255, 255, 255, 0.13);
    --text: #f7f8f8;
    --text-muted: #8a8f98;
    --accent: #7e8ce0;
    --accent-hover: #8b98e8;
    --accent-text: #ffffff;
    --nav-active-bg: #1c1d22;
    --danger: #f2555a;
    --success: #4cb782;

    --pastel-blue: #161a2e;
    --pastel-purple: #1a162e;
    --pastel-green: #11231a;
    --pastel-yellow: #221d0d;
    --dash-card-text: #f7f8f8;
    --dash-card-label: rgba(247, 248, 248, 0.5);

    --glow: rgba(0, 0, 0, 0.4);
    --glow-strong: rgba(0, 0, 0, 0.55);
}

* {
    box-sizing: border-box;
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background-color: var(--text-muted);
    opacity: 0.4;
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
    background-color: var(--accent);
}

body {
    margin: 0;
    font-family: 'Inter', -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    background: var(--page-bg);
    color: var(--text);
    padding: 20px;
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

.icon {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Layout */
.app-shell {
    display: flex;
    width: 100%;
    max-width: 2200px;
    min-height: calc(100vh - 40px);
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(23, 24, 28, 0.06), 0 0 0 1px var(--border);
}

[data-theme="dark"] .app-shell {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.sidebar {
    width: 220px;
    flex: 0 0 220px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 20px 14px;
    border-radius: 14px 0 0 14px;
    border-right: 1px solid var(--border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 4px 18px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
}

.sidebar-collapse-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    opacity: 0.5;
}

.sidebar-collapse-btn:hover { opacity: 1; color: var(--text); }

/* Collapsed sidebar — icon-only rail */
.app-shell.sidebar-collapsed .sidebar {
    width: 62px;
    flex: 0 0 62px;
    padding: 20px 8px;
}
.app-shell.sidebar-collapsed .sidebar-logo-text,
.app-shell.sidebar-collapsed .sidebar-search-wrap,
.app-shell.sidebar-collapsed .nav-label,
.app-shell.sidebar-collapsed .sidebar-user-info {
    display: none;
}
.app-shell.sidebar-collapsed .sidebar-logo {
    justify-content: center;
    padding: 4px 0 18px;
}
.app-shell.sidebar-collapsed .sidebar-collapse-btn { margin-left: 0; }
.app-shell.sidebar-collapsed .nav-icon {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}
.app-shell.sidebar-collapsed .sidebar-user-card {
    flex-direction: column;
    gap: 8px;
    padding: 8px 4px;
}

/* Sidebar search */
.sidebar-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 18px;
    cursor: text;
}

.sidebar-search-icon {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.sidebar-search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13px;
    color: var(--text);
    font-family: inherit;
    min-width: 0;
    outline: none;
}

.sidebar-search-input::placeholder { color: var(--text-muted); }

.sidebar-search-kbd {
    font-size: 10px;
    color: var(--text-muted);
    background: var(--column-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    font-family: inherit;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-logo-icon {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.04em;
    flex-shrink: 0;
    box-shadow: none;
}

.sidebar-app-name {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
}

/* WORKSPACE wordmark */
.sidebar-wordmark {
    font-family: 'Syne', sans-serif;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
    text-transform: uppercase;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.wm-work {
    color: var(--text);
}

.wm-space {
    color: var(--accent);
}

.brand-gradient {
    color: var(--text);
}

.brand-hard {
    color: var(--accent);
}

.sidebar-app-sub {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 3px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 600;
    opacity: 0.7;
}

.sidebar-section-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 12px 10px 4px;
    opacity: 0.6;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-bottom {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

/* User profile card */
.sidebar-user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    border-radius: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    cursor: default;
}

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-email {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.sidebar-user-theme {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: color 0.15s;
}

.sidebar-user-theme:hover { color: var(--text); }

.nav-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    pointer-events: none;
}

/* Generic visibility utility — only element-scoped .hidden variants existed before,
   so a plain <div class="hidden"> never actually hid (e.g. #workBlock). */
.hidden { display: none !important; }

.nav-badge.hidden {
    display: none;
}

.nav-icon {
    width: 100%;
    height: auto;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 9px 12px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, color 0.15s ease;
    text-align: left;
    position: relative;
}

.nav-icon:hover {
    background: rgba(127, 127, 127, 0.08);
    color: var(--text);
}

.nav-icon.active {
    background: var(--nav-active-bg);
    color: var(--accent);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--accent);
}

[data-theme="dark"] .nav-icon.active {
    background: var(--nav-active-bg);
    color: #ffffff;
    box-shadow: inset 2px 0 0 var(--accent);
}

[data-theme="dark"] .nav-icon.active .icon {
    filter: none;
    color: #ffffff;
}

.nav-label {
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.main-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border-radius: 0 14px 14px 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px 10px;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    border-radius: 0 14px 0 0;
    border-bottom: 1px solid var(--border);
}

.topbar h1 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
}

.topbar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.page {
    padding: 4px 24px 24px;
}

.page.hidden {
    display: none;
}

/* Topbar search hidden */
#searchWrap { display: none !important; }

/* Search */
.search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.search-wrap .icon {
    position: absolute;
    left: 14px;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    padding: 9px 14px 9px 38px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    width: 220px;
    background: var(--card-bg);
    color: var(--text);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Buttons */
.btn {
    padding: 9px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    background: var(--card-bg);
    color: var(--text);
}

.btn:hover {
    background: var(--column-bg);
}

.btn-secondary {
    background: var(--column-bg);
    border-color: transparent;
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-text);
    border-color: var(--accent);
    box-shadow: 0 4px 14px var(--glow);
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    box-shadow: 0 6px 20px var(--glow-strong);
}

.btn-compact {
    padding: 8px 12px;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-icon {
    padding: 8px 10px;
    font-size: 16px;
}

.btn-icon-danger {
    color: var(--text-muted);
}

.btn-icon-danger:hover {
    color: var(--danger);
}

.btn-icon-danger .icon {
    width: 16px;
    height: 16px;
}

.btn-icon-round {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Board */
.board {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    align-items: flex-start;
    min-height: calc(100vh - 150px);
}

.board-loading {
    padding: 40px;
    color: var(--text-muted);
}

.column {
    background: var(--column-bg);
    border-radius: var(--radius-lg);
    flex: 1 1 0;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 170px);
    padding: 6px;
}

.column-header {
    padding: 10px 10px 8px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.column-header span:last-child {
    background: var(--card-bg);
    border-radius: 999px;
    padding: 2px 9px;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.column-cards {
    flex: 1;
    overflow-y: auto;
    padding: 4px 6px 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 40px;
}

.column-cards.drag-over {
    background: var(--pastel-blue);
    border-radius: var(--radius-md);
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    box-shadow: 0 2px 8px rgba(20, 20, 43, 0.06), 0 0 0 1px rgba(20,20,43,0.04);
    cursor: pointer;
    border: 1px solid transparent;
    transition: box-shadow 0.18s ease, border-color 0.18s ease;
}

.card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(23, 24, 28, 0.09);
}

.card.dragging {
    opacity: 0.5;
}

.card-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 6px;
}

.card-phone {
    font-size: 14px;
    color: var(--text-muted);
}

.card-deal-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--success);
    margin-top: 6px;
}

.card-summary {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    background: var(--column-bg);
}

.badge-done {
    background: #e3fcef;
    color: var(--success);
}

.badge-failed {
    background: #ffebe6;
    color: var(--danger);
}

.badge-no-task {
    background: var(--pastel-yellow);
    color: #974f0c;
    font-size: 10px;
    font-weight: 600;
}

.badge-processing {
    background: #fff0b3;
    color: #974f0c;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 11, 16, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    width: 460px;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
}

.modal-wide {
    width: 700px;
}

.modal-crm {
    width: 92vw;
    max-width: 1400px;
    height: 88vh;
    max-height: 88vh;
    flex-direction: row;
    padding: 0;
    overflow: hidden;
}

.lead-panel-left {
    width: 476px;
    flex: 0 0 476px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.lead-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.lead-panel-header h2 {
    margin: 0;
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lead-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.lead-panel-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    background: var(--bg);
}

.lead-panel-right .lead-modal-tabs {
    flex-shrink: 0;
}

.lead-panel-right .modal-body {
    flex: 1;
    overflow-y: auto;
}

/* Phone block */
.lead-phone-display {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.lead-phone-input {
    width: 100%;
    font-size: 20px;
    font-weight: 700;
    background: transparent;
    border: none;
    color: var(--text);
    padding: 0;
    letter-spacing: 0.5px;
}

/* Section dividers in left panel form */
.form-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-top: 16px;
    margin-bottom: 2px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

/* Section headers in right panel */
.lead-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin: 0 0 14px;
    padding: 0 0 10px;
    border-bottom: 1px solid var(--border);
}

.lead-section h3 .icon {
    width: 15px;
    height: 15px;
    color: var(--accent);
    flex-shrink: 0;
}

.lead-section {
    padding-bottom: 20px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.lead-section:last-child {
    border-bottom: none;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    margin: 0;
    font-size: 17px;
}

.modal-body {
    padding: 16px 20px;
    overflow-y: auto;
}

.field-label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.settings-input {
    width: 100%;
    background: var(--column-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    padding: 8px 10px;
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color 0.15s;
}

.settings-input:focus {
    outline: none;
    border-color: var(--accent);
}

.lead-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lead-form label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.lead-form input,
.lead-form select,
.lead-form textarea {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text);
}

.lead-form input:focus,
.lead-form select:focus,
.lead-form textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.lead-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.lead-form .btn {
    margin-top: 10px;
    align-self: flex-start;
}


.task-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.task-item.done .task-title {
    text-decoration: line-through;
    color: var(--text-muted);
}

.task-title {
    flex: 1;
}

.task-due {
    font-size: 12px;
    color: var(--text-muted);
}

.task-item .task-delete {
    padding: 2px 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.task-add {
    display: flex;
    gap: 6px;
}

.task-add input[type="text"] {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid var(--field-border);
    border-radius: var(--radius-sm);
    background: var(--field-bg);
    color: var(--text);
}

.task-add input[type="datetime-local"] {
    padding: 9px 8px;
    border: 1px solid var(--field-border);
    border-radius: var(--radius-sm);
    background: var(--field-bg);
    color: var(--text);
}

.task-add input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(94, 106, 210, 0.15);
}

.comment-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.comment-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    background: var(--column-bg);
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.comment-date {
    font-size: 12px;
    color: var(--text-muted);
}

.comment-header .comment-delete {
    padding: 2px 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.comment-text {
    font-size: 14px;
    margin-top: 4px;
    white-space: pre-wrap;
}

.comment-add {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.comment-add textarea {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    background: var(--card-bg);
    color: var(--text);
}

.comment-add .btn {
    align-self: flex-start;
}

.call-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.call-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.call-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    cursor: pointer;
}

.call-item-summary {
    margin-top: 8px;
    font-size: 13px;
}

.call-item-details {
    margin-top: 8px;
    font-size: 13px;
    display: none;
}

.call-item.expanded .call-item-details {
    display: block;
}

.diarization-line {
    margin-bottom: 4px;
}

.diarization-speaker {
    font-weight: 600;
    color: var(--accent);
}

.extracted-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4px 10px;
    font-size: 13px;
    margin-top: 6px;
}

.extracted-grid dt {
    color: var(--text-muted);
}

.extracted-grid dd {
    margin: 0;
}

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--accent);
    color: var(--accent-text);
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 14px;
    z-index: 200;
    box-shadow: 0 10px 30px rgba(20, 20, 43, 0.2);
}

.toast.error {
    background: var(--danger);
    color: #fff;
}

.toast.hidden {
    display: none;
}

/* Dashboard */
.dashboard {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Hero banner */
.dash-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 26px 30px;
    border-radius: var(--radius-lg);
    background: var(--card-bg);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.dash-hero::after {
    content: '';
    position: absolute;
    top: -60px; right: -60px;
    width: 220px; height: 220px;
    background: none;
    pointer-events: none;
}

.dash-hero-eyebrow {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 6px;
}

.dash-hero-name {
    font-family: 'Syne', sans-serif;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin: 0;
    line-height: 1.1;
}

.dash-hero-right {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.dash-hero-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    white-space: nowrap;
}

.dash-hero-pill strong { color: var(--text); font-weight: 700; }

.dash-hero-pill-danger {
    color: var(--danger);
    border-color: rgba(229,72,77,0.2);
    background: rgba(229,72,77,0.05);
}

.dash-hero-pill-danger strong { color: var(--danger); }

/* Stat cards */
.dash-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.dash-card {
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: border-color 0.2s, transform 0.2s;
    cursor: default;
}

.dash-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.dash-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.dash-card-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.dash-card-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dash-icon-blue   { background: rgba(94,106,210,0.12);  color: var(--accent); }
.dash-icon-green  { background: rgba(26,155,80,0.12);  color: #1a9b50; }
.dash-icon-purple { background: rgba(139,111,196,0.13); color: #8b6fc4; }
.dash-icon-red    { background: rgba(229,72,77,0.12);  color: var(--danger); }

.dash-card-value {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1;
    color: var(--text);
}

.dash-card-danger .dash-card-value { color: var(--danger); }

/* 2-column grid */
.dash-main-grid {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 16px;
    align-items: start;
}

.dash-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dash-section-tasks {
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Compact task rows inside dashboard widget */
.dash-section-tasks .task-row {
    grid-template-columns: 28px 1fr auto 32px;
}

.dash-section-tasks .tr-due {
    font-size: 11px;
    padding: 2px 6px;
}

.dash-section-tasks .tr-stage,
.dash-section-tasks .tr-desc {
    display: none;
}

.dash-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: 0 4px 20px rgba(20, 20, 43, 0.04);
}

.dash-section h3 {
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: 700;
}

.dash-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.dash-section-header h3 {
    margin: 0;
}

.goal-progress {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.goal-bar {
    height: 10px;
    border-radius: 999px;
    background: var(--column-bg);
    overflow: hidden;
}

.goal-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--success);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.goal-label {
    font-size: 13px;
    color: var(--text-muted);
}

.call-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.call-stat {
    background: var(--column-bg);
    border-radius: var(--radius-md);
    padding: 12px 14px;
}

.call-stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.call-stat-value {
    font-size: 19px;
    font-weight: 700;
    margin-top: 6px;
}

/* Funnel */
.funnel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.funnel-row {
    display: grid;
    grid-template-columns: 140px 1fr 40px 110px;
    gap: 10px;
    align-items: center;
    font-size: 13px;
}

.funnel-label {
    color: var(--text-muted);
}

.funnel-bar-track {
    background: var(--column-bg);
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
}

.funnel-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    min-width: 2px;
    transition: width 0.3s ease;
}

.funnel-count {
    text-align: right;
    font-weight: 600;
}

.funnel-value {
    text-align: right;
    color: var(--success);
    font-weight: 600;
}

/* Tasks page */
.tasks-page {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.tasks-toolbar {
    font-size: 14px;
    color: var(--text-muted);
}

/* Tasks filter bar (Workly-style) */
.tasks-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--card-bg);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    white-space: nowrap;
}

.filter-pill:hover {
    border-color: var(--accent);
    background: var(--column-bg);
}

.filter-pill.active {
    border-color: var(--accent);
    background: rgba(94, 106, 210, 0.12);
    color: var(--accent);
    font-weight: 600;
}

.filter-pill.active .icon { color: var(--accent); }

.board-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

/* Filter dropdowns (tasks page) */
.filter-dropdown {
    position: relative;
    display: inline-flex;
}

.filter-pill.filter-open .filter-pill-arrow { transform: rotate(180deg); }
.filter-pill-arrow { transition: transform 0.15s; }

.filter-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 180px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.18);
    padding: 6px;
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.filter-menu.hidden { display: none; }

.filter-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s;
}

.filter-menu-item:hover { background: var(--column-bg); }

.filter-menu-item.active {
    color: var(--accent);
    font-weight: 600;
    background: rgba(94, 106, 210, 0.1);
}

.filter-pill .icon {
    width: 15px;
    height: 15px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.filter-pill-arrow {
    color: var(--text-muted);
    margin-left: 2px;
}

.filter-pill-check {
    cursor: pointer;
    user-select: none;
}

.filter-pill-check input {
    accent-color: var(--accent);
    cursor: pointer;
}

[data-theme="dark"] .filter-pill {
    background: rgba(24, 25, 41, 0.8);
    border-color: rgba(255,255,255,0.09);
}

[data-theme="dark"] .filter-pill:hover {
    border-color: rgba(126, 140, 224, 0.5);
    background: rgba(126, 140, 224, 0.08);
}

.task-group-title {
    font-size: 13px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 8px;
    letter-spacing: 0.04em;
}

.tasks-table-header {
    display: grid;
    grid-template-columns: 24px minmax(150px, 1fr) 150px 120px minmax(90px, 1.3fr) 68px;
    align-items: center;
    gap: 10px;
    padding: 7px 14px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.task-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.task-row {
    display: grid;
    grid-template-columns: 24px minmax(150px, 1fr) 150px 120px minmax(90px, 1.3fr) 68px;
    align-items: center;
    gap: 12px;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(23, 24, 28, 0.04);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.task-row:hover {
    border-color: var(--accent);
}

.task-row.done {
    opacity: 0.5;
}

.editable-field {
    cursor: pointer;
    border-radius: 4px;
    padding: 1px 3px;
    margin: -1px -3px;
    transition: background 0.1s;
}

.editable-field:hover {
    background: var(--column-bg);
}

.task-edit-input {
    width: 100%;
    border: none;
    border-bottom: 1.5px solid var(--accent);
    background: transparent;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text);
    outline: none;
    padding: 1px 0;
}

.task-due-input {
    border: none;
    border-bottom: 1.5px solid var(--accent);
    background: transparent;
    font-size: 12px;
    font-family: inherit;
    color: var(--text);
    outline: none;
    width: 100%;
}

.task-row.overdue {
    border-color: rgba(229, 72, 77, 0.35);
    background: rgba(229, 72, 77, 0.05);
    box-shadow: inset 3px 0 0 var(--danger);
}

.task-row.overdue .task-due {
    color: var(--danger);
    font-weight: 600;
}

.overdue-text { color: var(--danger); font-weight: 600; }

.tr-name { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tr-name .task-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.01em; }
.tr-name .task-lead { display: inline-flex; align-items: center; align-self: flex-start; max-width: 100%; font-size: 12px; color: var(--accent); background: var(--column-bg); border: 1px solid var(--border); border-radius: 6px; padding: 3px 9px; cursor: pointer; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: border-color 0.15s, background 0.15s; }
.tr-name .task-lead:hover { border-color: var(--accent); background: var(--glow); }
.tr-due { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; white-space: nowrap; justify-self: start; }
.tr-due .due-time { font-weight: 700; color: var(--accent); background: var(--nav-active-bg); border: 1px solid var(--accent); padding: 2px 7px; border-radius: 5px; }
.tr-due .due-date { color: var(--text-muted); font-weight: 600; }
.tr-due.overdue-text .due-time { color: var(--danger); border-color: var(--danger); background: rgba(229, 72, 77, 0.1); }
.tr-due.overdue-text .due-date { color: var(--danger); }
.tr-stage { }
.tr-desc { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-actions { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.tr-actions .btn-icon { padding: 4px 7px; font-size: 14px; line-height: 1; }
.tr-empty { color: var(--border); }
.tr-check { display: flex; align-items: center; }
.tr-del { display: flex; justify-content: flex-end; }

/* Custom checkbox for task rows */
.task-row input[type="checkbox"],
.task-item > input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 2px solid var(--field-border);
    border-radius: 5px;
    cursor: pointer;
    position: relative;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    background: var(--field-bg);
    flex-shrink: 0;
}

.task-row input[type="checkbox"]:hover,
.task-item > input[type="checkbox"]:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--glow);
}

.task-row input[type="checkbox"]:checked,
.task-item > input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.task-row input[type="checkbox"]:checked::after,
.task-item > input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 6px;
    height: 10px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}

/* Native date/time picker icon is dark-on-dark in dark theme — make it visible */
[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(1) brightness(1.4);
    opacity: 0.7;
    cursor: pointer;
}
[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover,
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator:hover,
[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.stage-badge-new       { background: var(--column-bg); color: var(--text-muted); }
.stage-badge-in_progress { background: var(--pastel-blue); color: #1e4db7; }
.stage-badge-interested  { background: var(--pastel-purple); color: #6e3fb5; }
.stage-badge-callback    { background: var(--pastel-yellow); color: #974f0c; }
.stage-badge-meeting     { background: var(--pastel-green); color: #1a7a40; }
.stage-badge-deal        { background: #d4f7e0; color: #166534; }
.stage-badge-rejected    { background: #fde8e8; color: var(--danger); }

.task-lead {
    font-size: 12px;
    color: var(--accent);
    cursor: pointer;
    text-decoration: underline;
}

/* Feed */
.feed-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 4px 0 8px;
}

.feed-empty {
    color: var(--text-muted);
    font-size: 14px;
    padding: 24px 0;
    text-align: center;
}

.feed-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.feed-item-icon {
    font-size: 18px;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--column-bg);
}

.feed-item-body {
    flex: 1;
    min-width: 0;
    background: var(--column-bg);
    border-radius: var(--radius-md);
    padding: 10px 14px;
}

.feed-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.feed-item-type {
    font-weight: 600;
    font-size: 13px;
}

.feed-item-date {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: auto;
}

.feed-call-summary {
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 6px;
}

.feed-call-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
}

.feed-call-processing {
    display: inline-block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.feed-expand-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    margin-top: 4px;
    text-decoration: underline;
    font-family: inherit;
}

.feed-call-details {
    margin-top: 8px;
    font-size: 13px;
}

.feed-call-details.hidden {
    display: none;
}

.feed-comment-text {
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.feed-delete-btn {
    margin-left: auto;
    opacity: 0.4;
}

.feed-delete-btn:hover {
    opacity: 1;
}

.lead-title-input {
    flex: 1;
    background: transparent;
    border: none;
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    font-family: inherit;
    min-width: 0;
    padding: 0;
}

.lead-title-input:focus {
    outline: none;
    border-bottom: 1px solid var(--accent);
}

.feed-input-area {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 20px 14px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.feed-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.feed-input-row textarea {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text);
    resize: none;
}

.feed-input-row textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.feed-attach-btn {
    cursor: pointer;
    color: var(--text-muted);
    flex-shrink: 0;
}

.feed-attach-btn:hover {
    color: var(--text);
}

.attachment-grid-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.attachment-grid-compact:empty {
    display: none;
}

/* Lead modal tabs */
.lead-modal-tabs {
    display: flex;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    gap: 0;
}

.lead-tab-btn {
    padding: 10px 18px;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}

.lead-tab-btn:hover {
    color: var(--text);
}

.lead-tab-btn.active {
    color: var(--text);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.lead-tab-panel.hidden {
    display: none;
}

/* Attachments */
.attachment-upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    transition: border-color 0.15s, color 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.attachment-upload-zone:hover,
.attachment-upload-zone.drag-over {
    border-color: var(--accent);
    color: var(--text);
}

.upload-link {
    color: var(--accent);
    text-decoration: underline;
    cursor: pointer;
}

.attachment-upload-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.attachment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.attachment-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
}

.attachment-thumb {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: var(--column-bg);
    display: block;
}

.attachment-icon {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--column-bg);
    font-size: 36px;
}

.attachment-info {
    padding: 6px 8px;
    flex: 1;
}

.attachment-name {
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.attachment-size {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
}

.attachment-actions {
    display: flex;
    gap: 4px;
    padding: 4px 6px;
    border-top: 1px solid var(--border);
}

/* Payments */
.payment-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.payment-item {
    display: grid;
    grid-template-columns: 120px 1fr 1fr auto auto;
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.payment-item.payment-paid {
    opacity: 0.55;
}

.payment-date.overdue {
    color: var(--danger);
    font-weight: 600;
}

.payment-amount {
    font-weight: 600;
}

.payment-note {
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.payment-actions {
    display: flex;
    gap: 4px;
}

.payment-actions .btn {
    padding: 3px 8px;
    font-size: 12px;
}

.payment-add {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.payment-add input {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}

.payment-add input[type="number"] { width: 120px; }
.payment-add input[type="date"] { width: 150px; }
.payment-add input[type="text"] { flex: 1; min-width: 120px; }

.payments-summary {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text-muted);
}

.payments-summary strong {
    color: var(--text);
}

.payments-debt-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.payments-debt-badge.is-debt {
    background: rgba(217,119,6,0.12);
    color: #d97706;
}
[data-theme="dark"] .payments-debt-badge.is-debt { color: #fbbf24; }

.payments-debt-badge.is-clear {
    background: rgba(34,197,94,0.12);
    color: var(--success);
}

.url-input-wrap {
    display: flex;
    gap: 6px;
    align-items: center;
}

.url-input-wrap input {
    flex: 1;
    min-width: 0;
}

.url-open-btn {
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--accent);
    text-decoration: none;
    font-size: 13px;
    background: var(--column-bg);
    flex: 0 0 auto;
    white-space: nowrap;
    transition: background 0.15s, opacity 0.15s;
    opacity: 0.7;
}

.url-open-btn:hover {
    background: var(--border);
    opacity: 1;
}

.attachment-actions .btn {
    flex: 1;
    padding: 4px 6px;
    font-size: 11px;
    border-radius: 6px;
    text-align: center;
}

/* ── Left panel: phone hero ── */
.lead-phone-block {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--column-bg);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    border: 1px solid var(--border);
}

.lead-project-status-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    padding: 9px 0;
    margin-bottom: 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--column-bg);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.lead-project-status-btn .icon { width: 14px; height: 14px; }

.lead-project-status-btn:hover { border-color: var(--accent); }

.lead-project-status-btn.lpsb-active { color: var(--accent); border-color: rgba(94,106,210,0.3); background: rgba(94,106,210,0.06); }
.lead-project-status-btn.lpsb-paused { color: #d97706; border-color: rgba(217,119,6,0.3); background: rgba(217,119,6,0.06); }
[data-theme="dark"] .lead-project-status-btn.lpsb-paused { color: #fbbf24; }
.lead-project-status-btn.lpsb-done { color: var(--success); border-color: rgba(34,197,94,0.35); background: rgba(34,197,94,0.08); }
.lead-project-status-btn.lpsb-done:hover { border-color: var(--accent); color: var(--accent); background: rgba(94,106,210,0.06); }

.lead-phone-icon-wrap {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-text);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.lead-phone-icon-wrap .icon {
    width: 16px;
    height: 16px;
}

/* ── Left panel: form section cards ── */
.form-section {
    margin-top: 16px;
}

.form-section-hd {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 0 6px 0;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}

.form-section-hd .icon {
    width: 12px;
    height: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
    opacity: 0.7;
}

.form-section-bd {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-section-bd textarea {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--field-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    background: var(--field-bg);
    color: var(--text);
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-section-bd textarea::placeholder { color: var(--text-muted); opacity: 0.7; }

.form-section-bd textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(94, 106, 210, 0.15);
}

/* ── Field rows ── */
.field-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 30px;
}

.field-lbl {
    width: 72px;
    flex-shrink: 0;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    line-height: 1.3;
}

.field-val {
    flex: 1;
    min-width: 0;
}

.field-val > input,
.field-val > select {
    width: 100%;
    padding: 7px 11px;
    border: 1px solid var(--field-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    background: var(--field-bg);
    color: var(--text);
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field-val > input::placeholder { color: var(--text-muted); opacity: 0.7; }

.field-val > input:hover,
.field-val > select:hover { border-color: var(--text-muted); }

.field-val > input:focus,
.field-val > select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(94, 106, 210, 0.15);
}

/* Kill the white/yellow Chrome autofill box that clashes with the dark fields.
   Chrome's UA autofill style is high-priority — needs !important to override. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-text-fill-color: var(--text) !important;
    -webkit-box-shadow: 0 0 0 1000px var(--field-bg) inset !important;
    box-shadow: 0 0 0 1000px var(--field-bg) inset !important;
    caret-color: var(--text) !important;
    transition: background-color 9999s ease-in-out 0s !important;
}

.field-val .url-input-wrap {
    width: 100%;
}

.field-val .url-input-wrap input {
    padding: 7px 11px;
    font-size: 13px;
    color: var(--text);
    background: var(--field-bg);
    border: 1px solid var(--field-border);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field-val .url-input-wrap input::placeholder { color: var(--text-muted); opacity: 0.7; }

.field-val .url-input-wrap input:hover { border-color: var(--text-muted); }

.field-val .url-input-wrap input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(94, 106, 210, 0.15);
}

/* Remove number input spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] { -moz-appearance: textfield; }

/* Force readable colors inside native select dropdowns */
select option {
    background: #ffffff;
    color: #13151c;
}

[data-theme="dark"] select option {
    background: #181929;
    color: #e4e6f4;
}

/* ── Dark theme: flat solid surfaces ── */
[data-theme="dark"] .card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    box-shadow: none;
}

[data-theme="dark"] .card:hover {
    border-color: var(--accent);
    box-shadow: none;
}

[data-theme="dark"] .column {
    background: var(--column-bg);
    border: 1px solid var(--border);
}

[data-theme="dark"] .dash-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    box-shadow: none;
}

[data-theme="dark"] .modal-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .task-row {
    background: var(--card-bg);
    border-color: var(--border);
}

[data-theme="dark"] .task-row:hover {
    border-color: var(--accent);
}

[data-theme="dark"] .btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: none;
}

[data-theme="dark"] .btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: none;
}

[data-theme="dark"] .topbar {
    border-bottom: 1px solid var(--border);
}

/* ══════════════════════════════════════
   STEPS PAGE — Алгоритм работы
══════════════════════════════════════ */

.steps-page {
    max-width: 760px;
    margin: 0 auto;
}

.steps-hero {
    padding: 4px 0 32px;
}

.steps-hero-title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--text);
}

.steps-hero-sub {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 6px;
}

.steps-list {
    display: flex;
    flex-direction: column;
}

.step-item {
    display: flex;
    gap: 24px;
}

.step-aside {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    padding-top: 2px;
}

.step-circle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
    font-size: 16px;
    font-family: 'Syne', 'Inter', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: none;
    position: relative;
    z-index: 1;
}

.step-line {
    width: 2px;
    flex: 1;
    min-height: 24px;
    background: var(--border);
    margin: 10px 0;
    border-radius: 999px;
}

.step-body {
    flex: 1;
    min-width: 0;
    padding-bottom: 44px;
}

.step-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding-top: 8px;
}

.step-title {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text);
}

.step-stage-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.step-stage-tag.new        { background: var(--pastel-blue);   color: #1e4db7; }
.step-stage-tag.interested { background: var(--pastel-purple); color: #6e3fb5; }
.step-stage-tag.callback   { background: var(--pastel-yellow); color: #974f0c; }
.step-stage-tag.deal       { background: #d4f7e0; color: #166534; }
.step-stage-tag.done       { background: rgba(94,106,210,0.1); color: var(--accent); }

/* Script block */
.step-script { margin-bottom: 20px; }

.step-script-label,
.step-check-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: block;
}

.script-block {
    background: #0b0d1c;
    border-radius: 12px;
    padding: 18px 18px 16px;
    position: relative;
    border: 1px solid rgba(255,255,255,0.07);
}

.script-block pre {
    margin: 0;
    font-family: 'Inter', monospace;
    font-size: 13px;
    line-height: 1.85;
    color: #b4c2ff;
    white-space: pre-wrap;
    word-wrap: break-word;
    padding-right: 100px;
}

.copy-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 7px;
    color: rgba(255,255,255,0.45);
    font-size: 12px;
    font-weight: 500;
    padding: 5px 12px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    white-space: nowrap;
}
.copy-btn:hover  { background: rgba(255,255,255,0.13); color: rgba(255,255,255,0.85); }
.copy-btn.copied { background: rgba(74,222,128,0.12); color: #4ade80; border-color: rgba(74,222,128,0.25); }

/* Checklists */
.step-check-section { margin-bottom: 20px; }

.csv-format-block {
    margin-top: 10px;
}

.csv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-bottom: 10px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.csv-table th {
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-weight: 600;
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.csv-table td {
    padding: 8px 12px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}

.csv-table tr:last-child td {
    border-bottom: none;
}

.csv-note {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    border-left: 3px solid var(--primary);
}

.step-checks {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.step-checks li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    color: var(--text);
    line-height: 1.5;
}

.step-checks li::before {
    content: '';
    width: 17px;
    height: 17px;
    min-width: 17px;
    border-radius: 5px;
    border: 1.5px solid var(--border);
    margin-top: 2px;
    flex-shrink: 0;
}

/* Numbered questions */
.step-questions {
    padding: 0;
    margin: 0;
    list-style: none;
    counter-reset: q;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.step-questions li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    counter-increment: q;
}

.step-questions li::before {
    content: "0" counter(q);
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    min-width: 22px;
    margin-top: 3px;
    font-family: 'Syne', sans-serif;
    flex-shrink: 0;
}

/* Niche chips */
.niches-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.niche-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 13px;
    color: var(--text);
    text-decoration: none;
    transition: all 0.18s;
    box-shadow: 0 1px 4px rgba(20,20,43,0.05);
}

.niche-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--nav-active-bg);
    box-shadow: 0 2px 8px rgba(23,24,28,0.08);
}

/* File cards */
.step-files { margin-bottom: 20px; }

.files-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.file-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    transition: all 0.15s;
    box-shadow: 0 1px 4px rgba(20,20,43,0.04);
}

.file-card:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(20,20,43,0.07);
}
.file-card .icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.7;
}

/* ── Reference gallery (референсы по нишам) ── */
.ref-collection {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
    gap: 10px;
    margin-top: 4px;
}

.ref-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 1px 4px rgba(20,20,43,0.04);
    min-width: 0;
}
.ref-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(20,20,43,0.08);
}

.ref-fav {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    object-fit: contain;
    padding: 4px;
}

.ref-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}
.ref-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ref-desc {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ref-arrow {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    fill: none;
    stroke: var(--text-muted);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0;
    transform: translate(-3px, 3px);
    transition: opacity 0.15s, transform 0.15s, stroke 0.15s;
}
.ref-card:hover .ref-arrow {
    opacity: 1;
    transform: translate(0, 0);
    stroke: var(--accent);
}

/* ── Requisites card (реквизиты для оплаты) ── */
.requisites-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(20,20,43,0.04);
}

.req-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}
.req-row:last-child { border-bottom: none; }
.req-row:hover { background: var(--bg-secondary); }

.req-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.req-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}
.req-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    word-break: break-word;
}

.req-copy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.req-copy svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.req-copy:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.req-copy.copied {
    border-color: var(--success);
    color: var(--success);
    background: rgba(34,197,94,0.08);
}

.req-row-action { padding: 10px; }
.req-copy-all {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--nav-active-bg, rgba(94,106,210,0.1));
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}
.req-copy-all:hover {
    background: var(--accent);
    color: var(--accent-text, #fff);
}
.req-copy-all.copied {
    background: rgba(34,197,94,0.12);
    color: var(--success);
}

/* ── Projects Page ── */
.projects-page {
    padding: 24px 28px;
    max-width: 1200px;
    margin: 0 auto;
}

.projects-page-header {
    margin-bottom: 24px;
}

.projects-page-title {
    font-family: 'Syne', sans-serif;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin: 0 0 4px;
}

.projects-page-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

.projects-summary-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.projects-summary-card {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 18px 22px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--card-bg);
}

.psum-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    flex: 1;
}

.psum-count {
    font-family: 'Syne', sans-serif;
    font-size: 26px;
    font-weight: 800;
    color: var(--text);
}

.psum-amount {
    font-size: 13px;
    font-weight: 700;
}

.psum-active { border-left: 3px solid #d97706; }
.psum-active .psum-amount { color: #d97706; }
[data-theme="dark"] .psum-active .psum-amount { color: #fbbf24; }

.psum-done { border-left: 3px solid var(--success); }
.psum-done .psum-amount { color: var(--success); }
.psum-subdebt { color: #d97706; font-weight: 600; }
[data-theme="dark"] .psum-subdebt { color: #fbbf24; }

.projects-content-row {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.projects-done-sidebar {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.projects-done-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.proj-done-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid rgba(34,197,94,0.25);
    background: rgba(34,197,94,0.06);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.proj-done-item:hover {
    border-color: var(--success);
    background: rgba(34,197,94,0.12);
}

.proj-done-item .icon {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    color: var(--success);
}

.proj-done-name {
    flex: 1;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.proj-done-amount {
    font-size: 11px;
    font-weight: 700;
    color: var(--success);
    flex-shrink: 0;
}

.proj-done-item.is-partial .proj-done-amount { color: #d97706; }
[data-theme="dark"] .proj-done-item.is-partial .proj-done-amount { color: #fbbf24; }
.proj-done-item.is-partial { border-color: rgba(217,119,6,0.3); background: rgba(217,119,6,0.05); }

.projects-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.projects-empty {
    color: var(--text-muted);
    font-size: 14px;
    padding: 40px 0;
    text-align: center;
    grid-column: 1 / -1;
}

.project-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.project-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 20px var(--glow);
}

.project-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.proj-status-pill {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    letter-spacing: 0.03em;
}

.pstatus-active { background: rgba(94,106,210,0.12); color: var(--accent); }
.pstatus-paused { background: rgba(234,179,8,0.15); color: #92400e; }
.pstatus-done   { background: rgba(34,197,94,0.15); color: #166534; }

[data-theme="dark"] .pstatus-paused { color: #fbbf24; }
[data-theme="dark"] .pstatus-done   { color: #4ade80; }

.proj-card-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
}

.proj-card-value-done { color: var(--success); }
.proj-card-value-debt { color: #d97706; }
[data-theme="dark"] .proj-card-value-debt { color: #fbbf24; }

.project-card-done {
    border-color: rgba(34,197,94,0.35);
    background: rgba(34,197,94,0.05);
}

.project-card-done:hover {
    border-color: var(--success);
}

.project-card-task {
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--column-bg);
    font-size: 12px;
}

.project-card-task .icon { width: 13px; height: 13px; flex-shrink: 0; color: var(--accent); }

.project-card-task .pct-title {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.project-card-task .pct-due {
    color: var(--text-muted);
    flex-shrink: 0;
}

.project-card-task .pct-more {
    color: var(--text-muted);
    font-weight: 600;
    flex-shrink: 0;
}

.project-card-task-empty {
    color: var(--text-muted);
}

.project-card-task-empty .icon { color: var(--text-muted); }

.project-card-name {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    line-height: 1.2;
}

.project-card-company {
    font-size: 12px;
    color: var(--text-muted);
}

.project-niche-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    background: rgba(139,111,196,0.13);
    color: #8b6fc4;
    padding: 2px 9px;
    border-radius: 999px;
}

[data-theme="dark"] .project-niche-tag { color: #b69ae0; }

.project-card-domain {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-muted);
    font-family: monospace;
}

.project-services-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.proj-svc-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 5px;
    background: var(--column-bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.proj-promo-badge {
    font-size: 11px;
    font-weight: 600;
    color: #d97706;
    background: rgba(251,191,36,0.12);
    padding: 3px 10px;
    border-radius: 999px;
    display: inline-block;
    align-self: flex-start;
}

/* Project modal */
.modal-project {
    width: 600px;
    max-width: 96vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.proj-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.proj-modal-name {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.proj-modal-phone {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.proj-modal-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.proj-deal-badge {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
}

.proj-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px 4px;
}

.proj-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.proj-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.proj-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}

.proj-input {
    width: 100%;
    padding: 10px 13px;
    background: var(--column-bg);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    transition: border-color 0.15s, background 0.15s;
    box-sizing: border-box;
    resize: vertical;
}

.proj-input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--card-bg);
}

.proj-input::placeholder { color: var(--text-muted); opacity: 0.6; }

select.proj-input { cursor: pointer; }

.proj-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.proj-modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}

/* Credentials */
.creds-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.creds-empty {
    font-size: 13px;
    color: var(--text-muted);
    padding: 10px 0;
    text-align: center;
}

.cred-card {
    background: var(--column-bg);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px 8px 12px;
}

.cred-card-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.cred-card-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.2px;
}

.cred-del .icon { width: 13px; height: 13px; }

.cred-line {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    min-width: 0;
}

.cred-line + .cred-line { border-top: 1px solid var(--border); }

.cred-line-name {
    font-size: 11px;
    color: var(--text-muted);
    width: 52px;
    flex-shrink: 0;
}

.cred-line-val {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cred-secret { -webkit-text-security: disc; text-security: disc; }

.cred-mini {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    color: var(--text-muted);
}

.cred-mini .icon { width: 14px; height: 14px; }
.cred-mini:hover { color: var(--accent); }

/* ── Add-access widget ── */
.cred-add { display: flex; flex-direction: column; }

.cred-add-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 9px 0;
    border: 1.5px dashed var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.cred-add-toggle .icon { width: 15px; height: 15px; }
.cred-add-toggle:hover { border-color: var(--accent); color: var(--accent); background: rgba(94,106,210,0.05); }

.cred-add-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--column-bg);
}

.cred-add-pair {
    display: flex;
    gap: 8px;
}

.cred-add-pair .cred-add-input { flex: 1; min-width: 0; }

.cred-add-input {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--field-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    background: var(--field-bg);
    color: var(--text);
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.cred-add-input::placeholder { color: var(--text-muted); opacity: 0.7; }

.cred-add-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(94, 106, 210, 0.15);
}

.cred-add-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Phone field in Контакт */
.phone-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 11px;
    background: var(--field-bg);
    border: 1px solid var(--field-border);
    border-radius: var(--radius-sm);
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.phone-input-wrap:hover { border-color: var(--text-muted); }
.phone-input-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(94, 106, 210, 0.15);
}

.phone-input-wrap .icon {
    width: 14px;
    height: 14px;
    color: var(--accent);
    flex-shrink: 0;
}

.phone-input-wrap input {
    flex: 1;
    min-width: 0;
    padding: 2px 0;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    box-sizing: border-box;
}

.phone-input-wrap input::placeholder { color: var(--text-muted); opacity: 0.7; }
.phone-input-wrap input:focus { outline: none; }

/* Promotion */
.promo-toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.take-work-prompt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    padding: 14px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.take-work-q {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.promo-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.promo-services-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
}

.promo-service-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 7px 14px 7px 30px;
    border: 1.5px solid var(--border);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    user-select: none;
}

.promo-service-chip:hover { border-color: var(--accent); }

.promo-service-chip input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.promo-service-chip::before {
    content: "";
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--border);
    border-radius: 4px;
    background: var(--column-bg);
    transition: border-color 0.15s, background 0.15s;
}

.promo-service-chip:has(input:checked) {
    border-color: var(--accent);
    background: rgba(94,106,210,0.08);
    color: var(--accent);
}

.promo-service-chip:has(input:checked)::before {
    border-color: var(--accent);
    background: var(--accent);
}

.promo-service-chip:has(input:checked)::after {
    content: "";
    position: absolute;
    left: 16px;
    top: 47%;
    width: 5px;
    height: 8px;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: translateY(-60%) rotate(45deg);
}

/* ── Payment Calendar Heatmap ── */
.dash-payment-cal-section { margin-top: 4px; }

.payment-calendar {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.pcal-month { flex: 1; min-width: 220px; }

.pcal-month-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: capitalize;
    color: var(--text-muted);
    margin-bottom: 10px;
    letter-spacing: 0.02em;
}

.pcal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.pcal-wd {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    padding-bottom: 5px;
    font-weight: 600;
}

.pcal-cell {
    aspect-ratio: 1;
    border-radius: 7px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    transition: filter 0.1s;
    cursor: default;
}

.pcal-cell[data-date]:hover { filter: brightness(0.85); cursor: pointer; }

.pcal-dn {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1;
    font-weight: 500;
}

.pcal-amt {
    font-size: 8.5px;
    font-weight: 800;
    line-height: 1;
    margin-top: 2px;
}

.pcal-filler, .pcal-empty {
    background: var(--column-bg, #f0f2f8);
    opacity: 0.45;
}

/* Unpaid intensity */
.pcal-l1 { background: rgba(94,106,210,0.13); }
.pcal-l2 { background: rgba(94,106,210,0.27); }
.pcal-l3 { background: rgba(94,106,210,0.44); }
.pcal-l4 { background: rgba(94,106,210,0.64); }
.pcal-l5 { background: rgba(94,106,210,0.86); }

.pcal-l1 .pcal-amt, .pcal-l2 .pcal-amt, .pcal-l3 .pcal-amt { color: var(--accent); }
.pcal-l4 .pcal-amt { color: #3050d0; }
.pcal-l5 .pcal-dn, .pcal-l5 .pcal-amt { color: #fff; }

/* Paid */
.pcal-paid { background: rgba(34,197,94,0.18); }
.pcal-paid .pcal-amt { color: #16a34a; }

/* Mixed */
.pcal-mixed { background: linear-gradient(135deg, rgba(94,106,210,0.32) 50%, rgba(34,197,94,0.28) 50%); }
.pcal-mixed .pcal-amt { color: var(--text); }

/* Overdue = past unpaid */
.pcal-overdue { outline: 2px solid rgba(229,72,77,0.55); outline-offset: -2px; }
.pcal-overdue .pcal-amt { color: var(--danger) !important; }

/* Today */
.pcal-today { outline: 2px solid var(--accent); outline-offset: -2px; }
.pcal-today.pcal-empty { opacity: 1; }

/* Legend */
.pcal-legend {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.pcal-legend-dot {
    width: 10px; height: 10px;
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
}

.pcal-legend-unpaid { background: rgba(94,106,210,0.6); }
.pcal-legend-paid   { background: rgba(34,197,94,0.55); }
.pcal-legend-overdue { background: rgba(229,72,77,0.55); }

/* Tooltip */
.pay-tooltip {
    position: fixed;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    box-shadow: 0 8px 28px rgba(20,20,43,0.18);
    z-index: 9000;
    min-width: 190px;
    max-width: 260px;
    pointer-events: none;
}

.pay-tooltip.hidden { display: none; }

.pt-date {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 7px;
    letter-spacing: 0.04em;
    text-transform: capitalize;
}

.pt-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 3px 0;
    border-bottom: 1px solid var(--border);
}

.pt-row:last-of-type { border-bottom: none; }

.pt-who { flex: 1; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-amt { font-weight: 700; color: var(--accent); white-space: nowrap; }
.pt-tag { font-size: 10px; color: #16a34a; font-weight: 700; }
.pt-paid .pt-amt { color: #16a34a; }

.pt-total {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 7px;
    padding-top: 5px;
    border-top: 1px solid var(--border);
}

.pt-total strong { color: var(--danger); }

.file-card:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--nav-active-bg);
    box-shadow: 0 2px 8px rgba(23,24,28,0.08);
}

/* Редактируемые ссылки-референсы (страница «Шаги») */
.step-links-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}
.step-links-edit {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 6px;
    flex-shrink: 0;
}
.step-links-edit:hover { background: var(--nav-active-bg); }

.niche-chip.link-empty,
.file-card.link-empty {
    opacity: 0.5;
    border-style: dashed;
}

.links-editor {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}
.links-editor-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.links-editor-label {
    flex: 0 0 190px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}
.links-editor-input {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    outline: none;
}
.links-editor-input:focus { border-color: var(--accent); }
.links-editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

/* Категории референсов / полезных ссылок */
.niches-grid { flex-direction: column; align-items: stretch; }

.rl-empty {
    font-size: 13px;
    color: var(--text-muted);
    padding: 8px 2px;
}

.rl-cat { width: 100%; margin-bottom: 18px; }
.rl-cat-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
}
.rl-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
}
.rl-card {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 12px 14px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 1px 4px rgba(20,20,43,0.04);
    min-width: 0;
}
.rl-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(20,20,43,0.08);
}
.rl-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rl-card-desc {
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.rl-card-host {
    font-size: 11px;
    color: var(--accent);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Редактор категорий */
.rl-editor { display: flex; flex-direction: column; gap: 10px; }
.rl-cat-edit {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    background: var(--column-bg);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.rl-cat-edit-hd { display: flex; align-items: center; gap: 8px; }
.rl-cat-name-input { font-weight: 600; }
.rl-link-row { display: flex; align-items: center; gap: 8px; }
.rl-link-row [data-f="title"] { flex: 0 0 32%; }
.rl-link-row [data-f="url"] { flex: 1; }
.rl-mini {
    align-self: flex-start;
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
}
.rl-mini:hover { border-color: var(--accent); background: var(--nav-active-bg); }
.rl-del {
    flex: 0 0 auto;
    color: var(--text-muted);
    padding: 6px 9px;
}
.rl-del:hover { color: var(--danger); border-color: var(--danger); background: transparent; }
.rl-add-cat { align-self: flex-start; }

[data-theme="dark"] .niche-chip,
[data-theme="dark"] .file-card {
    background: rgba(24,25,41,0.8);
    border-color: rgba(255,255,255,0.08);
}
[data-theme="dark"] .niche-chip:hover,
[data-theme="dark"] .file-card:hover {
    background: rgba(94,106,210,0.1);
    border-color: rgba(94,106,210,0.35);
}

/* ── Auth / Login ── */
html:not(.authed) .app-shell { display: none; }
html.authed .login-overlay { display: none; }

.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-card {
    width: 340px;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 32px 28px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
}

.login-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin-bottom: 6px;
}

.login-title {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 4px;
}

.login-card .settings-input {
    width: 100%;
    box-sizing: border-box;
}

.login-error {
    font-size: 13px;
    color: var(--danger);
    text-align: center;
}

.login-error.hidden { display: none; }

.login-submit {
    width: 100%;
    margin-top: 4px;
}

/* ── Polish: focus rings, status dots, tabular numerals ── */
:root { --focus-ring: 0 0 0 3px rgba(94, 106, 210, 0.16); }
[data-theme="dark"] { --focus-ring: 0 0 0 3px rgba(126, 140, 224, 0.22); }

.settings-input:focus,
.proj-input:focus,
.search-input:focus,
.lead-form input:focus,
.lead-form select:focus,
.lead-form textarea:focus,
.task-add input:focus,
.payment-add input:focus,
.comment-add textarea:focus,
.feed-input-row textarea:focus,
.form-section-bd textarea:focus {
    box-shadow: var(--focus-ring);
}

/* Linear-style status dot on stage badges */
[class*="stage-badge-"] {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

[class*="stage-badge-"]::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

/* Tabular numerals for data-dense numbers */
.dash-card-value,
.call-stat-value,
.funnel-count,
.funnel-value,
.card-deal-value,
.proj-card-value,
.psum-count,
.psum-amount,
.proj-done-amount,
.tr-due,
.pcal-amt,
.pcal-dn,
.payment-amount,
.dash-hero-pill strong,
.lead-phone-input {
    font-variant-numeric: tabular-nums;
}

/* ── Board: per-stage status dots on column headers ── */
.column-header span:first-child {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.column-header span:first-child::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--stage-dot, var(--text-muted));
    flex-shrink: 0;
}

.column[data-stage="new"]         { --stage-dot: #8a8f98; }
.column[data-stage="in_progress"] { --stage-dot: #5b8def; }
.column[data-stage="interested"]  { --stage-dot: #8b6fc4; }
.column[data-stage="callback"]    { --stage-dot: #e0a000; }
.column[data-stage="meeting"]     { --stage-dot: #2f9e6f; }
.column[data-stage="deal"]        { --stage-dot: #16a34a; }
.column[data-stage="rejected"]    { --stage-dot: #e5484d; }

/* ── Refined drag-over: dashed accent frame ── */
.column-cards.drag-over {
    background: rgba(94, 106, 210, 0.06);
    outline: 2px dashed rgba(94, 106, 210, 0.4);
    outline-offset: -2px;
    border-radius: var(--radius-md);
}

/* ── Subtle card hover lift ── */
.card {
    transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.card:hover {
    transform: translateY(-1px);
}

/* ── Accent text selection ── */
::selection { background: rgba(94, 106, 210, 0.22); }
[data-theme="dark"] ::selection { background: rgba(126, 140, 224, 0.30); }

/* ── Entrance animations ── */
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

@keyframes modalIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
}

@keyframes pageIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
}

.modal-overlay:not(.hidden) { animation: overlayIn 0.16s ease; }
.modal-overlay:not(.hidden) .modal { animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1); }
.toast:not(.hidden) { animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1); }
.page:not(.hidden) { animation: pageIn 0.18s ease; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================================
   Mobile / tablet adaptation
   ============================================================ */
@media (max-width: 768px) {
    body {
        padding: 0;
        display: block;
        -webkit-text-size-adjust: 100%;
    }

    .app-shell {
        flex-direction: column;
        min-height: 100vh;
        max-width: none;
        border-radius: 0;
        box-shadow: none;
    }
    [data-theme="dark"] .app-shell { box-shadow: none; }

    .main-area {
        border-radius: 0;
    }

    /* ── Sidebar → fixed top navigation bar (no horizontal scroll) ── */
    .sidebar {
        position: sticky;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        flex: none;
        flex-direction: row;
        align-items: center;
        gap: 2px;
        height: 54px;
        padding: 0 4px;
        border-radius: 0;
        border-right: none;
        border-bottom: 1px solid var(--border);
        z-index: 51;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    }
    .sidebar-logo,
    .sidebar-search-wrap,
    .sidebar-section-label,
    .sidebar-user-info,
    .nav-label { display: none; }

    .sidebar-nav {
        flex-direction: row;
        flex: 1;
        gap: 0;
        justify-content: space-around;
        overflow: visible;
        min-width: 0;
    }

    .nav-icon {
        flex: 1 1 0;
        min-width: 0;
        justify-content: center;
        gap: 0;
        padding: 8px 2px;
        border-radius: 10px;
    }
    .nav-icon .icon { width: 22px; height: 22px; }
    .nav-icon.active { box-shadow: inset 0 -3px 0 var(--accent); }
    [data-theme="dark"] .nav-icon.active { box-shadow: inset 0 -3px 0 var(--accent); }
    .nav-badge { top: 2px; right: 25%; }

    .sidebar-bottom {
        margin-top: 0;
        border-top: none;
        padding-top: 0;
        flex-shrink: 0;
        display: flex;
        align-items: center;
    }
    .sidebar-user-card { padding: 0 2px; gap: 2px; background: none; border: none; }

    /* Page nav bar sits above the topbar; topbar scrolls with content */
    .topbar {
        position: static;
        padding: 12px 14px 8px;
        gap: 8px;
    }
    .topbar h1 { font-size: 17px; }
    .topbar-actions { gap: 6px; }
    .topbar-actions .btn-primary { padding: 8px 12px; font-size: 13px; }

    .page { padding: 4px 12px 20px; }

    /* ── Dashboard ── */
    .dashboard { gap: 12px; }
    .dash-hero { flex-direction: column; align-items: flex-start; gap: 12px; }
    .dash-hero-right { flex-wrap: wrap; }
    .dash-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .dash-card { padding: 16px; }
    .dash-main-grid { grid-template-columns: 1fr; }

    /* ── Kanban board: swipeable full-width columns ── */
    .board {
        gap: 10px;
        min-height: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }
    .column {
        flex: 0 0 82vw;
        min-width: 82vw;
        max-height: calc(100vh - 220px);
        scroll-snap-align: start;
    }

    /* ── Projects ── */
    .projects-summary-row { grid-template-columns: 1fr; gap: 10px; margin-bottom: 16px; }
    .projects-content-row { flex-direction: column; gap: 16px; }
    .projects-done-sidebar { width: 100%; }
    .projects-grid { grid-template-columns: 1fr; }

    /* ── Tasks / steps ── */
    .tasks-page, .steps-page { max-width: none; }
    .task-add { flex-direction: column; align-items: stretch; }

    /* ── Generic modals → full-width bottom-anchored sheets ── */
    .modal-overlay { align-items: flex-end; }
    .modal {
        width: 100%;
        max-width: 100vw;
        max-height: 92vh;
        border-radius: 16px 16px 0 0;
    }
    .modal-wide { width: 100%; }
    .modal-project { width: 100%; max-width: 100vw; max-height: 92vh; border-radius: 16px 16px 0 0; }
    .proj-form-grid { grid-template-columns: 1fr; }

    /* ── Lead modal (CRM): stack the two panels, let the modal scroll ── */
    .modal-crm {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        flex-direction: column;
        border-radius: 0;
        overflow-y: auto;
    }
    .lead-panel-left {
        width: 100%;
        flex: none;
        border-right: none;
        border-bottom: 1px solid var(--border);
        overflow: visible;
    }
    .lead-panel-body { overflow: visible; }
    .lead-panel-right { overflow: visible; min-height: 60vh; }
    .lead-panel-right .modal-body { overflow: visible; }

    .lead-modal-tabs {
        padding: 0 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ── Tasks page: table → stacked cards (the 6-col grid collapses names on mobile) ── */
    .tasks-table-header { display: none; }
    .task-row {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        position: relative;
        padding: 12px 42px 12px 14px;
    }
    .task-row > input[type="checkbox"] { flex: 0 0 auto; order: 0; }
    .task-row > .tr-name { flex: 1 1 100%; order: 1; padding-right: 70px; }
    .task-row > .tr-due { flex: 0 0 auto; order: 2; }
    .task-row > .tr-stage { flex: 0 0 auto; order: 3; }
    .task-row > .tr-desc { flex: 1 1 100%; order: 4; white-space: normal; }
    .task-row > .tr-actions {
        position: absolute;
        top: 10px;
        right: 10px;
        order: 5;
    }
    .dash-section-tasks .task-row { padding-right: 14px; }

    /* ── Steps page: keep wide CSV table inside a scroll container ── */
    .step-item { gap: 12px; }
    .csv-format-block { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .csv-table { min-width: 460px; }

    /* ── Login ── */
    .login-card { width: 90vw; max-width: 360px; }
}

/* Hover effects don't belong on touch devices */
@media (hover: none) {
    .dash-card:hover { transform: none; }
    .card:hover { box-shadow: 0 2px 8px rgba(20, 20, 43, 0.06), 0 0 0 1px rgba(20,20,43,0.04); }
}
