:root {
  color-scheme: dark;
  --bg: #0b0d18;
  --surface: #111426;
  --surface-2: #181c31;
  --surface-3: #20253d;
  --border: #2b314d;
  --border-strong: #3b4365;
  --text: #f7f8fc;
  --muted: #a9b0c7;
  --subtle: #7f89a5;
  --accent: #ff8a3d;
  --accent-strong: #ff7024;
  --accent-soft: #3b251f;
  --positive: #49c792;
  --warning: #f4bd58;
  --danger: #ff6b72;
  --info: #7ba7ff;
  --focus: #b7ccff;
  --shadow: 0 24px 80px rgba(0, 0, 0, .38);
  --radius: 16px;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 80% -10%, #20254a 0, transparent 32rem), var(--bg); color: var(--text); line-height: 1.5; }
body.drawer-open { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button, select, input[type="checkbox"] { cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 16px; top: -60px; z-index: 100; padding: 12px 16px; border-radius: 10px; background: var(--accent); color: #17100d; font-weight: 800; }
.skip-link:focus { top: 16px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 26px 18px; display: flex; flex-direction: column; border-right: 1px solid var(--border); background: rgba(13, 16, 30, .9); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand--centered { justify-content: center; padding: 0; }
.brand__mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: var(--accent); color: #1a110c; box-shadow: 0 8px 24px rgba(255, 112, 36, .25); }
.brand__mark svg { width: 25px; fill: currentColor; }
.brand strong, .brand small, .user-chip strong, .user-chip small, .sidebar__footer strong, .sidebar__footer small { display: block; }
.brand strong { letter-spacing: .01em; }
.brand small, .user-chip small, .sidebar__footer small { color: var(--muted); font-size: 12px; }
nav { display: grid; gap: 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 13px; border-radius: 11px; color: var(--muted); text-decoration: none; font-weight: 650; transition: background-color .2s ease, color .2s ease; }
.nav-item svg { width: 20px; fill: currentColor; }
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item--active { color: var(--text); background: var(--surface-3); box-shadow: inset 3px 0 var(--accent); }
.sidebar__footer { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 14px 10px 0; border-top: 1px solid var(--border); }
.system-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--positive); box-shadow: 0 0 0 4px rgba(73, 199, 146, .12); }

.workspace { min-width: 0; }
.topbar { min-height: 88px; display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 18px clamp(20px, 3vw, 44px); border-bottom: 1px solid var(--border); background: rgba(11, 13, 24, .72); backdrop-filter: blur(18px); }
.topbar h1, .queue-card h2, .drawer__header h2, .action-dialog h2, .login-card h1 { margin: 0; line-height: 1.15; }
.topbar h1 { font-size: 27px; }
.eyebrow { margin: 0 0 4px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.topbar__actions { display: flex; align-items: center; gap: 12px; }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--muted); transition: border-color .2s ease, background-color .2s ease, color .2s ease; }
.icon-button:hover { border-color: var(--border-strong); background: var(--surface-2); color: var(--text); }
.icon-button svg { width: 20px; fill: currentColor; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 7px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.user-chip__avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: linear-gradient(135deg, #3c4570, #222741); color: var(--text); font-size: 12px; font-weight: 800; }
.text-button { min-height: 44px; padding: 0 10px; border: 0; background: transparent; color: var(--muted); }
.text-button:hover { color: var(--text); }

main { padding: 28px clamp(20px, 3vw, 44px) 56px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.metric-card { width: 100%; min-height: 126px; padding: 18px 20px; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(145deg, rgba(30,35,59,.9), rgba(17,20,38,.95)); color: var(--text); text-align: left; transition: border-color .2s ease, background-color .2s ease, box-shadow .2s ease; }
.metric-card:hover { border-color: var(--border-strong); }
.metric-card--accent { border-color: #6c4431; background: linear-gradient(145deg, #35231e, #171725); }
.metric-card[aria-pressed="true"] { box-shadow: inset 0 -3px var(--accent); }
.metric-card span { color: var(--muted); font-size: 13px; font-weight: 700; }
.metric-card strong { margin: 6px 0 2px; font-size: 32px; line-height: 1; }
.metric-card small { margin-top: auto; color: var(--subtle); }

.queue-card { position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: 18px; background: rgba(17, 20, 38, .93); box-shadow: var(--shadow); }
.queue-card__header { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.queue-card__header h2 { font-size: 19px; }
.queue-card__header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.filter-toggle { min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 14px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-2); color: var(--text); font-weight: 700; }
.filter-toggle svg { width: 18px; fill: currentColor; }
.filter-toggle span { color: var(--accent); }
.filters { padding: 18px 22px; border-bottom: 1px solid var(--border); background: #0f1221; }
.filters[data-open="false"] { display: none; }
.status-filter { margin: 0 0 16px; padding: 0; border: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.status-filter legend { width: 100%; margin-bottom: 7px; color: var(--muted); font-size: 12px; font-weight: 750; }
.status-filter label { position: relative; }
.status-filter input { position: absolute; opacity: 0; pointer-events: none; }
.status-filter span { min-height: 38px; display: flex; align-items: center; padding: 0 13px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 13px; font-weight: 700; transition: .2s ease; }
.status-filter input:checked + span { border-color: #bb6134; background: var(--accent-soft); color: #ffc19b; }
.status-filter input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 3px; }
.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; }
.filter-grid label, .dialog__fields label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
select, input, textarea { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); }
textarea { min-height: 90px; padding-block: 10px; resize: vertical; }
select:hover, input:hover, textarea:hover { border-color: var(--border-strong); }
.filters__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.button { min-height: 44px; padding: 0 16px; border: 1px solid transparent; border-radius: 11px; font-weight: 800; transition: background-color .2s ease, border-color .2s ease, color .2s ease; }
.button--primary { background: var(--accent); color: #1c110b; }
.button--primary:hover { background: var(--accent-strong); }
.button--ghost { border-color: var(--border); background: var(--surface-2); color: var(--text); }
.button--ghost:hover { border-color: var(--border-strong); background: var(--surface-3); }
.button--danger { border-color: #71383e; background: #321d25; color: #ffafb4; }
.button--danger:hover { background: #43212a; }
.loading-bar { position: absolute; z-index: 5; top: 0; left: 0; right: 0; height: 3px; overflow: hidden; background: var(--accent-soft); }
.loading-bar::after { content: ""; display: block; width: 32%; height: 100%; background: var(--accent); animation: loading 1s ease-in-out infinite; }
@keyframes loading { from { transform: translateX(-100%); } to { transform: translateX(410%); } }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 920px; }
th { height: 44px; padding: 0 16px; background: #0f1221; color: var(--subtle); font-size: 11px; letter-spacing: .05em; text-align: left; text-transform: uppercase; }
td { padding: 15px 16px; border-top: 1px solid var(--border); vertical-align: middle; }
tbody tr { transition: background-color .18s ease; }
tbody tr:hover { background: rgba(40, 46, 73, .55); }
.lead-main { display: grid; gap: 3px; }
.lead-main strong { font-size: 14px; }
.lead-main span, .cell-stack span { color: var(--muted); font-size: 12px; }
.cell-stack { display: grid; gap: 3px; }
.status-badge { width: max-content; min-height: 28px; display: inline-flex; align-items: center; gap: 7px; padding: 0 9px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 12px; font-weight: 800; }
.status-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-badge[data-status="new"] { border-color: #744529; background: #2f211c; color: #ffae75; }
.status-badge[data-status="taken"], .status-badge[data-status="contacted"] { color: var(--info); }
.status-badge[data-status="qualified"], .status-badge[data-status="won"] { color: var(--positive); }
.status-badge[data-status="lost"], .status-badge[data-status="spam"] { color: var(--danger); }
.overdue { color: var(--danger) !important; font-weight: 750; }
.row-open { width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); }
.row-open:hover { background: var(--surface-3); color: var(--text); }
.row-open svg { width: 18px; fill: currentColor; }
.mobile-list { display: none; }
.pagination { min-height: 58px; padding: 8px 20px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border); }

.tasks-screen { display: grid; gap: 16px; }
.tasks-toolbar { display: flex; justify-content: space-between; align-items: end; gap: 16px; }
.segmented, .task-buckets { display: flex; flex-wrap: wrap; gap: 8px; }
.segmented button, .task-buckets button { min-height: 44px; padding: 0 15px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); color: var(--muted); font-weight: 750; transition: border-color .2s ease, background-color .2s ease, color .2s ease; }
.segmented button:hover, .task-buckets button:hover { border-color: var(--border-strong); color: var(--text); }
.segmented button[aria-pressed="true"], .task-buckets button[aria-pressed="true"] { border-color: #bb6134; background: var(--accent-soft); color: #ffc19b; box-shadow: inset 0 -2px var(--accent); }
.task-manager-filter { min-width: 220px; display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.task-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.button--compact { min-height: 38px; padding-inline: 11px; font-size: 12px; }
.task-card { padding: 16px; border-top: 1px solid var(--border); }
.task-card__top { display: flex; justify-content: space-between; gap: 12px; }
.task-card h3 { margin: 10px 0 4px; font-size: 16px; }
.task-card p { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.task-card small { display: block; margin-bottom: 14px; color: var(--subtle); }

.drawer-backdrop { position: fixed; z-index: 30; inset: 0; background: rgba(3, 4, 10, .66); backdrop-filter: blur(4px); }
.lead-drawer { position: fixed; z-index: 40; top: 0; right: 0; width: min(570px, 100vw); height: 100vh; display: grid; grid-template-rows: auto 1fr auto; background: #101322; border-left: 1px solid var(--border); box-shadow: -30px 0 90px rgba(0,0,0,.45); transform: translateX(105%); transition: transform .25s ease; }
.lead-drawer[aria-hidden="false"] { transform: translateX(0); }
.drawer__header { display: flex; justify-content: space-between; gap: 20px; padding: 22px 24px; border-bottom: 1px solid var(--border); }
.drawer__header h2 { font-size: 22px; }
.drawer__body { overflow-y: auto; padding: 22px 24px 110px; }
.drawer__actions { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); background: rgba(16, 19, 34, .96); backdrop-filter: blur(12px); }
.detail-hero { padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: linear-gradient(145deg, var(--surface-2), #141729); }
.detail-hero__top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.detail-hero__contact { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 15px; }
.contact-link { min-height: 42px; display: inline-flex; align-items: center; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); text-decoration: none; font-weight: 700; }
.contact-link:hover { border-color: var(--accent); }
.detail-section { padding: 20px 2px; border-bottom: 1px solid var(--border); }
.detail-section h3 { margin: 0 0 13px; font-size: 14px; }
.detail-section p { margin: 0; color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.detail-grid--spaced { margin-top: 14px; }
.detail-field { min-width: 0; }
.detail-field span { display: block; margin-bottom: 3px; color: var(--subtle); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.detail-field strong { display: block; overflow-wrap: anywhere; font-size: 13px; }
.timer-card { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.timer-card strong, .timer-card span { display: block; }
.timer-card span { color: var(--muted); font-size: 12px; }
.timer-value { color: var(--warning); font-variant-numeric: tabular-nums; }
.timeline { position: relative; display: grid; gap: 0; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 10px; bottom: 10px; width: 1px; background: var(--border); }
.timeline-item { position: relative; padding: 0 0 17px 28px; }
.timeline-item::before { content: ""; position: absolute; left: 4px; top: 6px; width: 9px; height: 9px; border: 2px solid #101322; border-radius: 50%; background: var(--info); box-shadow: 0 0 0 1px var(--border-strong); }
.timeline-item strong, .timeline-item span { display: block; }
.timeline-item strong { font-size: 13px; }
.timeline-item span { color: var(--muted); font-size: 12px; }
.technical { padding: 14px; border-radius: 12px; background: #0b0d18; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; color: #b9c4df; overflow-wrap: anywhere; }

.action-dialog { width: min(500px, calc(100vw - 28px)); padding: 0; border: 1px solid var(--border-strong); border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.action-dialog::backdrop { background: rgba(3,4,10,.72); backdrop-filter: blur(5px); }
.dialog__header { display: flex; justify-content: space-between; gap: 18px; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.dialog__fields { display: grid; gap: 14px; padding: 20px 22px; }
.dialog__footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-actions button { min-height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); color: var(--text); }
.form-hint, .field-label { color: var(--muted); font-size: 12px; }
.field-label { margin: 0 0 8px; font-weight: 750; }

.empty-state { min-height: 130px; display: grid; place-content: center; gap: 5px; padding: 24px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--text); }
.empty-state--queue { border-top: 1px solid var(--border); }
.toast { position: fixed; z-index: 80; right: 22px; bottom: 22px; max-width: min(420px, calc(100vw - 44px)); padding: 14px 17px; border: 1px solid var(--border-strong); border-radius: 12px; background: #242a43; color: var(--text); box-shadow: var(--shadow); font-weight: 650; }
.toast[data-tone="error"] { border-color: #71383e; background: #321d25; }
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(470px, 100%); padding: 30px; border: 1px solid var(--border); border-radius: 22px; background: rgba(17, 20, 38, .95); box-shadow: var(--shadow); }
.login-card__copy { margin: 28px 0 22px; text-align: center; }
.login-card__copy h1 { font-size: 27px; }
.login-card__copy p:last-child { color: var(--muted); }
.demo-users { display: grid; gap: 10px; }
.credential-login { display: grid; gap: 14px; }
.credential-login label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
.credential-login input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); }
.credential-login .button { width: 100%; margin-top: 2px; }
.form-error { min-height: 20px; margin: 0; color: var(--danger); font-size: 13px; text-align: center; }
.demo-user { min-height: 58px; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--text); text-align: left; }
.demo-user:hover { border-color: var(--accent); }
.demo-user span, .demo-user small { display: block; }
.demo-user small { color: var(--muted); }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 78px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .brand { padding-inline: 7px; justify-content: center; }
  .brand > span:last-child, .nav-item:not(.nav-item--active)::after, .nav-item { font-size: 0; }
  .nav-item { justify-content: center; padding: 0; }
  .nav-item svg { width: 22px; }
  .sidebar__footer span:last-child { display: none; }
  .sidebar__footer { justify-content: center; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .filter-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; top: auto; width: auto; height: 70px; padding: 8px 14px; flex-direction: row; justify-content: center; border: 1px solid var(--border); border-radius: 18px 18px 0 0; }
  .sidebar .brand, .sidebar__footer { display: none; }
  .sidebar nav { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .nav-item, .nav-item:not(.nav-item--active)::after { font-size: 12px; }
  .nav-item { flex-direction: column; gap: 2px; min-height: 52px; }
  .nav-item svg { width: 20px; }
  .nav-item--active { box-shadow: inset 0 -3px var(--accent); }
  .topbar { min-height: 76px; padding: 14px 16px; }
  .topbar h1 { font-size: 23px; }
  .topbar .eyebrow, .user-chip span:last-child, .text-button { display: none; }
  .user-chip { padding: 5px; }
  main { padding: 18px 14px 100px; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card { min-height: 108px; padding: 15px; }
  .metric-card strong { font-size: 27px; }
  .queue-card__header { padding: 17px 16px; }
  .filters { display: none; position: fixed; z-index: 60; left: 10px; right: 10px; bottom: 10px; max-height: calc(100vh - 20px); overflow-y: auto; border: 1px solid var(--border-strong); border-radius: 18px; box-shadow: var(--shadow); }
  .filters[data-open="true"] { display: block; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .filters__actions { position: sticky; bottom: -18px; margin: 16px -22px -18px; padding: 13px 22px; background: #0f1221; border-top: 1px solid var(--border); }
  .table-wrap { display: none; }
  .mobile-list { display: grid; }
  .task-table-wrap { display: none; }
  .tasks-toolbar { align-items: stretch; flex-direction: column; }
  .task-manager-filter { min-width: 0; }
  .task-buckets { display: grid; grid-template-columns: 1fr 1fr; }
  .task-buckets button { padding-inline: 8px; }
  .task-actions .button { flex: 1 1 calc(50% - 4px); }
  .lead-card { padding: 16px; border-top: 1px solid var(--border); background: transparent; color: var(--text); text-align: left; }
  .lead-card:hover { background: var(--surface-2); }
  .lead-card__top, .lead-card__meta { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
  .lead-card__top strong { font-size: 15px; }
  .lead-card__top strong, .lead-card__top small { display: block; }
  .lead-card__summary { margin: 10px 0; color: var(--muted); font-size: 13px; }
  .lead-card__meta { color: var(--subtle); font-size: 12px; }
  .pagination { padding-inline: 16px; }
  .lead-drawer { width: 100vw; }
  .drawer__header, .drawer__body, .drawer__actions { padding-inline: 18px; }
  .drawer__actions { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .detail-grid { grid-template-columns: 1fr; }
  .toast { left: 16px; right: 16px; bottom: 86px; max-width: none; }
}

@media (max-width: 470px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 102px; }
  .metric-card small { font-size: 11px; }
  .filter-grid { grid-template-columns: 1fr; }
  .filter-toggle { padding-inline: 11px; }
  .queue-card__header p { display: none; }
  .drawer__actions .button { flex: 1 1 calc(50% - 6px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
