@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

:root {
  --green-900: #04342C; --green-800: #085041; --green-700: #0F6E56;
  --green-600: #1A6B4A; --green-500: #1D9E75; --green-100: #9FE1CB; --green-50: #E1F5EE;
  --gray-900: #1A1A1A; --gray-800: #2C2C2A; --gray-700: #444441;
  --gray-600: #5F5E5A; --gray-400: #888780; --gray-200: #D3D1C7; --gray-100: #F1EFE8; --gray-50: #FAFAF8;
  --red-600: #A32D2D; --red-100: #FCEBEB;
  --amber-100: #FAEEDA; --amber-600: #854F0B;
  --blue-100: #E6F1FB; --blue-600: #185FA5;
  --font: 'Outfit', sans-serif; --mono: 'DM Mono', monospace;
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-xl: 24px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06); --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --sidebar-width: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font); background: var(--gray-100); color: var(--gray-900); line-height: 1.6; }
a { color: var(--green-600); text-decoration: none; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width); background: var(--green-900);
  position: fixed; top: 0; left: 0; height: 100vh;
  display: flex; flex-direction: column; z-index: 200;
  transition: transform 0.25s ease;
}
.sidebar-logo { padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-nav { padding: 12px; flex: 1; overflow-y: auto; }
.nav-section { font-size: 10px; font-weight: 600; color: rgba(255,255,255,0.3); text-transform: uppercase; letter-spacing: 0.08em; padding: 12px 12px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); color: rgba(255,255,255,0.65); font-size: 14px; font-weight: 500; transition: all 0.15s; margin-bottom: 2px; cursor: pointer; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: white; text-decoration: none; }
.nav-item.active { background: rgba(255,255,255,0.12); color: white; }
.nav-icon { width: 20px; text-align: center; font-size: 15px; flex-shrink: 0; }
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-user strong { color: rgba(255,255,255,0.85); display: block; font-size: 13px; font-weight: 600; }
.sidebar-user span { color: rgba(255,255,255,0.4); font-size: 11px; }
.impersonate-bar { background: #EF9F27; color: #412402; font-size: 12px; font-weight: 600; padding: 8px 12px; text-align: center; }
.impersonate-bar a { color: #412402; font-weight: 700; }

/* ── Mobile header ── */
.mobile-header {
  display: none; position: fixed; top: 0; left: 0; right: 0; height: 56px;
  background: var(--green-900); z-index: 150;
  align-items: center; justify-content: space-between; padding: 0 16px;
}
.hamburger { background: none; border: none; cursor: pointer; padding: 4px; display: flex; flex-direction: column; gap: 5px; }
.hamburger span { display: block; width: 22px; height: 2px; background: white; border-radius: 2px; transition: all 0.2s; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 190; }

/* ── Layout ── */
.app-shell { display: flex; min-height: 100vh; }
.main-content { margin-left: var(--sidebar-width); flex: 1; padding: 28px; max-width: 1200px; }

/* ── Cards ── */
.card { background: white; border-radius: var(--radius-lg); border: 1px solid var(--gray-200); padding: 20px 24px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 600; }

/* ── Page header ── */
.page-header { margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { font-size: 14px; color: var(--gray-600); margin-top: 3px; }

/* ── Stats ── */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.stat-card { background: white; border-radius: var(--radius-md); border: 1px solid var(--gray-200); padding: 16px 20px; }
.stat-number { font-size: 30px; font-weight: 700; font-family: var(--mono); color: var(--green-700); }
.stat-label { font-size: 12px; color: var(--gray-600); margin-top: 2px; }
.stat-card.urgent .stat-number { color: var(--red-600); }

/* ── Alert cards ── */
.alert-list { display: flex; flex-direction: column; gap: 10px; }
.alert-card { background: white; border-radius: var(--radius-md); border: 1px solid var(--gray-200); padding: 14px 16px; display: flex; align-items: flex-start; gap: 12px; animation: slideDown 0.25s ease; }
@keyframes slideDown { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }
.alert-card.new-alert { border-left: 3px solid var(--green-500); }
.alert-card.resolved { opacity: 0.4; }
.alert-icon { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.alert-icon.urgent { background: var(--red-100); }
.alert-icon.normal { background: var(--green-50); }
.alert-icon.info { background: var(--blue-100); }
.alert-body { flex: 1; min-width: 0; }
.alert-meta { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 2px; gap: 8px; }
.alert-room { font-size: 14px; font-weight: 600; }
.alert-time { font-size: 11px; color: var(--gray-400); font-family: var(--mono); flex-shrink: 0; }
.alert-type { font-size: 13px; color: var(--gray-600); }
.alert-note { font-size: 12px; color: var(--gray-400); margin-top: 3px; font-style: italic; }
.alert-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm); font-family: var(--font); font-size: 13px; font-weight: 500; border: 1px solid transparent; cursor: pointer; transition: all 0.15s; text-decoration: none; white-space: nowrap; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--green-600); color: white; }
.btn-primary:hover { background: var(--green-700); color: white; }
.btn-outline { background: transparent; border-color: var(--green-600); color: var(--green-600); }
.btn-outline:hover { background: var(--green-50); }
.btn-resolve { background: var(--green-50); color: var(--green-700); border-color: var(--green-100); font-size: 12px; padding: 5px 10px; }
.btn-resolve:hover { background: var(--green-600); color: white; border-color: var(--green-600); }
.btn-ignore { background: var(--gray-100); color: var(--gray-600); border-color: var(--gray-200); font-size: 12px; padding: 5px 10px; }
.btn-danger { background: var(--red-100); color: var(--red-600); }
.btn-danger:hover { background: var(--red-600); color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; padding: 12px; font-size: 14px; }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-700); margin-bottom: 5px; }
.form-input { width: 100%; padding: 10px 14px; border: 1px solid var(--gray-200); border-radius: var(--radius-sm); font-family: var(--font); font-size: 14px; color: var(--gray-900); background: white; transition: border-color 0.15s; }
.form-input:focus { outline: none; border-color: var(--green-500); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
textarea.form-input { resize: vertical; min-height: 80px; }

/* ── Location cards ── */
.location-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.location-card { background: white; border-radius: var(--radius-lg); border: 1px solid var(--gray-200); padding: 18px; transition: all 0.15s; display: block; }
.location-card:hover { border-color: var(--green-400); box-shadow: var(--shadow-md); transform: translateY(-1px); text-decoration: none; }
.location-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 3px; color: var(--gray-900); }
.location-card .address { font-size: 13px; color: var(--gray-600); margin-bottom: 10px; }
.location-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 3px 10px; border-radius: 20px; }
.badge-open { background: var(--red-100); color: var(--red-600); }
.badge-ok { background: var(--green-50); color: var(--green-700); }
.badge-rooms { background: var(--gray-100); color: var(--gray-700); }

/* ── Table ── */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; padding: 10px 12px; font-size: 11px; font-weight: 600; color: var(--gray-600); border-bottom: 1px solid var(--gray-200); text-transform: uppercase; letter-spacing: 0.04em; }
.table td { padding: 12px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--gray-50); }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Live badge ── */
.live-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--green-700); font-weight: 500; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green-500); animation: pulse 1.8s infinite; }
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.4;transform:scale(0.8)} }

/* ── Toast ── */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.toast { background: var(--green-800); color: white; border-radius: var(--radius-md); padding: 14px 16px; display: flex; align-items: flex-start; gap: 10px; animation: toastIn 0.3s ease; }
@keyframes toastIn { from{opacity:0;transform:translateX(20px)} to{opacity:1;transform:translateX(0)} }
.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.toast-body { font-size: 12px; opacity: 0.8; }
.toast-close { margin-left: auto; background: none; border: none; color: white; opacity: 0.6; cursor: pointer; font-size: 16px; padding: 0; flex-shrink: 0; }

/* ── Push button ── */
.push-btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: var(--radius-sm); background: white; border: 1px solid var(--gray-200); font-family: var(--font); font-size: 13px; font-weight: 500; color: var(--gray-700); cursor: pointer; transition: all 0.15s; }
.push-btn:hover { border-color: var(--green-500); color: var(--green-700); }
.push-btn.enabled { background: var(--green-50); border-color: var(--green-100); color: var(--green-700); }

/* ── Alert/Message ── */
.alert-msg { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; }
.alert-msg.error { background: var(--red-100); color: var(--red-600); border: 1px solid #F7C1C1; }
.alert-msg.success { background: var(--green-50); color: var(--green-700); border: 1px solid var(--green-100); }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--gray-400); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }

/* ── Options editor ── */
.option-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--gray-100); }
.option-row:last-child { border-bottom: none; }
.option-icon-input { width: 48px; text-align: center; font-size: 20px; border: 1px solid var(--gray-200); border-radius: var(--radius-sm); padding: 6px; }
.option-toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.option-toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--gray-200); border-radius: 10px; cursor: pointer; transition: 0.2s; }
.toggle-slider:before { content: ''; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; background: white; border-radius: 50%; transition: 0.2s; }
.option-toggle input:checked + .toggle-slider { background: var(--green-500); }
.option-toggle input:checked + .toggle-slider:before { transform: translateX(16px); }

/* ── Rooms grid ── */
.rooms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-bottom: 20px; }
.room-card { background: white; border-radius: var(--radius-md); border: 1px solid var(--gray-200); padding: 12px 14px; }
.room-status { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.room-status.ok { background: var(--green-500); }
.room-status.warn { background: #EF9F27; }
.room-status.alert { background: #E24B4A; }
.room-name { font-size: 14px; font-weight: 500; }
.room-floor { font-size: 12px; color: var(--gray-400); }

/* ── Notification prefs ── */
.notif-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--gray-100); }
.notif-row:last-child { border-bottom: none; }
.notif-label { font-size: 14px; font-weight: 500; }
.notif-sub { font-size: 12px; color: var(--gray-600); }
.notif-controls { display: flex; gap: 10px; }

/* ── Mobile responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .mobile-header { display: flex; }
  .main-content { margin-left: 0; padding: 70px 16px 24px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid .stat-card:last-child { grid-column: span 2; }
  .location-grid { grid-template-columns: 1fr; }
  .rooms-grid { grid-template-columns: 1fr 1fr; }
  .page-title { font-size: 18px; }
  .card { padding: 16px; }
  .alert-meta { flex-wrap: wrap; }
  .table th, .table td { padding: 8px 10px; font-size: 13px; }
  .btn { font-size: 12px; padding: 7px 12px; }
  .toast-container { top: 68px; right: 12px; left: 12px; max-width: 100%; }
  .page-header > div { flex-direction: column; align-items: flex-start; gap: 10px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stats-grid .stat-card:last-child { grid-column: span 1; }
  .rooms-grid { grid-template-columns: 1fr; }
  .alert-actions { gap: 4px; }
}
