@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

:root {
    --ink: #20266a;      /* индиго Водолей */
    --accent: #3690c0;   /* голубой Водолей */
    --bg: #f2f4fa;
    --card: #ffffff;
    --muted: #8a90a8;
    --line: #e4e7f0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Montserrat', system-ui, sans-serif; background: var(--bg); color: #22263a; font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }

/* ===== Вход ===== */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #3690c0 0%, #20266a 100%); }
.login-box { background: #fff; border-radius: 16px; padding: 36px 32px; width: 340px; text-align: center;
    box-shadow: 0 20px 60px rgba(15, 20, 60, .35); }
.login-logo { width: 200px; max-width: 90%; margin-bottom: 10px; }
.login-box h1 { color: var(--ink); font-size: 20px; margin-bottom: 4px; }
.login-sub { color: var(--muted); font-size: 12px; margin-bottom: 20px; }
.login-box input { width: 100%; padding: 11px 14px; margin-bottom: 10px; border: 1px solid var(--line);
    border-radius: 9px; font: inherit; }
.login-box button { width: 100%; padding: 11px; background: var(--ink); color: #fff; border: 0;
    border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; }
.login-box button:hover { background: #2a3186; }
.login-error { background: #fdecec; color: #c0392b; border-radius: 8px; padding: 8px; font-size: 12px; margin-bottom: 12px; }

/* ===== Хаб (главная) ===== */
.hub-body { background: linear-gradient(170deg, #f6f4f1 0%, #f0ece6 60%, #f7ede6 100%); }
.hub { max-width: 760px; margin: 0 auto; padding: 48px 16px; text-align: center; }
.hub-logo { width: 240px; max-width: 80%; }
.hub-sub { color: var(--muted); font-size: 12px; margin: 8px 0 18px; }
.sandbox-note { display: inline-block; background: #fff7e0; border: 1px solid #f0deb0; color: #7a6320;
    font-size: 12px; border-radius: 10px; padding: 8px 14px; margin-bottom: 26px; }
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.tile { position: relative; background: var(--card); border-radius: 14px; padding: 22px 14px 18px; text-align: center;
    box-shadow: 0 3px 14px rgba(32, 38, 106, .07); transition: transform .12s, box-shadow .12s; color: inherit; display: block; }
a.tile:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(32, 38, 106, .14); }
.tile-ico { font-size: 30px; margin-bottom: 8px; }
.tile-name { font-weight: 600; color: var(--ink); }
.tile-desc { font-size: 11px; color: var(--muted); margin-top: 3px; }
.tile-soon { opacity: .55; }
.soon { position: absolute; top: 10px; right: 10px; background: var(--line); color: #666e8c;
    font-size: 10px; border-radius: 20px; padding: 2px 8px; }
.tile-badge { position: absolute; top: 10px; right: 10px; background: #eb5757; color: #fff;
    font-size: 11px; font-weight: 700; border-radius: 20px; padding: 2px 9px; }
.hub-foot { margin-top: 30px; font-size: 12px; color: var(--muted); }
.backup-bar { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
    margin-top: 22px; font-size: 12px; color: #5a6080; background: #fff; border-radius: 10px;
    padding: 10px 16px; box-shadow: 0 1px 4px rgba(32, 38, 106, .07); }

/* ===== Шапка ===== */
.topbar { display: flex; align-items: center; gap: 18px; background: linear-gradient(90deg, #3690c0, #20266a);
    color: #fff; padding: 0 16px; height: 52px; position: sticky; top: 0; z-index: 50; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; }
.brand img { height: 26px; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { color: #dfe9ff; padding: 6px 12px; border-radius: 8px; font-weight: 500; }
.topbar nav a.active, .topbar nav a:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.sandbox-chip { background: rgba(255, 247, 224, .95); color: #7a6320; font-size: 11px; padding: 4px 10px; border-radius: 20px; }
.btn-sync { background: #fff; color: var(--ink); border: 0; border-radius: 8px; padding: 7px 12px;
    font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.btn-sync:disabled { opacity: .7; cursor: default; }
.logout { color: #cfd8f5; font-size: 12px; }

/* ===== Панель над доской ===== */
.board-tools { display: flex; align-items: center; gap: 14px; padding: 12px 16px; }
.board-tools input { flex: 0 1 420px; padding: 9px 14px; border: 1px solid var(--line); border-radius: 9px; font: inherit; background: #fff; }
.board-totals { color: var(--muted); font-size: 12px; }

/* ===== Канбан ===== */
.board { display: flex; gap: 12px; padding: 0 16px 24px; overflow-x: auto; align-items: flex-start; min-height: calc(100vh - 130px); }
.col { flex: 0 0 272px; max-width: 272px; }
.col-head { display: flex; align-items: center; justify-content: space-between; background: var(--c);
    color: #fff; border-radius: 10px 10px 0 0; padding: 8px 12px; font-weight: 600; font-size: 13px; }
.col-count { background: rgba(255, 255, 255, .25); border-radius: 20px; padding: 1px 9px; font-size: 12px; }
.col-sum { background: #fff; border-bottom: 1px solid var(--line); padding: 6px 12px; font-size: 12px;
    font-weight: 600; color: var(--ink); }
.col-cards { display: flex; flex-direction: column; gap: 8px; padding: 10px 6px; background: #eaedf5;
    border-radius: 0 0 10px 10px; min-height: 60px; max-height: calc(100vh - 210px); overflow-y: auto; }
.card { background: #fff; border-radius: 10px; padding: 10px 12px; cursor: pointer;
    box-shadow: 0 1px 4px rgba(32, 38, 106, .08); transition: box-shadow .12s, transform .12s; }
.card:hover { box-shadow: 0 6px 18px rgba(32, 38, 106, .16); transform: translateY(-1px); }
.card-top { display: flex; justify-content: space-between; gap: 8px; }
.card-title { font-weight: 600; font-size: 13px; color: var(--ink); }
.card-sum { font-weight: 600; font-size: 13px; white-space: nowrap; }
.card-client { font-size: 12px; color: #4a5070; margin-top: 3px; }
.card-date { display: inline-block; font-size: 11px; color: #666e8c; background: #f0f2f9;
    border-radius: 6px; padding: 2px 7px; margin-top: 6px; }

/* ===== Модалка ===== */
.modal-back { position: fixed; inset: 0; background: rgba(20, 24, 50, .5); display: none;
    align-items: flex-start; justify-content: center; padding: 40px 12px; z-index: 100; overflow-y: auto; }
.modal-back.open { display: flex; }
.modal { background: #fff; border-radius: 14px; width: 640px; max-width: 100%;
    box-shadow: 0 30px 80px rgba(10, 14, 40, .4); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 20px 12px;
    border-bottom: 1px solid var(--line); }
.modal-title { font-size: 17px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.stage-badge { display: inline-block; color: #fff; font-size: 11px; font-weight: 600;
    border-radius: 20px; padding: 3px 10px; background: #888; }
.modal-close { background: none; border: 0; font-size: 18px; cursor: pointer; color: var(--muted); padding: 4px 8px; }
.modal-body { padding: 16px 20px 20px; }
.loading { color: var(--muted); padding: 30px 0; text-align: center; }
.deal-sum { background: #f0f6eb; border: 1px solid #d8e8cc; border-radius: 10px; padding: 10px 14px;
    margin-bottom: 14px; font-size: 15px; }
.props { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.props td { padding: 6px 8px; border-bottom: 1px solid #f0f2f8; vertical-align: top; }
.props td:first-child { color: var(--muted); white-space: nowrap; width: 150px; }
.modal-body h3 { color: var(--ink); font-size: 14px; margin: 14px 0 8px; }
.items { width: 100%; border-collapse: collapse; font-size: 13px; }
.items th { text-align: left; color: var(--muted); font-weight: 500; font-size: 11px; padding: 4px 8px; }
.items td { padding: 6px 8px; border-top: 1px solid #f0f2f8; }
.items-total td { font-weight: 700; color: var(--ink); }
.modal-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; font-size: 12px; }
.bx-link { font-weight: 600; }

/* ===== Формы ===== */
.btn-primary { background: var(--ink); color: #fff; border: 0; border-radius: 9px; padding: 9px 16px;
    font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn-primary:hover { background: #2a3186; }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 9px;
    padding: 8px 14px; font: inherit; font-size: 13px; cursor: pointer; }
.btn-ghost.danger { color: #c0392b; border-color: #f0c8c2; }
.btn-mini { background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 2px 8px;
    font: inherit; font-size: 11px; cursor: pointer; }
.modal-wide { width: 780px; }
.modal-body label { display: block; font-size: 12px; color: #4a5070; margin-bottom: 8px; }
.modal-body label input, .modal-body label select, .modal-body label textarea { display: block; width: 100%;
    margin-top: 3px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
.fg-block h3 { margin: 4px 0 8px !important; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.client-hint { min-height: 16px; font-size: 12px; margin-top: 3px; color: #27ae60; }
.status-btns { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.st-btn { border: 1px solid var(--c); color: var(--c); background: #fff; border-radius: 20px;
    padding: 3px 10px; font: inherit; font-size: 11px; font-weight: 600; cursor: pointer; }
.st-btn.on { background: var(--c); color: #fff; }
.item-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; flex-wrap: wrap;
    background: #f6f7fc; border-radius: 8px; padding: 6px 8px; }
.item-row select { padding: 7px 8px; border: 1px solid var(--line); border-radius: 7px; font: inherit; font-size: 12px; }
.item-row .num { width: 74px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 7px; font: inherit; font-size: 12px; }
.item-row .itSum { width: 84px; font-weight: 600; }
.item-row .x { color: var(--muted); }
.item-row .itArea { font-size: 11px; min-width: 48px; }
.item-row .cond { display: flex; align-items: center; gap: 2px; font-size: 15px; cursor: pointer; }
.item-row .itDone { border: 1px solid #b9dfc4; background: #fff; color: #b9c6bd; border-radius: 7px;
    padding: 6px 9px; cursor: pointer; font-size: 12px; }
.item-row .itDone.on { background: #27ae60; border-color: #27ae60; color: #fff; }
.item-row .itDel { border: 0; background: none; cursor: pointer; font-size: 13px; opacity: .6; }
.calc-total { background: #f0f6eb; border: 1px solid #d8e8cc; border-radius: 10px; padding: 10px 14px;
    margin-top: 10px; font-size: 14px; }
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.pill { border: 0; border-radius: 20px; padding: 5px 11px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.pill-work { background: #fdf1e2; color: #b26a00; }
.pill-done { background: #e5f6ec; color: #1e7e44; }
.btn-ghost.on-mine { background: var(--accent); border-color: var(--accent); color: #fff; }
.user-chip { color: #cfd8f5; font-size: 12px; }
.rowlink { cursor: pointer; }
.rowlink:hover { background: #f6f7fc; }
.col-cards.drop { outline: 2px dashed var(--accent); outline-offset: -4px; }
.card[draggable=true] { user-select: none; }

/* ===== Настройки ===== */
.hub-who { font-size: 12px; color: #6a7090; margin: -12px 0 16px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 16px; }
.tab { background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 9px 15px;
    font: inherit; font-size: 13px; cursor: pointer; color: #4a5070; }
.tab.on { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
    flex-wrap: wrap; margin-bottom: 12px; }
.sec-head h2 { font-size: 16px; color: var(--ink); }
.table-scroll { overflow-x: auto; }
.perm-table { width: 100%; min-width: 620px; border-collapse: collapse; background: #fff;
    border-radius: 10px; overflow: hidden; box-shadow: 0 1px 4px rgba(32, 38, 106, .08); }
.perm-table th { background: #eef1f8; color: var(--ink); font-size: 12px; padding: 10px 8px; text-align: center; }
.perm-table th:first-child { text-align: left; }
.perm-table td { border-top: 1px solid #f0f2f8; padding: 9px 8px; font-size: 13px; }
.perm-name { color: #3a4060; }
.perm-cell { text-align: center; }
.perm-cell input { width: 17px; height: 17px; cursor: pointer; }
.off-chip { background: #fdecec; color: #c0392b; font-size: 10px; border-radius: 20px; padding: 2px 8px; margin-left: 6px; }
.chk { display: flex !important; align-items: center; gap: 7px; margin: 10px 0; }
.chk input { width: auto !important; margin: 0 !important; }
.price-inp, #pOver, #pCond, #pMin { width: 110px; padding: 7px 9px; border: 1px solid var(--line);
    border-radius: 7px; font: inherit; font-size: 13px; }

/* ===== Каналы и звонки ===== */
.chan-box { background: #fff; border-radius: 12px; padding: 16px 18px; margin-bottom: 14px;
    box-shadow: 0 1px 4px rgba(32, 38, 106, .08); }
.chan-box h3 { color: var(--ink); font-size: 14px; margin-bottom: 4px !important; }
.chan-box p.muted { font-size: 12px; margin-bottom: 10px; }
.hook-url { background: #f4f6fc; border-radius: 8px; padding: 9px 12px; font-size: 12px; margin-top: 8px;
    word-break: break-all; }
.hook-url code { font-family: Consolas, monospace; color: var(--ink); }
.ch-chip { display: inline-block; background: #eef2fb; color: #46507a; font-size: 10px;
    border-radius: 20px; padding: 1px 8px; margin-top: 3px; }
.room-group { padding: 9px 14px 4px; font-size: 10px; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; color: var(--muted); background: #fafbfe; }
.room-none { padding: 10px 14px; font-size: 11px; color: var(--muted); }
.head-link { font-size: 12px; font-weight: 500; margin-left: 8px; }
.call-pop { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; gap: 12px;
    align-items: center; background: #fff; border-left: 4px solid #27ae60; border-radius: 12px;
    padding: 14px 16px; box-shadow: 0 12px 40px rgba(15, 20, 60, .28); font-size: 13px; max-width: 340px; }
.call-pop .call-ico { font-size: 26px; }
.call-pop button { background: none; border: 0; font-size: 15px; color: var(--muted); cursor: pointer; margin-left: auto; }

/* ===== Чаты ===== */
.nav-badge { display: none; background: #eb5757; color: #fff; border-radius: 20px; font-size: 10px;
    font-weight: 700; padding: 1px 6px; margin-left: 5px; vertical-align: top; }
.chat-wrap { display: flex; height: calc(100vh - 52px); }
.chat-rooms { width: 260px; flex: 0 0 260px; background: #fff; border-right: 1px solid var(--line);
    display: flex; flex-direction: column; }
.chat-rooms-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px;
    font-weight: 600; color: var(--ink); border-bottom: 1px solid var(--line); }
.room { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid #f2f4fa; }
.room:hover { background: #f6f7fc; }
.room.on { background: #eef3fb; border-left: 3px solid var(--accent); padding-left: 11px; }
.room-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.room-name { font-weight: 600; font-size: 13px; color: var(--ink); }
.room-badge { background: #eb5757; color: #fff; border-radius: 20px; font-size: 10px; font-weight: 700; padding: 1px 7px; }
.room-last { font-size: 11px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-hint { margin-top: auto; padding: 12px 14px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head { padding: 12px 18px; background: #fff; border-bottom: 1px solid var(--line);
    font-weight: 600; color: var(--ink); }
.chat-body { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.chat-empty { margin: auto; color: var(--muted); }
.chat-day { align-self: center; background: #e4e8f3; color: #5a6080; font-size: 11px;
    border-radius: 20px; padding: 2px 12px; margin: 6px 0; }
.msg { max-width: 62%; align-self: flex-start; background: #fff; border-radius: 12px 12px 12px 4px;
    padding: 8px 12px; box-shadow: 0 1px 3px rgba(32, 38, 106, .08); }
.msg.mine { align-self: flex-end; background: #dfeaf7; border-radius: 12px 12px 4px 12px; }
.msg-author { font-size: 11px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.msg-body { font-size: 13px; line-height: 1.45; word-wrap: break-word; }
.msg-time { font-size: 10px; color: var(--muted); text-align: right; margin-top: 3px; }
.chat-send { display: flex; gap: 8px; align-items: flex-end; padding: 10px 18px;
    background: #fff; border-top: 1px solid var(--line); }
.chat-send textarea { flex: 1; resize: none; padding: 10px 12px; border: 1px solid var(--line);
    border-radius: 10px; font: inherit; font-size: 13px; max-height: 120px; }

@media (max-width: 720px) {
    .chat-rooms { width: 140px; flex: 0 0 140px; }
    .chat-hint { display: none; }
    .msg { max-width: 85%; }
}

/* ===== Страницы-списки (клиенты, изделия) ===== */
.page { max-width: 1060px; margin: 0 auto; padding: 14px 16px 30px; }
.client-list { display: flex; flex-direction: column; gap: 8px; }
.client-row { display: grid; grid-template-columns: 1fr 200px 150px; gap: 10px; align-items: center;
    background: #fff; border-radius: 10px; padding: 12px 16px; cursor: pointer;
    box-shadow: 0 1px 4px rgba(32, 38, 106, .08); transition: box-shadow .12s; }
.client-row:hover { box-shadow: 0 6px 18px rgba(32, 38, 106, .16); }
.client-name { font-weight: 600; color: var(--ink); }
.client-phone { font-size: 13px; }
.client-kpi { display: flex; gap: 12px; flex-wrap: wrap; margin: 6px 0 12px; }
.kpi { background: #fff; border-radius: 10px; padding: 10px 18px; box-shadow: 0 1px 4px rgba(32, 38, 106, .08); }
.kpi b { display: block; font-size: 18px; color: var(--ink); }
.kpi span { font-size: 11px; color: var(--muted); }
.filter-btns { display: flex; gap: 6px; }
.filter-btns button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 12px;
    font: inherit; font-size: 12px; cursor: pointer; color: #4a5070; }
.filter-btns button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.items.wide { background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 4px rgba(32, 38, 106, .08); }
.items.wide th { padding: 10px 10px 6px; }
.items.wide td { padding: 8px 10px; }

@media (max-width: 640px) {
    .client-row { grid-template-columns: 1fr; gap: 3px; }
    .topbar nav { display: none; }
    .board { min-height: auto; }
    .col { flex: 0 0 86vw; max-width: 86vw; }
}
