:root {
  --navy: #14294a;
  --navy-2: #1d3760;
  --green: #1f8f3a;
  --green-soft: #e3f5e6;
  --green-text: #1d7a33;
  --blue: #2563c9;
  --blue-soft: #e5eefc;
  --orange: #c77700;
  --orange-soft: #fff1d6;
  --red: #c62f2f;
  --red-soft: #fde6e6;
  --purple: #7a4fd0;
  --gray-soft: #eef0f3;
  --bg: #f3f5f8;
  --card: #ffffff;
  --line: #e2e6ec;
  --line-2: #eef1f5;
  --text: #1c2430;
  --muted: #5d6878;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 41, 74, 0.06);
  font-family: 'Segoe UI', 'Segoe UI Variable', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); font-size: 14px; }
a { color: var(--blue); text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ico { width: 20px; height: 20px; flex: none; display: block; }
.rel { position: relative; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--navy), #0e1d36); padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 12px; padding: 28px; display: grid; gap: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-card h1 { font-size: 18px; margin: 0; }
.login-card p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.brand-row { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  border: 1px solid #cfd6e0; border-radius: 6px; padding: 8px 10px; background: #fff; width: 100%; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc0f5; outline-offset: -1px; border-color: var(--blue); }
.form-error { color: var(--red); font-size: 13px; min-height: 1px; }

/* ---------- Buttons ---------- */
.btn { border: 1px solid #cfd6e0; background: #fff; color: var(--text); border-radius: 6px; padding: 7px 14px; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.btn:hover { background: #f6f8fb; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #1d54ad; }
.btn.danger { color: var(--red); border-color: #f0c2c2; }
.btn.block { width: 100%; justify-content: center; padding: 10px; }
.btn .ico { width: 16px; height: 16px; }
.link-btn { background: none; border: 0; color: var(--blue); padding: 0; display: inline-flex; gap: 6px; align-items: center; }
.link-btn .ico { width: 16px; height: 16px; }
.icon-btn { background: none; border: 0; color: #fff; width: 36px; height: 36px; border-radius: 6px; display: grid; place-items: center; position: relative; }
.icon-btn:hover { background: rgba(255,255,255,.1); }
.icon-btn.dark { color: var(--muted); }
.icon-btn.dark:hover { background: var(--gray-soft); }
.row-act { background: none; border: 0; color: var(--muted); padding: 4px; border-radius: 4px; }
.row-act:hover { background: var(--gray-soft); color: var(--text); }
.row-act .ico { width: 16px; height: 16px; }

/* ---------- Top bar ---------- */
.topbar { background: var(--navy); color: #fff; height: 66px; display: flex; align-items: center; gap: 24px; padding: 0 20px; position: sticky; top: 0; z-index: 30; }
.brand { display: flex; align-items: center; gap: 14px; color: #fff; min-width: 0; }
.logo { width: 48px; height: 48px; background: var(--green); color: #fff; font-weight: 600; font-size: 20px; display: grid; place-items: center; border-radius: 3px; flex: none; }
.brand-title { font-size: 22px; font-weight: 600; letter-spacing: .1px; white-space: nowrap; }
.brand-sub { font-size: 11px; opacity: .85; letter-spacing: .3px; white-space: nowrap; }
.search-wrap { flex: 1; max-width: 530px; position: relative; margin-left: auto; }
.search-wrap input { height: 34px; padding-left: 36px; border: 0; border-radius: 4px; font-size: 13px; }
.search-icon { position: absolute; left: 10px; top: 7px; color: var(--muted); }
.search-icon .ico { width: 18px; height: 18px; }
.top-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.ai-btn { display: flex; align-items: center; gap: 6px; background: linear-gradient(135deg, #2b6de0, #7a4fd0); color: #fff; border: 0; border-radius: 18px; padding: 7px 14px; margin-right: 8px; }
.ai-btn .ico { width: 17px; height: 17px; }
.badge { position: absolute; top: 2px; right: 1px; background: #e0413a; color: #fff; border-radius: 9px; font-size: 10px; min-width: 17px; height: 17px; display: grid; place-items: center; padding: 0 4px; font-weight: 600; }
.user-btn { display: flex; align-items: center; gap: 8px; background: none; border: 0; color: #fff; padding: 4px 6px; border-radius: 6px; }
.user-btn:hover { background: rgba(255,255,255,.08); }
.user-btn .ico { width: 16px; height: 16px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #3b78e7; display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.user-name { font-size: 13px; white-space: nowrap; }

.dropdown { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; color: var(--text); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(20,41,74,.18); z-index: 50; max-height: 70vh; overflow: auto; }
.dropdown.right { left: auto; right: 0; min-width: 240px; }
.dropdown a, .dropdown button { display: block; width: 100%; text-align: left; padding: 10px 14px; border: 0; background: none; color: var(--text); }
.dropdown a:hover, .dropdown button:hover { background: #f4f7fb; }
.dropdown .dd-item { display: flex; flex-direction: column; gap: 2px; border-bottom: 1px solid var(--line-2); }
.dropdown .dd-empty { padding: 14px; color: var(--muted); }
#alertsMenu { min-width: 330px; }

/* ---------- Top nav ---------- */
.tabs-nav { background: #fff; border-bottom: 1px solid var(--line); display: flex; gap: 6px; padding: 0 20px 0 82px; overflow-x: auto; position: sticky; top: 66px; z-index: 20; scrollbar-width: none; }
.tabs-nav a { color: var(--text); padding: 12px 14px 10px; white-space: nowrap; border-bottom: 3px solid transparent; font-size: 14px; }
.tabs-nav a:hover { color: var(--blue); }
.tabs-nav a.active { border-bottom-color: var(--blue); font-weight: 600; }
.nav-toggle { display: none; background: none; border: 0; color: var(--text); padding: 8px; }

/* ---------- Layout ---------- */
.layout { display: flex; align-items: flex-start; gap: 14px; padding: 12px 14px 24px; }
.sidebar { width: 220px; flex: none; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 0; position: sticky; top: 124px; max-height: calc(100vh - 136px); overflow: auto; }
.sidebar a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; color: var(--text); border-left: 3px solid transparent; margin: 1px 0; font-size: 14px; }
.sidebar a:hover { background: #f4f7fb; }
.sidebar a.active { background: #eef1f6; border-left-color: var(--navy); font-weight: 500; }
.sidebar .ico { width: 20px; height: 20px; color: #3a4556; }
.side-sep { border-top: 1px solid var(--line); margin: 8px 0; }
.main { flex: 1; min-width: 0; display: grid; gap: 14px; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 20px; font-weight: 600; }
.page-head .spacer { flex: 1; }

.div-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.div-card { overflow: hidden; cursor: pointer; display: flex; flex-direction: column; text-align: left; padding: 0; color: var(--text); }
.div-card:hover { border-color: #b9c6d8; }
.div-card.selected { outline: 2px solid var(--blue); outline-offset: -1px; }
.div-photo { height: 126px; background-size: cover; background-position: center; display: grid; place-items: center; color: rgba(255,255,255,.92); }
.div-photo .ico { width: 56px; height: 56px; stroke-width: 1.4; }
.ph-0 { background: linear-gradient(135deg, #7c1d1d, #b8432a); }
.ph-1 { background: linear-gradient(135deg, #0f3b2a, #2d7a3e); }
.ph-2 { background: linear-gradient(135deg, #3c2614, #9a6a2c); }
.ph-3 { background: linear-gradient(135deg, #3b2a1f, #8a6046); }
.ph-4 { background: linear-gradient(135deg, #24395e, #5a7fae); }
.ph-5 { background: linear-gradient(135deg, #3a2b5c, #7b5bb5); }
.div-body { display: flex; gap: 12px; padding: 12px 14px; align-items: flex-start; }
.div-icon { width: 40px; height: 40px; display: grid; place-items: center; color: var(--orange); }
.div-icon .ico { width: 34px; height: 34px; }
.div-icon.i-cannabis { color: var(--green); }
.div-icon.i-hotel, .div-icon.i-building { color: var(--blue); }
.div-name { font-size: 15px; font-weight: 600; }
.div-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.div-chev { margin-left: auto; color: var(--muted); }
.div-chev .ico { width: 18px; height: 18px; }
.dot-active { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--green-text); margin-top: 3px; }
.dot-active::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--green); }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.kpi { display: flex; gap: 14px; padding: 16px; align-items: flex-start; color: var(--text); }
.kpi-icon { width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; color: #fff; flex: none; }
.kpi-icon .ico { width: 22px; height: 22px; }
.kpi-label { font-size: 12.5px; }
.kpi-value { font-size: 24px; font-weight: 600; margin: 2px 0; }
.kpi-sub { font-size: 12px; display: flex; gap: 4px; align-items: center; color: var(--muted); }
.kpi-sub .ico { width: 13px; height: 13px; }
.kpi-sub.good { color: var(--green-text); }
.kpi-sub.bad { color: var(--red); }
.kpi-sub.warn { color: var(--orange); }

/* Division panel */
.division-panel { display: grid; grid-template-columns: 270px minmax(0,1fr); overflow: hidden; }
.loc-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.loc-list-head { display: flex; gap: 12px; padding: 16px; align-items: center; border-bottom: 1px solid var(--line-2); }
.loc-list-head .div-icon .ico { width: 36px; height: 36px; }
.loc-list-head h3 { margin: 0; font-size: 18px; font-weight: 600; }
.loc-list-items { padding: 8px; display: grid; gap: 1px; overflow: auto; max-height: 520px; }
.loc-item { text-align: left; background: none; border: 0; padding: 9px 14px; border-radius: 4px; color: var(--text); border-left: 3px solid transparent; }
.loc-item:hover { background: #f4f7fb; }
.loc-item.active { background: #eef1f6; border-left-color: var(--green); font-weight: 600; }
.loc-list .link-btn { padding: 12px 22px 16px; }
.loc-detail { min-width: 0; }
.loc-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 22px 10px; flex-wrap: wrap; }
.loc-head h2 { margin: 0; font-size: 22px; font-weight: 600; }
.loc-head .addr { margin-top: 4px; color: #333d4a; }
.loc-head .spacer { flex: 1; }
.sub-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; scrollbar-width: none; }
.sub-tabs button { background: none; border: 0; padding: 11px 12px; white-space: nowrap; border-bottom: 3px solid transparent; color: var(--text); }
.sub-tabs button.active { border-bottom-color: var(--green); font-weight: 600; }
.loc-body { padding: 14px; display: grid; gap: 14px; }
.overview-top { display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: 14px; }
.info-grid { display: grid; grid-template-columns: max-content 1fr max-content 1fr; gap: 14px 26px; padding: 18px 20px; align-content: start; }
.info-grid .k { color: #333d4a; }
.loc-photo { border-radius: 4px; min-height: 140px; background-size: cover; background-position: center; display: grid; place-items: center; color: rgba(255,255,255,.9); position: relative; overflow: hidden; }
.loc-photo .ico { width: 54px; height: 54px; stroke-width: 1.4; }
.loc-photo .photo-btn { position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,.55); color: #fff; border: 0; border-radius: 4px; padding: 5px 9px; font-size: 12px; display: flex; gap: 5px; align-items: center; }
.loc-photo .photo-btn .ico { width: 14px; height: 14px; }
.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mini-grid > *, .overview-top > *, .report-grid > * { min-width: 0; }
.mini-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.mini-head h4 { margin: 0; font-size: 15px; font-weight: 600; }
.mini-head .ico { color: var(--blue); }
.mini-head .spacer { flex: 1; }
.mini-foot { padding: 8px 14px 12px; }
.mini-grid table.data th, .mini-grid table.data td { padding-left: 10px; padding-right: 8px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-weight: 500; color: #333d4a; padding: 8px 12px; background: #f6f8fb; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); white-space: nowrap; }
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data tr:hover td { background: #fafbfd; }
table.data td.actions { white-space: nowrap; text-align: right; width: 1%; }
table.data .empty { color: var(--muted); text-align: center; padding: 22px; }
.num { font-variant-numeric: tabular-nums; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; background: var(--gray-soft); color: #3a4556; white-space: nowrap; }
.pill.green { background: var(--green-soft); color: var(--green-text); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.orange { background: var(--orange-soft); color: var(--orange); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.dot::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 0; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
.toolbar input[type=search] { max-width: 260px; }
.toolbar select { max-width: 200px; }

/* Reports */
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.bars { display: grid; gap: 10px; padding: 14px 16px 18px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 90px; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { height: 14px; background: var(--gray-soft); border-radius: 3px; overflow: hidden; display: flex; }
.bar-fill { height: 100%; background: var(--blue); }
.bar-fill.paid { background: var(--green); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); padding: 0 16px; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; background: var(--blue); vertical-align: -1px; }
.legend span.paid::before { background: var(--green); }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(14,29,54,.45); display: grid; place-items: center; z-index: 80; padding: 16px; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 620px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; flex: 1; }
.modal-body { padding: 16px 18px; overflow: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-body .full { grid-column: 1 / -1; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); align-items: center; }
.modal-foot .form-error { flex: 1; }
.check-row { display: flex; align-items: center; gap: 8px; color: var(--text); padding-top: 22px; }
.check-row input { width: 16px; height: 16px; }
.req { color: var(--red); }

/* Toast */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1c2430; color: #fff; padding: 10px 18px; border-radius: 6px; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.error { background: var(--red); }

/* AI panel */
.ai-panel { position: fixed; right: 16px; bottom: 16px; top: 82px; width: 420px; max-width: calc(100vw - 32px); background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 20px 50px rgba(20,41,74,.25); z-index: 60; display: flex; flex-direction: column; }
.ai-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.ai-head > .ico { color: var(--purple); }
.ai-head strong { flex: none; }
.ai-head .muted { flex: 1; }
.ai-messages { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; padding: 9px 12px; border-radius: 10px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 3px; }
.msg.assistant { align-self: flex-start; background: #f2f4f8; border-bottom-left-radius: 3px; white-space: normal; }
.msg.assistant p { margin: 0 0 6px; }
.msg.assistant p:last-child { margin: 0; }
.msg.assistant table { border-collapse: collapse; font-size: 12px; margin: 6px 0; }
.msg.assistant td, .msg.assistant th { border: 1px solid #d6dbe3; padding: 3px 6px; }
.msg.assistant ul { margin: 4px 0; padding-left: 18px; }
.msg.error { background: var(--red-soft); color: var(--red); }
.msg.thinking { color: var(--muted); font-style: italic; }
.ai-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ai-actions span { background: var(--green-soft); color: var(--green-text); border-radius: 10px; font-size: 11.5px; padding: 2px 8px; }
.ai-suggest { display: flex; flex-direction: column; gap: 6px; padding: 0 14px 10px; }
.ai-suggest button { text-align: left; background: #f6f8fb; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 12.5px; color: var(--text); }
.ai-suggest button:hover { border-color: #b9c6d8; }
.ai-form { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); align-items: flex-end; }
.ai-form textarea { resize: none; flex: 1; }

.help p, .help li { line-height: 1.55; }

/* ---------- Responsive ---------- */
@media (max-width: 1250px) {
  .overview-top { grid-template-columns: 1fr; }
  .loc-photo { min-height: 180px; }
}
@media (max-width: 1100px) {
  .division-panel { grid-template-columns: 1fr; }
  .loc-list { border-right: 0; border-bottom: 1px solid var(--line); }
  .loc-list-items { max-height: 220px; }
  .mini-grid, .report-grid { grid-template-columns: 1fr; }
  .user-name, .brand-sub { display: none; }
}
.mobile-only, .loc-select { display: none; }

/* ---------- Tablet & phone ---------- */
@media (max-width: 860px) {
  .mobile-only { display: grid; }
  .tabs-nav { display: none; }
  .topbar { height: 58px; gap: 6px; padding: 0 8px; }
  .brand { gap: 8px; }
  .brand-title { font-size: 16px; }
  .logo { width: 34px; height: 34px; font-size: 14px; }
  .top-actions { gap: 0; }
  .top-actions a.icon-btn[href="#/help"], .top-actions a.icon-btn[href="#/settings"] { display: none; }
  .ai-btn { padding: 7px 10px; margin-right: 2px; }
  .ai-label { display: none; }
  .avatar { width: 30px; height: 30px; font-size: 12px; }
  .user-btn > .ico { display: none; }

  /* search drops down under the header */
  .search-wrap { display: none; position: fixed; top: 58px; left: 0; right: 0; max-width: none; padding: 8px; background: var(--navy); z-index: 40; margin: 0; }
  body.search-open .search-wrap { display: block; }
  .search-wrap .search-icon { left: 18px; top: 15px; }
  #searchResults { left: 8px; right: 8px; }

  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; max-height: none; z-index: 70; border-radius: 0; transform: translateX(-100%); transition: transform .2s; width: 260px; padding-top: 16px; }
  body.side-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .layout { padding: 10px 10px 24px; gap: 0; }
  .main { gap: 12px; }

  /* division cards: swipe sideways */
  .div-cards { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; margin: 0 -10px; padding: 0 10px 4px; scrollbar-width: none; }
  .div-card { flex: 0 0 64%; scroll-snap-align: start; }
  .div-photo { height: 74px; }
  .div-photo .ico { width: 34px; height: 34px; }
  .div-body { padding: 10px; gap: 8px; }
  .div-icon { width: 28px; height: 28px; }
  .div-icon .ico { width: 24px; height: 24px; }
  .div-name { font-size: 14px; }

  /* KPIs: 2 per row, compact */
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 10px; gap: 10px; }
  .kpi-icon { width: 30px; height: 30px; }
  .kpi-icon .ico { width: 17px; height: 17px; }
  .kpi-label { font-size: 12px; }
  .kpi-value { font-size: 19px; }
  .kpi-sub { font-size: 11px; }

  /* location picker becomes a dropdown */
  .division-panel { grid-template-columns: 1fr; }
  .loc-list { border-right: 0; border-bottom: 1px solid var(--line); }
  .loc-list-head { padding: 12px 14px 8px; border-bottom: 0; }
  .loc-list-head h3 { font-size: 16px; }
  .loc-list-items { display: none; }
  .loc-select { display: block; margin: 0 14px 12px; width: calc(100% - 28px); font-weight: 600; }
  .loc-list .link-btn { padding: 0 14px 12px; }
  .loc-head { padding: 14px 14px 8px; }
  .loc-head h2 { font-size: 18px; }
  .loc-body { padding: 10px; gap: 10px; }
  .sub-tabs { padding: 0 4px; }
  .sub-tabs button { padding: 10px 10px; }
  .info-grid { grid-template-columns: max-content 1fr; padding: 14px; gap: 10px 14px; }
  .loc-photo { min-height: 120px; }
  .mini-grid, .report-grid { grid-template-columns: 1fr; gap: 10px; }

  /* tables turn into stacked cards */
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody { display: block; }
  table.responsive tr { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border-bottom: 1px solid var(--line-2); position: relative; }
  table.responsive.has-actions tr { padding-right: 52px; }
  table.responsive td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0; border: 0; font-size: 13px; text-align: right; }
  table.responsive td::before { content: attr(data-label); color: var(--muted); flex: none; }
  table.responsive td.primary { font-weight: 600; font-size: 14px; margin-bottom: 2px; text-align: left; }
  table.responsive td.primary::before { display: none; }
  table.responsive td.actions { position: absolute; top: 8px; right: 8px; flex-direction: column; gap: 4px; width: auto; }
  table.responsive td.actions::before { display: none; }
  table.responsive td.empty { display: block; padding: 18px; }
  table.responsive td.empty::before { display: none; }
  table.data tr:hover td { background: none; }

  .page-head h2 { font-size: 18px; }
  .toolbar input[type=search], .toolbar select { max-width: none; flex: 1 1 140px; }
  .bar-row { grid-template-columns: 80px 1fr 80px; }

  /* forms and AI full screen */
  .modal-back { padding: 0; place-items: stretch; }
  .modal { max-width: none; max-height: none; height: 100%; border-radius: 0; }
  .modal-body { grid-template-columns: 1fr; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .form-error { flex-basis: 100%; }
  .ai-panel { inset: 0; width: auto; max-width: none; border-radius: 0; top: 0; }
  .dropdown.right { position: fixed; top: 58px; left: 8px; right: 8px; min-width: 0; }
  input, select, textarea { font-size: 16px !important; } /* stops iPhone zooming in */
}
@media (max-width: 400px) {
  .brand-title { display: none; }
}
