:root {
  --bg: #080e1a;
  --bg2: #0c1526;
  --panel: #111d33;
  --panel2: #162642;
  --surface: #1a2d4a;
  --text: #e8f0ff;
  --text2: #94a8c8;
  --text3: #5d7499;
  --border: #1e3355;
  --border2: #263f66;
  --accent: #2d7aff;
  --accent2: #1b5fd4;
  --cyan: #06d6a0;
  --green: #34d399;
  --amber: #f5a623;
  --red: #ef4444;
  --magenta: #e879f9;
  --shadow: 0 8px 32px rgba(0,0,0,.4);
  --radius: 12px;
  --radius-lg: 18px;
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  background: linear-gradient(rgba(8,14,26,.88), rgba(8,14,26,.94)), url("assets/hmm-maintenance-ops.png") center center / cover fixed no-repeat, var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}
body::before {
  content: '';
  background: url('assets/hmm-maintenance-ops.png') center center / contain no-repeat;
  opacity: .08;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-25deg);
  font-size: 8vw;
  font-weight: 800;
  letter-spacing: 6px;
  color: rgba(45, 122, 255, 0.025);
  white-space: nowrap;
  pointer-events: none;
  z-index: 0;
  user-select: none;
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 15% 20%, rgba(45,122,255,0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 80%, rgba(6,214,160,0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(45,122,255,0.015) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--accent); text-decoration: none; }

/* Login Screen */
.login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
  position: relative; z-index: 1;
}
.login-card {
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%; max-width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
  text-align: center;
}
.login-brand {
  font-size: 48px; font-weight: 800; letter-spacing: 4px;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-brand-sub {
  font-size: 14px; font-weight: 600; letter-spacing: 3px;
  color: var(--text2); text-transform: uppercase; margin-bottom: 8px;
}
.login-desc { color: var(--text3); font-size: 13px; margin-bottom: 24px; }
.login-hint {
  margin-top: 20px; padding: 14px; border-radius: 10px;
  background: rgba(45,122,255,.06); border: 1px solid rgba(45,122,255,.15);
  text-align: left;
}
.login-hint p { font-size: 11px; color: var(--text3); line-height: 1.7; }

/* Loading */
.loading-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100vh; gap: 8px; position: relative; z-index: 1;
}
.loading-brand { font-size: 48px; font-weight: 700; letter-spacing: 4px; color: var(--accent); }
.loading-sub { color: var(--text2); font-size: 14px; letter-spacing: 3px; text-transform: uppercase; }
.loading-bar { width: 200px; height: 3px; background: var(--border); border-radius: 4px; overflow: hidden; margin-top: 24px; }
.loading-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--cyan)); border-radius: 4px; animation: load 1.5s ease forwards; }
@keyframes load { to { width: 100%; } }

/* Layout */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  position: relative; z-index: 1;
}
.sidebar {
  background: rgba(8, 14, 26, .95);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  overflow-y: auto;
  z-index: 50;
}
.sidebar-brand {
  padding: 24px 20px 4px;
  display: flex; align-items: baseline; gap: 8px;
}
.sidebar-brand h1 { font-size: 22px; font-weight: 700; letter-spacing: 1px; color: var(--accent); }
.sidebar-brand span { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 2px; }
.sidebar-desc { padding: 0 20px 16px; font-size: 11px; color: var(--cyan); line-height: 1.6; font-weight: 500; }
.sidebar-section { padding: 4px 12px; margin-top: 4px; display:flex; flex-direction:column; flex:1; }
.sidebar-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text3); padding: 8px 8px 4px; font-weight: 600; }
.nav-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 12px; border-radius: 10px;
  color: var(--text2); font-size: 13px; font-weight: 500;
  transition: all .15s;
  position: relative;
}
.nav-btn:hover { background: var(--panel); color: var(--text); }
.nav-btn.active {
  background: linear-gradient(135deg, rgba(45,122,255,.15), rgba(6,214,160,.08));
  color: #fff; font-weight: 600;
}
.nav-btn.active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; background: var(--accent); border-radius: 0 4px 4px 0;
}
.nav-icon { width: 18px; height: 18px; opacity: .7; flex-shrink: 0; }
.nav-btn.active .nav-icon { opacity: 1; }
.nav-badge {
  margin-left: auto; background: var(--red); color: #fff; font-size: 10px;
  padding: 1px 6px; border-radius: 10px; font-weight: 700;
}

/* Main */
.main-content {
  padding: 24px 32px;
  min-width: 0;
  position: relative;
}
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-header h2 { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.page-header p { color: var(--text2); font-size: 13px; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Cards */
.card {
  background: linear-gradient(180deg, var(--panel) 0%, rgba(12, 21, 38, .95) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.card h4 { font-size: 13px; font-weight: 600; color: var(--text2); }
.card-grid { display: grid; gap: 16px; }
.card-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.card-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.card-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.card-grid.cols-6 { grid-template-columns: repeat(6, 1fr); }

/* KPI Cards */
.kpi-card {
  background: linear-gradient(135deg, var(--panel), var(--panel2));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.kpi-card::after {
  content: ''; position: absolute; top: -30%; right: -20%; width: 80px; height: 80px;
  border-radius: 50%; opacity: .06;
}
.kpi-card.blue::after { background: var(--accent); }
.kpi-card.green::after { background: var(--green); }
.kpi-card.amber::after { background: var(--amber); }
.kpi-card.red::after { background: var(--red); }
.kpi-card.cyan::after { background: var(--cyan); }
.kpi-val { font-size: 32px; font-weight: 700; font-family: var(--mono); }
.kpi-card.blue .kpi-val { color: var(--accent); }
.kpi-card.green .kpi-val { color: var(--green); }
.kpi-card.amber .kpi-val { color: var(--amber); }
.kpi-card.red .kpi-val { color: var(--red); }
.kpi-card.cyan .kpi-val { color: var(--cyan); }
.kpi-label { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--border); background: var(--panel);
  color: var(--text); transition: all .15s;
}
.btn:hover { background: var(--surface); border-color: var(--border2); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent; color: #fff;
}
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { background: rgba(239,68,68,.15); border-color: rgba(239,68,68,.3); color: var(--red); }
.btn.danger:hover { background: rgba(239,68,68,.25); }
.btn.success { background: rgba(52,211,153,.12); border-color: rgba(52,211,153,.3); color: var(--green); }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn.icon-only { padding: 8px; }
.tts-btn svg { width: 16px; height: 16px; }
.tts-btn.active { background: rgba(45,122,255,.2); border-color: var(--accent); color: var(--accent); }

/* Inputs */
.input, .select {
  width: 100%; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg2);
  color: var(--text); font-size: 13px;
  transition: border-color .15s;
}
.input:focus, .select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45,122,255,.12);
}
textarea.input { resize: vertical; min-height: 80px; }
.form-label { display: block; font-size: 11px; font-weight: 600; color: var(--text2); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .5px; }
.form-group { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* Table */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { position: sticky; top: 0; z-index: 2; }
th {
  background: var(--bg2); color: var(--text2); font-size: 11px;
  text-transform: uppercase; letter-spacing: .5px; font-weight: 600;
  padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 10px 12px; border-bottom: 1px solid rgba(30,51,85,.4);
  vertical-align: top;
}
tr { transition: background .1s; }
tbody tr:hover { background: rgba(45,122,255,.04); }
tbody tr.clickable { cursor: pointer; }

/* Pills */
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: .3px;
}
.pill.high, .pill.critical { background: rgba(239,68,68,.15); color: #fca5a5; }
.pill.normal { background: rgba(52,211,153,.12); color: #86efac; }
.pill.low { background: rgba(94,168,255,.12); color: #93c5fd; }
.pill.planned { background: rgba(45,122,255,.12); color: #93c5fd; }
.pill.submitted { background: rgba(168,85,247,.12); color: #c4b5fd; }
.pill.in-progress, .pill.inprogress { background: rgba(232,121,249,.12); color: #f0abfc; }
.pill.complete, .pill.done { background: rgba(52,211,153,.15); color: #86efac; }
.pill.waiting-parts, .pill.waitingparts, .pill.holding-queue, .pill.holdingqueue, .pill.deferred {
  background: rgba(245,166,35,.12); color: #fcd34d;
}
.pill.open { background: rgba(239,68,68,.12); color: #fca5a5; }
.pill.resolved, .pill.acknowledged { background: rgba(52,211,153,.12); color: #86efac; }
.pill.current { background: rgba(6,214,160,.12); color: var(--cyan); }
.pill.running { background: rgba(52,211,153,.12); color: #86efac; }
.pill.yes { background: rgba(245,166,35,.12); color: #fcd34d; }
.pill.no { background: rgba(94,168,255,.08); color: #93c5fd; }
.pill.tier-1 { background: rgba(239,68,68,.12); color: #fca5a5; }
.pill.tier-2 { background: rgba(245,166,35,.12); color: #fcd34d; }
.pill.tier-3 { background: rgba(94,168,255,.08); color: #93c5fd; }
.pill.admin { background: rgba(232,121,249,.12); color: #f0abfc; }
.pill.management { background: rgba(245,166,35,.12); color: #fcd34d; }
.pill.employee { background: rgba(94,168,255,.12); color: #93c5fd; }
.pill.work_order { background: rgba(45,122,255,.12); color: #93c5fd; }
.pill.escalation { background: rgba(239,68,68,.12); color: #fca5a5; }
.pill.escalation_reply { background: rgba(6,214,160,.12); color: var(--cyan); }
.pill.site_request { background: rgba(232,121,249,.12); color: #f0abfc; }
.pill.chat { background: rgba(52,211,153,.12); color: #86efac; }
.pill.message { background: rgba(94,168,255,.12); color: #93c5fd; }
.pill.system { background: rgba(94,168,255,.08); color: var(--text3); }

/* Due dates */
.due-past { color: var(--red); font-weight: 600; }
.due-soon { color: var(--amber); font-weight: 600; }
.esc-due { font-size: 11px; margin-left: 8px; }

/* Search Toolbar */
.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar .input { max-width: 360px; }

/* Calendar */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-header {
  text-align: center; font-size: 11px; font-weight: 600;
  color: var(--text3); text-transform: uppercase; padding: 8px 0;
}
.cal-day {
  min-height: 100px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px; cursor: pointer;
  transition: all .15s; font-size: 11px; overflow: hidden;
}
.cal-day:hover { border-color: var(--accent); background: var(--panel2); }
.cal-day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cal-day.other-month { opacity: .35; }
.cal-day-num { font-weight: 700; font-size: 13px; margin-bottom: 4px; color: var(--text2); }
.cal-day.today .cal-day-num { color: var(--accent); }
.cal-event {
  padding: 2px 6px; border-radius: 4px; margin-bottom: 2px;
  font-size: 10px; line-height: 1.4; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.cal-event.high { background: rgba(239,68,68,.15); color: #fca5a5; }
.cal-event.normal { background: rgba(45,122,255,.1); color: #93c5fd; }
.cal-event.pm { background: rgba(6,214,160,.1); color: var(--cyan); }
.cal-nav {
  display: flex; align-items: center; gap: 16px; margin-bottom: 16px;
}
.cal-nav h3 { font-size: 18px; font-weight: 600; min-width: 200px; }

/* Notifications panel */
.notif-panel {
  position: fixed; right: 0; top: 0; bottom: 0; width: 380px;
  background: var(--bg2); border-left: 1px solid var(--border);
  z-index: 100; transform: translateX(100%);
  transition: transform .25s ease; overflow-y: auto;
  box-shadow: -8px 0 32px rgba(0,0,0,.5);
}
.notif-panel.open { transform: translateX(0); }
.notif-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg2); z-index: 2;
}
.notif-header h3 { font-size: 16px; }
.notif-item {
  padding: 14px 20px; border-bottom: 1px solid rgba(30,51,85,.3);
  cursor: pointer; transition: background .1s;
}
.notif-item:hover { background: var(--panel); }
.notif-item.unread { border-left: 3px solid var(--accent); }
.notif-item.critical { border-left: 3px solid var(--red); }
.notif-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.notif-msg { font-size: 12px; color: var(--text2); line-height: 1.4; }
.notif-time { font-size: 10px; color: var(--text3); margin-top: 4px; }
.notif-empty { padding: 40px 20px; text-align: center; color: var(--text3); }

/* Overlay */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 90;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.overlay.open { opacity: 1; pointer-events: auto; }

/* Modal */
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--panel); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); padding: 28px;
  z-index: 110; width: 90%; max-width: 600px; max-height: 85vh;
  overflow-y: auto; box-shadow: 0 24px 64px rgba(0,0,0,.6);
  display: none;
}
.modal.open { display: block; }
.modal h3 { font-size: 18px; margin-bottom: 16px; }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg2); border: 1px solid var(--border); color: var(--text2);
  transition: all .15s;
}
.modal-close:hover { background: var(--surface); color: var(--text); }

/* Detail view */
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.detail-label { font-size: 10px; text-transform: uppercase; color: var(--text3); letter-spacing: .5px; font-weight: 600; }
.detail-value { font-size: 14px; margin-top: 2px; }

/* Progress bar */
.progress { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--cyan)); transition: width .5s ease; }

/* Chart bar */
.chart-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.chart-bar-label { width: 120px; font-size: 12px; color: var(--text2); flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-bar-track { flex: 1; }
.chart-bar-val { width: 30px; font-size: 12px; font-weight: 700; text-align: right; font-family: var(--mono); }

/* Escalation queue */
.esc-item {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px; border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 10px; background: var(--panel);
  transition: all .15s;
}
.esc-item:hover { border-color: var(--border2); }
.esc-item.open { border-left: 3px solid var(--red); }
.esc-item.resolved { border-left: 3px solid var(--green); opacity: .7; }
.esc-body { flex: 1; min-width: 0; }
.esc-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.esc-reason { font-size: 12px; color: var(--text2); margin-bottom: 6px; }
.esc-meta { font-size: 11px; color: var(--text3); }
.esc-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Report Items */
.report-item {
  padding: 14px; border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 10px; background: var(--panel); transition: all .15s;
}
.report-item:hover { border-color: var(--border2); }
.report-item.past-due { border-left: 3px solid var(--red); }
.report-item-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.report-item-footer { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.replied-check { color: var(--green); font-size: 14px; font-weight: 700; }

/* Message Items */
.msg-item {
  padding: 14px; border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 8px; background: var(--panel); cursor: pointer;
  transition: all .15s;
}
.msg-item:hover { border-color: var(--border2); }
.msg-item.unread { border-left: 3px solid var(--accent); background: rgba(45,122,255,.04); }
.msg-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.msg-subject { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.msg-body { font-size: 12px; color: var(--text2); line-height: 1.4; }
.msg-time { font-size: 10px; color: var(--text3); }

/* Notice */
.notice {
  border-left: 3px solid var(--cyan); background: rgba(6,214,160,.06);
  border-radius: 0 10px 10px 0; padding: 14px 16px;
  color: var(--text2); font-size: 12px; line-height: 1.5;
}
.notice.warning { border-left-color: var(--amber); background: rgba(245,166,35,.06); }
.notice.danger { border-left-color: var(--red); background: rgba(239,68,68,.06); }

/* Toast */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 14px 20px; border-radius: 12px; font-size: 13px;
  background: var(--panel2); border: 1px solid var(--border2);
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  animation: slideIn .3s ease;
  max-width: 380px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--accent); }
.toast.warning { border-left: 3px solid var(--amber); }
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Report */
.report-box {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; font-family: var(--mono); font-size: 12px;
  white-space: pre-wrap; max-height: 400px; overflow-y: auto;
  line-height: 1.6; color: var(--text2);
}

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 0; overflow-x: auto; }
.tab-btn {
  padding: 10px 18px; font-size: 13px; font-weight: 500;
  color: var(--text2); border-bottom: 2px solid transparent;
  transition: all .15s; white-space: nowrap;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Empty state */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text3); }
.empty-state h4 { font-size: 16px; color: var(--text2); margin-bottom: 4px; }
.empty-state p { font-size: 13px; }

/* Skeleton */
.skeleton { background: linear-gradient(90deg, var(--panel) 25%, var(--panel2) 50%, var(--panel) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* AI Chat Widget */
.ai-chat-fab {
  position: fixed; bottom: 24px; right: 24px;
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  color: #fff; display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 150;
  box-shadow: 0 4px 20px rgba(45,122,255,.4);
  transition: transform .2s, box-shadow .2s;
}
.ai-chat-fab:hover { transform: scale(1.1); box-shadow: 0 6px 28px rgba(45,122,255,.5); }
.ai-chat-fab svg { width: 28px; height: 28px; }
.ai-chat-panel {
  position: fixed; bottom: 90px; right: 24px;
  width: 360px; max-height: 500px;
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); overflow: hidden;
  z-index: 150; display: none; flex-direction: column;
  box-shadow: 0 16px 48px rgba(0,0,0,.6);
}
.ai-chat-panel.open { display: flex; }
.ai-chat-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; background: var(--panel);
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 14px;
}
.ai-chat-messages {
  flex: 1; overflow-y: auto; padding: 12px;
  max-height: 350px; min-height: 200px;
}
.ai-msg {
  padding: 10px 14px; border-radius: 12px; margin-bottom: 8px;
  font-size: 13px; line-height: 1.5; max-width: 85%;
}
.ai-msg.bot {
  background: var(--panel); color: var(--text);
  border-bottom-left-radius: 4px;
}
.ai-msg.user {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; margin-left: auto;
  border-bottom-right-radius: 4px;
}
.ai-msg.typing { opacity: .6; }
.ai-chat-input {
  display: flex; gap: 8px; padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.ai-chat-input .input { flex: 1; }

/* Install Bar */
.install-bar {
  position: fixed; top: 0; left: 0; right: 0;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  color: #fff; padding: 10px 20px;
  display: flex; align-items: center; justify-content: center; gap: 16px;
  font-size: 13px; font-weight: 500; z-index: 200;
}
.install-bar .btn { color: #fff; border-color: rgba(255,255,255,.3); }

/* Mobile */
@media (max-width: 980px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 280px;
    transform: translateX(-100%); transition: transform .25s ease;
    z-index: 100;
  }
  .sidebar.open { transform: none; }
  .mobile-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; background: var(--bg2);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
  }
  .mobile-bar .ham { display: flex; flex-direction: column; gap: 4px; padding: 6px; }
  .mobile-bar .ham span { display: block; width: 20px; height: 2px; background: var(--text); border-radius: 2px; }
  .main-content { padding: 16px; }
  .card-grid.cols-6, .card-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .card-grid.cols-3, .card-grid.cols-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .calendar-grid { grid-template-columns: repeat(7, 1fr); }
  .cal-day { min-height: 60px; padding: 4px; }
  .cal-event { font-size: 8px; }
  .notif-panel { width: 100%; }
  .page-header { flex-direction: column; }
  .ai-chat-panel { width: calc(100% - 32px); right: 16px; bottom: 80px; }
}
@media (min-width: 981px) {
  .mobile-bar { display: none; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border2); }

/* Animate on enter */
.fade-in { animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Admin AI Console */
.admin-ai-console {
  border: 1px solid var(--accent);
  background: linear-gradient(135deg, rgba(45,122,255,.05), rgba(6,214,160,.03));
}
.admin-ai-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 8px; flex-wrap: wrap; gap: 8px;
}
.admin-ai-header h3 {
  display: flex; align-items: center;
}
.admin-ai-caps {
  display: flex; gap: 4px; flex-wrap: wrap;
}
.ai-cap-pill {
  display: inline-block; font-size: 10px; padding: 2px 8px;
  background: var(--surface); color: var(--cyan); border-radius: 10px;
  border: 1px solid rgba(6,214,160,.2); font-weight: 500;
}
.admin-ai-messages {
  max-height: 400px; overflow-y: auto; margin-bottom: 12px;
  min-height: 80px;
}
.admin-ai-suggestions {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.ai-suggest-btn {
  font-size: 11px !important; padding: 4px 10px !important;
  border: 1px solid var(--border2) !important;
  color: var(--text2) !important;
  background: var(--surface) !important;
  transition: all .15s;
}
.ai-suggest-btn:hover {
  color: var(--accent) !important;
  border-color: var(--accent) !important;
  background: rgba(45,122,255,.08) !important;
}
.ai-actions-badge {
  margin-top: 6px; font-size: 11px; color: var(--cyan);
  background: rgba(6,214,160,.08); border: 1px solid rgba(6,214,160,.2);
  padding: 3px 8px; border-radius: 6px; display: inline-block;
}
.ai-thinking-dots {
  display: inline-block;
}
.ai-thinking-dots::after {
  content: '...';
  animation: aiDots 1.4s steps(4, end) infinite;
}
@keyframes aiDots {
  0%, 20% { content: ''; }
  40% { content: '.'; }
  60% { content: '..'; }
  80%, 100% { content: '...'; }
}
.ai-msg code {
  background: var(--surface); padding: 1px 5px; border-radius: 4px;
  font-family: var(--mono); font-size: 12px;
}
.btn.danger {
  color: var(--red); border-color: var(--red);
}
.btn.danger:hover {
  background: rgba(239,68,68,.12);
}
.user-role-select {
  cursor: pointer;
}
.user-role-select:focus {
  outline: 1px solid var(--accent);
}

/* ── Inline Edit Mode ── */
.edit-mode-fab {
  position: fixed;
  bottom: 90px;
  left: 20px;
  z-index: 9999;
  background: var(--card);
  border: 2px solid var(--border);
  color: var(--text1);
  padding: 10px 18px;
  border-radius: 28px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  transition: all 0.2s;
  user-select: none;
}
.edit-mode-fab:hover { border-color: var(--accent); background: rgba(59,130,246,0.08); }
.edit-mode-fab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  animation: editPulse 2s ease infinite;
}
@keyframes editPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(59,130,246,0.3); }
  50% { box-shadow: 0 4px 30px rgba(59,130,246,0.6); }
}

.inline-edit-mode [data-ec] {
  outline: 2px dashed rgba(59,130,246,0.4);
  outline-offset: 2px;
  border-radius: 3px;
  cursor: text;
  transition: outline-color 0.2s, background 0.2s;
}
.inline-edit-mode [data-ec]:hover {
  outline-color: var(--accent);
  background: rgba(59,130,246,0.06);
}
.inline-edit-mode [data-ec]:focus {
  outline: 2px solid var(--accent);
  background: rgba(59,130,246,0.08);
}

.inline-edit-mode td[data-field] {
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}
.inline-edit-mode td[data-field]:hover {
  background: rgba(59,130,246,0.08);
}
.inline-edit-mode td[data-field]::after {
  content: "\270E";
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 11px;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.15s;
}
.inline-edit-mode td[data-field]:hover::after {
  opacity: 0.7;
}

.inline-cell-editor {
  width: 100%;
  background: var(--bg2);
  border: 2px solid var(--accent);
  color: var(--text1);
  border-radius: 4px;
  padding: 4px 6px;
  font: inherit;
  font-size: 12px;
  outline: none;
}

.edit-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.edit-mode-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ── Integration Cards ── */
.integration-card {
  text-align: center;
}
.integration-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.integration-link {
  display: inline-block;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 3px;
  transition: all .15s;
}
.integration-link:hover {
  background: rgba(45,122,255,.08);
  border-color: var(--accent);
}
