:root {
  --bg: #f5f5f4; --panel: #ffffff; --ink: #1c1917; --ink-2: #44403c; --muted: #78716c; --line: #e7e5e4;
  --line-2: #d6d3d1; --brand: #0f766e; --brand-ink: #ffffff; --brand-soft: #ccfbf1; --side: #134e4a;
  --side-ink: #d1fae5; --side-active: #0f766e; --focus: #14b8a6;
  --green: #15803d; --green-soft: #dcfce7; --amber: #b45309; --amber-soft: #fef3c7; --red: #b91c1c;
  --red-soft: #fee2e2; --blue: #1d4ed8; --blue-soft: #dbeafe; --purple: #7e22ce; --purple-soft: #f3e8ff;
  --gray-soft: #f5f5f4; --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 1px 3px rgba(0,0,0,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 0 0 8px; }
p { margin: 0 0 10px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }

/* ---------- layout */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-ink); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; font-size: 17px; padding: 4px 8px 14px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: #2dd4bf; color: #134e4a; display: grid; place-items: center; font-weight: 800; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #99f6e4; opacity: .7; margin: 14px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 9px; color: var(--side-ink); padding: 7px 10px; border-radius: 8px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.nav a.active { background: var(--side-active); color: #fff; }
.nav .count { margin-left: auto; background: #f87171; color: #fff; border-radius: 99px; font-size: 11px; padding: 0 7px; }
.ico { width: 18px; text-align: center; opacity: .9; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 22px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .spacer { flex: 1; }
.prop-switch { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 0 1 auto; margin: 0; }
.prop-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.prop-switch select { font-weight: 600; min-width: 220px; }
.prop-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn { display: none; }
.content { padding: 20px 22px 60px; max-width: 1500px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- surfaces */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-h h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.stat a { color: inherit; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafaf9; white-space: nowrap; }
.table tr:hover td { background: #fafaf9; }
.table tfoot td { font-weight: 700; background: #fafaf9; }
.table .num, .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.table.compact td, .table.compact th { padding: 5px 8px; }
tr.muted-row td { color: var(--muted); }

/* ---------- forms */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; color: var(--ink-2); }
input[type=text], input[type=email], input[type=number], input[type=password], input[type=date], input[type=time],
input[type=datetime-local], input[type=url], input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; font: inherit; color: inherit;
}
input[type=color] { width: 60px; height: 36px; padding: 2px; border: 1px solid var(--line-2); border-radius: 8px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
input[type=checkbox] { width: 16px; height: 16px; vertical-align: -3px; accent-color: var(--brand); }
select[multiple] { min-height: 110px; }
.field { margin-bottom: 14px; }
.field.check label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.help { color: var(--muted); font-size: 12px; margin-top: 3px; }
.errorlist { color: var(--red); margin: 4px 0 0; padding: 0; list-style: none; font-size: 12.5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 12px; }
.form-grid .wide, .form-grid-3 .wide, .form-grid-4 .wide { grid-column: 1 / -1; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }
.actions input, .actions select, .inline-form > input, .inline-form > select { width: auto; max-width: 260px; }
.page-head .actions form { margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 12px; }
.filters > div { min-width: 140px; }
.filters label { font-size: 12px; }
.checkbox-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.checkbox-groups fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.checkbox-groups legend { font-weight: 700; padding: 0 4px; }
.checkbox-groups label { font-weight: 400; display: flex; gap: 8px; align-items: flex-start; margin: 4px 0; }
ul.plain { list-style: none; padding: 0; margin: 0; }
#id_permissions { list-style: none; padding: 0; }

/* ---------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line-2);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #fafaf9; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: #115e59; }
.btn-danger { background: #fff; border-color: #fca5a5; color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { padding: 14px 20px; font-size: 16px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }

/* ---------- badges & messages */
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--gray-soft); color: var(--ink-2); white-space: nowrap; border: 1px solid var(--line); }
.b-green { background: var(--green-soft); color: var(--green); border-color: #bbf7d0; }
.b-amber { background: var(--amber-soft); color: var(--amber); border-color: #fde68a; }
.b-red { background: var(--red-soft); color: var(--red); border-color: #fecaca; }
.b-blue { background: var(--blue-soft); color: var(--blue); border-color: #bfdbfe; }
.b-purple { background: var(--purple-soft); color: var(--purple); border-color: #e9d5ff; }
.b-gray { background: var(--gray-soft); color: var(--muted); }
.msgs { margin-bottom: 14px; }
.msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; border: 1px solid; }
.msg-success { background: var(--green-soft); border-color: #bbf7d0; color: #14532d; }
.msg-error { background: var(--red-soft); border-color: #fecaca; color: #7f1d1d; }
.msg-warning { background: var(--amber-soft); border-color: #fde68a; color: #78350f; }
.msg-info { background: var(--blue-soft); border-color: #bfdbfe; color: #1e3a8a; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.strong { font-weight: 700; }
.red { color: var(--red); } .green { color: var(--green); } .amber { color: var(--amber); }
.mt { margin-top: 12px; } .mb { margin-bottom: 12px; } .mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.flex { display: flex; gap: 8px; align-items: center; }
.flex.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.empty { padding: 26px; text-align: center; color: var(--muted); }
.pill-color { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: 0; margin-right: 4px; }

/* ---------- tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- reservation header */
.res-head { display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: center; }
.res-head .big { font-size: 20px; font-weight: 700; }
.res-head .meta { color: var(--muted); }
.money-box { display: flex; gap: 22px; }
.money-box div span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.money-box div b { font-size: 18px; }

/* ---------- tape chart */
.tape-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.tape { --label: 150px; --col: 58px; min-width: calc(var(--label) + var(--days) * var(--col)); }
.tape-row { display: grid; grid-template-columns: var(--label) repeat(var(--days), minmax(var(--col), 1fr)); position: relative; min-height: 36px; border-bottom: 1px solid var(--line); }
.tape-row > * { grid-row: 1; }
.tape-head { position: sticky; top: 0; background: #fafaf9; z-index: 3; font-size: 12px; }
.tape-head .day { text-align: center; padding: 6px 2px; border-left: 1px solid var(--line); line-height: 1.2; }
.tape-head .day.weekend { background: #f5f5f4; }
.tape-head .day.today { background: var(--brand-soft); font-weight: 700; }
.tape-label { padding: 8px 10px; font-weight: 600; border-right: 1px solid var(--line); background: #fff; position: sticky; left: 0; z-index: 2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tape-label .hk { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.tape-cell { border-left: 1px solid var(--line); min-height: 36px; display: block; }
.tape-cell:hover { background: var(--brand-soft); }
.tape-cell.weekend { background: #fafaf9; }
.tape-cell.today { background: #f0fdfa; }
.tape-type { background: #f5f5f4; font-size: 12px; color: var(--ink-2); }
.tape-type .tape-label { background: #f5f5f4; font-weight: 700; }
.tape-type .avail { text-align: center; padding: 6px 0; border-left: 1px solid var(--line); font-weight: 700; }
.avail.zero { color: var(--red); } .avail.neg { background: var(--red-soft); color: var(--red); }
.bar { align-self: center; margin: 3px 2px; height: 28px; border-radius: 6px; padding: 4px 8px; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: #fff; z-index: 1; box-shadow: 0 1px 2px rgba(0,0,0,.15); line-height: 20px; }
.bar:hover { text-decoration: none; filter: brightness(1.08); }
.bar.s-confirmed { background: #2563eb; } .bar.s-provisional { background: #d97706; } .bar.s-checked_in { background: #16a34a; }
.bar.s-checked_out { background: #78716c; } .bar.block { background: repeating-linear-gradient(45deg, #fecaca, #fecaca 6px, #fee2e2 6px, #fee2e2 12px); color: var(--red); box-shadow: none; }
.bar.clip-l { border-top-left-radius: 0; border-bottom-left-radius: 0; } .bar.clip-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }

/* ---------- gantt (vehicles) */
.gantt { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow-x: auto; }
.gantt-inner { min-width: 900px; }
.g-row { display: grid; grid-template-columns: 190px 1fr; border-bottom: 1px solid var(--line); min-height: 46px; }
.g-label { padding: 8px 10px; border-right: 1px solid var(--line); font-weight: 600; }
.g-label .small { font-weight: 400; }
.g-track { position: relative; }
.g-hours { position: relative; height: 26px; font-size: 11px; color: var(--muted); }
.g-hours span { position: absolute; top: 6px; transform: translateX(-50%); }
.g-grid { position: absolute; inset: 0; background-image: linear-gradient(to right, var(--line) 1px, transparent 1px); background-size: calc(100% / 18) 100%; pointer-events: none; }
.g-bar { position: absolute; top: 6px; bottom: 6px; border-radius: 6px; color: #fff; font-size: 11.5px; padding: 3px 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; z-index: 1; line-height: 1.25; }
.g-bar:hover { text-decoration: none; filter: brightness(1.08); }
.g-buffer { position: absolute; top: 12px; bottom: 12px; background: repeating-linear-gradient(45deg, #e7e5e4, #e7e5e4 4px, transparent 4px, transparent 8px); }
.g-bar.other { background: #a8a29e !important; }
.g-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--red); z-index: 2; }

/* ---------- housekeeping board */
.hk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.hk-card { background: #fff; border: 1px solid var(--line); border-left: 6px solid var(--line-2); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow); }
.hk-card.st-dirty { border-left-color: #dc2626; } .hk-card.st-cleaning { border-left-color: #d97706; }
.hk-card.st-clean { border-left-color: #16a34a; } .hk-card.st-inspected { border-left-color: #2563eb; }
.hk-card.blocked { background: repeating-linear-gradient(45deg, #fff, #fff 8px, #fef2f2 8px, #fef2f2 16px); }
.hk-card .room { font-size: 16px; font-weight: 700; }
.hk-card .task { border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 6px; font-size: 12.5px; }
.hk-status-btns { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.task-big { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; margin-bottom: 10px; }
.checklist label { font-weight: 400; display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 15px; }

/* ---------- month calendar */
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.month .dow { background: #fafaf9; padding: 6px; font-size: 12px; font-weight: 700; color: var(--muted); border-bottom: 1px solid var(--line); }
.month .day { min-height: 110px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 12px; }
.month .day.other { background: #fafaf9; color: var(--muted); }
.month .day.today { background: #f0fdfa; }
.month .day .n { font-weight: 700; margin-bottom: 4px; }
.month .ev { display: block; padding: 2px 6px; border-radius: 5px; margin-bottom: 3px; background: var(--blue-soft); color: var(--blue); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.month .ev.proj { background: #fff; border: 1px dashed var(--line-2); color: var(--muted); }
.month .ev.p1 { background: var(--red-soft); color: var(--red); } .month .ev.p2 { background: var(--amber-soft); color: var(--amber); }
.month .ev.done { background: var(--green-soft); color: var(--green); text-decoration: line-through; }

/* ---------- roster */
.roster td { min-width: 120px; }
.shift { display: block; background: var(--brand-soft); color: #134e4a; border-radius: 6px; padding: 3px 6px; margin-bottom: 3px; font-size: 12px; }

/* ---------- template editor */
.editor { display: grid; grid-template-columns: 1fr 340px; gap: 16px; }
.editor textarea { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; min-height: 520px; }
.field-picker { max-height: 640px; overflow-y: auto; }
.field-picker h4 { margin: 10px 0 4px; font-size: 12px; text-transform: uppercase; color: var(--muted); }
.field-picker button { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 5px 8px; margin-bottom: 4px; cursor: pointer; font-size: 12px; }
.field-picker button:hover { border-color: var(--brand); background: #f0fdfa; }
.field-picker code { display: block; color: var(--brand); word-break: break-all; }

/* ---------- auth & public pages */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #134e4a, #0f766e 55%, #14b8a6); }
.center-card { width: 100%; max-width: 420px; background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.center-card h1 { margin-bottom: 4px; }
.pay-amount { font-size: 34px; font-weight: 800; letter-spacing: -.02em; margin: 10px 0 18px; }

/* ---------- autocomplete */
.ac { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; background: #fff; border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 280px; overflow-y: auto; }
.ac-list button { display: block; width: 100%; text-align: left; border: 0; background: #fff; padding: 8px 10px; cursor: pointer; font: inherit; }
.ac-list button:hover { background: #f0fdfa; }

/* ---------- responsive */
@media (max-width: 1100px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; width: 250px; z-index: 50; transition: left .2s; }
  body.nav-open .sidebar { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .menu-btn { display: inline-flex; }
  .content { padding: 14px 14px 60px; }
  .topbar { padding: 8px 14px; }
  .prop-switch { flex: 1 1 auto; }
  .prop-switch select { min-width: 0; width: 100%; }
  .cols-2, .cols-3, .cols-4, .form-grid, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 6px; }
  .hide-mobile { display: none; }
  .money-box { gap: 14px; flex-wrap: wrap; }
}
@media print {
  .sidebar, .topbar, .noprint, .actions, .tabs, .msgs { display: none !important; }
  .app { display: block; } body { background: #fff; } .card { box-shadow: none; border: 0; padding: 0; }
  .content { padding: 0; max-width: none; }
}
