:root {
    --bg: #f4f1f5;
    --surface: #ffffff;
    --fg: #241b29;
    --muted: #8a7f91;
    --accent: #7b1f3a;          /* черника/ягода */
    --accent-2: #a8324f;
    --accent-soft: #f6e8ee;
    --green: #2f7d4f;           /* лисички/свежесть */
    --border: #ece6ef;
    --shadow: 0 1px 3px rgba(40, 20, 45, .06), 0 8px 24px rgba(40, 20, 45, .05);
    --radius: 14px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: var(--bg);
    color: var(--fg);
    font-size: 14px;
    line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 28px 0 12px; }
.muted { color: var(--muted); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
    background: linear-gradient(180deg, #2a1020 0%, #3b1730 100%);
    color: #f3e9ee;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { font-size: 19px; font-weight: 700; letter-spacing: -.02em; margin: 4px 8px 26px; }
.brand span { color: #e7a9bc; }
.brand-mark { margin-right: 4px; }

.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side-nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; border-radius: 10px;
    color: #d9c7d0; font-weight: 500; text-decoration: none;
    transition: background .15s, color .15s;
}
.side-nav a .ic { font-size: 15px; width: 18px; text-align: center; }
.side-nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.side-nav a.active { background: rgba(255,255,255,.14); color: #fff; }

.side-user { display: flex; align-items: center; gap: 11px; padding: 12px 8px 4px; border-top: 1px solid rgba(255,255,255,.1); margin-top: 12px; }
.avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--accent-2); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px;
}
.su-meta { display: flex; flex-direction: column; line-height: 1.25; }
.su-name { font-weight: 600; color: #fff; }
.su-meta a { color: #cf9fae; font-size: 12px; }

.content { padding: 30px 36px; max-width: 1200px; }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; margin: 18px 0 8px; }
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}
.card-value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.card-label { color: var(--muted); font-size: 12.5px; margin-top: 4px; text-transform: lowercase; }
.card.accent { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%); border: 0; color: #fff; }
.card.accent .card-label { color: rgba(255,255,255,.8); }

/* ---------- panels & tables ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
.panel table { box-shadow: none; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); }
th { background: #faf7fb; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfafd; }

/* ---------- badges / statuses ---------- */
.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; display: inline-block; }
.status { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-pending, .b-new { background: #eef0f3; color: #5b6470; }
.status-running { background: #fff3d4; color: #8a6500; }
.status-done, .b-client { background: #def3e4; color: #1f6b3c; }
.status-error, .b-declined { background: #fde0e0; color: #b00020; }
.b-sent { background: var(--accent-soft); color: var(--accent); }
.b-replied { background: #e3edff; color: #2a52a8; }

/* ---------- forms / buttons ---------- */
.btn, button.btn, .filters button, .parse-form button, .row-edit button {
    padding: 9px 15px; border: 0; border-radius: 9px;
    background: var(--accent); color: #fff; cursor: pointer; font-size: 14px; font-weight: 600;
}
.btn:hover { opacity: .93; text-decoration: none; }
.btn.ghost { background: var(--surface); color: var(--accent); border: 1px solid var(--border); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 16px 0; }
.filters select, .filters input,
.parse-form input, .parse-form select,
.row-edit select, .row-edit input {
    padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); font-size: 13.5px;
}
.filters select:focus, .filters input:focus, .parse-form input:focus, .parse-form select:focus {
    outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-soft);
}

.row-edit { display: flex; gap: 6px; align-items: center; }
.row-edit button { padding: 6px 11px; }

.parse-form { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin: 16px 0; box-shadow: var(--shadow); }
.parse-form .field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }
.parse-form .field label { font-weight: 600; }

.pager { display: flex; gap: 16px; align-items: center; margin: 18px 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 6px; }
.head-actions { display: flex; gap: 8px; }

.btn-del { background: transparent; border: 0; cursor: pointer; font-size: 15px; opacity: .6; padding: 4px; }
.btn-del:hover { opacity: 1; }

/* --- CRM доска --- */
.crm-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: start; }
.crm-col { background: #faf7fb; border: 1px solid var(--border); border-radius: 12px; padding: 10px; min-height: 80px; }
.crm-col-head { font-weight: 600; font-size: 13px; padding: 4px 6px 10px; display: flex; align-items: center; gap: 8px; }
.crm-count { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 1px 8px; font-size: 12px; }
.crm-empty { padding: 6px; font-size: 13px; }
.crm-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 11px; margin-bottom: 10px; box-shadow: var(--shadow); }
.crm-card-head { font-weight: 600; font-size: 14px; }
.crm-card-sub { color: var(--muted); font-size: 12px; margin: 3px 0 8px; }
.crm-edit { display: flex; flex-direction: column; gap: 7px; }
.crm-edit textarea { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; font-size: 13px; resize: vertical; font-family: inherit; }
.crm-edit select, .crm-edit input[type=date] { border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; font-size: 12.5px; }
.crm-edit-row { display: flex; gap: 6px; }
.crm-edit-row select { flex: 1; }
.crm-date { display: flex; flex-direction: column; font-size: 10px; color: var(--muted); gap: 2px; }
.crm-edit button { align-self: flex-start; padding: 6px 14px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; }

@media (max-width: 900px) { .crm-board { grid-template-columns: 1fr 1fr; } }

/* ---------- login ---------- */
.login-page {
    margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(1200px 600px at 70% -10%, #5c1d36 0%, #2a1020 55%, #1b0a16 100%);
}
.login-card {
    background: var(--surface); border-radius: 18px; padding: 36px 34px; width: 340px;
    display: flex; flex-direction: column; gap: 15px;
    box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.login-card .login-logo { font-size: 30px; text-align: center; }
.login-card h1 { margin: 0; text-align: center; font-size: 22px; }
.login-card .sub { text-align: center; color: var(--muted); margin: -6px 0 8px; font-size: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.login-card input { padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; font-size: 15px; }
.login-card input:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card button { margin-top: 8px; padding: 12px; background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%); color: #fff; border: 0; border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer; }
.login-card button:hover { opacity: .95; }
.error { color: #b00020; font-size: 13px; margin: 0; text-align: center; background: #fde0e0; padding: 8px; border-radius: 8px; }
