/* =====================================================================
   AREMIS - Aero UI design system
   Glassmorphic surfaces, layered 3D depth, gradient mesh background.
   Light + dark theme, fully responsive (desktop sidebar / mobile tab bar).
   ===================================================================== */

:root {
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-300: #93c5fd;
  --accent: #06b6d4;
  --accent-600: #0891b2;

  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --purple: #a855f7;
  --slate: #64748b;

  --bg: #eef3fb;
  --bg-2: #dfe9f8;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --surface-2: rgba(255, 255, 255, 0.5);
  --border: rgba(255, 255, 255, 0.75);
  --border-2: rgba(15, 23, 42, 0.08);

  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 26px;

  --shadow-1: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .06);
  --shadow-2: 0 2px 4px rgba(15, 23, 42, .06), 0 12px 28px rgba(15, 23, 42, .10);
  --shadow-3: 0 8px 16px rgba(15, 23, 42, .08), 0 24px 56px rgba(15, 23, 42, .16);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, .85), inset 0 -1px 0 rgba(15, 23, 42, .04);
  --glow: 0 0 0 4px rgba(37, 99, 235, .14);

  --sidebar-w: 264px;
  --header-h: 68px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

html[data-theme="dark"] {
  --bg: #070c17;
  --bg-2: #0d1526;
  --surface: rgba(23, 33, 54, 0.66);
  --surface-solid: #131c2f;
  --surface-2: rgba(30, 41, 66, 0.5);
  --border: rgba(255, 255, 255, 0.09);
  --border-2: rgba(255, 255, 255, 0.06);
  --text: #e8eefc;
  --text-2: #a3b0c9;
  --text-3: #6b7a96;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 12px rgba(0, 0, 0, .32);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, .45), 0 14px 34px rgba(0, 0, 0, .45);
  --shadow-3: 0 10px 24px rgba(0, 0, 0, .5), 0 30px 70px rgba(0, 0, 0, .6);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, .07), inset 0 -1px 0 rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ------------------------- gradient mesh backdrop ------------------- */
.aero-bg {
  position: fixed; inset: 0; z-index: -2;
  background:
    radial-gradient(1100px 700px at 8% -10%, rgba(6, 182, 212, .30), transparent 60%),
    radial-gradient(1000px 620px at 100% 0%, rgba(37, 99, 235, .28), transparent 58%),
    radial-gradient(900px 620px at 60% 110%, rgba(168, 85, 247, .20), transparent 60%),
    linear-gradient(160deg, var(--bg) 0%, var(--bg-2) 100%);
}
.aero-bg::after {
  content: ''; position: absolute; inset: 0;
  background-image:
    radial-gradient(rgba(255,255,255,.5) 1px, transparent 1px);
  background-size: 26px 26px;
  opacity: .18; mix-blend-mode: overlay;
}
html[data-theme="dark"] .aero-bg::after { opacity: .05; }

.aero-orb {
  position: fixed; border-radius: 50%; filter: blur(46px); z-index: -1;
  opacity: .5; pointer-events: none; animation: float 18s ease-in-out infinite;
}
.aero-orb.o1 { width: 340px; height: 340px; top: -80px; right: 6%;
  background: radial-gradient(circle at 30% 30%, #67e8f9, #0891b2); }
.aero-orb.o2 { width: 260px; height: 260px; bottom: 4%; left: -60px; animation-delay: -7s;
  background: radial-gradient(circle at 30% 30%, #c4b5fd, #7c3aed); }
@keyframes float {
  0%,100% { transform: translate3d(0,0,0) scale(1); }
  50% { transform: translate3d(-24px, 30px, 0) scale(1.06); }
}

/* ------------------------------- glass ------------------------------ */
.glass {
  background: var(--surface);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2), var(--shadow-inset);
  border-radius: var(--radius);
}
.glass-sm { border-radius: var(--radius-sm); box-shadow: var(--shadow-1), var(--shadow-inset); }

/* ------------------------------ layout ------------------------------ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px 12px; z-index: 40;
  background: var(--surface);
  backdrop-filter: blur(26px) saturate(180%);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  border-right: 1px solid var(--border);
  box-shadow: 8px 0 30px rgba(15, 23, 42, .06);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 2px; }
.brand img { height: 40px; width: auto; max-width: 190px; object-fit: contain;
  filter: drop-shadow(0 6px 14px rgba(37,99,235,.35)); }
.brand-fallback { font-weight: 800; letter-spacing: 3px; font-size: 22px;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Emergency button - directly under the logo */
.emergency-btn {
  margin: 10px 6px 6px; padding: 12px 14px; border: none; cursor: pointer; width: calc(100% - 12px);
  border-radius: 16px; font-weight: 800; font-size: 13.5px; letter-spacing: 1.4px; color: #fff;
  background: linear-gradient(140deg, #ff5f6d 0%, #dc2626 55%, #991b1b 100%);
  box-shadow: 0 8px 20px rgba(220, 38, 38, .42), inset 0 1px 0 rgba(255,255,255,.45),
              inset 0 -2px 6px rgba(0,0,0,.22);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .12s ease, box-shadow .2s ease;
  position: relative; overflow: hidden;
}
.emergency-btn::after {
  content: ''; position: absolute; inset: 0 0 55% 0;
  background: linear-gradient(180deg, rgba(255,255,255,.42), rgba(255,255,255,0));
  pointer-events: none;
}
.emergency-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(220,38,38,.5), inset 0 1px 0 rgba(255,255,255,.5); }
.emergency-btn:active { transform: translateY(1px) scale(.99); }
.emergency-btn.armed { animation: pulseRed 1s infinite; }
@keyframes pulseRed {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.6), 0 8px 20px rgba(220,38,38,.42); }
  50% { box-shadow: 0 0 0 14px rgba(239,68,68,0), 0 8px 20px rgba(220,38,38,.42); }
}

.nav { flex: 1; overflow-y: auto; padding: 6px 2px; display: flex; flex-direction: column; gap: 2px; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
.nav-section { font-size: 10.5px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--text-3); padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 13px;
  color: var(--text-2); text-decoration: none; font-weight: 600; font-size: 13.8px;
  transition: all .16s ease; position: relative; border: 1px solid transparent;
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); transform: translateX(2px); }
.nav-item.active {
  color: #fff; border-color: rgba(255,255,255,.28);
  background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
  box-shadow: 0 6px 16px rgba(37, 99, 235, .38), inset 0 1px 0 rgba(255,255,255,.4);
}
.nav-item .badge { margin-left: auto; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--header-h); position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  background: var(--surface); backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 750; letter-spacing: -.3px; }
.topbar .sub { font-size: 12px; color: var(--text-3); font-weight: 500; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.content { padding: 20px; flex: 1; }
.page-enter { animation: pageIn .32s cubic-bezier(.2,.7,.3,1); }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ------------------------------ buttons ----------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 13px; border: 1px solid var(--border);
  background: var(--surface-solid); color: var(--text); font-weight: 650; font-size: 13.5px;
  cursor: pointer; font-family: inherit; transition: all .15s ease;
  box-shadow: var(--shadow-1), var(--shadow-inset); white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary {
  color: #fff; border-color: transparent;
  background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
  box-shadow: 0 6px 16px rgba(37,99,235,.34), inset 0 1px 0 rgba(255,255,255,.4);
}
.btn-danger { color: #fff; border-color: transparent;
  background: linear-gradient(135deg, #f87171, #dc2626);
  box-shadow: 0 6px 16px rgba(220,38,38,.34), inset 0 1px 0 rgba(255,255,255,.35); }
.btn-success { color: #fff; border-color: transparent;
  background: linear-gradient(135deg, #4ade80, #16a34a);
  box-shadow: 0 6px 16px rgba(22,163,74,.32), inset 0 1px 0 rgba(255,255,255,.35); }
.btn-warning { color: #fff; border-color: transparent;
  background: linear-gradient(135deg, #fbbf24, #d97706);
  box-shadow: 0 6px 16px rgba(217,119,6,.32), inset 0 1px 0 rgba(255,255,255,.35); }
.btn-ghost { background: transparent; box-shadow: none; border-color: var(--border-2); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 10px; }
.btn-lg { padding: 13px 24px; font-size: 15px; border-radius: 16px; }
.btn-icon { padding: 9px; width: 38px; height: 38px; border-radius: 12px; }
.btn-block { width: 100%; }

/* ------------------------------- cards ------------------------------ */
.card {
  background: var(--surface); backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-2), var(--shadow-inset);
  padding: 18px; transition: transform .2s ease, box-shadow .2s ease;
}
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-3); }
.card-title { font-size: 15px; font-weight: 700; margin: 0 0 2px; display: flex; align-items: center; gap: 8px; }
.card-sub { font-size: 12.5px; color: var(--text-3); margin-bottom: 14px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); }

/* ------------------------------- stats ------------------------------ */
.stat {
  position: relative; overflow: hidden; padding: 16px 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-2), var(--shadow-inset);
  backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
  transition: transform .2s ease, box-shadow .2s ease;
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-3); }
.stat::before {
  content: ''; position: absolute; right: -28px; top: -28px; width: 96px; height: 96px;
  border-radius: 50%; opacity: .18; background: var(--_c, var(--primary));
}
.stat-label { font-size: 11.5px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--text-3); }
.stat-value { font-size: 30px; font-weight: 800; letter-spacing: -1px; line-height: 1.15; margin-top: 4px; }
.stat-foot { font-size: 12px; color: var(--text-2); margin-top: 3px; display: flex; align-items: center; gap: 6px; }
.stat-link { display: block; text-decoration: none; color: inherit; position: relative; }
.stat-link:active { transform: translateY(0) scale(.99); }
.stat-go { position: absolute; right: 12px; bottom: 10px; color: var(--text-3); opacity: .6; }
.stat-link:hover .stat-go { opacity: 1; color: var(--primary); transform: translateX(2px); }

.stat-icon {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--_c, var(--primary)), color-mix(in srgb, var(--_c, var(--primary)) 60%, #000));
  box-shadow: 0 6px 14px rgba(15,23,42,.2), inset 0 1px 0 rgba(255,255,255,.4);
}

/* ------------------------------ badges ------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .2px; white-space: nowrap;
  background: rgba(100,116,139,.14); color: var(--text-2); border: 1px solid rgba(100,116,139,.18);
}
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.b-success { background: rgba(34,197,94,.15); color: #15803d; border-color: rgba(34,197,94,.28); }
.badge.b-warning { background: rgba(245,158,11,.16); color: #b45309; border-color: rgba(245,158,11,.3); }
.badge.b-danger  { background: rgba(239,68,68,.15); color: #b91c1c; border-color: rgba(239,68,68,.28); }
.badge.b-info    { background: rgba(37,99,235,.14); color: #1d4ed8; border-color: rgba(37,99,235,.26); }
.badge.b-purple  { background: rgba(168,85,247,.15); color: #7e22ce; border-color: rgba(168,85,247,.28); }
html[data-theme="dark"] .badge.b-success { color: #4ade80; }
html[data-theme="dark"] .badge.b-warning { color: #fbbf24; }
html[data-theme="dark"] .badge.b-danger { color: #f87171; }
html[data-theme="dark"] .badge.b-info { color: #93c5fd; }
html[data-theme="dark"] .badge.b-purple { color: #d8b4fe; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 650; cursor: pointer; user-select: none;
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text-2);
  transition: all .15s ease;
}
.chip:hover { background: var(--surface-solid); color: var(--text); }
.chip.active { background: linear-gradient(135deg, var(--accent), var(--primary)); color: #fff; border-color: transparent;
  box-shadow: 0 4px 12px rgba(37,99,235,.3); }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------ forms ------------------------------- */
.field { margin-bottom: 14px; }
.label { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-2); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; padding: 10px 13px; border-radius: 13px; font-family: inherit; font-size: 14px;
  color: var(--text); background: var(--surface-solid);
  border: 1px solid var(--border-2); box-shadow: var(--shadow-inset);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.textarea { min-height: 92px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary-300); box-shadow: var(--glow);
}
.input[type=color] { height: 44px; padding: 4px 6px; cursor: pointer; }
.input[type=file] { padding: 8px 10px; cursor: pointer; }
.select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 15px; padding-right: 36px; }
.hint { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track {
  width: 46px; height: 26px; border-radius: 999px; position: relative; transition: background .2s ease;
  background: rgba(100,116,139,.3); box-shadow: inset 0 2px 5px rgba(0,0,0,.16);
}
.switch .track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.28); transition: transform .2s cubic-bezier(.3,1.4,.5,1);
}
.switch input:checked + .track { background: linear-gradient(135deg, var(--accent), var(--primary)); }
.switch input:checked + .track::after { transform: translateX(20px); }

/* ------------------------------- table ------------------------------ */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.tbl th {
  text-align: left; padding: 11px 14px; font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .7px; color: var(--text-3); background: var(--surface-2);
  border-bottom: 1px solid var(--border-2); position: sticky; top: 0; backdrop-filter: blur(8px);
}
table.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border-2); vertical-align: middle; }
table.tbl tbody tr { transition: background .12s ease; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr:last-child td { border-bottom: none; }

/* --------------------------- room map grid -------------------------- */
.floor-block { margin-bottom: 22px; }
.floor-head { display: flex; align-items: center; gap: 10px; margin: 0 4px 12px; }
.floor-head h3 { margin: 0; font-size: 15px; font-weight: 750; }
.floor-line { flex: 1; height: 1px; background: linear-gradient(90deg, var(--border-2), transparent); }

.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 12px; }
.room {
  position: relative; padding: 12px 12px 10px; border-radius: 16px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-solid);
  box-shadow: var(--shadow-1), var(--shadow-inset);
  transition: transform .16s cubic-bezier(.2,.8,.3,1), box-shadow .2s ease;
  overflow: hidden; min-height: 96px; display: flex; flex-direction: column;
}
.room::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 5px; background: var(--_c, var(--slate));
}
.room::after {
  content: ''; position: absolute; right: -26px; bottom: -26px; width: 74px; height: 74px; border-radius: 50%;
  background: var(--_c, var(--slate)); opacity: .1;
}
.room:hover { transform: translateY(-4px) scale(1.02); box-shadow: var(--shadow-3); }
.room-no { font-size: 17px; font-weight: 800; letter-spacing: -.4px; }
.room-type { font-size: 10.5px; font-weight: 700; letter-spacing: .6px; color: var(--text-3); text-transform: uppercase; }
.room-status { font-size: 11px; font-weight: 700; color: var(--_c, var(--slate)); margin-top: auto; }
.room-icons { position: absolute; top: 9px; right: 9px; display: flex; gap: 4px; align-items: center; }
.room-pill { font-size: 9.5px; font-weight: 800; padding: 2px 6px; border-radius: 999px; color: #fff; }
.room-pill.vip { background: linear-gradient(135deg, #fbbf24, #d97706); box-shadow: 0 2px 6px rgba(217,119,6,.4); }
.room-pill.job { background: linear-gradient(135deg, #f87171, #dc2626); }
.room-pill.hk  { background: linear-gradient(135deg, #c084fc, #9333ea); }
.room-pill.lock { background: #0f172a; }
.room.compact { min-height: 74px; padding: 9px 10px; }
.room.compact .room-no { font-size: 14px; }

.area-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.area-card {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 16px; cursor: pointer;
  background: var(--surface-solid); border: 1px solid var(--border);
  box-shadow: var(--shadow-1), var(--shadow-inset); transition: transform .16s ease, box-shadow .2s ease;
}
.area-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-3); }
.area-icon { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 14px; display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: 0 6px 14px rgba(15,23,42,.18), inset 0 1px 0 rgba(255,255,255,.4); }

.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); font-weight: 600; }
.legend-swatch { width: 13px; height: 13px; border-radius: 5px; box-shadow: inset 0 1px 0 rgba(255,255,255,.5); }

/* ------------------------------ job card ---------------------------- */
.job-card {
  display: flex; gap: 13px; padding: 14px; border-radius: 16px; cursor: pointer;
  background: var(--surface-solid); border: 1px solid var(--border);
  box-shadow: var(--shadow-1), var(--shadow-inset);
  transition: transform .16s ease, box-shadow .2s ease; position: relative; overflow: hidden;
}
.job-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.job-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--_c, var(--primary)); }
.job-thumb { width: 62px; height: 62px; flex: 0 0 62px; border-radius: 13px; object-fit: cover;
  background: var(--surface-2); box-shadow: var(--shadow-1); }
.job-thumb.ph { display: grid; place-items: center; color: var(--text-3); }
.job-body { min-width: 0; flex: 1; }
.job-title { font-weight: 700; font-size: 14px; margin-bottom: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-meta { font-size: 12px; color: var(--text-3); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.job-foot { margin-top: 8px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.timer { font-variant-numeric: tabular-nums; font-weight: 750; font-size: 12.5px; }
.timer.ok { color: var(--success); }
.timer.warn { color: var(--warning); }
.timer.late { color: var(--danger); animation: blinkText 1.4s infinite; }
@keyframes blinkText { 50% { opacity: .42; } }

.progress { height: 6px; border-radius: 999px; background: rgba(100,116,139,.2); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 999px; transition: width .4s ease;
  background: linear-gradient(90deg, var(--accent), var(--primary)); }
.progress.warn > i { background: linear-gradient(90deg, #fbbf24, #d97706); }
.progress.late > i { background: linear-gradient(90deg, #f87171, #dc2626); }

/* --------------------- hierarchical job groups ---------------------- */
.jgroup {
  border: 1px solid var(--border); border-radius: 16px; overflow: hidden; margin-bottom: 10px;
  background: var(--surface); box-shadow: var(--shadow-1), var(--shadow-inset);
}
.jgroup-head {
  display: flex; align-items: center; gap: 8px; padding: 12px 13px; cursor: pointer;
  user-select: none; font-size: 13.5px;
}
.jgroup-head:active { background: var(--surface-2); }
.jgroup-caret { display: inline-flex; color: var(--text-3); transition: transform .2s ease; }
.jgroup.open .jgroup-caret { transform: rotate(90deg); }
.jgroup-title { font-weight: 750; }
.jgroup-sub { font-size: 11.5px; color: var(--text-3); }
.jgroup-body { display: none; padding: 0 9px 9px; }
.jgroup.open .jgroup-body { display: block; }
.jgroup-body .job-card { margin-bottom: 8px; }
.jgroup-body .job-card:last-child { margin-bottom: 0; }

.job-card.compact { padding: 11px 12px; }
.job-card.compact .job-title { font-size: 14.5px; font-weight: 800; }
.job-sub { font-size: 12.5px; color: var(--text-2); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-card.compact .job-foot { margin-top: 7px; }
.job-card.compact .progress { margin-top: 7px; height: 5px; }

/* ------------------------------ timeline ---------------------------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px;
  background: linear-gradient(180deg, var(--primary), var(--accent), transparent); border-radius: 2px; }
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item::before {
  content: ''; position: absolute; left: -21px; top: 4px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface-solid); border: 2.5px solid var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.14);
}
.tl-item.ev-done::before { border-color: var(--success); box-shadow: 0 0 0 3px rgba(34,197,94,.16); }
.tl-item.ev-escalated::before { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(239,68,68,.18); }
.tl-item.ev-not_done::before { border-color: var(--warning); box-shadow: 0 0 0 3px rgba(245,158,11,.18); }
.tl-title { font-weight: 700; font-size: 13.5px; }
.tl-meta { font-size: 11.5px; color: var(--text-3); }
.tl-note { font-size: 13px; color: var(--text-2); margin-top: 3px; }

/* ------------------------------- modal ------------------------------ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 18px;
  background: rgba(8, 15, 30, .5); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: min(660px, 100%); max-height: 90vh; overflow: hidden; display: flex; flex-direction: column;
  background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3); animation: modalIn .26s cubic-bezier(.2,.9,.3,1);
}
.modal.wide { width: min(980px, 100%); }
.modal.narrow { width: min(440px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(22px) scale(.97); } }
.modal-head { padding: 18px 20px 14px; border-bottom: 1px solid var(--border-2);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 750; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border-2);
  display: flex; gap: 9px; justify-content: flex-end; background: var(--surface-2); }

/* ---------------------------- context menu -------------------------- */
.ctx-menu {
  position: fixed; z-index: 300; min-width: 232px; padding: 7px; border-radius: 16px;
  background: var(--surface-solid); border: 1px solid var(--border); box-shadow: var(--shadow-3);
  animation: modalIn .16s ease;
}
.ctx-item { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 11px;
  font-size: 13.5px; font-weight: 600; cursor: pointer; color: var(--text-2); }
.ctx-item:hover { background: var(--surface-2); color: var(--text); }
.ctx-item.danger { color: var(--danger); }
.ctx-sep { height: 1px; background: var(--border-2); margin: 5px 7px; }
.ctx-head { padding: 8px 11px 6px; font-size: 11px; font-weight: 800; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-3); }

/* ------------------------------ toasts ------------------------------ */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 400; display: flex; flex-direction: column; gap: 9px;
  max-width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 11px; padding: 13px 15px; border-radius: 15px; align-items: flex-start;
  background: var(--surface-solid); border: 1px solid var(--border); box-shadow: var(--shadow-3);
  animation: toastIn .3s cubic-bezier(.2,1.2,.4,1); position: relative; overflow: hidden;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } }
.toast::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary); }
.toast.t-success::before { background: var(--success); }
.toast.t-error::before { background: var(--danger); }
.toast.t-warning::before { background: var(--warning); }
.toast-title { font-weight: 700; font-size: 13.5px; }
.toast-body { font-size: 12.5px; color: var(--text-2); }

/* ---------------------- emergency alert overlay --------------------- */
.emergency-overlay {
  position: fixed; inset: 0; z-index: 900; display: grid; place-items: center; padding: 20px;
  background: rgba(60, 0, 0, .55); backdrop-filter: blur(6px);
  animation: flashRed 1s steps(1) infinite;
}
@keyframes flashRed {
  0%, 49% { background: rgba(190, 18, 18, .62); box-shadow: inset 0 0 220px 70px rgba(239,68,68,.85); }
  50%, 100% { background: rgba(40, 0, 0, .58); box-shadow: inset 0 0 90px 20px rgba(239,68,68,.4); }
}
.emergency-card {
  width: min(520px, 100%); text-align: center; padding: 30px 26px; border-radius: 26px;
  background: var(--surface-solid); border: 3px solid #dc2626;
  box-shadow: 0 0 60px rgba(239,68,68,.7), var(--shadow-3);
  animation: shake .6s cubic-bezier(.36,.07,.19,.97) 2;
}
@keyframes shake {
  10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); } 40%, 60% { transform: translateX(7px); }
}
.emergency-icon {
  width: 84px; height: 84px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(140deg, #ff6b6b, #dc2626); color: #fff;
  box-shadow: 0 0 0 10px rgba(239,68,68,.22), 0 12px 30px rgba(220,38,38,.5);
  animation: pulseRed 1s infinite;
}
.emergency-card h2 { margin: 0 0 6px; font-size: 27px; font-weight: 900; letter-spacing: 2px; color: #dc2626; }

/* ------------------------------ gallery ----------------------------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 9px; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 13px; cursor: pointer;
  box-shadow: var(--shadow-1); transition: transform .18s ease; }
.photo-grid img:hover { transform: scale(1.05); box-shadow: var(--shadow-2); }

.dropzone {
  border: 2px dashed var(--border-2); border-radius: 16px; padding: 20px; text-align: center;
  cursor: pointer; transition: all .18s ease; background: var(--surface-2); color: var(--text-3);
  font-size: 13px; font-weight: 600;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); color: var(--primary); background: rgba(37,99,235,.06); }

/* ------------------------------- misc ------------------------------- */
.avatar {
  width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; font-weight: 800;
  font-size: 13px; color: #fff; background: linear-gradient(135deg, var(--accent), var(--primary));
  box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255,255,255,.35); flex: 0 0 36px;
}
.dot-live { width: 8px; height: 8px; border-radius: 50%; background: var(--success);
  box-shadow: 0 0 0 3px rgba(34,197,94,.22); animation: blinkText 2s infinite; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--border-2);
  border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 44px 20px; color: var(--text-3); }
.empty svg { width: 46px; height: 46px; opacity: .4; margin-bottom: 10px; }
.skeleton { border-radius: 12px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--border-2) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.muted { color: var(--text-3); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.flex { display: flex; } .items-center { align-items: center; } .gap-6 { gap: 6px; }
.gap-10 { gap: 10px; } .gap-16 { gap: 16px; } .ml-auto { margin-left: auto; }
.wrap { flex-wrap: wrap; } .col { flex-direction: column; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.text-right { text-align: right; } .center { text-align: center; }
.hidden { display: none !important; }

/* ------------------------------- login ------------------------------ */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: min(430px, 100%); padding: 34px 30px; border-radius: 28px; text-align: center;
  background: var(--surface); backdrop-filter: blur(26px) saturate(180%);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  border: 1px solid var(--border); box-shadow: var(--shadow-3), var(--shadow-inset);
  animation: modalIn .45s cubic-bezier(.2,.9,.3,1);
}
.login-card img { height: 74px; margin-bottom: 6px; filter: drop-shadow(0 10px 22px rgba(37,99,235,.35)); }
.login-card h1 { font-size: 22px; margin: 6px 0 2px; font-weight: 800; letter-spacing: -.4px; }

/* -------------------------- mobile tab bar -------------------------- */
.tabbar { display: none; }
.mobile-only { display: none; }

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 860px) {
  /* Denser, calmer mobile typography: one step down and tighter line height,
     with the base size exposed as a variable so it is easy to tune. */
  :root { --header-h: 58px; --radius: 15px; --radius-sm: 11px; }
  body { font-size: 13.6px; line-height: 1.45; }
  .card { padding: 14px; }
  .card-title { font-size: 14px; }
  .card-sub { font-size: 11.5px; margin-bottom: 10px; }
  .stat { padding: 13px 14px; }
  .stat-label { font-size: 10.5px; letter-spacing: .6px; }
  .stat-value { font-size: 25px; }
  .stat-foot { font-size: 11px; }
  .stat-icon { width: 34px; height: 34px; border-radius: 11px; }
  .badge { font-size: 10.5px; padding: 2px 7px; }
  .chip { font-size: 12px; padding: 7px 12px; }
  .btn { padding: 10px 15px; }               /* keep touch targets big */
  .btn-sm { padding: 7px 11px; }
  .input, .select, .textarea { font-size: 16px; }   /* 16px stops iOS zooming in */
  .label { font-size: 12px; }
  .job-meta { font-size: 11.5px; gap: 8px; }
  .timer { font-size: 12px; }
  table.tbl { font-size: 12.5px; }
  table.tbl th, table.tbl td { padding: 9px 10px; }
  /* the dashboard's two side panels are noise on a phone */
  .mobile-hide { display: none !important; }
  /* the filter bar must not eat half the first screen */
  .content > .card:first-child { padding: 11px; }
  .chip-row { gap: 6px; }
  .grid { gap: 12px; }
  .mb-16 { margin-bottom: 12px; }
  .topbar h1 { font-size: 15.5px; }
  .topbar .sub { font-size: 11px; }
  .job-card { padding: 12px; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-102%);
    transition: transform .28s cubic-bezier(.3,.9,.3,1); box-shadow: var(--shadow-3);
    width: min(300px, 86vw); flex-basis: min(300px, 86vw);
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  /* above the tab bar (z-index 50) so the account row is always tappable */
  .sidebar.open { transform: none; z-index: 70; }
  .sidebar-scrim { z-index: 65; }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 39; background: rgba(8,15,30,.45); backdrop-filter: blur(3px); }
  .content { padding: 12px 11px 100px; }
  .topbar { padding: 0 13px; }
  .topbar h1 { font-size: 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .grid-auto { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .room-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 9px; }
  .area-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .mobile-only { display: block; }
  .desktop-only { display: none !important; }
  .modal { border-radius: 22px; }
  .modal.wide { width: 100%; }

  .tabbar {
    display: flex; position: fixed; left: 10px; right: 10px; bottom: 10px; z-index: 50;
    padding: 7px; border-radius: 22px; justify-content: space-around; align-items: center;
    background: var(--surface); backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--border); box-shadow: var(--shadow-3), var(--shadow-inset);
  }
  .tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 4px;
    border-radius: 15px; font-size: 10px; font-weight: 700; color: var(--text-3);
    text-decoration: none; transition: all .16s ease; position: relative;
  }
  .tab svg { width: 21px; height: 21px; }
  .tab.active { color: #fff; background: linear-gradient(135deg, var(--accent), var(--primary));
    box-shadow: 0 5px 14px rgba(37,99,235,.4); }
  .tab .tab-badge { position: absolute; top: 3px; right: calc(50% - 18px); min-width: 15px; height: 15px;
    border-radius: 999px; background: var(--danger); color: #fff; font-size: 9px; font-weight: 800;
    display: grid; place-items: center; padding: 0 3px; }
  .toasts { top: auto; bottom: 86px; left: 12px; right: 12px; max-width: none; }
}

@media print {
  .sidebar, .topbar, .tabbar, .toasts, .emergency-btn { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; }
}
