/* ===== Payment Calendar — Hilari Light Theme ===== */
:root {
  --bg: #f2f7fa;
  --bg-card: #ffffff;
  --bg-card-hover: #f5f9fb;
  --bg-surface: #ffffff;
  --bg-input: #edf2f6;
  --border: #dce4ec;
  --border-hover: #b8c8d6;
  --text: #1a2a3a;
  --text-muted: #5e7a90;
  --text-dim: #95a8b8;
  --accent: #4CC5E4;
  --accent-2: #35A8C8;
  --gradient: linear-gradient(135deg, #4CC5E4, #35A8C8);
  --gradient-glow: linear-gradient(135deg, rgba(76,197,228,.10), rgba(53,168,200,.10));
  --green: #16a34a;
  --green-dim: rgba(22,163,74,.08);
  --red: #dc2626;
  --red-dim: rgba(220,38,38,.06);
  --amber: #d97706;
  --amber-dim: rgba(217,119,6,.08);
  --sidebar-w: 192px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
  --shadow-lg: 0 4px 24px rgba(0,0,0,.08);
  --transition: .2s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}

#app { display: flex; height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  z-index: 10;
  box-shadow: 2px 0 8px rgba(0,0,0,.03);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 4px 8px 20px;
  justify-content: center;
}

.logo-icon {
  display: none;
}

.logo-img {
  height: 153px;
  width: auto;
  object-fit: contain;
}

.logo-text {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  letter-spacing: -0.01em;
  display: none;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  transition: var(--transition);
  border: 1px solid transparent;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; stroke: var(--accent-2); }
.nav-link:hover { color: var(--text); background: rgba(76,197,228,.10); }
.nav-link.active {
  color: var(--accent-2);
  background: rgba(76,197,228,.16);
  border: 1px solid rgba(76,197,228,.22);
  font-weight: 600;
}
.nav-link.active svg { stroke: var(--accent-2); }

.sidebar-footer { padding: 8px 0 4px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-version { display: none; }
#sidebar-user-info { color: var(--text); }

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 28px 32px;
  background: var(--bg);
}

/* ===== View Header ===== */
.view-header { margin-bottom: 24px; }
.view-header h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.view-header p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ===== KPI Cards ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.kpi-card.blue::before { background: var(--gradient); }
.kpi-card.green::before { background: linear-gradient(90deg, #16a34a, #34d399); }
.kpi-card.red::before { background: linear-gradient(90deg, #dc2626, #f87171); }
.kpi-card.amber::before { background: linear-gradient(90deg, #d97706, #fbbf24); }

.kpi-card:hover { border-color: var(--border-hover); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.kpi-value { font-size: 24px; font-weight: 700; margin-top: 8px; letter-spacing: -0.02em; color: var(--text); }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.kpi-value.positive { color: var(--green); }
.kpi-value.negative { color: var(--red); }

/* ===== Cards / Panels ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.card-title .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot.red { background: var(--red); }
.dot.green { background: var(--green); }
.dot.amber { background: var(--amber); }
.dot.blue { background: var(--accent); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ===== Charts ===== */
.chart-container { position: relative; width: 100%; height: 280px; }

/* ===== Cash Gap Warning ===== */
.gap-list { display: flex; flex-direction: column; gap: 8px; }
.gap-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--red-dim);
  border: 1px solid rgba(220,38,38,.12);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.gap-item .gap-date { font-weight: 600; color: var(--text); }
.gap-item .gap-amount { color: var(--red); font-weight: 600; }
.no-gaps { text-align: center; padding: 24px; color: var(--green); font-size: 13px; }
.no-gaps-icon { font-size: 32px; margin-bottom: 8px; }

/* ===== Top Expenses ===== */
.top-expense-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.top-expense-item:last-child { border: none; }
.top-expense-rank {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}
.top-expense-name { flex: 1; color: var(--text); }
.top-expense-amount { font-weight: 600; color: var(--text); }
.top-expense-bar {
  height: 4px;
  background: var(--gradient);
  border-radius: 2px;
  margin-top: 4px;
}

/* ===== Calendar ===== */
.calendar-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.month-nav { display: flex; align-items: center; gap: 12px; }

.month-nav-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
  box-shadow: var(--shadow);
}
.month-nav-btn:hover { background: var(--bg-input); border-color: var(--border-hover); }

.month-label {
  font-size: 18px;
  font-weight: 700;
  min-width: 180px;
  text-align: center;
  color: var(--text);
}

.calendar-table-wrapper {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: calc(100vh - 200px);
  background: var(--bg-card);
  box-shadow: var(--shadow);
}

.calendar-table {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  min-width: 100%;
  font-size: 12px;
}

.calendar-table th,
.calendar-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  white-space: nowrap;
  text-align: right;
  min-width: 90px;
}

.calendar-table th {
  background: #f8f9fb;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 3;
  font-size: 11px;
  color: var(--text-muted);
}
.calendar-table th.weekend { color: var(--red); }

.calendar-table td:first-child,
.calendar-table th:first-child {
  position: sticky;
  left: 0;
  z-index: 4;
  background: #f8f9fb;
  text-align: left;
  min-width: 200px;
  max-width: 200px;
  font-weight: 500;
  border-right: 2px solid var(--border);
  color: var(--text);
}
.calendar-table th:first-child { z-index: 5; }

/* Summary columns (Plan/Fact/Dev) */
.calendar-table .col-plan,
.calendar-table .col-fact,
.calendar-table .col-dev {
  background: rgba(76,197,228,.04);
  font-weight: 600;
  min-width: 110px;
  border-right: 1px solid var(--border);
}
.calendar-table th.col-plan,
.calendar-table th.col-fact,
.calendar-table th.col-dev {
  background: rgba(76,197,228,.08);
  color: var(--accent-2);
}
.calendar-table th.col-dev,
.calendar-table td.col-dev {
  border-right: 2px solid var(--border);
}
.calendar-table .col-plan { cursor: pointer; }
.calendar-table .col-plan:hover { background: rgba(76,197,228,.10) !important; }
.dev-pos { color: var(--green); font-weight: 600; }
.dev-neg { color: var(--red); font-weight: 600; }

/* Previous month columns */
.calendar-table .col-prev {
  background: rgba(217,119,6,.04);
  color: var(--text-muted);
  font-size: 11px;
  min-width: 90px;
}
.calendar-table th.col-prev {
  background: rgba(217,119,6,.08);
  color: var(--amber);
  font-weight: 600;
}

/* Row types */
.row-section td {
  background: rgba(76,197,228,.06) !important;
  font-weight: 700;
  color: var(--accent-2);
  font-size: 12px;
}
.row-section td:first-child { font-size: 13px; }

.row-total td {
  background: rgba(0,0,0,.02) !important;
  font-weight: 700;
  border-top: 2px solid var(--border);
}

.row-balance td {
  background: rgba(22,163,74,.04) !important;
  font-weight: 700;
}
.row-balance-negative td {
  background: var(--red-dim) !important;
  color: var(--red);
  font-weight: 700;
}

.row-group-header td {
  background: #f0f2f5 !important;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.row-group-header td:first-child::before { content: '▸ '; font-size: 10px; }
.row-group-header.expanded td:first-child::before { content: '▾ '; }

/* Today column highlight */
.calendar-table th.col-today {
  background: rgba(76,197,228,.18) !important;
  color: var(--accent-2) !important;
  font-weight: 700;
}
.calendar-table td.col-today {
  background: rgba(76,197,228,.06) !important;
}
.calendar-table .row-balance td.col-today,
.calendar-table .row-balance-negative td.col-today {
  background: rgba(76,197,228,.10) !important;
}

/* Weekend / Holiday column highlight */
.calendar-table th.col-holiday {
  background: rgba(220,38,38,.08) !important;
  color: var(--red) !important;
}
.calendar-table td.col-holiday {
  background: rgba(220,38,38,.03) !important;
}
.calendar-table .row-balance td.col-holiday,
.calendar-table .row-balance-negative td.col-holiday {
  background: rgba(220,38,38,.06) !important;
}
/* Today takes priority over holiday */
.calendar-table th.col-today.col-holiday {
  background: rgba(76,197,228,.18) !important;
  color: var(--accent-2) !important;
}
.calendar-table td.col-today.col-holiday {
  background: rgba(76,197,228,.06) !important;
}

/* Cash gap warning */
.cashgap-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, rgba(220,38,38,.06), rgba(251,191,36,.06));
  border: 1px solid rgba(220,38,38,.2);
  border-left: 4px solid var(--red);
  border-radius: var(--radius);
  padding: 12px 18px;
  margin-bottom: 16px;
  animation: fadeIn .3s ease;
  font-size: 13px;
}
.cashgap-alert-icon { font-size: 24px; flex-shrink: 0; }
.cashgap-alert-text { flex: 1; }
.cashgap-alert-title { font-weight: 700; color: var(--red); font-size: 14px; }
.cashgap-alert-detail { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.cashgap-alert .btn { flex-shrink: 0; }

/* Editable cells */
.cell-edit { cursor: pointer; transition: background var(--transition); }
.cell-edit:hover { background: rgba(76,197,228,.06); }
.cell-edit input {
  width: 80px;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 4px;
  color: var(--text);
  padding: 2px 6px;
  font-size: 12px;
  font-family: inherit;
  text-align: right;
  outline: none;
}
.cell-positive { color: var(--green); }
.cell-negative { color: var(--red); }
.cell-dev-bad { color: var(--red); font-weight: 600; }
.cell-dev-good { color: var(--green); }

/* ===== Analytics ===== */
.plan-fact-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.plan-fact-table th,
.plan-fact-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: right;
}
.plan-fact-table th { color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; }
.plan-fact-table td:first-child,
.plan-fact-table th:first-child { text-align: left; }
.plan-fact-table .pf-over { color: var(--red); }
.plan-fact-table .pf-under { color: var(--green); }

.progress-bar-bg {
  width: 100%; height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill { height: 100%; border-radius: 3px; transition: width .3s ease; }

/* ===== Settings ===== */
.settings-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}
.settings-tab {
  padding: 8px 20px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color var(--transition), border-color var(--transition);
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.settings-section { margin-bottom: 28px; }
.settings-section h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.form-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  max-width: 320px;
  transition: var(--transition);
}
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(76,197,228,.12); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
}
.btn-primary { background: var(--gradient); color: #fff; border: none; }
.btn-primary:hover { opacity: .9; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(76,197,228,.35); }
.btn-outline { background: var(--bg-card); border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--border-hover); background: var(--bg-input); }
.btn-danger { background: var(--bg-card); border: 1px solid rgba(220,38,38,.2); color: var(--red); }
.btn-danger:hover { background: var(--red-dim); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== Category List ===== */
.cat-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.cat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.cat-item-group { color: var(--text-muted); font-size: 11px; margin-left: 8px; }
.cat-remove {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 16px; padding: 0 4px;
  transition: var(--transition);
}
.cat-remove:hover { color: var(--red); }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.2); }

/* ===== Bank Reconciliation ===== */
.recon-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--red-dim);
  border: 1px solid rgba(220,38,38,.15);
  border-left: 4px solid var(--red);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 16px;
  animation: fadeIn .3s ease;
}
.recon-alert-icon { font-size: 20px; flex-shrink: 0; margin-top: 2px; }
.recon-alert-title { font-weight: 700; font-size: 13px; color: var(--red); }
.recon-alert-detail { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.bank-recon-card { margin-bottom: 20px; }
.bank-recon-grid { display: flex; gap: 16px; flex-wrap: wrap; }
.bank-recon-item {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}
.bank-recon-logo { font-size: 20px; flex-shrink: 0; }
.bank-recon-name { font-weight: 600; font-size: 13px; white-space: nowrap; min-width: 90px; }
.bank-recon-item .bank-bal-input { max-width: 160px; flex: 1; }
.bank-recon-status { font-size: 11px; font-weight: 500; white-space: nowrap; }

/* ===== Balance Sheet ===== */
.balance-sheet { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.balance-col { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.balance-section-title { font-size: 14px; font-weight: 800; color: var(--accent-2); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 2px solid var(--accent); }
.balance-group { margin-bottom: 16px; }
.balance-group-title { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.balance-subgroup-title { font-size: 11px; font-weight: 600; color: var(--text-dim); margin: 8px 0 4px 12px; }
.balance-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; border-radius: 6px; font-size: 13px; gap: 8px; }
.balance-row:hover { background: var(--bg-input); }
.balance-row.bal-auto { background: rgba(76,197,228,.04); }
.bal-label { flex: 1; color: var(--text); }
.bal-value { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bal-auto-tag { font-size: 9px; background: var(--accent); color: #fff; padding: 1px 5px; border-radius: 4px; margin-left: 6px; font-weight: 600; vertical-align: middle; }
.bal-editable { cursor: pointer; }
.bal-editable:hover { background: rgba(76,197,228,.06); }
.bal-editable:hover .bal-value { color: var(--accent); }
.bal-inline-input { width: 130px; padding: 3px 6px; font-size: 13px; font-weight: 600; text-align: right; border: 1px solid var(--accent); border-radius: 4px; background: var(--bg-card); outline: none; font-family: inherit; }
.balance-subtotal { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; font-weight: 700; font-size: 13px; }
.balance-subtotal .bal-value { color: var(--accent-2); }
.balance-grand-total { background: var(--gradient); color: #fff; border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 12px; font-weight: 800; font-size: 14px; display: flex; justify-content: space-between; }
.balance-grand-total .bal-value { color: #fff; }
.balance-sub-detail { display: flex; gap: 16px; padding: 4px 8px; font-size: 11px; color: var(--text-dim); margin-top: -2px; }

/* ===== Fixed Assets Table ===== */
.fa-table-wrap { overflow-x: auto; }
.fa-table { font-size: 12px; }
.fa-table th { font-size: 11px; white-space: nowrap; }
.dep-bar { width: 50px; height: 6px; background: var(--bg-input); border-radius: 3px; overflow: hidden; flex-shrink: 0; }
.dep-bar-fill { height: 100%; border-radius: 3px; transition: width .3s; }
.fa-col-inv { width: 45px; max-width: 55px; font-size: 11px; }
.fa-editable { cursor: pointer; position: relative; }
.fa-editable:hover { background: rgba(76,197,228,.08); outline: 1px dashed var(--accent); outline-offset: -1px; }
.fa-inline-input { width: 100%; min-width: 60px; padding: 2px 4px; font-size: 12px; border: 1px solid var(--accent); border-radius: 4px; background: var(--bg-card); }
.fa-calc { color: var(--text-muted); font-style: italic; }

/* ===== Modal ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 300; backdrop-filter: blur(4px); }
.modal-card { background: var(--bg-card); border-radius: var(--radius); padding: 28px 24px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); max-width: 440px; width: 90%; }

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn .3s ease-out; }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .sidebar { width: 60px; min-width: 60px; padding: 16px 8px; }
  .sidebar .logo-text, .sidebar .nav-link span, .sidebar-footer { display: none; }
  .sidebar-logo { justify-content: center; padding: 8px 0 20px; }
  .nav-link { justify-content: center; padding: 10px; }
  .main-content { padding: 20px 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 13px;
  z-index: 100;
  box-shadow: var(--shadow-lg);
  animation: fadeIn .2s ease-out;
}
.toast.success { border-color: rgba(22,163,74,.3); color: var(--green); }
.toast.error { border-color: rgba(220,38,38,.3); color: var(--red); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.3);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  animation: fadeIn .15s ease;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%; max-width: 480px;
  box-shadow: var(--shadow-lg);
}
.modal h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.modal select.form-input { max-width: 100%; }

/* ===== Panels Row Layout ===== */
.panels-row {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  align-items: flex-start;
}
.panels-row > * { flex: 1; min-width: 0; margin-bottom: 0; }

/* ===== Today Payments Panel ===== */
.today-panel {
  background: #fff;
  border: 1px solid rgba(76,197,228,.2);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.today-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.today-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-2);
}
.today-count {
  font-weight: 600;
  color: var(--accent);
  font-size: 13px;
}
.today-done {
  font-weight: 600;
  color: var(--green);
  font-size: 12px;
  margin-left: 8px;
}
.today-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
}
.today-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(76,197,228,.04);
  border: 1px solid rgba(76,197,228,.1);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.today-item-done {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(22,163,74,.04);
  border: 1px solid rgba(22,163,74,.1);
  border-radius: var(--radius-sm);
  font-size: 13px;
  opacity: 0.7;
}
.today-info { flex: 1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.today-cat { font-weight: 600; color: var(--text); }
.today-desc { color: var(--text-muted); font-size: 12px; }
.today-amount { font-weight: 700; color: var(--accent-2); min-width: 100px; text-align: right; }
.today-amount-done { font-weight: 600; color: var(--green); min-width: 100px; text-align: right; text-decoration: line-through; opacity: 0.7; }
.today-status { font-size: 16px; color: var(--green); width: 24px; text-align: center; }
.today-actions { display: flex; gap: 6px; }

/* ===== Overdue Panel ===== */
.overdue-panel {
  background: #fff;
  border: 1px solid rgba(220,38,38,.2);
  border-left: 4px solid var(--red);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.overdue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.overdue-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--red);
}
.overdue-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
}
.overdue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--red-dim);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.overdue-info { flex: 1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.overdue-cat { font-weight: 600; color: var(--text); }
.overdue-desc { color: var(--text-muted); font-size: 12px; }
.overdue-date-badge {
  background: rgba(220,38,38,.12);
  color: var(--red);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}
.overdue-amount { font-weight: 700; color: var(--red); min-width: 100px; text-align: right; }
.overdue-actions { display: flex; gap: 6px; }

/* ===== Scheduled Payment Cell States ===== */
.cell-sch-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
}

.cell-sch-paid {
  background: rgba(22,163,74,.08) !important;
  border-left: 3px solid var(--green) !important;
}
.cell-sch-pending {
  background: rgba(76,197,228,.06) !important;
  border-left: 3px solid var(--accent) !important;
}
.cell-sch-overdue {
  background: rgba(220,38,38,.06) !important;
  border-left: 3px solid var(--red) !important;
  animation: pulseRed 2s ease-in-out infinite;
}

.sch-amount { font-style: italic; }

.sch-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 800;
  flex-shrink: 0;
}
.sch-badge.sch-paid {
  background: var(--green);
  color: #fff;
}
.sch-badge.sch-pending {
  background: var(--accent);
  color: #fff;
  font-size: 8px;
}
.sch-badge.sch-overdue {
  background: var(--red);
  color: #fff;
}

@keyframes pulseRed {
  0%, 100% { background: rgba(220,38,38,.06); }
  50% { background: rgba(220,38,38,.12); }
}

/* Unconfirmed fact cells */
.cell-sch-unconfirmed {
  background: rgba(217,119,6,.04) !important;
  border-left: 3px solid var(--amber) !important;
}
.sch-badge.sch-unconfirmed {
  background: var(--amber);
  color: #fff;
  font-size: 8px;
}

/* ===== Drag & Drop ===== */
[data-sch-drag] {
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}
[data-sch-drag]:active { cursor: grabbing; }
/* Block pointer-events on drag-related children only */
[data-sch-drag] > .cell-sch-wrap { pointer-events: none; }
[data-sch-drag] .sch-badge { pointer-events: none; }
[data-sch-drag] .sch-amount { pointer-events: none; }
/* Re-enable pointer-events for popups and inputs inside draggable cells */
[data-sch-drag] .sch-popup,
[data-sch-drag] .sch-popup *,
[data-sch-drag] input { pointer-events: auto; }

.cell-dragging {
  opacity: 0.35 !important;
  outline: 2px dashed var(--accent) !important;
  background: rgba(76,197,228,.08) !important;
}

.cell-drop-candidate {
  background: rgba(76,197,228,.04) !important;
  outline: 1px dashed rgba(76,197,228,.3);
  outline-offset: -1px;
  transition: background .15s ease, outline-color .15s ease;
}

.cell-drop-over {
  background: rgba(76,197,228,.15) !important;
  outline: 2px solid var(--accent) !important;
  outline-offset: -2px;
  box-shadow: inset 0 0 12px rgba(76,197,228,.2);
  transition: background .1s ease;
}

/* ===== Scheduled Payment Popup ===== */
.sch-popup {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 30;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  animation: fadeIn .15s ease;
}
.sch-popup-title {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 500;
}
.sch-popup-amount {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}
.sch-popup-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sch-popup-actions .btn { width: 100%; justify-content: center; }

/* ===== Login Screen ===== */
#login-screen {
  display: none;
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #e8f6fa 0%, #dff0f8 50%, #e5f4fb 100%);
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: 0 8px 40px rgba(76,197,228,.12), 0 2px 12px rgba(0,0,0,.06);
  border: 1px solid rgba(76,197,228,.10);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.login-brand {
  font-size: 22px;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 20px;
}

.login-tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
}
.login-tab.active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.login-form .form-input {
  max-width: 100% !important;
}

.auth-error {
  color: var(--red);
  font-size: 12px;
  min-height: 18px;
  margin-bottom: 8px;
  font-weight: 500;
}

.login-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 16px;
}

/* ===== User Info in Sidebar ===== */
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-details { flex: 1; min-width: 0; }
.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* ===== Admin Panel ===== */
.user-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.user-item-info { flex: 1; min-width: 0; }
.user-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.user-item-login {
  font-size: 11px;
  color: var(--text-muted);
}

.user-self-badge {
  display: inline-block;
  background: var(--gradient-glow);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(99,102,241,.15);
  margin-left: 4px;
}

.user-item-role {
  min-width: 140px;
}
.user-item-role .form-input {
  max-width: 100%;
  font-size: 12px;
  padding: 6px 8px;
}

.user-item-actions {
  display: flex;
  gap: 4px;
}

.roles-table { overflow-x: auto; }
.roles-table table { width: 100%; }
.roles-table td { text-align: center; font-size: 13px; }
.roles-table td:first-child { text-align: left; font-weight: 600; }

/* ── Profit Distribution Widget ──────────────────────────── */
.pd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 8px;
}
.pd-table th {
  text-align: left;
  padding: 6px 10px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
.pd-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(0,0,0,.04);
  vertical-align: middle;
}
.pd-table tbody tr:hover { background: rgba(99,102,241,.03); }
.pd-table .dot { margin-right: 6px; }

.pd-plan, .pd-fact { font-variant-numeric: tabular-nums; }
.pd-dev { font-variant-numeric: tabular-nums; font-weight: 600; }
.pd-dev-pos { color: var(--green); }
.pd-dev-neg { color: var(--red); }

.pd-editable-cursor { cursor: pointer; }
.pd-editable-cursor:hover { background: rgba(99,102,241,.08); border-radius: 4px; }

.pd-auto { color: var(--text-muted); position: relative; }
.pd-auto-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(99,102,241,.1);
  border-radius: 3px;
  padding: 1px 4px;
  margin-left: 5px;
  vertical-align: middle;
  letter-spacing: .04em;
}

.pd-total-row td {
  font-weight: 700;
  border-top: 2px solid var(--border);
  border-bottom: none;
  padding-top: 10px;
}

.pd-warning {
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.25);
  color: var(--red);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  margin-bottom: 8px;
}

.pd-config-btn {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
  transition: all .15s;
}
.pd-config-btn:hover, .pd-config-btn.active {
  background: rgba(99,102,241,.1);
  color: var(--accent);
  border-color: var(--accent);
}
.card-title { display: flex; align-items: center; gap: 8px; }

/* Config panel */
.pd-config-panel {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.pd-config-inner { display: flex; flex-direction: column; gap: 14px; }
.pd-config-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.pd-config-fund {
  background: var(--surface);
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
}
.pd-config-fund-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
}
.pd-config-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.pd-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(99,102,241,.1);
  border: 1px solid rgba(99,102,241,.2);
  color: var(--text-dim);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 500;
}
.pd-tag-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  line-height: 1;
  display: flex;
  align-items: center;
}
.pd-tag-remove:hover { color: var(--red); }

.pd-reset-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 0 2px;
  margin-left: 4px;
  vertical-align: middle;
  opacity: .6;
  transition: opacity .15s, color .15s;
}
.pd-reset-btn:hover { opacity: 1; color: var(--accent); }
.pd-is-auto { color: var(--text-dim); }

/* ===== ФОТ / Payroll ===== */
.payroll-page { display: flex; flex-direction: column; gap: 16px; }

/* Header */
.pr-header { padding: 16px 20px !important; }
.pr-header-top { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.pr-filter-btn { font-size: 12px; padding: 3px 10px; border-radius: 20px; border: 1px solid var(--border); background: none; color: var(--text-muted); cursor: pointer; transition: var(--transition); white-space: nowrap; }
.pr-filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.pr-filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pr-filter-unpaid.active { background: var(--text-muted); border-color: var(--text-muted); }
.pr-filter-paid.active { background: #16a34a; border-color: #16a34a; }
.pr-filter-question.active { background: #b45309; border-color: #b45309; }
.pr-title-block { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 200px; }
.pr-month-nav { display: flex; align-items: center; gap: 8px; }
.pr-month-label { font-size: 16px; font-weight: 600; min-width: 140px; text-align: center; color: var(--text); }
.pr-header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pr-status-group { display: flex; gap: 4px; flex-wrap: wrap; }
.pr-status-btn { font-size: 12px !important; padding: 4px 10px !important; }
.pr-status-btn.active { font-weight: 600; }
.pr-status-open.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pr-status-questions.active { background: var(--amber); color: #fff; border-color: var(--amber); }
.pr-status-counted.active { background: #6366f1; color: #fff; border-color: #6366f1; }
.pr-status-paid.active { background: var(--green); color: #fff; border-color: var(--green); }
.pr-toggle-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.pr-toggle-label input { cursor: pointer; }

/* KPI */
.payroll-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.payroll-kpi .kpi-card { padding: 10px 14px; }
.payroll-kpi .kpi-value { font-size: 16px; margin-top: 4px; }
.payroll-kpi .kpi-label { font-size: 10px; }

/* Method breakdown */
.pr-method-card { padding: 14px 18px !important; }
.pr-method-item { display: flex; align-items: center; gap: 10px; padding: 3px 0; border-bottom: 1px solid var(--border); font-size: 12px; flex-wrap: wrap; }
.pr-method-item:last-child { border-bottom: none; }
.pr-method-item span { color: var(--text-muted); }
.pr-method-item span b { color: var(--text); }

/* Payment method badges */
.pr-pay-badge { display: inline-block; font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 4px; white-space: nowrap; }
.pr-pay- { background: #e2e8f0; color: #475569; }
.pr-pay-цех-нал- { background: rgba(217,119,6,.12); color: var(--amber); }
.pr-pay-карта-точка { background: rgba(76,197,228,.12); color: var(--accent-2); }
.pr-pay-перевод { background: rgba(22,163,74,.12); color: var(--green); }
.pr-pay-самозанят { background: rgba(139,92,246,.12); color: #7c3aed; }
.pr-pay-нал { background: rgba(220,38,38,.10); color: var(--red); }
.pr-pay-другое { background: #e2e8f0; color: #475569; }

/* Table */
.pr-table-card { padding: 0 !important; overflow: hidden; }
.pr-table-wrapper { overflow-x: auto; max-width: 100%; }
.pr-table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 900px; }

/* Column widths */
.pr-col-name { width: 170px; min-width: 140px; }
.pr-col-position { width: 130px; min-width: 100px; }
.pr-col-method { width: 100px; min-width: 80px; }
.pr-col-num { width: 100px; min-width: 88px; text-align: right; }
.pr-col-tk { }
.pr-col-adv { }
.pr-col-pay { }
.pr-col-auto { background: rgba(0,0,0,.02); font-weight: 600; text-align: right; min-width: 96px; }
.pr-col-tail { text-align: right; min-width: 88px; font-weight: 600; }
.pr-col-comment { min-width: 160px; max-width: 220px; }
.pr-col-actions { width: 32px; min-width: 32px; }

/* Sticky employee column */
.pr-sticky { position: sticky; left: 0; z-index: 2; background: var(--bg-card); }
.pr-thead-row .pr-sticky { z-index: 3; }

/* Header row */
.pr-thead-row th {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: 5px 8px;
  border-bottom: 2px solid var(--border);
  text-align: right;
  white-space: nowrap;
  vertical-align: bottom;
}
.pr-thead-row th.pr-col-name,
.pr-thead-row th.pr-col-position,
.pr-thead-row th.pr-col-method { text-align: left; }
.pr-thead-row th.pr-col-comment { text-align: left; }

/* Department header row */
.pr-dept-row td {
  background: var(--bg);
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.pr-dept-row td span { border-left: 3px solid var(--accent); padding-left: 8px; }

/* Employee rows */
.pr-emp-row td { padding: 3px 8px; border-bottom: 1px solid rgba(0,0,0,.05); vertical-align: middle; }
.pr-emp-row:hover td { background: var(--bg-card-hover); }
.pr-emp-row:hover .pr-sticky { background: var(--bg-card-hover); }
.pr-dismissed td { opacity: .55; }
/* Employee info columns */
.pr-emp-name { font-weight: 500; font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.pr-name-struck { text-decoration: line-through; text-decoration-color: var(--text-muted); opacity: .6; }
.pr-position-text { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 100%; }
.pr-info-cell { cursor: text; display: block; }
.pr-info-cell:hover { background: var(--bg-card-hover) !important; }
.pr-name-wrap { display: flex; align-items: center; gap: 4px; overflow: hidden; cursor: default; }
.pr-drag-handle { color: var(--text-muted); font-size: 13px; cursor: grab; flex-shrink: 0; opacity: 0; transition: opacity .15s; user-select: none; line-height: 1; }
.pr-emp-row:hover .pr-drag-handle { opacity: .5; }
.pr-drag-handle:hover { opacity: 1 !important; }
.pr-drag-handle:active { cursor: grabbing; }
.pr-drag-src { opacity: .35; }
.pr-emp-row.pr-drag-over > td { background: rgba(59,130,246,.07) !important; box-shadow: inset 0 2px 0 var(--accent); }
.pr-dept-row.pr-drag-over > td { background: rgba(59,130,246,.12) !important; box-shadow: inset 0 0 0 2px var(--accent); }
.pr-inline-select { font-size: 12px; padding: 1px 4px; border: 1px solid var(--accent); border-radius: 4px; background: var(--bg-card); color: var(--text); outline: none; width: 100%; }
.pr-info-input { font-size: 12px; width: 100%; padding: 1px 4px; border: 1px solid var(--accent); border-radius: 4px; background: var(--bg-card); color: var(--text); outline: none; box-sizing: border-box; }
.pr-dismissed-badge { font-size: 10px; background: var(--red-dim); color: var(--red); padding: 1px 6px; border-radius: 4px; font-weight: 500; text-decoration: none; }
.pr-emp-menu-btn { margin-left: auto; flex-shrink: 0; background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 14px; padding: 0 2px; line-height: 1; border-radius: 4px; opacity: 0; transition: opacity .15s; }
.pr-emp-row:hover .pr-emp-menu-btn { opacity: 1; }
.pr-emp-menu-btn:hover { background: var(--bg); color: var(--text); }

/* Data cells */
.pr-cell { padding: 3px 8px 22px !important; text-align: center; white-space: nowrap; position: relative; }
.pr-col-name.pr-cell { text-align: left; }
.pr-cell-val { display: block; text-align: center; }

.pr-editable { cursor: pointer; }
.pr-editable:hover { background: rgba(76,197,228,.08) !important; }

/* Bottom-center icon bar */
.pr-cell-icons { position: absolute; bottom: 3px; left: 0; right: 0; display: flex; justify-content: center; align-items: center; gap: 6px; opacity: 0; transition: opacity .15s; }
.pr-cell:hover .pr-cell-icons { opacity: 1; }
.pr-pay-ok .pr-cell-icons, .pr-pay-q .pr-cell-icons { opacity: 0; }
.pr-pay-ok:hover .pr-cell-icons, .pr-pay-q:hover .pr-cell-icons { opacity: 1; }
.pr-empty { color: var(--text-dim); }
.pr-penalty { color: var(--red); }
.pr-bonus-cell { color: var(--green); }

/* Tail coloring */
.pr-tail-zero { color: var(--text-muted); }
.pr-tail-pos { color: var(--amber); background: var(--amber-dim); }
.pr-tail-neg { color: var(--red); background: var(--red-dim); }

/* Prev-tail hint on earned cell */
.pr-prev-tail { display: block; font-size: 10px; color: var(--text-dim); font-weight: 400; }

/* Suggested 30е */
.pr-suggest { display: block; font-size: 10px; color: var(--accent-2); font-weight: 400; }

/* Cell comment indicator */
.pr-cell-comment-btn { font-size: 11px; cursor: pointer; line-height: 1; opacity: 0.35; transition: opacity .15s; }
.pr-cell-comment-btn:hover { opacity: 1; }
.pr-cell-comment-btn.pr-has-note { opacity: 1; filter: sepia(1) saturate(3) hue-rotate(180deg); }
.pr-check-btn { font-size: 11px; font-weight: 700; color: #16a34a; cursor: pointer; line-height: 1; user-select: none; padding: 0 2px; border-radius: 2px; }
.pr-check-btn:hover { background: rgba(22,163,74,.15); }
.pr-quest-btn { font-size: 11px; font-weight: 700; color: #b45309; cursor: pointer; line-height: 1; user-select: none; padding: 0 2px; border-radius: 2px; }
.pr-quest-btn:hover { background: rgba(180,83,9,.12); }
.pr-paste-btn { font-size: 12px; color: var(--accent); cursor: pointer; line-height: 1; user-select: none; opacity: 0.8; padding: 0 2px; border-radius: 2px; }
.pr-paste-btn:hover { background: rgba(76,197,228,.18); opacity: 1; }
.pr-pay-ok { background: rgba(22,163,74,.1) !important; }
.pr-emp-row:hover .pr-pay-ok { background: rgba(22,163,74,.16) !important; }
.pr-pay-q { background: rgba(234,179,8,.12) !important; }
.pr-emp-row:hover .pr-pay-q { background: rgba(234,179,8,.2) !important; }

/* Inline edit input */
.pr-inline-input { width: 100%; border: none; background: #fff; box-shadow: 0 0 0 2px var(--accent); border-radius: 4px; padding: 2px 6px; font-size: 13px; text-align: right; outline: none; }

/* Comment text input (Комментарий column) */
.pr-comment-input { width: 100%; border: 1px solid transparent; background: transparent; padding: 3px 6px; font-size: 12px; border-radius: 4px; outline: none; color: var(--text-muted); transition: border-color .15s, background .15s; }
.pr-comment-input:hover, .pr-comment-input:focus { background: var(--bg-input); border-color: var(--border-hover); color: var(--text); }
.pr-comment-text { font-size: 12px; color: var(--text-muted); }

/* Totals row */
.pr-total-row td { padding: 5px 8px; border-top: 2px solid var(--border); background: var(--bg) !important; font-size: 12px; text-align: right; }
.pr-total-row .pr-col-name { text-align: left; }

/* Comment popover */
.pr-comment-popover { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 12px; }
.pr-pop-title { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .4px; }
.pr-pop-textarea { width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 8px; font-size: 13px; font-family: inherit; resize: vertical; min-height: 72px; outline: none; background: var(--bg-input); color: var(--text); }
.pr-pop-textarea:focus { border-color: var(--accent); }
.pr-pop-actions { display: flex; gap: 6px; margin-top: 8px; align-items: center; }

/* Employee modal */
.pr-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.pr-modal { background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto; }
.pr-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.pr-modal-header h3 { font-size: 16px; font-weight: 600; margin: 0; }
.pr-modal-close { background: none; border: none; cursor: pointer; font-size: 16px; color: var(--text-muted); padding: 4px; border-radius: 4px; }
.pr-modal-close:hover { color: var(--text); background: var(--bg); }
.pr-modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.pr-modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; }
.pr-modal-dismiss { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--border); }
.pr-dismissed-cell { background: rgba(0,0,0,.01); }

/* ===== Реквизиты ===== */
.req-page { display: flex; flex-direction: column; gap: 16px; }
.req-bottom-row { display: flex; gap: 16px; align-items: flex-start; }

.req-table-card { overflow: hidden; }
.req-table-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; }
.req-table-wrap { overflow-x: auto; }

.req-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.req-table th { padding: 7px 10px; text-align: left; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--bg); position: sticky; top: 0; z-index: 1; }
.req-table td { border-bottom: 1px solid var(--border-light, rgba(0,0,0,.05)); vertical-align: middle; }
.req-table tr:last-child td { border-bottom: none; }
.req-table-sm { font-size: 12px; }
.req-table-sm th { font-size: 10px; }

.req-th-pos     { width: 150px; }
.req-th-name    { width: 180px; }
.req-th-sbp     { width: 145px; }
.req-th-card    { width: 165px; }
.req-th-comment { min-width: 160px; }
.req-th-del     { width: 28px; }

/* Dept header rows */
.req-dept-row td { background: var(--bg); padding: 6px 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.req-add-row td { padding: 4px 10px; background: transparent; }
.req-add-btn { font-size: 11px; color: var(--accent); background: none; border: none; cursor: pointer; padding: 2px 4px; border-radius: 4px; opacity: 0.7; }
.req-add-btn:hover { opacity: 1; background: rgba(76,197,228,.1); }

/* Editable cell */
.req-cell { padding: 0 !important; }
.req-cell-ro { padding: 0 !important; }
.req-cell-inner { position: relative; display: flex; align-items: center; padding: 5px 10px; min-height: 32px; gap: 4px; }
.req-editable .req-cell-inner { cursor: pointer; }
.req-editable:hover { background: rgba(76,197,228,.07); }
.req-cell-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.req-cell-text:empty::before { content: '—'; color: var(--text-dim); }

/* Copy button */
.req-copy-btn { flex-shrink: 0; font-size: 12px; padding: 1px 4px; border: none; background: none; cursor: pointer; color: var(--text-muted); border-radius: 4px; opacity: 0; transition: opacity .12s; line-height: 1; }
.req-cell-inner:hover .req-copy-btn { opacity: 1; }
.req-copy-btn:hover { background: rgba(76,197,228,.15); color: var(--accent); }

/* Delete button */
.req-cell-del { width: 28px; text-align: center; }
.req-delete-btn { font-size: 14px; border: none; background: none; cursor: pointer; color: var(--text-dim); border-radius: 4px; padding: 0 4px; line-height: 1.4; opacity: 0; transition: opacity .12s; }
.req-emp-row:hover .req-delete-btn { opacity: 1; }
.req-delete-btn:hover { color: var(--red); background: var(--red-dim); }

/* Inline edit input */
.req-inline-input { width: 100%; border: none; outline: none; background: #fff; box-shadow: 0 0 0 2px var(--accent); border-radius: 3px; padding: 3px 6px; font-size: 13px; font-family: inherit; }

/* Side card */
.req-side-card { overflow: hidden; }
.req-side-card .card-title { padding: 12px 16px 8px; }

/* Settings section toggles */
.settings-toggle-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; }
.settings-toggle-label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 500; font-size: 13px; min-width: 110px; }
.settings-toggle-label input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }
.settings-toggle-desc { font-size: 12px; color: var(--text-muted); }

@media (max-width: 900px) {
  .req-bottom-row { flex-direction: column; }
}

/* ===== Себестоимость ===== */
.cost-page { }
.cost-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.cost-header-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; padding-top: 4px; }
.cost-sync-info { font-size: 12px; color: var(--text-dim); }
.cost-stale { color: var(--amber); font-weight: 500; }

/* Banners */
.cost-banner { padding: 10px 16px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 13px; line-height: 1.5; }
.cost-banner-error { background: var(--red-dim); border: 1px solid rgba(220,38,38,.14); color: var(--red); }
.cost-banner-warn  { background: var(--amber-dim); border: 1px solid rgba(217,119,6,.14); color: var(--amber); }

/* Empty state */
.cost-empty { text-align: center; padding: 64px 20px; }
.cost-empty-icon { font-size: 48px; margin-bottom: 16px; }
.cost-empty-title { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.cost-empty-desc  { color: var(--text-muted); font-size: 13px; max-width: 400px; margin: 0 auto 20px; line-height: 1.6; }

/* Table */
.cost-table-scroll { overflow-x: auto; }
.cost-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cost-table th { padding: 10px 14px; background: var(--bg-input); font-weight: 600; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); white-space: nowrap; }
.cost-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.cost-table tbody tr:last-child td { border-bottom: none; }
.cost-table tbody tr:hover { background: var(--bg-card-hover); }
.cost-th-cat  { min-width: 180px; text-align: left; }
.cost-th-cur  { min-width: 120px; text-align: right; }
.cost-th-chg  { min-width: 64px;  text-align: center; }
.cost-th-hist { min-width: 96px;  text-align: right; color: var(--text-dim); }
.cost-th-st   { width: 36px; text-align: center; }

/* Cells */
.cost-td-cat  { }
.cost-td-cur  { text-align: right; font-weight: 600; color: var(--text); white-space: nowrap; }
.cost-td-chg  { text-align: center; }
.cost-td-hist { text-align: right; color: var(--text-muted); white-space: nowrap; }
.cost-td-st   { text-align: center; }
.cost-cat-name  { font-weight: 500; color: var(--text); }
.cost-cat-count { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.cost-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.cost-tag { font-size: 10px; font-weight: 500; padding: 2px 6px; border-radius: 4px; line-height: 1.5; }
.cost-tag-error   { background: var(--red-dim);   color: var(--red); }
.cost-tag-warning { background: var(--amber-dim); color: var(--amber); }
.cost-tag-info    { background: var(--green-dim); color: var(--green); }

/* Row highlights */
.cost-row-err  { background: rgba(220,38,38,.025); }
.cost-row-err:hover  { background: rgba(220,38,38,.05) !important; }
.cost-row-warn { background: rgba(217,119,6,.025); }
.cost-row-warn:hover { background: rgba(217,119,6,.05) !important; }

/* Status icons */
.cost-st-ok   { color: var(--green); font-weight: 700; font-size: 13px; }
.cost-st-warn { color: var(--amber); font-weight: 700; font-size: 15px; }
.cost-st-err  { color: var(--red);   font-weight: 700; font-size: 15px; }

/* Change indicators */
.cost-chg { font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
.cost-chg-up   { color: var(--red);        background: var(--red-dim); }
.cost-chg-dn   { color: var(--green);      background: var(--green-dim); }
.cost-chg-flat { color: var(--text-muted); background: var(--bg-input); }

/* Misc */
.cost-nd   { color: var(--text-dim); }
.cost-zero { color: var(--amber); font-weight: 600; }

/* Legend */
.cost-legend { display: flex; gap: 14px; align-items: center; padding: 10px 16px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; }

/* Progress / spinner */
.cost-progress { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--bg-input); border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 13px; color: var(--text-muted); }
.cost-progress-bar { width: 18px; height: 18px; border: 2px solid var(--accent); border-top-color: transparent; border-radius: 50%; animation: cost-spin .7s linear infinite; flex-shrink: 0; }
.cost-spin { display: inline-block; width: 12px; height: 12px; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: cost-spin .7s linear infinite; }
@keyframes cost-spin { to { transform: rotate(360deg); } }
