:root {
    --bg: #f5f7fb;
    --card: #ffffff;
    --border: #e1e6f0;
    --fg: #0e1116;
    --muted: #6b7280;
    --brand: #003DA5;
    --primary: #1e56c6;
    --primary-hover: #003DA5;
    --brand-soft: #e6ecf7;
    --ok: #1f9e4b;
    --bad: #d12e2e;
    --warn: #b35a00;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", system-ui, sans-serif;
}

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

/* ───── topbar ───── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: .8rem 1.4rem;
    box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.brand { display: flex; align-items: center; gap: .8rem; color: inherit; }
.brand:hover { text-decoration: none; }
.brand .logo { height: 32px; }
.brand h1 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.brand .sub { color: var(--muted); font-size: .8rem; }
.topbar-actions { display: flex; gap: .5rem; align-items: center; }

/* ───── container & tabs ───── */
.container {
    max-width: 1500px;
    margin: 1.2rem auto;
    padding: 0 1.4rem;
}

.tabs {
    display: flex;
    gap: .25rem;
    margin-bottom: .8rem;
    border-bottom: 1px solid var(--border);
}
.tab {
    padding: .55rem 1rem;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}
.tab:hover { color: var(--fg); text-decoration: none; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab .cnt {
    background: var(--brand-soft);
    color: var(--brand);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: .72rem;
    font-weight: 600;
}
.tab.active .cnt { background: var(--brand); color: #fff; }

.filters {
    display: flex;
    gap: .5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}
.filters select, .filters input[type=search] {
    padding: .45rem .7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    font-size: .88rem;
    color: var(--fg);
    min-width: 180px;
}
.filters input[type=search] { min-width: 280px; }
.filters select:focus, .filters input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

/* ───── table ───── */
.table-wrap {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow-x: auto;
}
table.rows {
    width: 100%;
    min-width: 1200px;
    border-collapse: collapse;
    font-size: .87rem;
}
table.rows thead th {
    text-align: left;
    padding: .7rem .9rem;
    background: #f9fbff;
    color: var(--muted);
    font-weight: 600;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
}
table.rows tbody td {
    padding: .7rem .9rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
table.rows tbody tr:last-child td { border-bottom: none; }
table.rows tbody tr:hover { background: #fafcff; }
table.rows tbody tr.overdue { background: #fff5f5; }
table.rows tbody tr.overdue:hover { background: #ffeaea; }

.subj { max-width: 280px; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.bad { color: var(--bad); }

td.actions {
    white-space: nowrap;
    text-align: right;
}
td.actions form {
    display: inline-block;
    margin: 0 0 .25rem .25rem;
}

/* ───── tags ───── */
.tag {
    display: inline-block;
    padding: 1px 7px;
    font-size: .68rem;
    font-weight: 600;
    border-radius: 4px;
    background: var(--brand-soft);
    color: var(--brand);
    margin-right: .3rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    vertical-align: 1px;
}
.tag-deal    { background: #e6f5ec; color: #1f7a40; }
.tag-lead    { background: var(--brand-soft); color: var(--brand); }
.tag-contact { background: #fff3e0; color: #b35a00; }
.tag-company { background: #f0e6f5; color: #6c2bb3; }

/* ───── badges ───── */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-new          { background: #fdecec; color: var(--bad); }
.badge-in_progress  { background: #fff3df; color: var(--warn); }
.badge-done         { background: #e6f5ec; color: var(--ok); }

/* ───── buttons ───── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: .5rem 1rem;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 1px 2px rgba(0,61,165,.18);
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
    background: #fff;
    color: var(--brand);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--brand-soft); border-color: var(--brand); }

.btn-ghost {
    background: transparent;
    color: var(--muted);
}
.btn-ghost:hover { background: var(--brand-soft); color: var(--brand); }

/* ───── empty ───── */
.empty {
    background: var(--card);
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    color: var(--muted);
}

/* ───── login ───── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.login-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 2rem;
    width: 100%;
    max-width: 360px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,61,165,.06);
}
.login-card .logo { height: 44px; margin-bottom: .8rem; }
.login-card h1 { margin: 0 0 .25rem; font-size: 1.2rem; }
.login-card p.muted { margin: 0 0 1.2rem; }
.login-card input {
    width: 100%;
    padding: .65rem .8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: .8rem;
    font-size: .95rem;
    text-align: center;
}
.login-card input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
.login-card .btn { width: 100%; }
.login-card .error {
    background: #fdecec;
    color: var(--bad);
    border-radius: 8px;
    padding: .5rem;
    margin-bottom: .8rem;
    font-size: .85rem;
}
