*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0a0a0a; --surface: #141414; --surface2: #1a1a1a; --border: #2a2a2a;
  --gold: #c9a96e; --gold-dim: #8a6f42; --text: #e8e8e8; --muted: #888;
  --blue: #60a5fa; --blue-bg: #1e3a5f; --yellow: #fbbf24; --yellow-bg: #3b2f00;
  --green: #4ade80; --green-bg: #14532d; --red: #f87171; --red-bg: #3b0000;
  --sidebar-w: 220px;
}
body { font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; }

/* Sidebar */
.sidebar { width: var(--sidebar-w); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 10; }
.sidebar-logo { padding: 1.5rem 1.25rem 1rem; border-bottom: 1px solid var(--border); }
.sidebar-logo .logo-title { font-size: 1.1rem; font-weight: 700; color: var(--gold); letter-spacing: 0.02em; }
.sidebar-logo .logo-sub { font-size: 0.72rem; color: var(--muted); margin-top: 0.15rem; text-transform: uppercase; letter-spacing: 0.08em; }
nav { flex: 1; padding: 0.75rem 0; }
.nav-item { display: flex; align-items: center; gap: 0.65rem; padding: 0.6rem 1.25rem; cursor: pointer; font-size: 0.9rem; color: var(--muted); border-left: 3px solid transparent; transition: all 0.15s; user-select: none; }
.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active { color: var(--gold); border-left-color: var(--gold); background: rgba(201,169,110,0.06); }
.sidebar-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); }
.ws-status { display: flex; align-items: center; gap: 0.5rem; font-size: 0.78rem; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #444; flex-shrink: 0; }
.dot.on { background: var(--green); }
.dot.err { background: var(--red); }

/* Main */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { padding: 1rem 1.75rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; background: var(--surface); position: sticky; top: 0; z-index: 5; }
.topbar-title { font-size: 1.15rem; font-weight: 600; }
.badge-admin { background: rgba(201,169,110,0.15); color: var(--gold); border: 1px solid var(--gold-dim); border-radius: 5px; padding: 0.2rem 0.65rem; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.05em; }
.content { padding: 1.75rem; flex: 1; }

/* Views */
.view { display: none; }
.view.active { display: block; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem; display: flex; flex-direction: column; gap: 0.4rem; }
.stat-label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-card.blue .stat-value { color: var(--blue); }
.stat-card.yellow .stat-value { color: var(--yellow); }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.red .stat-value { color: var(--red); }
.stat-card.gold .stat-value { color: var(--gold); }

/* Tables */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.table-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.table-header h2 { font-size: 0.95rem; font-weight: 600; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 0.65rem 1rem; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid var(--border); font-weight: 500; }
td { padding: 0.7rem 1rem; font-size: 0.875rem; border-bottom: 1px solid #1e1e1e; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }
.empty-row td { text-align: center; color: var(--muted); padding: 2.5rem; }
tr[data-status="new"] td { background: rgba(30,58,95,0.35); border-bottom-color: rgba(96,165,250,0.1); }
tr[data-status="new"]:hover td { background: rgba(30,58,95,0.55); }
tr[data-status="new"] td:first-child { border-left: 3px solid var(--blue); }
tr[data-status="in_progress"] td { background: rgba(59,47,0,0.3); border-bottom-color: rgba(251,191,36,0.08); }
tr[data-status="in_progress"]:hover td { background: rgba(59,47,0,0.5); }
tr[data-status="in_progress"] td:first-child { border-left: 3px solid var(--yellow); }
tr[data-status="completed"] td { opacity: 0.55; }
tr[data-status="canceled"] td { opacity: 0.4; }

/* Badges */
.badge { display: inline-block; padding: 0.18rem 0.55rem; border-radius: 4px; font-size: 0.72rem; font-weight: 600; white-space: nowrap; }
.badge-new { background: var(--blue-bg); color: var(--blue); }
.badge-in_progress { background: var(--yellow-bg); color: var(--yellow); }
.badge-completed { background: var(--green-bg); color: var(--green); }
.badge-canceled { background: var(--red-bg); color: var(--red); }

/* Buttons */
button { cursor: pointer; border: none; border-radius: 6px; font-size: 0.8rem; font-weight: 500; transition: opacity 0.15s; padding: 0.35rem 0.75rem; }
button:hover { opacity: 0.8; }
button:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary { background: var(--gold); color: #0a0a0a; padding: 0.6rem 1.25rem; font-size: 0.9rem; border-radius: 8px; width: 100%; margin-top: 0.25rem; }
.btn-sm-progress { background: var(--yellow-bg); color: var(--yellow); }
.btn-sm-done { background: var(--green-bg); color: var(--green); }
.btn-sm-cancel { background: var(--red-bg); color: var(--red); }
.btn-sm-danger { background: var(--red-bg); color: var(--red); }
.btn-refresh { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); border-radius: 6px; font-size: 0.8rem; }
.btn-edit { background: rgba(201,169,110,0.12); color: var(--gold); border: 1px solid var(--gold-dim); border-radius: 5px; font-size: 0.75rem; padding: 0.28rem 0.65rem; }
.btn-chat { position: relative; background: rgba(201,169,110,0.12); color: var(--gold); border: 1px solid var(--gold-dim); border-radius: 5px; font-size: 0.75rem; padding: 0.28rem 0.55rem; }
.chat-unread-badge { position: absolute; top: -6px; right: -6px; background: var(--red); color: #fff; border-radius: 50%; min-width: 16px; height: 16px; font-size: 0.62rem; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 2px; pointer-events: none; }
.nav-unread-badge { margin-left: auto; background: var(--red); color: #fff; border-radius: 10px; min-width: 18px; height: 18px; font-size: 0.7rem; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; flex-shrink: 0; }

/* Lounge view */
.lounge-layout { display: grid; grid-template-columns: 1fr 380px; gap: 1.5rem; align-items: start; }
.lounge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.lounge-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; }
.lounge-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.lounge-name { font-size: 1rem; font-weight: 600; color: var(--gold); }
.lounge-desc { font-size: 0.85rem; color: var(--muted); }
.lounge-meta { display: flex; gap: 0.75rem; font-size: 0.78rem; color: var(--muted); flex-wrap: wrap; margin-top: 0.25rem; }
.lounge-map-thumb { border-radius: 6px; overflow: hidden; height: 120px; margin-top: 0.5rem; background: #1a1a1a; border: 1px solid var(--border); position: relative; z-index: 0; }

/* Form panel */
.form-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem; position: sticky; top: 5rem; max-height: calc(100vh - 8rem); overflow-y: auto; }
.form-panel h2 { font-size: 0.95rem; font-weight: 600; margin-bottom: 1rem; }
.field { margin-bottom: 0.85rem; }
label { display: block; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.35rem; }
input[type=text], input[type=search], input[type=tel], input[type=password], textarea, select {
  width: 100%; padding: 0.5rem 0.7rem; background: #0f0f0f; border: 1px solid var(--border);
  border-radius: 7px; color: var(--text); font-size: 0.875rem; outline: none; font-family: inherit; transition: border-color 0.15s;
}
input[type=time] { padding: 0.4rem 0.5rem; background: #0f0f0f; border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 0.875rem; outline: none; font-family: inherit; color-scheme: dark; }
input[type=text]:focus, input[type=search]:focus, input[type=tel]:focus, input[type=password]:focus, textarea:focus, select:focus { border-color: var(--gold); }
textarea { resize: vertical; min-height: 55px; }
select option { background: #1a1a1a; }
.form-msg { font-size: 0.8rem; margin-top: 0.5rem; min-height: 1.2em; }

/* Schedule */
.sched-days { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-bottom: 0.65rem; }
.day-toggle { padding: 0.3rem 0.55rem; border-radius: 5px; font-size: 0.78rem; font-weight: 600; background: var(--surface2); border: 1px solid var(--border); color: var(--muted); cursor: pointer; transition: all 0.15s; user-select: none; }
.day-toggle.active { background: rgba(201,169,110,0.15); border-color: var(--gold-dim); color: var(--gold); }
.sched-rows { display: flex; flex-direction: column; gap: 0.4rem; }
.sched-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; }
.sched-row .day-label { width: 28px; color: var(--muted); font-weight: 600; flex-shrink: 0; }
.sched-row .sep { color: var(--muted); }

/* Map / address */
.addr-search { display: flex; gap: 0.4rem; margin-bottom: 0.5rem; }
.addr-search input { flex: 1; }
.addr-search button { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 0.45rem 0.7rem; border-radius: 7px; white-space: nowrap; font-size: 0.8rem; }
.addr-results { background: #0f0f0f; border: 1px solid var(--border); border-radius: 7px; margin-bottom: 0.5rem; overflow: hidden; max-height: 200px; overflow-y: auto; }
.addr-result-item { padding: 0.5rem 0.75rem; font-size: 0.8rem; cursor: pointer; border-bottom: 1px solid var(--border); color: var(--text); }
.addr-result-item:last-child { border-bottom: none; }
.addr-result-item:hover { background: var(--surface2); }
.leaflet-map { height: 220px; border-radius: 7px; border: 1px solid var(--border); background: #111; }
.coord-info { font-size: 0.75rem; color: var(--muted); margin-top: 0.4rem; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.75); z-index: 50; display: none; align-items: center; justify-content: center; padding: 1rem; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 960px; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.5rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-head h2 { font-size: 1rem; font-weight: 600; }
.modal-close { background: var(--surface2); border: 1px solid var(--border); color: var(--muted); border-radius: 6px; font-size: 1.1rem; line-height: 1; padding: 0.2rem 0.55rem; }
.modal-body { display: grid; grid-template-columns: 1fr 320px; overflow: hidden; flex: 1; }
.modal-col { padding: 1.25rem; overflow-y: auto; }
.modal-col + .modal-col { border-left: 1px solid var(--border); background: var(--surface2); }
.modal-col h3 { font-size: 0.85rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 1rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: 0.75rem; justify-content: flex-end; flex-shrink: 0; }
.btn-save { background: var(--gold); color: #0a0a0a; padding: 0.55rem 1.5rem; font-size: 0.875rem; border-radius: 8px; font-weight: 600; }
.btn-cancel-modal { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); padding: 0.55rem 1.25rem; font-size: 0.875rem; border-radius: 8px; }

/* Staff panel */
.staff-list { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
.staff-item { display: flex; align-items: center; gap: 0.6rem; background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 0.55rem 0.75rem; font-size: 0.85rem; }
.staff-item-name { flex: 1; font-weight: 500; }
.staff-item-role { font-size: 0.75rem; color: var(--muted); }
.add-staff-form { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 0.85rem; }
.add-staff-form h4 { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.65rem; font-weight: 600; }
.add-staff-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 0.5rem; }
.btn-add-staff { background: rgba(201,169,110,0.15); color: var(--gold); border: 1px solid var(--gold-dim); border-radius: 6px; width: 100%; padding: 0.45rem; font-size: 0.82rem; margin-top: 0.25rem; }

/* Role checkboxes */
.role-checkboxes { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.role-checkbox-item { display: flex; align-items: center; gap: 0.35rem; background: var(--surface2); border: 1px solid var(--border); border-radius: 5px; padding: 0.3rem 0.6rem; font-size: 0.8rem; cursor: pointer; user-select: none; transition: all 0.15s; }
.role-checkbox-item:has(input:checked) { background: rgba(201,169,110,0.12); border-color: var(--gold-dim); color: var(--gold); }
.role-checkbox-item input[type=checkbox] { width: 13px; height: 13px; accent-color: var(--gold); cursor: pointer; }

/* Misc */
.section-title { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }
.realtime-badge { display: inline-flex; align-items: center; gap: 0.4rem; background: rgba(74,222,128,0.1); color: var(--green); border: 1px solid rgba(74,222,128,0.2); border-radius: 5px; padding: 0.2rem 0.6rem; font-size: 0.75rem; font-weight: 500; }
.toast { position: fixed; bottom: 1.5rem; right: 1.5rem; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 0.7rem 1.15rem; font-size: 0.875rem; z-index: 200; opacity: 0; transform: translateY(8px); transition: all 0.2s; pointer-events: none; max-width: 320px; }
.toast.show { opacity: 1; transform: translateY(0); }
@keyframes alarmBlink { 0%,100%{opacity:1} 50%{opacity:0.3} }
.alarm-indicator { display: none; align-items: center; gap: 0.4rem; background: var(--red-bg); border: 1px solid var(--red); border-radius: 7px; padding: 0.25rem 0.65rem; font-size: 0.78rem; color: var(--red); font-weight: 600; animation: alarmBlink 1s ease-in-out infinite; }
.alarm-indicator.active { display: flex; }

/* Chat modal */
.chat-modal-inner { max-width: 520px; display: flex; flex-direction: column; height: min(600px, 90vh); }
.chat-messages { display: flex; flex-direction: column; gap: 0.75rem; padding: 1rem; overflow-y: auto; flex: 1; }
.chat-bubble { max-width: 82%; display: flex; flex-direction: column; gap: 0.2rem; }
.chat-bubble.me { align-self: flex-end; align-items: flex-end; }
.chat-bubble.them { align-self: flex-start; align-items: flex-start; }
.bubble-meta { font-size: 0.7rem; color: var(--muted); }
.bubble-text { padding: 0.5rem 0.85rem; border-radius: 10px; font-size: 0.875rem; line-height: 1.45; word-break: break-word; }
.chat-bubble.me .bubble-text { background: rgba(201,169,110,0.15); border: 1px solid var(--gold-dim); border-bottom-right-radius: 3px; }
.chat-bubble.them .bubble-text { background: var(--surface2); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.chat-empty { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 2.5rem 1rem; }
.chat-input-area { padding: 0.85rem 1rem; border-top: 1px solid var(--border); display: flex; gap: 0.5rem; flex-shrink: 0; }
.btn-send { background: var(--gold); color: #0a0a0a; padding: 0.5rem 1rem; border-radius: 7px; font-weight: 600; white-space: nowrap; }

/* Login overlay */
#login-overlay { position: fixed; inset: 0; background: var(--bg); z-index: 500; display: flex; align-items: center; justify-content: center; }
#login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 2rem; width: 340px; }
#login-box .lb-title { font-size: 1.4rem; font-weight: 700; color: var(--gold); text-align: center; margin-bottom: 0.2rem; }
#login-box .lb-sub { font-size: 0.78rem; color: var(--muted); text-align: center; margin-bottom: 1.75rem; text-transform: uppercase; letter-spacing: 0.08em; }

/* Responsive */
.sidebar { transition: transform 0.25s; }
#menu-btn { display: none; }
#sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 9; }
#sidebar-overlay.show { display: block; }
@media (max-width: 768px) {
  body { flex-direction: column; }
  .sidebar { transform: translateX(-100%); position: fixed; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  #menu-btn { display: inline-flex; }
  .content { padding: 1rem; }
  .topbar { padding: 0.75rem 1rem; gap: 0.5rem; }
  .table-wrap { overflow-x: auto; }
  table { min-width: 600px; }
  .lounge-layout { grid-template-columns: 1fr; }
  .form-panel { position: static; max-height: none; }
  .modal-body { grid-template-columns: 1fr; }
  .modal-col + .modal-col { border-left: none; border-top: 1px solid var(--border); }
  .add-staff-row { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
.leaflet-container { background: #111; }
.leaflet-popup-content-wrapper { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.leaflet-popup-tip { background: var(--surface); }
