/* Maintenance Pro — theme
   Palette + type are CSS variables on purpose: retint here if your established
   brand hex differs from these placeholders. */

:root {
  --navy-950: #0A1628;
  --navy-900: #0F2137;
  --navy-800: #1B3555;
  --navy-700: #28466B;
  --gold-500: #C7A059;
  --gold-400: #DEC384;
  --gold-100: #FBF3E1;
  --paper: #F7F4EE;
  --surface: #FFFFFF;
  --ink: #1B2430;
  --muted: #66707F;
  --border: #E4DFD3;
  --danger: #B3261E;
  --danger-bg: #FBEAE8;
  --warning: #9A6B14;
  --warning-bg: #FBF0DC;
  --info: #2B5F8A;
  --info-bg: #E7F0F7;
  --success: #2F7D46;
  --success-bg: #E7F4EA;
  --muted-bg: #EEF0F2;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(10,22,40,.06), 0 1px 1px rgba(10,22,40,.04);
  --shadow-md: 0 8px 24px rgba(10,22,40,.10), 0 2px 6px rgba(10,22,40,.06);
  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --sidebar-w: 264px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 2px; }

#app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy-950), var(--navy-900));
  color: #E8ECF1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 30;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-mark {
  width: 42px; height: 42px;
  border: 1px solid var(--gold-500);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  color: var(--gold-400);
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
  line-height: 1.15;
  color: #fff;
  letter-spacing: 0.2px;
}
.brand-tag {
  font-size: 11px;
  color: var(--gold-400);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Property switcher styled like a building directory plaque */
.property-switcher {
  margin: 16px 16px 8px;
  padding: 12px 14px;
  background: var(--navy-800);
  border: 1px solid rgba(199,160,89,.35);
  border-radius: var(--radius-md);
}
.property-switcher label {
  display: block;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gold-400);
  margin-bottom: 6px;
}
.property-switcher select {
  width: 100%;
  background: transparent;
  color: #fff;
  border: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14.5px;
  padding: 2px 0;
}
.property-switcher select option { color: var(--ink); }

.nav { display: flex; flex-direction: column; padding: 10px 12px; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #C9D2DE;
  font-size: 14px;
  font-weight: 500;
  transition: background .12s ease, color .12s ease;
}
.nav a svg { flex-shrink: 0; opacity: .85; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--gold-500); color: var(--navy-950); font-weight: 600; }
.nav a.active svg { opacity: 1; }

.sidebar-footer {
  padding: 14px 20px 18px;
  font-size: 10.5px;
  color: rgba(255,255,255,.35);
  border-top: 1px solid rgba(255,255,255,.08);
}
.install-btn {
  display: none;
  width: 100%;
  justify-content: center;
  margin-bottom: 10px;
}

.menu-toggle {
  display: none;
  position: fixed; top: 14px; left: 14px; z-index: 40;
  width: 40px; height: 40px;
  background: var(--navy-950); color: #fff;
  border: none; border-radius: var(--radius-sm);
  align-items: center; justify-content: center;
  box-shadow: var(--shadow-md);
}
.overlay { display: none; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; padding: 28px 32px 60px; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-head h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 32px;
  margin: 0;
  color: var(--navy-950);
}
.page-sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.loading { padding: 60px 0; text-align: center; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover { box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy-950); border-color: var(--navy-950); color: #fff; }
.btn-primary:hover { background: var(--navy-900); }
.btn-gold { background: var(--gold-500); border-color: var(--gold-500); color: var(--navy-950); }
.btn-gold:hover { background: var(--gold-400); }
.btn-danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-ghost { background: transparent; border-color: transparent; padding: 8px 10px; }
.btn-ghost:hover { background: var(--muted-bg); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Cards / stat grid ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 14px; margin-bottom: 26px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.stat-card .num { font-family: var(--font-display); font-size: 34px; font-weight: 700; color: var(--navy-950); line-height: 1; }
.stat-card .label { font-size: 12px; color: var(--muted); margin-top: 6px; font-weight: 500; }
.stat-card.alert .num { color: var(--danger); }
.stat-card.warn .num { color: var(--warning); }

.panel-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
@media (max-width: 1000px) { .panel-grid { grid-template-columns: 1fr; } }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.panel-head h3 { margin: 0; font-family: var(--font-display); font-size: 19px; font-weight: 700; }
.panel-body { padding: 4px 0; }
.panel-empty { padding: 28px 18px; text-align: center; color: var(--muted); font-size: 13.5px; }

/* ---------- Lists / rows ---------- */
.row-list { display: flex; flex-direction: column; }
.row-item { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.row-item:last-child { border-bottom: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; color: var(--navy-950); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.badge-open { background: var(--info-bg); color: var(--info); }
.badge-in_progress { background: var(--gold-100); color: #8A6416; }
.badge-on_hold { background: var(--muted-bg); color: var(--muted); }
.badge-completed { background: var(--success-bg); color: var(--success); }
.badge-cancelled { background: var(--muted-bg); color: var(--muted); text-decoration: line-through; }
.badge-low { background: var(--muted-bg); color: var(--muted); }
.badge-medium { background: var(--info-bg); color: var(--info); }
.badge-high { background: var(--warning-bg); color: var(--warning); }
.badge-emergency { background: var(--danger-bg); color: var(--danger); }
.badge-occupied { background: var(--success-bg); color: var(--success); }
.badge-vacant { background: var(--muted-bg); color: var(--muted); }
.badge-make_ready { background: var(--warning-bg); color: var(--warning); }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: center; }
.toolbar input[type="text"], .toolbar input[type="search"], .toolbar select {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13.5px; background: var(--surface); color: var(--ink); font-family: inherit;
}
.toolbar .search-box { flex: 1; min-width: 180px; max-width: 320px; }
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-left: auto; }
.view-toggle button { border: none; background: var(--surface); padding: 8px 14px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.view-toggle button.active { background: var(--navy-950); color: #fff; }

/* ---------- Table ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-sm); }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left; padding: 11px 16px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); border-bottom: 1px solid var(--border); background: var(--paper); font-weight: 600;
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr.clickable:hover { background: var(--paper); cursor: pointer; }
.data-table .num-cell { text-align: right; font-variant-numeric: tabular-nums; }
.low-stock { color: var(--danger); font-weight: 700; }
.actions-cell { display: flex; gap: 6px; justify-content: flex-end; }

/* mobile card list fallback for tables */
.card-list { display: none; flex-direction: column; gap: 10px; }
.data-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.data-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
.data-card-title { font-weight: 700; color: var(--navy-950); }
.data-card-row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); padding: 3px 0; }

@media (max-width: 720px) {
  .table-wrap { display: none; }
  .card-list { display: flex; }
}

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(230px,1fr)); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.kanban-col { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius-md); min-height: 120px; }
.kanban-col-head { padding: 12px 14px; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; }
.kanban-col.drop-target { outline: 2px dashed var(--gold-500); outline-offset: -2px; }
.kanban-cards { padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 60px; }
.wo-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 12px; cursor: grab; box-shadow: var(--shadow-sm); position: relative; border-left: 4px solid var(--muted);
}
.wo-card[data-priority="emergency"] { border-left-color: var(--danger); }
.wo-card[data-priority="high"] { border-left-color: var(--warning); }
.wo-card[data-priority="medium"] { border-left-color: var(--info); }
.wo-card[data-priority="low"] { border-left-color: var(--muted); }
.wo-card:active { cursor: grabbing; }
.wo-card.dragging { opacity: .45; }
.wo-card-title { font-weight: 600; font-size: 13.5px; margin-bottom: 4px; }
.wo-card-meta { font-size: 11.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 900px) { .kanban { grid-template-columns: 1fr; } }

/* ---------- Forms / Modal ---------- */
.overlay-modal { position: fixed; inset: 0; background: rgba(10,22,40,.55); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 100; overflow-y: auto; }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 560px; box-shadow: var(--shadow-md); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-family: var(--font-display); font-size: 22px; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.modal-body { padding: 20px 22px; max-height: 68vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: var(--navy-950); }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: inherit; background: var(--surface); color: var(--ink);
}
.field textarea { resize: vertical; min-height: 70px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }
.field-error { color: var(--danger); font-size: 12px; margin-top: 8px; }

/* ---------- Detail page ---------- */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.detail-title { font-family: var(--font-display); font-size: 28px; font-weight: 700; color: var(--navy-950); }
.detail-badges { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 14px; padding: 16px 18px; }
.kv-grid .kv label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 3px; }
.kv-grid .kv div { font-size: 14px; font-weight: 600; color: var(--navy-950); }

.note-list { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; }
.note-item { background: var(--paper); border-radius: var(--radius-sm); padding: 10px 13px; font-size: 13px; }
.note-time { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.note-add { display: flex; gap: 8px; padding: 4px 18px 18px; }
.note-add textarea { flex: 1; min-height: 44px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; font-size: 13px; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 60px 24px; color: var(--muted); }
.empty-state h3 { font-family: var(--font-display); font-size: 22px; color: var(--navy-950); margin: 0 0 8px; }
.empty-state p { margin: 0 0 18px; font-size: 14px; }

/* ---------- Toasts ---------- */
.toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--navy-950); color: #fff; padding: 11px 16px; border-radius: var(--radius-sm); font-size: 13px; box-shadow: var(--shadow-md); animation: toast-in .18s ease; }
.toast.error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: translateY(0);} }

/* ---------- Utility ---------- */
.text-muted { color: var(--muted); }
.mt-0 { margin-top: 0; }
.flex-gap { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Responsive: sidebar drawer ---------- */
@media (max-width: 900px) {
  .menu-toggle { display: flex; }
  .sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--shadow-md);
  }
  .sidebar.open { transform: translateX(0); }
  .overlay.show { display: block; position: fixed; inset: 0; background: rgba(10,22,40,.4); z-index: 25; }
  .main { padding: 70px 16px 50px; }
  .page-head h1 { font-size: 26px; }
  .kv-grid { grid-template-columns: repeat(2,1fr); }
}

/* ---------- Print ---------- */
@media print {
  .sidebar, .menu-toggle, .page-actions, .toolbar, .modal-foot, .toast-root { display: none !important; }
  .main { padding: 0; }
  body { background: #fff; }
  .panel, .stat-card, .table-wrap { box-shadow: none; border-color: #ccc; }
}
