:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #e2e6ea;
  --line-strong: #cdd4da;
  --text: #23303a;
  --muted: #7c8a97;
  --accent: #2f6f5e;         /* Naibor green */
  --accent-dark: #245546;
  --weekend: #f9fafb;
  --today: #fff7e6;
  /* пастельные статусы (заливка / рамка / текст) */
  --paid-bg:#dff3e6;    --paid-bd:#8fd4ab;
  --deposit-bg:#fef3d6; --deposit-bd:#f0cf80;
  --unpaid-bg:#fbe3e3;  --unpaid-bd:#eaa3a3;
  --inhouse-ring:#2f6f5e;
  --checkout-bg:#eceff1; --checkout-bd:#c3ccd3;
  --row-h: 40px;
  --label-w: 170px;
  --day-w: 34px;
}
* { box-sizing: border-box; }
html,body { margin:0; height:100%; font-family:-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif; color:var(--text); background:var(--bg); }
button { font-family:inherit; cursor:pointer; }
.hidden { display:none !important; }

/* ---------- Login ---------- */
#login { position:fixed; inset:0; display:flex; align-items:center; justify-content:center; background:var(--bg); z-index:100; }
.login-card { background:var(--panel); padding:32px; border-radius:14px; box-shadow:0 10px 40px rgba(0,0,0,.08); width:320px; }
.login-card h1 { margin:0 0 4px; font-size:20px; }
.login-card p { margin:0 0 20px; color:var(--muted); font-size:13px; }
.login-card input { width:100%; padding:11px 12px; margin-bottom:12px; border:1px solid var(--line-strong); border-radius:8px; font-size:14px; }
.login-card button { width:100%; padding:11px; background:var(--accent); color:#fff; border:none; border-radius:8px; font-size:14px; font-weight:600; }
.login-card button:hover { background:var(--accent-dark); }
.login-err { color:#c0392b; font-size:13px; min-height:18px; margin-bottom:8px; }

/* ---------- Header ---------- */
header { background:var(--panel); border-bottom:1px solid var(--line); padding:10px 18px; display:flex; align-items:center; gap:16px; flex-wrap:wrap; }
.brand { font-weight:700; font-size:16px; color:var(--accent); white-space:nowrap; }
.tabs { display:flex; gap:6px; flex:1; flex-wrap:wrap; }
.tab { padding:8px 14px; border:1px solid var(--line-strong); background:#fff; border-radius:20px; font-size:13px; color:var(--muted); }
.tab.active { background:var(--accent); color:#fff; border-color:var(--accent); font-weight:600; }
.user-box { display:flex; align-items:center; gap:10px; font-size:13px; color:var(--muted); }
.user-box button { border:none; background:none; color:var(--accent); font-size:13px; }

/* ---------- Toolbar ---------- */
.toolbar { display:flex; align-items:center; gap:12px; padding:10px 18px; }
.toolbar .month { font-weight:600; font-size:15px; min-width:150px; text-align:center; }
.toolbar button.nav { border:1px solid var(--line-strong); background:#fff; border-radius:8px; width:34px; height:34px; font-size:16px; }
.toolbar .spacer { flex:1; }
.btn-primary { background:var(--accent); color:#fff; border:none; border-radius:8px; padding:9px 16px; font-size:13px; font-weight:600; }
.btn-primary:hover { background:var(--accent-dark); }
.legend { display:flex; gap:14px; font-size:12px; color:var(--muted); align-items:center; }
.legend .dot { display:inline-block; width:11px; height:11px; border-radius:3px; margin-right:5px; vertical-align:-1px; border:1px solid; }

/* ---------- Grid / шахматка ---------- */
.grid-wrap { overflow:auto; margin:0 18px 18px; border:1px solid var(--line); border-radius:10px; background:#fff; }
.grid-head, .grid-row { display:grid; }
.grid-head { position:sticky; top:0; z-index:5; background:#fafbfc; border-bottom:1px solid var(--line-strong); }
.cell-label {
  position:sticky; left:0; z-index:2; background:#fafbfc; border-right:1px solid var(--line-strong);
  display:flex; align-items:center; padding:0 10px; font-size:13px; font-weight:500;
  width:var(--label-w); min-width:var(--label-w);
}
.grid-row .cell-label { background:#fff; }
.grid-row.maint .cell-label { color:var(--muted); font-style:italic; }
.day-head { text-align:center; padding:4px 0; font-size:11px; border-right:1px solid var(--line); color:var(--muted); }
.day-head .dow { display:block; font-size:9px; text-transform:uppercase; }
.day-head.weekend { background:var(--weekend); }
.day-head.today { background:var(--today); color:var(--accent-dark); font-weight:700; }

.grid-row { border-bottom:1px solid var(--line); position:relative; height:var(--row-h); }
.day-cell { border-right:1px solid var(--line); grid-row:1; }
.day-cell.weekend { background:var(--weekend); }
.day-cell.today { background:var(--today); }
.day-cell:hover { background:#eef5f2; cursor:cell; }

/* Бронь-бар поверх ячеек дней — цветовой язык Nebula Room Chart */
.booking { grid-row:1; z-index:3; margin:5px 2px; border-radius:6px; border:1px solid; padding:0 8px;
  display:flex; flex-direction:column; justify-content:center; line-height:1.15;
  font-size:11px; font-weight:600; overflow:hidden; white-space:nowrap;
  cursor:pointer; box-shadow:0 1px 2px rgba(0,0,0,.12); color:#12321f; }
.booking .bk-no { font-size:9px; opacity:.75; font-weight:600; }
.booking .bk-name { overflow:hidden; text-overflow:ellipsis; }
.booking:hover { filter:brightness(.96); }
/* IN HOUSE (зелёный) — заселён */
.booking.st-inhouse   { background:#7ac79a; border-color:#4faa77; color:#0e2c1b; }
/* GUARANTEED (синий) — забронирован, оплачен/предоплата */
.booking.st-guaranteed{ background:#5b8def; border-color:#3f6fd0; color:#fff; }
/* NON GUARANTEED (голубой) — забронирован, не оплачен */
.booking.st-nonguar   { background:#bcd8fb; border-color:#8bbdf3; color:#183a63; }
/* OUT (серый) — выселен */
.booking.st-out       { background:#d7dde1; border-color:#b5bfc6; color:#5a6670; text-decoration:line-through; }
/* MAINTENANCE (красный) — юнит на ремонте (блок) */
.booking.st-maint     { background:#f19a9a; border-color:#e07a7a; color:#5a1414; }

/* ---------- Sidebar ---------- */
.overlay { position:fixed; inset:0; background:rgba(20,30,40,.28); opacity:0; pointer-events:none; transition:opacity .2s; z-index:40; }
.overlay.open { opacity:1; pointer-events:auto; }
.sidebar { position:fixed; top:0; right:0; height:100%; width:380px; max-width:92vw; background:#fff; box-shadow:-8px 0 30px rgba(0,0,0,.12);
  transform:translateX(100%); transition:transform .25s ease; z-index:50; display:flex; flex-direction:column; }
.sidebar.open { transform:translateX(0); }
.sidebar header.sb-head { display:flex; justify-content:space-between; align-items:center; padding:16px 18px; border-bottom:1px solid var(--line); }
.sb-head h2 { margin:0; font-size:16px; }
.sb-close { border:none; background:none; font-size:22px; color:var(--muted); line-height:1; }
.sb-body { padding:18px; overflow:auto; flex:1; }
.field { margin-bottom:14px; }
.field label { display:block; font-size:11px; text-transform:uppercase; color:var(--muted); margin-bottom:4px; letter-spacing:.03em; }
.field input, .field select, .field textarea { width:100%; padding:9px 10px; border:1px solid var(--line-strong); border-radius:8px; font-size:14px; font-family:inherit; }
.field textarea { resize:vertical; min-height:56px; }
.field .static { font-size:14px; padding:4px 0; }
.tag { display:inline-block; background:#eef5f2; color:var(--accent-dark); border-radius:12px; padding:2px 10px; font-size:12px; margin:2px 4px 2px 0; }
.sb-actions { padding:14px 18px; border-top:1px solid var(--line); display:flex; gap:8px; flex-wrap:wrap; }
.sb-actions button { flex:1; min-width:120px; padding:10px; border-radius:8px; font-size:13px; font-weight:600; border:1px solid var(--line-strong); background:#fff; }
.sb-actions .primary { background:var(--accent); color:#fff; border-color:var(--accent); }
.sb-actions .danger  { color:#c0392b; border-color:#eaa3a3; }
.row2 { display:flex; gap:10px; }
.row2 .field { flex:1; }

/* Автокомплит */
.autocomplete { position:relative; }
.ac-list { position:absolute; left:0; right:0; top:100%; background:#fff; border:1px solid var(--line-strong); border-top:none;
  border-radius:0 0 8px 8px; max-height:200px; overflow:auto; z-index:10; box-shadow:0 6px 16px rgba(0,0,0,.08); }
.ac-item { padding:9px 11px; font-size:13px; border-bottom:1px solid var(--line); }
.ac-item:hover { background:#eef5f2; cursor:pointer; }
.ac-item small { color:var(--muted); }
.ac-new { color:var(--accent); font-weight:600; }
.toast { position:fixed; bottom:20px; left:50%; transform:translateX(-50%); background:#23303a; color:#fff; padding:11px 18px;
  border-radius:8px; font-size:13px; z-index:80; opacity:0; transition:opacity .2s; }
.toast.show { opacity:1; }
.toast.err { background:#c0392b; }

/* ---------- Переключатель видов ---------- */
.views { display:flex; gap:4px; }
.view-btn { padding:8px 16px; border:none; background:none; border-radius:8px; font-size:14px; color:var(--muted); font-weight:500; }
.view-btn:hover { background:#eef2f5; }
.view-btn.active { background:var(--accent); color:#fff; font-weight:600; }
header .spacer { flex:1; }
.muted { color:var(--muted); font-size:13px; }

/* ---------- Таблица гостей ---------- */
.search { flex:0 1 420px; padding:9px 12px; border:1px solid var(--line-strong); border-radius:8px; font-size:14px; }
.search:focus { outline:none; border-color:var(--accent); }
.table-wrap { margin:0 18px 18px; border:1px solid var(--line); border-radius:10px; background:#fff; overflow:auto; max-height:calc(100vh - 190px); }
.tbl { width:100%; border-collapse:collapse; font-size:13px; }
.tbl thead th { position:sticky; top:0; background:#fafbfc; text-align:left; padding:10px 12px;
  border-bottom:1px solid var(--line-strong); font-size:11px; text-transform:uppercase;
  letter-spacing:.03em; color:var(--muted); z-index:2; }
.tbl td { padding:10px 12px; border-bottom:1px solid var(--line); }
.tbl tbody tr:hover { background:#eef5f2; cursor:pointer; }
.tbl .num { text-align:right; }
.tbl td.name { font-weight:600; }
.tbl .empty { text-align:center; padding:40px; color:var(--muted); }

/* ---------- Бейджи источников ---------- */
.src { display:inline-block; padding:2px 9px; border-radius:11px; font-size:11px; font-weight:600; white-space:nowrap; }
.src-agent   { background:#e7edfb; color:#2f4f9e; }
.src-website { background:#dff3e6; color:#1f6b45; }
.src-direct  { background:#e6f2f0; color:#245546; }
.src-phone   { background:#fef3d6; color:#8a6a12; }
.src-ota     { background:#fbe3f2; color:#8e2f6d; }
.src-walk_in { background:#eef0f2; color:#5a6670; }
.src-repeat  { background:#e9e2fb; color:#553f9e; }
.src-unknown { background:#f1f3f5; color:#98a4ae; }

/* история броней в карточке гостя */
.hist { margin-top:6px; }
.hist-row { display:flex; justify-content:space-between; gap:8px; padding:7px 0;
  border-bottom:1px solid var(--line); font-size:12px; }
.hist-row:last-child { border-bottom:none; }
.hist-row .h-unit { font-weight:600; }
.hist-row .h-dates { color:var(--muted); }

/* ---------- Reports ---------- */
.cards { display:flex; gap:12px; margin:0 18px 14px; flex-wrap:wrap; }
.kpi { flex:1; min-width:170px; background:#fff; border:1px solid var(--line); border-radius:10px; padding:14px 16px; }
.kpi .k-label { font-size:11px; text-transform:uppercase; letter-spacing:.03em; color:var(--muted); }
.kpi .k-value { font-size:24px; font-weight:700; color:var(--text); margin-top:4px; }
.kpi .k-sub { font-size:12px; color:var(--muted); margin-top:2px; }
.kpi.warn { border-color:#f0cf80; background:#fff7e6; }
.charts { display:flex; gap:12px; margin:0 18px 14px; flex-wrap:wrap; }
.card-box { flex:1; min-width:340px; background:#fff; border:1px solid var(--line); border-radius:10px; padding:14px 16px; }
.card-box h3 { margin:0 0 10px; font-size:13px; color:var(--muted); text-transform:uppercase; letter-spacing:.03em; font-weight:600; }
