:root {
    color-scheme: light;
    --bg: #f5f6f8;
    --surface: #ffffff;
    --border: #e3e6eb;
    --text: #1d2330;
    --muted: #6b7280;
    --primary: #2c4f8a;          /* GII logo navy */
    --primary-hover: #1f3a68;
    --primary-soft: #e8eef8;
    --danger: #dc2626;
    --sidebar: #ffffff;
    --sidebar-text: #4b5563;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.center { text-align: center; }

/* Layout */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--sidebar);
    color: var(--sidebar-text);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; color: var(--primary); font-weight: 700; font-size: 18px; padding: 0 10px 20px; }
.sidebar .brand:hover { text-decoration: none; }
.brand img { width: 44px; height: 44px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { color: var(--sidebar-text); padding: 8px 10px; border-radius: 6px; }
.sidebar nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.sidebar nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sidebar-footer { margin-top: auto; padding: 10px; display: flex; flex-direction: column; gap: 4px; }

.content { flex: 1; min-width: 0; padding: 24px 28px; }

.page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.section-header h2 { margin: 0; }

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

.flash {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.block { width: 100%; justify-content: center; }
.btn.disabled { opacity: .5; pointer-events: none; }
button.link { background: none; border: 0; padding: 0; color: var(--sidebar-text); cursor: pointer; font: inherit; text-align: left; }
button.link:hover { color: var(--primary); }
.profile-link { color: var(--sidebar-text); }
.profile-link.active, .profile-link:hover { color: var(--primary); }
.profile { align-items: start; }

.mail-settings .section-header { margin-bottom: 4px; }
.mail-settings p { margin: 0; }
.mail-result { margin-top: 10px !important; padding: 8px 12px; border-radius: 6px; }
.mail-result.ok { background: #ecfdf5; color: #065f46; }
.mail-result.fail { background: #fef2f2; color: #991b1b; }

/* Email campaigns */
.notice { background: var(--primary-soft); border: 1px solid #c9d6ec; color: var(--text); padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; }
.notice.warn { background: #fffbeb; border-color: #fcd34d; }
.notice.fail { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.badge.campaign-draft { background: #64748b; }
.badge.campaign-sending { background: #2563eb; }
.badge.campaign-completed { background: #16a34a; }
.badge.campaign-cancelled { background: #9ca3af; }
.badge.recipient-pending { background: #94a3b8; }
.badge.recipient-sent { background: #16a34a; }
.badge.recipient-failed { background: #dc2626; }
.badge.recipient-skipped { background: #9ca3af; }
.campaign { align-items: start; margin-bottom: 16px; }
.preview { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 14px; margin: 10px 0 6px; max-height: 340px; overflow: auto; }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.recipients .section-header { padding: 16px 18px 0; }
.stat .badge { font-size: 14px; }
code { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; font-size: 12px; }

.limits { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.limits div { flex: 1 1 160px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; display: flex; flex-direction: column; }
.limits strong { font-size: 18px; color: var(--primary); }
.limits span { font-size: 12px; color: var(--muted); }
.notice.small { font-size: 12px; margin: 0 0 10px; }

/* Lead form */
input.input-error { border-color: var(--danger); }
.form-actions .send-email { margin-right: auto; }
.nowrap { white-space: nowrap; }
.email-preview { background: #fff; }
.email-preview img { max-width: 100%; height: auto; }
.email-preview table { border-collapse: collapse; }
.email-preview td, .email-preview th { border: 1px solid var(--border); padding: 4px 8px; }
.email-preview p { margin: 0 0 10px; }
.jodit-container { font-weight: 400; }
.phones .phone-row { display: flex; align-items: center; gap: 6px; }
.phones .phone-row + .phone-row { margin-top: 4px; }
.call-btn { padding: 2px 8px; color: #fff; background: #16a34a; border-color: #16a34a; }
.call-btn:hover { background: #15803d; border-color: #15803d; color: #fff; }
.leads-table td, .leads-table th { padding: 10px 10px; }
.badge.category-technical { background: #0e7490; }
.badge.category-managerial { background: #7c3aed; }
.call-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.call-form { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; margin-top: 8px; }
.call-form .span-all { grid-column: 1 / -1; }
.history-notes { white-space: pre-line; color: var(--muted); border-left: 3px solid var(--border); padding-left: 8px; margin-top: 2px; }
@media (max-width: 800px) { .call-form { grid-template-columns: 1fr; } }
input.input-error:focus { outline-color: var(--danger); }
.phone-field { display: flex; gap: 6px; }
.phone-field select { flex: 0 0 42%; min-width: 0; }
.phone-field input { flex: 1; min-width: 0; }
.assignees { border: 0; padding: 0; margin: 0 0 12px; min-width: 0; font-weight: 500; }
.assignees legend { padding: 0; margin-bottom: 4px; }
.assignee-list { max-height: 150px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-weight: 400; }
.form .assignee-list label.checkbox { margin-bottom: 4px; }
.meeting-form { display: grid; grid-template-columns: 240px 1fr auto; gap: 12px; align-items: start; margin-bottom: 8px; }
.meeting-form label { margin-bottom: 0; }
.meeting-form .btn { margin-top: 24px; }
.meeting-actions { display: inline-flex; gap: 6px; flex-shrink: 0; }
.history-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.history-item:last-child { border-bottom: 0; }

/* Meetings */
.badge.meeting-scheduled { background: var(--primary); }
.badge.meeting-done { background: #16a34a; }
.badge.meeting-cancelled { background: #9ca3af; }
.badge.meeting-overdue { background: #dc2626; }
.nav-badge { background: #dc2626; color: #fff; border-radius: 999px; font-size: 11px; font-weight: 600; padding: 1px 7px; margin-left: 4px; }
.calendar-wrap { overflow-x: auto; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(110px, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.calendar-head { padding: 6px 8px; font-size: 12px; font-weight: 600; color: var(--muted); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.calendar-day { min-height: 92px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); min-width: 0; }
.calendar-day.other-month { background: var(--bg); color: var(--muted); }
.calendar-day.today { background: var(--primary-soft); }
.calendar-date { font-size: 12px; font-weight: 600; }
.calendar-event { display: block; font-size: 12px; padding: 2px 6px; margin-top: 3px; border-radius: 4px; background: var(--primary); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calendar-event:hover { text-decoration: none; background: var(--primary-hover); }
.calendar-event.done { background: #9ca3af; text-decoration: line-through; }
.calendar-event.overdue { background: #dc2626; }
.meeting-alert { position: fixed; right: 16px; bottom: 16px; z-index: 50; width: min(340px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border); border-left: 4px solid #f59e0b; border-radius: var(--radius); box-shadow: 0 10px 28px rgba(16, 24, 40, .2); padding: 12px 14px; }
.meeting-alert[hidden] { display: none; }
.meeting-alert-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.meeting-alert-close { border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.meeting-alert ul { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

@media (max-width: 800px) {
    .meeting-form { grid-template-columns: 1fr; }
    .meeting-form .btn { margin-top: 0; }
    .list-row { flex-wrap: wrap; }
}

/* Lead import */
.import { align-items: start; }
.import .hint { margin: -6px 0 12px; }
.import-report { border-left: 4px solid #16a34a; }
.import-report.has-issues { border-left-color: #f59e0b; }
.import-report h3 { font-size: 14px; margin: 14px 0 6px; }
.report-list { margin: 0; padding-left: 18px; color: var(--muted); }
.format th { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); width: 110px; padding: 6px 10px 6px 0; }
.format td { padding: 6px 0; color: var(--muted); }

/* Forms */
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; margin-bottom: 12px; }
.form label.checkbox { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

input, select, textarea {
    font: inherit;
    font-weight: 400;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    width: 100%;
}
input[type="checkbox"] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.error { color: var(--danger); font-size: 12px; font-weight: 400; margin: -8px 0 10px; }
.form-grid .error { margin: 0; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters input { max-width: 340px; }
.filters select { max-width: 180px; }

.danger-zone { margin-top: 8px; }

/* Guest pages */
body.guest { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 18px; color: var(--primary); font-size: 20px; }
.auth-card .brand img { width: 96px; height: 96px; }
.login-options { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.login-options .checkbox { margin-bottom: 0; }
.login-options a { font-size: 13px; }
.auth-switch { text-align: center; margin: 14px 0 0; color: var(--muted); }
.auth-switch[hidden] { display: none; }

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 18px; }
.tabs a { flex: 1; text-align: center; padding: 8px 10px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }

.password-field { position: relative; display: block; }
.password-field input { padding-right: 64px; }
.password-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    border: 0;
    background: none;
    color: var(--primary);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 4px;
}
.password-toggle:hover { background: var(--bg); }

/* Tables */
.table-wrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
.team { margin-top: 16px; }
.team .section-header { padding: 16px 18px 0; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: #e5e7eb; color: #fff; }
.status-new { background: #3b82f6; }
.status-contacted { background: #8b5cf6; }
.status-qualified { background: #16a34a; }
.status-unqualified { background: #9ca3af; }
.status-converted { background: #0f766e; }
.role-admin { background: var(--primary); }
.role-user { background: #64748b; }

/* Dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 16px; }
.stats .card { margin: 0; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat strong { font-size: 24px; }
a.stat { color: var(--text); }
a.stat:hover { text-decoration: none; border-color: var(--primary); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 .card { margin: 0; }
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.bar-label { display: flex; justify-content: space-between; margin-bottom: 4px; color: var(--text); }
a.bar-label:hover { text-decoration: none; color: var(--primary); }
.bar { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 999px; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); color: var(--text); }
.list-row:last-child { border-bottom: 0; }
.list-row:hover { text-decoration: none; background: var(--bg); }

/* Kanban board */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.column {
    flex: 0 0 270px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 140px);
}
.column header { padding: 12px 14px; border-top: 4px solid; border-radius: var(--radius) var(--radius) 0 0; border-bottom: 1px solid var(--border); }
.column header > div { display: flex; justify-content: space-between; }
.column .cards { padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; overflow-y: auto; flex: 1; }
.column.drag-over .cards { background: var(--bg); }
.deal { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px; cursor: grab; }
.deal.dragging { opacity: .4; }
.deal-value { font-weight: 600; margin: 2px 0; }
.add-deal { padding: 10px 14px; border-top: 1px solid var(--border); color: var(--muted); }

@media (max-width: 800px) {
    .shell { flex-direction: column; }
    .sidebar { width: auto; flex-direction: row; align-items: center; padding: 10px 16px; gap: 12px; flex-wrap: wrap; }
    .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
    .sidebar .brand { padding: 0; }
    .sidebar .brand img { width: 36px; height: 36px; }
    .sidebar nav { flex-direction: row; }
    .sidebar-footer { margin: 0 0 0 auto; flex-direction: row; align-items: center; gap: 10px; padding: 0; }
    .content { padding: 16px; }
    .form-grid, .grid-2 { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
    .filters { flex-wrap: wrap; }
    .filters input, .filters select { max-width: none; }
}
