* { box-sizing: border-box; }
body { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; margin: 0;
       background: #f4f5f7; color: #1a1d24; font-size: 14px; }
header { background: #1f2430; color: #fff; padding: 12px 24px;
         display: flex; justify-content: space-between; align-items: center; }
.logo { color: #fff; text-decoration: none; font-weight: 700; font-size: 18px; }
.user { color: #aab; font-size: 13px; }
.user .logout { color: #8fa0ff; text-decoration: none; margin-left: 10px; }
.user .logout:hover { color: #fff; }
/* Вход */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #1f2430; }
.login-card { background: #fff; padding: 32px; border-radius: 12px; width: 300px; display: flex; flex-direction: column; gap: 12px; }
.login-logo { font-weight: 700; font-size: 22px; text-align: center; margin-bottom: 6px; }
.login-card input { padding: 10px; border: 1px solid #d4d8e0; border-radius: 8px; font-size: 14px; }
.login-card button { padding: 10px; background: #4a6cf7; color: #fff; border: 0; border-radius: 8px; font-size: 15px; cursor: pointer; }
.login-err { background: #fff1f0; color: #c0392b; padding: 8px; border-radius: 6px; font-size: 13px; text-align: center; }
.access-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: #fff; padding: 10px 14px; border: 1px solid #e3e6ec; border-radius: 8px; }
.topnav { display: flex; gap: 18px; margin-left: 32px; flex: 1; }
.topnav a { color: #cdd3e0; text-decoration: none; font-size: 14px; }
.topnav a:hover { color: #fff; }
.staff .num { width: 90px; padding: 5px 7px; border: 1px solid #d4d8e0; border-radius: 6px; }
.staff .pct { width: 56px; }
tr.inactive { opacity: .45; }
.chk { font-size: 12px; color: #5a6072; white-space: nowrap; }
main { max-width: 1100px; margin: 0 auto; padding: 24px; }
h1 { margin: 8px 0 4px; }
.muted { color: #8a90a0; }
.back { color: #4a6cf7; text-decoration: none; font-size: 13px; }
a.btn, .btn { display: inline-block; padding: 6px 12px; background: #fff; border: 1px solid #d4d8e0;
      border-radius: 6px; text-decoration: none; color: #1a1d24; font-size: 13px; }
a.btn.on { background: #4a6cf7; color: #fff; border-color: #4a6cf7; font-weight: 600; }
.toolbar .sep { color: #cdd2db; }

/* Дашборд */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
         gap: 14px; margin-top: 16px; }
.card { background: #fff; border: 1px solid #e3e6ec; border-radius: 10px; padding: 16px;
        text-decoration: none; color: inherit; transition: box-shadow .15s; }
.card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.card-name { font-weight: 600; font-size: 15px; }
.card-inn { color: #8a90a0; font-size: 12px; margin: 2px 0 10px; }
.card-bal { font-size: 20px; font-weight: 700; }
.card-stat { margin-top: 8px; display: flex; gap: 8px; align-items: center; }
.badge { padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.ok { background: #e3f6e9; color: #1a7f44; }
.badge.warn { background: #fff1d6; color: #9a6a00; }

/* Таблица разноски */
.toolbar { margin: 14px 0; display: flex; gap: 12px; align-items: center; }
table.pay { width: 100%; border-collapse: collapse; background: #fff;
            border-radius: 10px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
table.pay th { text-align: left; padding: 10px; background: #eef0f4; font-size: 12px;
               color: #5a6072; border-bottom: 1px solid #e3e6ec; }
table.pay th a.sort { color: #5a6072; text-decoration: none; cursor: pointer; white-space: nowrap; }
table.pay th a.sort:hover { color: #4a6cf7; }
table.pay td { padding: 9px 10px; border-bottom: 1px solid #f0f1f5; vertical-align: top; }
.r { text-align: right; }
.nowrap { white-space: nowrap; }
/* Изменяемый блок таблицы (тянуть правый-нижний угол), полная ширина страницы */
body.wide main { max-width: none; }
.table-wrap { overflow: auto; resize: both; min-width: 380px; min-height: 240px;
              border: 1px solid #e3e6ec; border-radius: 10px; background: #fff; }
.table-wrap > table.pay { box-shadow: none; border-radius: 0; }
.table-tools { display: flex; align-items: center; gap: 10px; margin: 6px 0; }

/* Изменяемые ширины колонок (тянуть границу заголовка) */
table.resizable th { position: relative; }
table.resizable th .col-resizer { position: absolute; top: 0; right: -3px; width: 7px; height: 100%;
       cursor: col-resize; user-select: none; z-index: 5; }
table.resizable th .col-resizer:hover, table.resizable th .col-resizer.drag { background: #9db0ee; }
.cp-name { font-weight: 600; }
.cp-purpose { color: #6b7180; font-size: 12px; margin-top: 2px; max-width: 600px;
              white-space: normal; overflow-wrap: anywhere; }
.cp-bank { font-size: 11px; margin-top: 2px; }
.amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount.in { color: #1a7f44; }
.amount.out { color: #c0392b; }
tr.done { background: #fbfdfb; }
tr.done .save { background: #e3f6e9; color: #1a7f44; border-color: #b6e3c6; }
select.cat, input.deal, input.comment { padding: 5px 7px; border: 1px solid #d4d8e0; border-radius: 6px;
                         font-size: 13px; max-width: 190px; }
input.comment { color: #444; }
.hint { color: #9a6a00; font-size: 11px; margin-top: 3px; }
button.save { padding: 6px 12px; background: #4a6cf7; color: #fff; border: 0;
              border-radius: 6px; cursor: pointer; font-size: 13px; }
button.save:hover { background: #3a5ce0; }
.hint a { color: #4a6cf7; text-decoration: none; }

/* Экран сделки */
h2 { margin-top: 24px; }
.dealgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 12px; margin: 16px 0; }
.dcard { background: #fff; border: 1px solid #e3e6ec; border-radius: 10px; padding: 12px 14px; }
.dlabel { color: #8a90a0; font-size: 12px; }
.dval { font-weight: 600; margin-top: 3px; }
.margin-box { display: flex; align-items: center; gap: 16px; background: #fff; border: 1px solid #e3e6ec;
              border-radius: 12px; padding: 18px 22px; margin: 8px 0 4px; }
.mcol { text-align: center; }
.mval { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mval.in { color: #1a7f44; } .mval.out { color: #c0392b; }
.mop { font-size: 22px; color: #8a90a0; }
.checks { display: flex; flex-direction: column; gap: 4px; margin: 14px 0; }
.chk-item { font-size: 13px; padding: 6px 10px; border-radius: 6px; background: #fff; border: 1px solid #e3e6ec; }
.chk-item.ok { border-left: 3px solid #1a7f44; }
.chk-item.bad { border-left: 3px solid #c0392b; background: #fff6f5; }
.chk-dot { font-weight: 700; margin-right: 6px; }
.chk-item.ok .chk-dot { color: #1a7f44; } .chk-item.bad .chk-dot { color: #c0392b; }
table.pnl td, table.pnl th { font-variant-numeric: tabular-nums; }
tr.total td { border-top: 2px solid #d4d8e0; background: #f7f8fb; }
.close-box { margin: 10px 0 4px; display: flex; align-items: center; gap: 10px; }
.close-box form { display: flex; align-items: center; gap: 10px; }
.btn.primary { background: #4a6cf7; color: #fff; border-color: #4a6cf7; cursor: pointer; font-weight: 600; }
.btn { cursor: pointer; }
.hint-ok { color: #1a7f44; font-size: 13px; }

/* Разбивка платежа на строки-части */
.split-link { color: #4a6cf7; text-decoration: none; font-size: 12px; cursor: pointer; }
.split-link:hover { text-decoration: underline; }
tbody.pay-group { border-bottom: 1px solid #e3e6ec; }
tr.partial { background: #fffaf0; }
/* строки-части: компактный межстрочный отступ */
tr.split-part > td { vertical-align: top; padding-top: 3px; padding-bottom: 3px; }
tr.split-edit > td { background: #f7f9ff; }
tr.split-view > td { background: #f3fbf5; }   /* сохранённый вид — зелёный */
/* объединённые ячейки (Excel-вид): название слева и «Итого» справа — по центру по вертикали */
tr.split-part > td.cp[rowspan], tr.split-part > td.split-total-cell { vertical-align: middle; }
tr.split-edit > td.cp[rowspan] { background: #eef2fb; }
tr.split-view > td.cp[rowspan] { background: #ecf8ef; }
.split-total-cell { text-align: center; background: #ecf8ef !important; }
tr.split-edit .split-total-cell { background: #eef2fb !important; }
.split-rem-line { font-size: 14px; margin-bottom: 6px; white-space: nowrap; }
.split-remaining { color: #1a7f44; font-variant-numeric: tabular-nums; }
tbody.split-bad .split-remaining { color: #c0392b; }
.split-actions { display: flex; gap: 8px; justify-content: center; }
.split-err-inline { color: #c0392b; font-size: 12px; display: block; margin: 4px 0; }
/* «+» под суммой и «✕» убрать строку */
tr.split-addrow > td { border-bottom: 1px solid #f0f1f5; padding: 2px 10px 8px; background: #f7f9ff; }
.split-add { font-size: 16px; font-weight: 700; width: 30px; height: 26px; cursor: pointer;
             border: 1px dashed #b9c0d0; border-radius: 6px; background: #fff; color: #4a6cf7; }
.split-add:hover { border-color: #4a6cf7; background: #f0f3ff; }
.split-del { margin-left: 5px; background: #fff; border: 1px solid #e3c4c4; color: #c0392b;
             border-radius: 5px; cursor: pointer; padding: 3px 7px; font-size: 12px; }
.split-del:hover { background: #fff1f0; }
.split-amt { width: 92px; text-align: right; padding: 5px 7px; border: 1px solid #d4d8e0;
             border-radius: 6px; font-size: 13px; font-variant-numeric: tabular-nums; }
.row-flag-ok { color: #1a7f44; font-weight: 700; font-size: 18px; }   /* единая галочка на весь платёж */
.amount .split-amt { color: inherit; }
.split-cancel { margin-left: 6px; }
