:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e3e5e9;
  --text: #1b1d22;
  --muted: #6b7280;
  --primary: #2f6fed;
  --primary-dark: #1f52b8;
  --sidebar-bg: #14161f;
  --sidebar-text: #c7c9d4;
  --sidebar-active: #232636;
  --success: #1a9e6d;
  --success-bg: #e5f6ef;
  --warning: #c98a12;
  --warning-bg: #fdf3e0;
  --danger: #d9432f;
  --danger-bg: #fbe7e4;
  --info: #2f6fed;
  --info-bg: #e9f0fe;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20,22,31,0.06), 0 1px 8px rgba(20,22,31,0.04);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 16px; }

/* --- Login --- */
.login-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #14161f, #232636);
}
.login-card {
  background: var(--panel);
  padding: 36px 32px;
  border-radius: var(--radius);
  width: 320px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  text-align: center;
}
.login-card h1 { margin: 0 0 4px; letter-spacing: 0.5px; }
.login-card .muted { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.login-card input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 12px;
}
.login-card .btn-primary { width: 100%; }
.error { color: var(--danger); font-size: 13px; margin-top: 10px; }

/* --- Layout --- */
.app { display: flex; height: 100vh; }
.mobile-menu-btn { display: none; }
.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 18px 12px;
  overflow: hidden;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 6px 8px 22px; flex-shrink: 0; }
.brand-mark {
  background: var(--primary); color: #fff; font-weight: 700; font-size: 12px;
  padding: 6px 8px; border-radius: 6px; letter-spacing: 0.5px;
}
.brand-text { font-weight: 600; font-size: 15px; color: #fff; }
nav { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; overflow-y: auto; }
.nav-item {
  background: none; border: none; text-align: left; color: var(--sidebar-text);
  padding: 10px 12px; border-radius: 8px; font-size: 13.5px;
}
.nav-item:hover { background: rgba(255,255,255,0.05); }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 500; }

/* --- Collapsible sidebar categories --- */
.nav-group { display: flex; flex-direction: column; }
.nav-group-header {
  background: none; border: none; text-align: left; width: 100%;
  color: rgba(199,201,212,0.55); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 12px 12px 6px; display: flex; align-items: center; gap: 5px; cursor: pointer;
}
.nav-group-header:hover { color: rgba(199,201,212,0.85); }
.nav-group-chevron { display: inline-block; font-size: 9px; transition: transform 0.15s; }
.nav-group.collapsed .nav-group-chevron { transform: rotate(-90deg); }
.nav-group-items { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.nav-group.collapsed .nav-group-items { display: none; }
.logout-btn {
  background: none; border: 1px solid rgba(255,255,255,0.12); color: var(--sidebar-text);
  padding: 8px; border-radius: 8px; font-size: 12.5px; margin-top: 8px; flex-shrink: 0;
}
.logout-btn:hover { color: #fff; border-color: rgba(255,255,255,0.3); }
.current-user-box { padding: 8px 12px; margin-bottom: 4px; color: var(--sidebar-text); font-size: 12.5px; flex-shrink: 0; }
.current-user-box .name { font-weight: 600; color: #fff; }
.current-user-box .role { font-size: 11px; opacity: 0.7; }
.role-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; }
.role-badge.admin { background: var(--info-bg); color: var(--info); }
.role-badge.technician { background: #eef0f3; color: var(--muted); }

/* --- Global search --- */
.sidebar-search-wrap { position: relative; margin: 0 4px 14px; flex-shrink: 0; }
.sidebar-search {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06); color: #fff; font-size: 12.5px;
}
.sidebar-search::placeholder { color: #7d8093; }
.sidebar-search:focus { outline: none; border-color: var(--primary); background: rgba(255,255,255,0.1); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; width: 320px; max-height: 420px; overflow-y: auto;
  background: #fff; border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,0.35); z-index: 50; padding: 8px 0;
}
.search-group-label { padding: 6px 14px 4px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.search-result-item { padding: 8px 14px; cursor: pointer; font-size: 13px; color: var(--text); }
.search-result-item:hover { background: var(--bg); }
.search-result-item .sub { font-size: 11.5px; color: var(--muted); }
.search-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 12.5px; }

/* --- Photo gallery --- */
.photo-gallery { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.photo-thumb { position: relative; width: 96px; height: 96px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb .photo-delete {
  position: absolute; top: 3px; right: 3px; background: rgba(15,17,23,0.65); color: #fff; border: none;
  border-radius: 6px; width: 20px; height: 20px; font-size: 12px; line-height: 1; cursor: pointer;
}
.photo-upload-btn {
  width: 96px; height: 96px; border: 1.5px dashed var(--border); border-radius: 8px; background: #fafbfc;
  color: var(--muted); font-size: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  cursor: pointer;
}
.photo-upload-btn:hover { border-color: var(--primary); color: var(--primary); }

/* --- Warranty widget --- */
.warranty-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.warranty-row:last-child { border-bottom: none; }
.warranty-days { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.warranty-days.soon { background: var(--danger-bg); color: var(--danger); }
.warranty-days.ok { background: var(--warning-bg); color: var(--warning); }

/* --- Calendar --- */
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-nav button { background: none; border: 1px solid var(--border); border-radius: 8px; width: 30px; height: 30px; font-size: 14px; color: var(--text); }
.cal-nav button:hover { background: var(--bg); }
.cal-month-label { font-size: 15px; font-weight: 600; min-width: 160px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.cal-weekday { background: #f4f5f7; padding: 6px 8px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; color: var(--muted); text-align: center; }
.cal-day { background: #fff; min-height: 90px; padding: 6px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; }
.cal-day:hover { background: #fafbfc; }
.cal-day.other-month { background: #fafbfc; }
.cal-day.today { background: #eef4ff; }
.cal-day-num { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.cal-day.today .cal-day-num { color: var(--primary); }
.cal-event { font-size: 10.5px; padding: 2px 5px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal-event.project { background: var(--info-bg); color: var(--info); }
.cal-event.task { background: var(--warning-bg); color: var(--warning); }
.cal-event.quote_expiry { background: var(--danger-bg); color: var(--danger); }
.cal-event.icloud_external { background: #f0f0f2; color: #4b4d57; cursor: default; }
.cal-event.google_external { background: #e8f0fe; color: #1a56db; cursor: default; }
.cal-subscribe-box { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cal-feed-url { flex: 1; min-width: 240px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); font-size: 12.5px; font-family: monospace; overflow-x: auto; white-space: nowrap; }
.cal-provider-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); gap: 12px; flex-wrap: wrap; }
.cal-provider-row:last-child { border-bottom: none; }
.cal-provider-name { font-weight: 600; font-size: 13.5px; }
.cal-provider-status { font-size: 12px; color: var(--muted); margin-top: 2px; }
.cal-status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.cal-status-dot.on { background: var(--success); }
.cal-status-dot.off { background: #c6c9d0; }
.cal-warning-box { background: var(--warning-bg); color: var(--warning); border-radius: 8px; padding: 10px 14px; font-size: 12.5px; margin-top: 10px; }

/* --- Finance chart --- */
.finance-legend { display: flex; gap: 18px; margin-bottom: 14px; font-size: 12.5px; }
.finance-legend-item { display: flex; align-items: center; gap: 6px; }
.finance-legend-dot { width: 10px; height: 10px; border-radius: 3px; }
.finance-bar-group { cursor: default; }
.finance-bar-group:hover rect { opacity: 0.85; }
.finance-tooltip-label { font-size: 10px; fill: var(--muted); }

/* --- Property floor plan --- */
.room-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.room-row:last-child { border-bottom: none; }
.room-row .room-name { flex: 1; }
.room-row .room-surface { color: var(--muted); white-space: nowrap; }
.floor-plan-svg { width: 100%; height: auto; border-radius: 8px; overflow: hidden; margin-top: 10px; }
.floor-plan-room-rect { stroke: #fff; stroke-width: 2; }
.floor-plan-room-label { font-size: 12px; font-weight: 600; fill: #fff; pointer-events: none; }
.floor-plan-room-surface { font-size: 10px; fill: rgba(255,255,255,0.85); pointer-events: none; }

/* --- Interactive plan editor --- */
.plan-editor-overlay {
  position: fixed; inset: 0; background: rgba(15,17,23,0.75); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.plan-editor-modal { background: #fff; border-radius: 12px; width: 100%; max-width: 1100px; max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; }
.plan-editor-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.plan-editor-header h3 { margin: 0; font-size: 16px; }
.plan-editor-toolbar { display: flex; gap: 8px; padding: 12px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; align-items: center; }
.plan-floor-tabs { display: flex; gap: 4px; padding: 10px 20px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.plan-floor-tab {
  background: none; border: none; padding: 8px 14px; font-size: 12.5px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer;
}
.plan-floor-tab:hover { color: var(--text); }
.plan-floor-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.plan-floor-tab.plan-floor-add { color: var(--primary); font-weight: 600; }
.plan-device-btn {
  background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px;
  font-size: 12.5px; display: flex; align-items: center; gap: 6px; cursor: pointer;
}
.plan-device-btn:hover { border-color: var(--primary); color: var(--primary); }
.plan-editor-canvas-wrap { flex: 1; overflow: auto; background: #eef0f3; padding: 20px; }
.plan-canvas {
  position: relative; background: #fff;
  background-image: linear-gradient(#e3e5e9 1px, transparent 1px), linear-gradient(90deg, #e3e5e9 1px, transparent 1px);
  border: 1px solid var(--border); margin: 0 auto; user-select: none;
}
.plan-room {
  position: absolute; border: 2px solid #1b1d22; border-radius: 4px; cursor: move;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  font-size: 12px; font-weight: 600; color: #1b1d22; background: rgba(47,111,237,0.12);
}
.plan-room .plan-room-surface { font-size: 10.5px; font-weight: 400; color: var(--muted); }
.plan-room .plan-room-dims { font-size: 9.5px; font-weight: 400; color: var(--muted); }
.plan-room-resize-handle {
  position: absolute; right: -6px; bottom: -6px; width: 14px; height: 14px; border-radius: 50%;
  background: #1b1d22; border: 2px solid #fff; cursor: nwse-resize;
}
.plan-room-delete { position: absolute; top: -8px; left: -8px; width: 18px; height: 18px; border-radius: 50%; background: var(--danger); color: #fff; border: none; font-size: 11px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.plan-device {
  position: absolute; width: 36px; height: 36px; border-radius: 50%; background: #14161f; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 16px; cursor: move;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3); z-index: 5;
}
.plan-device-label {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%); white-space: nowrap;
  font-size: 10.5px; background: #14161f; color: #fff; padding: 2px 6px; border-radius: 4px; margin-top: 3px;
}
.plan-device-delete { position: absolute; top: -6px; right: -6px; width: 16px; height: 16px; border-radius: 50%; background: var(--danger); color: #fff; border: none; font-size: 9px; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 6; }
.plan-coverage-circle { position: absolute; border-radius: 50%; background: rgba(47,111,237,0.12); border: 1.5px dashed var(--primary); pointer-events: none; z-index: 1; }
.plan-coverage-resize-handle {
  position: absolute; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid #fff;
  cursor: ew-resize; z-index: 6;
}
.plan-editor-footer { padding: 10px 20px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted); }

/* --- Walls (selectable per room, material affects coverage) --- */
.plan-wall {
  position: absolute; cursor: pointer; z-index: 3; background: transparent;
}
.plan-wall:hover { background: rgba(47,111,237,0.25); }
.plan-wall.has-material { background: rgba(217,67,47,0.35); }
.plan-wall.has-material:hover { background: rgba(217,67,47,0.5); }
.wall-editor-popover {
  position: absolute; background: #fff; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,0.25);
  padding: 14px; width: 220px; z-index: 50; border: 1px solid var(--border);
}
.wall-editor-popover label { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.wall-editor-popover select, .wall-editor-popover input { width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 16px; margin-bottom: 10px; }
.wall-editor-actions { display: flex; gap: 8px; }
.wall-editor-actions button { flex: 1; padding: 6px; font-size: 12px; border-radius: 6px; border: none; cursor: pointer; }

/* --- Device edit modal --- */
.device-edit-popover {
  position: absolute; background: #fff; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,0.25);
  padding: 14px; width: 200px; z-index: 50; border: 1px solid var(--border);
}
.device-edit-popover label { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.device-edit-popover input { width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 16px; margin-bottom: 10px; }

.plan-coverage-base-circle { position: absolute; border-radius: 50%; border: 1.5px dashed rgba(47,111,237,0.4); pointer-events: none; z-index: 1; }

/* --- Settings --- */
.settings-group { margin-bottom: 20px; }
.settings-group-title { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.settings-field { margin-bottom: 14px; }
.settings-field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: var(--muted); }
.settings-field input { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; }
.settings-field .help { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.settings-restart-overlay {
  position: fixed; inset: 0; background: rgba(15,17,23,0.7); display: flex; align-items: center;
  justify-content: center; z-index: 200; color: #fff; font-size: 15px; text-align: center; flex-direction: column; gap: 10px;
}

.content { flex: 1; overflow-y: auto; padding: 28px 32px; }
.view { max-width: 1200px; margin: 0 auto; }

/* --- Common components --- */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.page-header h2 { margin: 0; font-size: 20px; }
.page-header .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.btn-primary {
  background: var(--primary); color: #fff; border: none; padding: 9px 16px;
  border-radius: 8px; font-size: 13.5px; font-weight: 500;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
  background: #fff; color: var(--text); border: 1px solid var(--border); padding: 8px 14px;
  border-radius: 8px; font-size: 13.5px;
}
.btn-secondary:hover { border-color: #c6c9d0; }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: none; padding: 8px 14px; border-radius: 8px; font-size: 13px; }
.btn-icon { background: none; border: none; padding: 4px 6px; border-radius: 6px; color: var(--muted); }
.btn-icon:hover { background: var(--bg); color: var(--text); }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-card .label { color: var(--muted); font-size: 12.5px; margin-bottom: 6px; }
.stat-card .value { font-size: 24px; font-weight: 700; }
.stat-card .value.small { font-size: 20px; }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; }
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: var(--bg); }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--border); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.clickable:hover { background: #fafbfc; cursor: pointer; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge-lead { background: var(--info-bg); color: var(--info); }
.badge-client { background: var(--success-bg); color: var(--success); }
.badge-draft { background: #eef0f3; color: var(--muted); }
.badge-sent { background: var(--info-bg); color: var(--info); }
.badge-accepted { background: var(--success-bg); color: var(--success); }
.badge-refused { background: var(--danger-bg); color: var(--danger); }
.badge-planned { background: #eef0f3; color: var(--muted); }
.badge-in_progress { background: var(--warning-bg); color: var(--warning); }
.badge-done { background: var(--success-bg); color: var(--success); }
.badge-cancelled { background: var(--danger-bg); color: var(--danger); }
.badge-open { background: var(--danger-bg); color: var(--danger); }
.badge-resolved, .badge-closed { background: var(--success-bg); color: var(--success); }
.badge-normal { background: #eef0f3; color: var(--muted); }
.badge-high { background: var(--warning-bg); color: var(--warning); }
.badge-urgent { background: var(--danger-bg); color: var(--danger); }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.search-input { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; width: 240px; }
.filter-select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { background: none; border: none; padding: 9px 14px; font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }

/* --- Modal --- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,17,23,0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto; z-index: 100;
}
.modal {
  background: #fff; border-radius: 12px; width: 560px; max-width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px 22px; max-height: 70vh; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: var(--muted); }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
}
.form-row textarea { resize: vertical; min-height: 60px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.quote-items-table th, .quote-items-table td { padding: 6px 8px; font-size: 13px; }
.quote-items-table input { padding: 6px 8px; font-size: 16px; }
.item-row-total { font-weight: 600; white-space: nowrap; }
.totals-box { margin-top: 12px; text-align: right; font-size: 13.5px; }
.totals-box .line { margin-bottom: 4px; color: var(--muted); }
.totals-box .grand { font-size: 16px; font-weight: 700; color: var(--text); }

.detail-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.detail-header h2 { margin: 0 0 4px; }
.back-link { background: none; border: none; color: var(--muted); font-size: 13px; margin-bottom: 12px; padding: 0; }
.back-link:hover { color: var(--text); }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.info-item .label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 3px; }
.info-item .value { font-size: 14px; }

.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; color: var(--muted); margin: 24px 0 10px; }
.activity-item { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.activity-item:last-child { border-bottom: none; }
.activity-meta { color: var(--muted); font-size: 11.5px; margin-top: 3px; }

.checklist-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.checklist-row:last-child { border-bottom: none; }
.checklist-row.done .task-title { text-decoration: line-through; color: var(--muted); }

/* ============ Mobile responsive layout ============ */
@media (max-width: 780px) {
  .mobile-menu-btn {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 12px; left: 12px; z-index: 40;
    width: 40px; height: 40px; border-radius: 10px; border: none;
    background: var(--sidebar-bg); color: #fff; font-size: 18px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
  }
  .app { position: relative; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 240px; z-index: 45;
    transform: translateX(-100%); transition: transform 0.2s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.25);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(15,17,23,0.5); z-index: 44;
  }
  .sidebar-backdrop.mobile-open { display: block; }
  .content { padding-top: 68px; width: 100%; padding-left: 16px; padding-right: 16px; }
  .view { padding: 0 12px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid-2 { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
  .modal-overlay { padding: 0; align-items: stretch; }
  .modal { max-width: 100%; width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  .modal-body { max-height: calc(100vh - 130px); }
  .plan-editor-modal { max-width: 100%; max-height: 100%; height: 100%; border-radius: 0; }
  .plan-editor-toolbar { overflow-x: auto; flex-wrap: nowrap; }
}

/* ============ Mobile Quick Room Capture ============ */
.quick-capture-overlay {
  position: fixed; inset: 0; background: #fff; z-index: 120;
  display: flex; flex-direction: column;
}
.quick-capture-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.quick-capture-header h3 { margin: 0; font-size: 16px; }
.quick-capture-header .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.quick-capture-body { flex: 1; overflow-y: auto; padding: 20px 18px; }
.qc-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.qc-preset-btn {
  padding: 10px 16px; border-radius: 999px; border: 1.5px solid var(--border);
  background: #fff; font-size: 14px; color: var(--text);
}
.qc-preset-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.qc-field { margin-bottom: 18px; }
.qc-field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.qc-field input {
  width: 100%; padding: 16px; border: 1.5px solid var(--border); border-radius: 12px;
  font-size: 22px; text-align: center; font-weight: 600;
}
.qc-field input:focus { border-color: var(--primary); outline: none; }
.qc-dims-row { display: flex; align-items: center; gap: 10px; }
.qc-dims-row .qc-field { flex: 1; margin-bottom: 0; }
.qc-dims-x { font-size: 20px; color: var(--muted); font-weight: 600; margin-top: 24px; }
.qc-surface-preview {
  text-align: center; font-size: 15px; color: var(--muted); margin: 4px 0 18px;
  padding: 10px; background: var(--bg); border-radius: 10px;
}
.qc-surface-preview strong { color: var(--text); font-size: 17px; }
.qc-add-btn {
  width: 100%; padding: 18px; border-radius: 14px; border: none;
  background: var(--success); color: #fff; font-size: 17px; font-weight: 700;
}
.qc-add-btn:active { opacity: 0.85; }
.qc-added-list { margin-top: 24px; }
.qc-added-list .section-title { margin-top: 0; }
.qc-added-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 14.5px;
}
.qc-added-row .qc-added-name { font-weight: 600; }
.qc-added-row .qc-added-dims { color: var(--muted); font-size: 13px; }
.qc-added-row button { background: none; border: none; color: var(--danger); font-size: 18px; padding: 4px 8px; }
.qc-done-btn {
  padding: 14px 18px; border-radius: 12px; border: 1.5px solid var(--border);
  background: #fff; font-size: 15px; font-weight: 600; flex-shrink: 0;
}

/* ============ Notification bell ============ */
.notif-bell-wrap { position: relative; margin: 0 4px 14px; flex-shrink: 0; }
.notif-bell-btn {
  width: 100%; text-align: left; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  color: var(--sidebar-text); padding: 9px 10px; border-radius: 8px; font-size: 12.5px; position: relative;
}
.notif-bell-btn:hover { background: rgba(255,255,255,0.1); }
.notif-badge {
  background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; padding: 1px 6px;
  border-radius: 999px; margin-left: 6px;
}
.notif-panel {
  position: absolute; top: calc(100% + 6px); left: 0; width: 320px; max-height: 420px; overflow-y: auto;
  background: #fff; border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,0.35); z-index: 55; padding: 6px 0;
}
.notif-panel-header { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--border); }
.notif-panel-header span { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.notif-panel-header button { background: none; border: none; color: var(--primary); font-size: 11.5px; }
.notif-item { padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: #eef4ff; }
.notif-item .title { font-size: 12.5px; font-weight: 600; color: var(--text); }
.notif-item .message { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.notif-item .time { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.notif-empty { padding: 20px; text-align: center; color: var(--muted); font-size: 12.5px; }

/* ============ My Day view ============ */
.myday-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.myday-card.urgent { border-left: 4px solid var(--danger); }
.myday-card-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.myday-card-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.myday-card-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.myday-card-actions button, .myday-card-actions a {
  padding: 9px 14px; border-radius: 8px; font-size: 12.5px; border: 1px solid var(--border); background: #fff;
  text-decoration: none; color: var(--text); display: inline-flex; align-items: center; gap: 4px;
}
.myday-card-actions .btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ============ My Account / 2FA ============ */
.tfa-qr-box { text-align: center; padding: 16px; }
.tfa-qr-box img { width: 200px; height: 200px; border: 1px solid var(--border); border-radius: 10px; }
.tfa-secret-code { font-family: monospace; font-size: 13px; background: var(--bg); padding: 8px 12px; border-radius: 8px; margin-top: 10px; display: inline-block; letter-spacing: 1px; }
.tfa-status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; }
.tfa-status-badge.on { background: var(--success-bg); color: var(--success); }
.tfa-status-badge.off { background: #eef0f3; color: var(--muted); }

/* ============ Audit log ============ */
.audit-row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; align-items: flex-start; }
.audit-row:last-child { border-bottom: none; }
.audit-action-badge { flex-shrink: 0; font-size: 10.5px; font-weight: 700; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; }
.audit-action-badge.delete { background: var(--danger-bg); color: var(--danger); }
.audit-action-badge.create { background: var(--success-bg); color: var(--success); }
.audit-action-badge.update, .audit-action-badge.status_change { background: #eef4ff; color: var(--primary); }

/* ============ Calendar day detail modal ============ */
.day-detail-row { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.day-detail-row:last-child { border-bottom: none; }
.day-detail-row.clickable { cursor: pointer; }
.day-detail-row.clickable:hover { background: var(--bg); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 8px; }
.day-detail-icon { font-size: 18px; flex-shrink: 0; width: 26px; text-align: center; }
.day-detail-title { font-weight: 600; font-size: 14px; }
.day-detail-desc { font-size: 12.5px; color: var(--muted); white-space: pre-wrap; margin-top: 4px; }

/* ============ Emails ============ */
.email-row { padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.email-row:last-child { border-bottom: none; }
.email-row:hover { background: var(--bg); }
.email-row-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.email-direction { font-size: 15px; flex-shrink: 0; }
.email-subject { font-weight: 600; font-size: 13.5px; flex: 1; }
.email-date { font-size: 11.5px; color: var(--muted); flex-shrink: 0; white-space: nowrap; }
.email-from { font-size: 12px; color: var(--muted); margin-top: 2px; }
.email-body-full { white-space: pre-wrap; font-size: 13px; line-height: 1.6; padding: 14px 16px; background: var(--bg); border-radius: 8px; margin-top: 8px; max-height: 320px; overflow-y: auto; }
.email-account-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.email-account-row:last-child { border-bottom: none; }
.email-sync-status { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.email-sync-status.error { color: var(--danger); }

/* ============ Calendar day view (inline, replacing the old popup) ============ */
.day-view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 10px; }
.day-view-title { font-size: 18px; margin: 0 0 14px; }
.day-detail-time { color: var(--primary); font-weight: 700; }
.cal-event.manual { background: #f0e7fb; color: #6b3fa0; }

/* ============ Workshop (Atelier) board ============ */
.workshop-board { display: flex; gap: 14px; overflow-x: auto; overflow-y: hidden; padding-bottom: 12px; align-items: flex-start; }
.workshop-column {
  flex: 0 0 260px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  max-height: calc(100vh - 220px);
  display: flex;
  flex-direction: column;
}
.workshop-column-header {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; color: var(--muted);
  padding: 2px 4px 12px; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0;
  border-bottom: 1px solid var(--border); margin-bottom: 10px;
}
.workshop-column-header span:last-child {
  background: var(--bg); color: var(--text); border-radius: 999px; padding: 1px 8px; font-size: 11px;
}
.workshop-column-cards { overflow-y: auto; flex: 1; min-height: 60px; border-radius: 8px; transition: background-color 0.1s; }
.workshop-column-cards.drag-over { background: var(--info-bg); outline: 2px dashed var(--primary); outline-offset: -2px; }
.workshop-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; margin-bottom: 8px; cursor: grab; transition: border-color 0.1s, opacity 0.1s;
}
.workshop-card.dragging { opacity: 0.4; }
.workshop-card:active { cursor: grabbing; }
.workshop-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.workshop-card .device { font-weight: 600; font-size: 13.5px; margin-bottom: 4px; line-height: 1.3; word-break: break-word; }
.workshop-card .client { font-size: 12px; color: var(--muted); }
.workshop-card .meta-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted); }
.workshop-item-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.workshop-item-row:last-child { border-bottom: none; }
@media (max-width: 780px) {
  .workshop-column { flex-basis: 220px; max-height: none; }
}

/* ============ POS (Caisse) — touch-friendly ============ */
.pos-layout { display: flex; gap: 16px; align-items: flex-start; }
.pos-products { flex: 1; min-width: 0; }
.pos-search { width: 100%; padding: 14px 16px; font-size: 16px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; }
.pos-product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.pos-product-btn {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 10px;
  cursor: pointer; text-align: center; min-height: 90px; display: flex; flex-direction: column; justify-content: center; gap: 6px;
}
.pos-product-btn:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.pos-product-btn:active { background: var(--info-bg); }
.pos-product-btn .name { font-weight: 600; font-size: 13px; line-height: 1.3; }
.pos-product-btn .price { color: var(--primary); font-weight: 700; font-size: 14px; }
.pos-product-btn .low-stock { color: var(--danger); font-size: 10.5px; }
.pos-cart { flex: 0 0 380px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; position: sticky; top: 20px; }
.pos-cart-items { max-height: 320px; overflow-y: auto; margin: 12px 0; }
.pos-cart-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.pos-cart-row .desc { flex: 1; font-size: 13px; }
.pos-cart-row .qty-controls { display: flex; align-items: center; gap: 4px; }
.pos-cart-row .qty-controls button { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); cursor: pointer; }
.pos-cart-row .line-total { width: 60px; text-align: right; font-weight: 600; font-size: 13px; }
.pos-cart-total { font-size: 22px; font-weight: 700; text-align: right; padding: 12px 0; border-top: 2px solid var(--text); }
.pos-payment-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.pos-payment-btns button { padding: 12px 6px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); font-size: 13px; cursor: pointer; }
.pos-payment-btns button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pos-checkout-btn { width: 100%; padding: 16px; font-size: 16px; font-weight: 700; border-radius: 12px; border: none; background: var(--success); color: #fff; cursor: pointer; margin-top: 8px; }
.pos-checkout-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pos-customer-box { border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 4px; }
.pos-customer-selected { display: flex; justify-content: space-between; align-items: center; }
@media (max-width: 900px) {
  .pos-layout { flex-direction: column; }
  .pos-cart { flex: 1; width: 100%; position: static; }
}

/* ============ Loyalty (Fidélité) ============ */
.loyalty-reward-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.loyalty-reward-card .points { color: var(--primary); font-weight: 700; font-size: 18px; }
