/* Font: DM Sans, hosted on this server (no outside requests) */
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/dm-sans-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/dm-sans-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/dm-sans-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/dm-sans-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Amp'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/dm-sans-latin-400-normal.woff2) format('woff2'); unicode-range: U+0026; }
@font-face { font-family: 'Amp'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/dm-sans-latin-500-normal.woff2) format('woff2'); unicode-range: U+0026; }
@font-face { font-family: 'Amp'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/dm-sans-latin-600-normal.woff2) format('woff2'); unicode-range: U+0026; }
@font-face { font-family: 'Amp'; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/dm-sans-latin-700-normal.woff2) format('woff2'); unicode-range: U+0026; }
/* Amp: a plain '&' (Archivo's own looks like a backwards 3) */
@font-face { font-family: 'Archivo'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/archivo-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Archivo'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/archivo-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Archivo'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/archivo-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Archivo'; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/archivo-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Archivo Narrow'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/archivo-narrow-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Archivo Narrow'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/archivo-narrow-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Archivo Narrow'; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/archivo-narrow-latin-700-normal.woff2) format('woff2'); }

:root {
  /* Spruce + brass on fieldstone */
  --navy: #173f35;         /* spruce: header, strong UI */
  --navy-2: #215546;
  --brass: #c4902e;        /* accent: logo, selection, active tabs */
  --brass-soft: #f7ecd6;
  --green: #2f8a4e;
  --green-soft: #e2f1e6;
  --green-text: #22703d;
  --blue: #1d6a55;         /* primary actions & links (spruce-teal) */
  --blue-soft: #e1efea;
  --blue-hover: #165846;
  --info: #2f63a3;
  --info-soft: #e4ecf7;
  --orange: #a8660a;
  --orange-soft: #fbefd9;
  --red: #b83a2a;
  --red-soft: #fbe5e1;
  --purple: #6e4fa8;
  --gray-soft: #edf0ed;
  --bg: #eef1ee;
  --card: #ffffff;
  --line: #dbe2dd;
  --line-2: #e9eeea;
  --text: #18231f;
  --muted: #5b6a63;
  --input-line: #c9d3cc;
  --hover: #f3f6f3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(11, 58, 130, 0.05), 0 2px 8px rgba(11, 58, 130, 0.04);
  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  font-family: 'Public Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  font-feature-settings: 'tnum' 1;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); font-size: 16px; line-height: 1.4; }
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: 14px; }
.ico { width: 20px; height: 20px; flex: none; display: block; }
.rel { position: relative; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(120% 90% at 20% 0%, #24604f 0%, var(--navy) 55%, #0f2b24 100%); padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 12px; padding: 28px; display: grid; gap: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-card h1 { font-family: var(--serif); font-size: 22px; font-weight: 600; margin: 0; }
.login-card p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.brand-row { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
label { display: grid; gap: 5px; font-size: 15px; 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 var(--input-line); border-radius: 7px; padding: 8px 10px; background: var(--card); width: 100%; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc0f5; outline-offset: -1px; border-color: var(--blue); }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #9cc0f5; outline-offset: -1px; }
.form-error { color: var(--red); font-size: 15px; min-height: 1px; }

/* ---------- Buttons ---------- */
.btn { border: 1px solid var(--input-line); background: var(--card); color: var(--text); border-radius: 7px; padding: 7px 14px; font-weight: 500; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-hover); border-color: var(--blue-hover); }
.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: 46px; height: 46px; background: var(--brass); color: #1b2a22; font-family: var(--serif); font-weight: 700; font-size: 21px; display: grid; place-items: center; border-radius: 9px; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.brand-title { font-family: var(--serif); font-size: 23px; font-weight: 600; letter-spacing: -.2px; white-space: nowrap; }
.brand-sub { font-size: 14px; opacity: .72; white-space: nowrap; }
.search-wrap { flex: 1; max-width: 530px; position: relative; margin-left: auto; }
.search-wrap input { height: 36px; padding-left: 36px; border: 1px solid rgba(255,255,255,.14); border-radius: 8px; font-size: 15.5px; background: rgba(255,255,255,.96); }
.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: transparent; color: #f3dcae; border: 1px solid rgba(196,144,46,.7); border-radius: 18px; padding: 6px 14px; margin-right: 8px; font-weight: 500; }
.ai-btn:hover { background: rgba(196,144,46,.16); color: #fff; }
.ai-btn .ico { width: 17px; height: 17px; }
.badge { position: absolute; top: 2px; right: 1px; background: #d9543f; 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: #2f6b59; box-shadow: inset 0 0 0 1.5px rgba(196,144,46,.8); display: grid; place-items: center; font-size: 15px; font-weight: 600; }
.user-name { font-size: 15px; white-space: nowrap; }

.dropdown { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(11,58,130,.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: var(--hover); }
.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: var(--card); 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: 16px; }
.tabs-nav a:hover { color: var(--navy); }
.tabs-nav a.active { border-bottom-color: var(--brass); color: var(--navy); 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: 246px; flex: none; background: var(--card); 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: 16px; }
.sidebar a:hover { background: var(--hover); }
.sidebar a.active { background: var(--blue-soft); border-left-color: var(--brass); color: var(--navy); font-weight: 600; }
.sidebar a.active .ico { color: var(--navy); }
.sidebar .ico { width: 20px; height: 20px; color: #3b4a43; }
.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-family: var(--serif); font-size: 24px; font-weight: 600; letter-spacing: -.2px; }
.page-head .spacer { flex: 1; }

.div-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 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: #b7c4bb; }
.div-card.selected { outline: 2px solid var(--brass); 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(140deg, #5e1f17, #a8462a); }
.ph-1 { background: linear-gradient(140deg, #123a2c, #2f7a49); }
.ph-2 { background: linear-gradient(140deg, #3a2614, #a3712c); }
.ph-3 { background: linear-gradient(140deg, #2c3a44, #5f7d8c); }
.ph-4 { background: linear-gradient(140deg, #2f3833, #6c7d72); }
.ph-5 { background: linear-gradient(140deg, #2b2822, #b07a1f); }
.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 { color: #3f6476; }
.div-icon.i-building { color: #56665c; }
.div-icon.i-construction { color: #b07a1f; }
.div-name { font-size: 17.5px; font-weight: 600; letter-spacing: -.1px; }
.div-meta { font-size: 14px; color: var(--muted); margin-top: 3px; }
.div-chev { margin-left: auto; color: var(--muted); }
/* the photo already shows the division icon */
.div-card .div-body > .div-icon { display: none; }
.div-chev .ico { width: 18px; height: 18px; }
.dot-active { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; 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-fit, minmax(168px, 1fr)); gap: 14px; }
.kpi { display: flex; gap: 14px; padding: 16px; align-items: flex-start; color: var(--text); }
.kpi:hover { border-color: #b7c4bb; }
.kpi-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex: none; }
.kpi-icon .ico { width: 22px; height: 22px; }
.kpi-label { font-size: 14.5px; color: var(--muted); font-weight: 500; }
.kpi-value { font-family: var(--serif); font-size: 30px; font-weight: 600; line-height: 1.1; margin: 3px 0 2px; letter-spacing: -.4px; font-variant-numeric: lining-nums tabular-nums; }
.kpi-sub { font-size: 14px; 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-family: var(--serif); font-size: 20px; 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: 6px; color: var(--text); border-left: 3px solid transparent; }
.loc-item:hover { background: var(--hover); }
.loc-item.active { background: var(--blue-soft); border-left-color: var(--brass); color: var(--navy); 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-family: var(--serif); font-size: 26px; font-weight: 600; letter-spacing: -.3px; }
.loc-head .addr { margin-top: 4px; color: #33413b; }
.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(--brass); color: var(--navy); font-weight: 600; }
.sub-tabs button:hover { color: var(--navy); }
.loc-body { padding: 14px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.overview-top { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 14px; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px 28px; padding: 18px 20px; align-content: start; }
.info-grid .kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px; align-items: baseline; }
.info-grid .kv.wide { grid-column: 1 / -1; }
.info-grid .k { color: var(--muted); }
.info-grid .v { overflow-wrap: anywhere; }

.loc-photo { border-radius: var(--radius); 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: 14px; 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: 17px; font-weight: 600; color: var(--navy); }
.mini-head .ico { color: var(--brass); }
.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: 15px; }
table.data th { text-align: left; font-weight: 600; font-size: 14.5px; color: #33413b; padding: 8px 12px; background: var(--hover); 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: #f7f9f7; }
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 10px; border-radius: 999px; font-size: 14px; font-weight: 500; background: var(--gray-soft); color: #3b4a43; white-space: nowrap; }
.pill.green { background: var(--green-soft); color: var(--green-text); }
.pill.blue { background: var(--info-soft); color: var(--info); }
.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: 15px; }
.bar-track { height: 14px; background: var(--gray-soft); border-radius: 3px; overflow: hidden; display: flex; }
.bar-fill { height: 100%; background: var(--brass); }
.bar-fill.paid { background: var(--green); }
.legend { display: flex; gap: 14px; font-size: 14px; 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(--brass); vertical-align: -1px; }
.legend span.paid::before { background: var(--green); }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(8,24,54,.45); display: grid; place-items: center; z-index: 80; padding: 16px; }
.modal { background: var(--card); 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-family: var(--serif); font-size: 19px; font-weight: 600; flex: 1; }
.modal-body { padding: 16px 18px; overflow: auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.modal-body > * { min-width: 0; }
.modal-body input, .modal-body select, .modal-body textarea { max-width: 100%; min-width: 0; }
.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: var(--navy); 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: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 20px 50px rgba(11,58,130,.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(--brass); }
.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(--navy); color: #fff; border-bottom-right-radius: 3px; }
.msg.assistant { align-self: flex-start; background: #f1f4f1; 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: 14px; margin: 6px 0; }
.msg.assistant td, .msg.assistant th { border: 1px solid #d3dbd5; 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: 13.5px; padding: 2px 8px; }
.ai-suggest { display: flex; flex-direction: column; gap: 6px; padding: 0 14px 10px; }
.ai-suggest button { text-align: left; background: var(--hover); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 14.5px; color: var(--text); }
.ai-suggest button:hover { border-color: #b7c4bb; }
.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; }
}
/* ---------- Photos ---------- */
.photos-cell { width: 1%; white-space: nowrap; }
.photo-thumb { position: relative; width: 40px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--hover); overflow: visible; display: grid; place-items: center; color: var(--muted); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 5px; display: block; }
.photo-thumb:hover { border-color: var(--blue); }
.photo-count { position: absolute; top: -6px; right: -7px; background: var(--navy); color: #fff; font-size: 10px; font-weight: 600; min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; border: 2px solid #fff; }
.photo-add { display: inline-flex; align-items: center; gap: 5px; border: 1px dashed #b7c4bb; background: none; color: var(--blue); border-radius: 6px; padding: 5px 9px; font-size: 14px; }
.photo-add .ico { width: 15px; height: 15px; }
.photo-add:hover { background: var(--blue-soft); border-color: var(--blue); }

.photo-section { display: grid; gap: 8px; }
.photo-section-title { font-size: 15px; color: var(--muted); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.photo-grid.big { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.gallery-body { display: block; min-height: 180px; }
.photo-tile { position: relative; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--hover); }
.photo-tile.pending { outline: 2px dashed #9cc0f5; outline-offset: -2px; }
.photo-open { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-doc { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; height: 100%; padding: 8px; color: var(--text); font-size: 13px; text-align: center; word-break: break-word; }
.photo-doc .ico { width: 28px; height: 28px; color: var(--red); }
.photo-doc span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.photo-del { position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(20,30,45,.7); color: #fff; display: grid; place-items: center; padding: 0; }
.photo-del .ico { width: 14px; height: 14px; }
.photo-del:hover { background: var(--red); }
.photo-new { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 1.5px dashed #b7c4bb; color: var(--blue); background: var(--card); font-size: 14.5px; }
.photo-new .ico { width: 26px; height: 26px; }
.photo-new:hover { border-color: var(--blue); background: var(--blue-soft); }

.viewer { position: fixed; inset: 0; background: rgba(8,14,26,.92); z-index: 120; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; cursor: zoom-out; }
.viewer img { max-width: 100%; max-height: calc(100vh - 90px); object-fit: contain; border-radius: 4px; }
.viewer-bar { display: flex; gap: 16px; align-items: center; color: #e3ebe6; margin-top: 12px; font-size: 15px; flex-wrap: wrap; justify-content: center; }
.viewer-bar a { color: #9cc0f5; }
.viewer-bar button { background: var(--card); border: 0; border-radius: 6px; padding: 6px 14px; }

/* ---------- Documents & folders ---------- */
.ico.inline { display: inline-block; width: 15px; height: 15px; vertical-align: -3px; }
.docs-card { position: relative; }
.docs-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.docs-head .spacer { flex: 1; }
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 16px; min-width: 0; }
.crumbs a { display: inline-flex; align-items: center; gap: 6px; }
.crumbs a .ico { width: 18px; height: 18px; color: var(--brass); }
.crumbs .sep { color: var(--muted); }
.crumbs strong { font-weight: 600; }
.doc-list { display: grid; }
.doc-row { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 6px; border-bottom: 1px solid var(--line-2); }
.doc-row:hover { background: #f7f9f7; }
.doc-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; padding: 8px; color: var(--text); border-radius: 6px; }
a.doc-main:hover .doc-name { color: var(--blue); text-decoration: underline; }
.doc-icon { width: 38px; height: 38px; border-radius: 6px; display: grid; place-items: center; flex: none; background: #f1f4f1; color: var(--red); overflow: hidden; }
.doc-icon .ico { width: 22px; height: 22px; }
.doc-icon.is-folder { background: var(--brass-soft); color: var(--brass); }
.doc-icon.is-folder .ico { fill: #e8c172; stroke: #a8761f; }
.doc-icon.thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-text { display: flex; flex-direction: column; min-width: 0; }
.doc-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { font-size: 14px; color: var(--muted); }
.doc-acts { display: flex; gap: 2px; flex: none; }
.doc-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 34px 16px; color: var(--muted); }
.doc-empty > .ico { width: 44px; height: 44px; color: var(--brass); }
.doc-empty strong { color: var(--text); font-size: 17px; }
.doc-empty.small { padding: 22px 16px; flex-direction: row; justify-content: center; }
.doc-empty.small > .ico { width: 22px; height: 22px; }
.doc-empty-acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 4px 0; }
.docs-status { padding: 8px 14px; min-height: 8px; }
.drop-hint { display: none; position: absolute; inset: 0; background: rgba(232,240,254,.94); border: 2px dashed var(--blue); border-radius: var(--radius); color: var(--blue); font-weight: 600; flex-direction: column; align-items: center; justify-content: center; gap: 8px; pointer-events: none; z-index: 5; }
.drop-hint .ico { width: 34px; height: 34px; }
.docs-card.dragging .drop-hint { display: flex; }
.tab-files.dragging { outline: 2px dashed var(--blue); outline-offset: 2px; }
.small-modal { max-width: 460px; }
.modal-body.one-col { grid-template-columns: 1fr; }

/* ---------- Record summary view ---------- */
.cell-link { background: none; border: 0; padding: 0; color: var(--blue); font: inherit; font-weight: inherit; text-align: left; cursor: pointer; }
.cell-link:hover { text-decoration: underline; }
.view-modal { max-width: 760px; }
.view-body { display: block; }
.vgroup { margin-bottom: 18px; }
.vgroup h4, .form-section { margin: 0 0 8px; font-size: 16px; color: var(--navy); font-weight: 600; border-bottom: 1px solid var(--line-2); padding-bottom: 6px; }
.form-section { margin-top: 6px; }
.vrow { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 12px; padding: 5px 0; }
.vrow .k { color: var(--muted); }
.vrow .v { overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; }
.modal-foot .spacer { flex: 1; }

/* ---------- Logins (Owner only) ---------- */
.vault-note { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 15px; }
.vault-note .ico { width: 16px; height: 16px; color: var(--green); }
.vault-row { display: grid; grid-template-columns: minmax(170px, 1.2fr) minmax(150px, 1fr) minmax(190px, 1fr) minmax(190px, 1fr) auto; gap: 14px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
.vault-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.vault-cred { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 6px; row-gap: 2px; min-width: 0; }
.vault-cred .k { grid-column: 1 / -1; font-size: 13.5px; color: var(--muted); }
.vault-cred .v { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px; overflow-wrap: anywhere; }
.vault-cred > span:last-child { display: inline-flex; }
.vault-lock { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 34px 18px; max-width: 420px; margin: 0 auto; width: 100%; }
.vault-lock > .ico { width: 40px; height: 40px; color: var(--navy); }
.vault-lock input { max-width: 280px; }
.role-help { display: grid; gap: 4px; }
.note-row { grid-template-columns: minmax(170px, 1fr) auto auto; }
.note-text { white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14.5px; background: var(--hover); border: 1px solid var(--line); border-radius: 6px; padding: 12px; margin: 0; max-height: 60vh; overflow: auto; }
textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14.5px; }
.import-choices { gap: 10px; }
.choice { text-align: left; display: grid; gap: 4px; border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 12px 14px; color: var(--text); }
.choice span { color: var(--muted); font-size: 14.5px; }
.choice:hover { border-color: var(--blue); background: var(--blue-soft); }
.secret-btns { display: inline-flex; gap: 4px; }
.mini-btn { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--card); border-radius: 5px; padding: 3px 8px; font-size: 14px; color: var(--text); }
.mini-btn:hover { border-color: var(--blue); color: var(--blue); }
.mini-btn .ico { width: 14px; height: 14px; }

.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: 17px; }
  .logo { width: 34px; height: 34px; font-size: 16px; }
  .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: 14px; }
  .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: 16px; }

  /* 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: 14px; }
  .kpi-value { font-size: 23px; }
  .kpi-sub { font-size: 13px; }

  /* 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: 17px; }
  .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: 21px; }
  .loc-body { padding: 10px; gap: 10px; }
  .sub-tabs { padding: 0 4px; }
  .sub-tabs button { padding: 10px 10px; }
  .info-grid { grid-template-columns: 1fr; padding: 14px; gap: 10px; }
  .info-grid .kv { grid-template-columns: 118px minmax(0, 1fr); }
  .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: 15px; 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: 16px; 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.photos-cell { width: auto; margin-top: 4px; }
  .docs-head .btn { flex: 1 1 auto; justify-content: center; }
  .vrow { grid-template-columns: 1fr; gap: 2px; padding: 6px 0; }
  .vault-row { grid-template-columns: 1fr auto; }
  .vault-main { grid-column: 1; }
  .vault-row .doc-acts { grid-column: 2; grid-row: 1; }
  .vault-cred { grid-column: 1 / -1; }
  .crumbs { flex-basis: 100%; }
  .doc-row { padding-right: 6px; }
  .photo-grid.big { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  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: 20px; }
  .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 { flex: 1; }
  .modal-body { grid-template-columns: minmax(0, 1fr); }
  .modal { width: 100%; max-width: 100vw; overflow-x: hidden; }
  .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; }
}

/* ================= Ocean theme (chosen look) ================= */
:root {
  --navy: #0b3a82; --brass: #f59e0b; --blue: #1d6ff2; --blue-soft: #e8f0fe; --blue-hover: #1559c9;
  --bg: #f1f5fb; --line: #dfe7f2; --line-2: #ebf0f7; --text: #0e1b33; --muted: #5a6b85; --gray-soft: #edf2f8; --hover: #f4f7fc;
  --input-line: #cdd8e6;
  --radius: 12px; --shadow: 0 2px 6px rgba(11,58,130,.06);
  --serif: 'Amp', 'Archivo Narrow', 'Archivo', system-ui, sans-serif;
  font-family: 'Amp', 'Archivo', 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}
.topbar { background: linear-gradient(90deg, var(--top-a), var(--top-b)); }
.logo { background: var(--card); color: #0b3a82; border-radius: 12px; font-family: inherit; font-weight: 700; box-shadow: none; }
.login-card .logo { background: linear-gradient(135deg, var(--top-a), var(--top-b)); color: #fff; }
.login { background: linear-gradient(150deg, var(--top-a), var(--top-b)); }
.brand-sub { opacity: .7; }
.ai-btn { background: #f59e0b; color: #111; border: 0; font-weight: 600; padding: 7px 14px; }
.ai-btn:hover { background: #fbb33a; color: #111; }
.avatar { background: #f59e0b; color: #111; box-shadow: none; }
.div-card .div-body > .div-icon { display: none; } /* the card photo already shows the icon */
.kpi-value { font-size: 27px; font-weight: 700; letter-spacing: -.3px; white-space: nowrap; }
.kpi { gap: 12px; padding: 16px 14px; }
.kpi-icon { width: 34px; height: 34px; }
.sidebar a.active { border-left-color: #1d6ff2; color: #0b3a82; }
.sidebar a.active .ico { color: #1d6ff2; }
.loc-item.active { border-left-color: #1d6ff2; color: #0b3a82; }
.mini-head .ico { color: #1d6ff2; }
.bar-fill, .legend span::before { background: #1d6ff2; }
.ph-0 { background: linear-gradient(140deg, #b91c1c, #f97316); }
.ph-1 { background: linear-gradient(140deg, #166534, #22c55e); }
.ph-2 { background: linear-gradient(140deg, #92400e, #f59e0b); }
.ph-3 { background: linear-gradient(140deg, #0b3a82, #38bdf8); }
.ph-4 { background: linear-gradient(140deg, #1e3a8a, #6366f1); }
.ph-5 { background: linear-gradient(140deg, #c2410c, #fbbf24); }
.doc-icon.is-folder { background: #fff4dc; color: #d48806; }
.doc-icon.is-folder .ico { fill: #fcd34d; stroke: #d48806; }
@media (max-width: 860px) {
  .kpi-value { font-size: 22px; }
  .kpi { padding: 10px; gap: 10px; }
  .kpi-icon { width: 30px; height: 30px; }
}

/* tab / store switch: keep the old content while the new one loads */
.loc-body.is-loading, .loc-detail.is-loading { opacity: .55; transition: opacity .12s; pointer-events: none; }
/* laptop screens: 3 number tiles per row so labels don't wrap */
@media (min-width: 861px) and (max-width: 1650px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .sub-tabs button { padding: 11px 10px; }
}

/* Hub logo */
.logo .logo-mark { width: 72%; height: 72%; display: block; }
.login-card .logo { background: var(--card); box-shadow: 0 0 0 1px var(--line), 0 2px 6px rgba(11,58,130,.08); }

/* Pop-up forms: the form scrolls inside itself, the page behind stays still,
   and the Save button is always visible at the bottom */
.modal { min-height: 0; }
.modal-head, .modal-foot { flex: none; }
.modal-body { min-height: 0; flex: 1 1 auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
html:has(#modalRoot .modal-back), body:has(#modalRoot .modal-back) { overflow: hidden; }
@media (max-width: 860px) {
  .modal-back { height: 100vh; height: 100dvh; overflow: hidden; }
  .modal { height: 100%; max-height: 100%; }
  .modal-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); background: var(--card); }
}

/* Ask AI is hidden for now (the assistant is set up and can be turned back on) */
.ai-btn { display: none !important; }

/* Phone: a small search box always visible in the header */
@media (max-width: 860px) {
  .search-wrap { display: block; position: relative; top: auto; left: auto; right: auto; flex: 1 1 auto; min-width: 0; max-width: none; padding: 0; margin: 0 4px; background: none; }
  .search-wrap input { height: 36px; padding-left: 32px; border-radius: 9px; }
  .search-wrap .search-icon { left: 9px; top: 9px; }
  .search-wrap .search-icon .ico { width: 17px; height: 17px; }
  #searchResults { position: fixed; top: 58px; left: 8px; right: 8px; }
  .top-actions [data-act=toggleSearch] { display: none; }
  .brand > div:last-child { display: none; }
}

/* Recycle bin on phones: buttons sit in a row under each item */
@media (max-width: 860px) {
  table.responsive.recycle td.actions { position: static; flex-direction: row; justify-content: flex-start; gap: 8px; margin-top: 8px; }
  table.responsive.recycle td.actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* Phone header: logo drawn in white straight on the blue (no white tile) */
@media (max-width: 860px) {
  .topbar .logo { background: none; box-shadow: none; width: 34px; height: 34px; }
  .topbar .logo .logo-mark { width: 100%; height: 100%; }
  .topbar .logo-mark g { stroke: #fff; }
  .topbar .logo-mark circle { fill: #fff; }
  .topbar .logo-mark circle:last-child { fill: #f59e0b; stroke: none; }
}

/* Private notes from spreadsheets: shown like a sheet (scroll sideways for wide tabs) */
.note-modal { max-width: 1100px; }
.note-table-wrap { overflow: auto; max-height: 65vh; border: 1px solid var(--line); border-radius: 8px; }
.note-table { border-collapse: collapse; font-size: 14px; min-width: 100%; }
.note-table td { border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line-2); padding: 7px 10px; white-space: nowrap; vertical-align: top; }
.note-table tr:nth-child(even) td { background: #f8fafd; }
.note-table tr:first-child td { background: var(--blue-soft); font-weight: 600; color: var(--navy); }
.note-table tr.note-title td { background: #eef2f8; font-weight: 600; }
@media (max-width: 860px) { .note-table-wrap { max-height: none; } .note-table { font-size: 13px; } }

/* Sortable columns */
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--blue); }
table.data th.sortable::after { content: '↕'; margin-left: 5px; font-size: 11px; opacity: .35; }
table.data th.sorted[data-dir=asc]::after { content: '▲'; opacity: .9; color: var(--blue); font-size: 10px; }
table.data th.sorted[data-dir=desc]::after { content: '▼'; opacity: .9; color: var(--blue); font-size: 10px; }
.sort-bar { display: none; }
@media (max-width: 860px) {
  .sort-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line-2); font-size: 14px; color: var(--muted); }
  .sort-bar select { flex: 1; min-width: 0; padding: 6px 8px; }
}

/* Files box on section tabs + wide insurance card on the main screen */
.tab-files { margin-top: 0; }
.tab-files .mini-head { flex-wrap: wrap; gap: 8px; }
.tab-files .mini-head > .muted { margin-left: 2px; }
.mini-grid .mini-wide { grid-column: 1 / -1; }

/* Edit fields on the store's main screen with the pencil */
.kv.editable { position: relative; border-radius: 6px; margin: -3px -6px; padding: 3px 34px 3px 6px; }
.kv-pen, .name-pen { border: 0; background: none; color: var(--blue); cursor: pointer; border-radius: 6px; display: inline-grid; place-items: center; padding: 4px; opacity: .45; }
.kv-pen { position: absolute; right: 2px; top: 1px; }
.kv-pen .ico, .name-pen .ico { width: 15px; height: 15px; }
.kv.editable:hover .kv-pen, .kv-pen:focus-visible, .loc-head h2:hover .name-pen { opacity: 1; }
.kv-pen:hover, .name-pen:hover { background: var(--blue-soft); }
.name-pen { margin-left: 6px; vertical-align: middle; }
.kv.editing { background: var(--blue-soft); }
.kv.editing .kv-pen { display: none; }
.inline-form { display: grid; gap: 8px; }
.inline-form label { display: grid; gap: 3px; font-size: 13px; color: var(--muted); }
.inline-form input, .inline-form select, .inline-form textarea { padding: 6px 8px; }
.inline-acts { display: flex; gap: 6px; }
.btn.sm { padding: 5px 12px; font-size: 14px; }
.name-form { display: flex; gap: 6px; align-items: center; }
.name-form input { font-size: 18px; font-weight: 600; min-width: 0; width: min(420px, 60vw); }
@media (hover: none) { .kv-pen, .name-pen { opacity: .7; } }


/* Alarm password modal */
.alarm-modal { max-width: 560px; }
.alarm-intro { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; padding: 14px; border: 1px solid var(--line); background: linear-gradient(180deg, #f8fbff, #f3f7fd); border-radius: 12px; }
.alarm-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; }
.alarm-icon .ico { width: 22px; height: 22px; }
.alarm-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.alarm-status { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.alarm-status.saved { background: #e8f7ee; color: #18794e; }
.alarm-status.empty { background: #f3f4f6; color: #6b7280; }
.alarm-secret-card, .alarm-replace-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--card); }
.alarm-secret-head { display: flex; justify-content: space-between; gap: 10px; align-items: start; margin-bottom: 10px; }
.alarm-card-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.tiny { font-size: 12px; }
.alarm-secret-value { min-height: 52px; border: 1px solid var(--line); border-radius: 10px; background: #f8fafc; padding: 14px 16px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 19px; display: flex; align-items: center; letter-spacing: .2px; overflow-wrap: anywhere; }
.alarm-field { display: grid; gap: 6px; }
.alarm-field > span { font-size: 13px; color: var(--muted); font-weight: 600; }
.alarm-replace-card input { width: 100%; }
@media (max-width: 520px) {
  .alarm-secret-head { flex-direction: column; }
  .alarm-secret-head .secret-btns { width: 100%; }
  .alarm-secret-head .mini-btn { flex: 1 1 0; justify-content: center; }
  .alarm-secret-value { font-size: 17px; }
}

/* Inline alarm password controls alongside the label/value */
.info-grid .kv.alarm-overview-row { align-items: center; }
.alarm-inline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.alarm-inline-secret { display: inline-block; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; min-width: 64px; overflow-wrap: anywhere; }
.alarm-inline .mini-btn { white-space: nowrap; padding: 4px 7px; }
.alarm-inline .mini-btn:disabled { opacity: .5; cursor: wait; }

/* Store list: closed stores at the bottom, drag to reorder */
.loc-item { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.loc-item > span:first-child { flex: 1; min-width: 0; }
.loc-item.is-closed { color: var(--muted); }
.closed-tag { flex: none; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--red-soft); color: var(--red); }
.loc-item[draggable=true] { cursor: grab; }
.loc-item[draggable=true]:active { cursor: grabbing; }
.dragging-item { opacity: .45; outline: 2px dashed var(--blue); outline-offset: -2px; }
.div-card[draggable=true] { cursor: grab; }
.div-card:focus-visible, .loc-item:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ================= Spreadsheet import ================= */
.import-page { display: grid; gap: 14px; }
.imp-card { padding: 16px 18px; }
.imp-step { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.imp-step h3 { margin: 0; font-size: 18px; }
.imp-num { width: 28px; height: 28px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.imp-drop { border: 2px dashed var(--input-line); border-radius: 12px; padding: 28px 16px; display: grid; justify-items: center; gap: 10px; text-align: center; color: var(--muted); transition: background .12s, border-color .12s; }
.imp-drop > .ico { width: 34px; height: 34px; color: var(--blue); }
.imp-drop.dragging { border-color: var(--blue); background: var(--blue-soft); }
.imp-drop.busy { opacity: .6; pointer-events: none; }
.imp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px 16px; align-items: start; }
.imp-grid > label { display: grid; gap: 4px; }
.imp-grid > label > span, .imp-defaults > span { font-size: 14px; color: var(--muted); font-weight: 600; }
.imp-grid small { line-height: 1.35; }
.imp-check { display: flex !important; align-items: center; gap: 8px; grid-column: 1 / -1; font-size: 15px; }
.imp-check input { width: auto; }
.imp-defaults { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px 16px; padding: 12px; background: var(--hover); border-radius: 10px; }
.imp-defaults > span { grid-column: 1 / -1; }
.imp-defaults label { display: grid; gap: 4px; font-size: 14px; }
.imp-file { display: flex; align-items: center; gap: 6px; padding: 8px 0; overflow-wrap: anywhere; }
.imp-help { margin: 0 0 12px; }
.imp-cols { display: grid; gap: 6px; }
.imp-col { display: grid; grid-template-columns: minmax(0, 1.1fr) 22px minmax(0, 1.4fr); gap: 10px; align-items: center; padding: 9px 10px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--card); }
.imp-col.on { border-color: #c9dafa; background: #f7faff; }
.imp-col.locked { background: #fff7f5; border-color: var(--red-soft); }
.imp-col-src { min-width: 0; }
.imp-col-src .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imp-arrow { color: var(--muted); }
.imp-col-dst { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.imp-col-dst select { flex: 1 1 160px; min-width: 0; }
.imp-lock { color: var(--red); font-size: 14px; display: flex; gap: 6px; align-items: center; }
.imp-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.imp-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.imp-chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 12px; font-size: 14px; color: var(--text); cursor: pointer; }
.imp-chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.imp-selbar { font-size: 14px; margin-bottom: 8px; color: var(--muted); }
.imp-rows { display: grid; gap: 6px; }
.imp-row { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 6px; padding: 10px; border: 1px solid var(--line-2); border-radius: 10px; }
.imp-row.st-new { border-left: 4px solid var(--green); }
.imp-row.st-update { border-left: 4px solid var(--blue); }
.imp-row.st-error, .imp-row.st-skip { border-left: 4px solid var(--red); background: #fffafa; }
.imp-row.st-same { opacity: .75; }
.imp-row-check input { width: 18px; height: 18px; margin-top: 2px; }
.imp-row-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.imp-changes { margin: 6px 0 0; padding-left: 18px; font-size: 14px; display: grid; gap: 2px; }
.imp-changes .k { color: var(--muted); }
.imp-changes .from { color: var(--muted); text-decoration: line-through; overflow-wrap: anywhere; }
.imp-changes .to { font-weight: 600; overflow-wrap: anywhere; }
.imp-changes .tag, .imp-detail .tag { font-size: 12px; padding: 0 6px; border-radius: 6px; background: var(--blue-soft); color: var(--blue); }
.imp-kept { margin-top: 6px; font-size: 14px; }
.imp-kept summary { cursor: pointer; color: var(--muted); }
.imp-kept ul { margin: 4px 0; padding-left: 18px; }
.imp-warn { margin: 6px 0 0; padding: 0; list-style: none; font-size: 14px; color: var(--orange); display: grid; gap: 2px; }
.imp-warn .ico { width: 14px; height: 14px; vertical-align: -2px; }
.imp-err { color: var(--red); font-size: 14px; margin-top: 4px; }
.imp-note { margin: 8px 0; padding: 8px 10px; border-radius: 8px; background: var(--orange-soft); color: var(--orange); font-size: 14px; white-space: pre-line; }
.imp-apply { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 12px -18px -16px; padding: 12px 18px; background: var(--card); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }
.imp-apply .ico { width: 15px; height: 15px; vertical-align: -3px; color: var(--green); }
.imp-done { text-align: center; padding: 30px 18px; }
.imp-done > .ico { width: 42px; height: 42px; color: var(--green); }
.imp-done .imp-actions { justify-content: center; }
.imp-detail { padding-left: 18px; }
@media (max-width: 860px) {
  .imp-col { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .imp-arrow { display: none; }
  .imp-apply { margin: 12px -12px -12px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .imp-apply .btn { width: 100%; justify-content: center; }
  .imp-card { padding: 14px 12px; }
}
.imp-grid select.needs { border-color: var(--orange); background: var(--orange-soft); }
.imp-done > .ico { display: block; margin: 0 auto 6px; }

/* ----- Import: friendlier layout ----- */
.imp-head h2 { margin-bottom: 2px; }
.imp-stepper { list-style: none; display: flex; gap: 6px; margin: 0 0 14px; padding: 0; flex-wrap: wrap; }
.imp-stepper li { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.imp-stepper li span { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--gray-soft); font-weight: 700; font-size: 13px; }
.imp-stepper li span .ico { width: 14px; height: 14px; }
.imp-stepper li.now { border-color: var(--blue); color: var(--navy); font-weight: 600; }
.imp-stepper li.now span { background: var(--blue); color: #fff; }
.imp-stepper li.done span { background: var(--green-soft); color: var(--green-text); }
.imp-start { padding: 22px; }
.imp-drop { padding: 40px 16px; }
.imp-drop-title { font-size: 19px; font-weight: 600; color: var(--text); }
.imp-promise { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.imp-promise li { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: var(--muted); }
.imp-promise .ico { width: 18px; height: 18px; color: var(--green); flex: none; margin-top: 1px; }
.imp-filebar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; flex-wrap: wrap; }
.imp-filebar > .ico { color: var(--blue); width: 22px; height: 22px; }
.imp-filebar-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.imp-inline-select { width: auto !important; max-width: 280px; padding: 4px 8px; }
.imp-q { padding: 4px 0 16px; border-bottom: 1px solid var(--line-2); margin-bottom: 14px; }
.imp-q:last-of-type { border-bottom: 0; }
.imp-q-title { font-size: 17px; font-weight: 600; margin-bottom: 10px; }
.imp-choices { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.imp-choice { display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 14px 8px 8px; font-size: 15px; color: var(--text); cursor: pointer; }
.imp-choice .div-icon { width: 30px; height: 30px; display: grid; place-items: center; }
.imp-choice .div-icon .ico { width: 20px; height: 20px; }
.imp-choice:hover { border-color: var(--blue); }
.imp-choice.on { border-color: var(--blue); background: var(--blue-soft); font-weight: 600; box-shadow: 0 0 0 2px rgba(29,111,242,.15); }
.imp-radio { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; margin-bottom: 8px; cursor: pointer; max-width: 640px; }
.imp-radio input { width: auto; margin-top: 4px; }
.imp-radio.on { border-color: var(--blue); background: var(--blue-soft); }
.imp-radio .pill { font-size: 12px; padding: 0 8px; }
.imp-more, .imp-skipped { margin-top: 4px; }
.imp-more > summary, .imp-skipped > summary { cursor: pointer; color: var(--blue); font-weight: 500; padding: 6px 0; }
.imp-more .imp-grid { margin-top: 8px; }
.imp-skipped .imp-cols { margin-top: 8px; }
.imp-next { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.imp-next .btn { padding: 10px 22px; font-size: 16px; }
.imp-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.imp-stat { border: 1.5px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px; text-align: left; cursor: pointer; display: grid; gap: 2px; color: var(--muted); font-size: 14px; }
.imp-stat b { font-size: 26px; color: var(--text); line-height: 1.1; }
.imp-stat.blue b { color: var(--blue); } .imp-stat.green b { color: var(--green-text); } .imp-stat.red b { color: var(--red); }
.imp-stat.active { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(29,111,242,.15); }
.imp-listbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 10px; }
.imp-filters { display: flex; gap: 14px; flex-wrap: wrap; }
.imp-filters .link-btn.active { font-weight: 700; text-decoration: underline; text-underline-offset: 4px; }
.imp-row-head strong { font-size: 16px; }
.imp-rown { margin-left: auto; }
.imp-apply { justify-content: flex-start; }
.imp-apply-note { flex: 1; }
.imp-apply .btn.primary { padding: 10px 22px; font-size: 16px; }
.imp-done { padding: 36px 18px; }
.imp-done-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--green-soft); color: var(--green-text); display: grid; place-items: center; margin: 0 auto 10px; }
.imp-done-icon .ico { width: 34px; height: 34px; }
.imp-done h3 { font-size: 22px; margin: 0 0 6px; }
.imp-done-sum { font-size: 17px; margin: 0 0 4px; }
@media (max-width: 860px) {
  .imp-stepper li { padding: 4px 10px 4px 4px; font-size: 13px; }
  .imp-stepper li:not(.now) { font-size: 0; gap: 0; padding: 4px; }
  .imp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .imp-next .btn, .imp-apply .btn { width: 100%; justify-content: center; }
  .imp-apply-note { order: -1; flex-basis: 100%; }
  .imp-choice { flex: 1 1 45%; }
  .imp-inline-select { max-width: 100%; }
}
#impHeader { flex: 1 1 100%; width: 100% !important; max-width: 100%; min-width: 0; }
.imp-filebar, .imp-filebar-main, .import-page, .imp-card { min-width: 0; max-width: 100%; }

@media (max-width: 860px) {
  .imp-backlist { display: none; }
  .imp-head { flex-wrap: wrap; }
  .imp-filebar { align-items: flex-start; }
  .imp-filebar > .ico { display: none; }
  .imp-filebar-main { flex-basis: 100%; }
  .imp-another { width: 100%; justify-content: center; }
  .imp-apply { flex-wrap: nowrap; gap: 8px; }
  .imp-apply-note { display: none; }
  .imp-apply .btn { width: auto; }
  .imp-apply .btn:not(.primary) { flex: 0 0 auto; padding: 10px 12px; }
  .imp-apply .btn.primary { flex: 1; justify-content: center; }
}
.imp-defaults input, .imp-defaults select, .imp-grid select, .imp-grid input:not([type=checkbox]) { width: 100%; max-width: 420px; padding: 8px 10px; border: 1px solid var(--input-line); border-radius: 7px; background: var(--card); font: inherit; color: var(--text); }

/* ================= Personal settings: color, dark mode, text size, spacing ================= */
:root { --top-a: #0a2e6b; --top-b: #1456c4; --blue-soft: color-mix(in srgb, var(--blue) 11%, #fff); }
html[data-accent=green]    { --blue: #059669; --blue-hover: #047857; --top-a: #053d30; --top-b: #0b8a62; --navy: #064e3b; }
html[data-accent=purple]   { --blue: #7c3aed; --blue-hover: #6d28d9; --top-a: #2e1065; --top-b: #6d28d9; --navy: #3b0f8c; }
html[data-accent=teal]     { --blue: #0d9488; --blue-hover: #0f766e; --top-a: #0f3d3b; --top-b: #0f8a83; --navy: #134e4a; }
html[data-accent=orange]   { --blue: #ea580c; --blue-hover: #c2410c; --top-a: #6b1d0c; --top-b: #c2410c; --navy: #7c2d12; }
html[data-accent=graphite] { --blue: #475569; --blue-hover: #334155; --top-a: #0f172a; --top-b: #334155; --navy: #1e293b; }
html[data-accent] { --blue-soft: color-mix(in srgb, var(--blue) 11%, var(--card)); }

html[data-theme=dark] {
  color-scheme: dark;
  --bg: #0e1522; --card: #162133; --line: #26344b; --line-2: #1f2c41; --text: #e5ebf4; --muted: #95a3ba;
  --gray-soft: #1d2a3e; --hover: #1b273b; --input-line: #34445e;
  --green-soft: #133626; --green-text: #4ade80; --orange-soft: #3a2a10; --orange: #fbbf24; --red-soft: #3f1c1c; --red: #f87171;
  --info-soft: #1b2c4a; --info: #93c5fd; --brass-soft: #3a2e14;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  --blue-soft: color-mix(in srgb, var(--blue) 24%, var(--card));
}
html[data-theme=dark] body { background: var(--bg); color: var(--text); }
html[data-theme=dark] input, html[data-theme=dark] select, html[data-theme=dark] textarea { background: var(--card); color: var(--text); border-color: var(--input-line); }
html[data-theme=dark] .navy, html[data-theme=dark] .loc-item.active, html[data-theme=dark] .sidebar a.active,
html[data-theme=dark] .sub-tabs button.active, html[data-theme=dark] .tabs-nav a.active, html[data-theme=dark] .mini-head h4,
html[data-theme=dark] .vgroup h4, html[data-theme=dark] .form-section, html[data-theme=dark] .imp-stepper li.now { color: #fff; }
html[data-theme=dark] .sidebar a.active .ico, html[data-theme=dark] .mini-head .ico { color: color-mix(in srgb, var(--blue) 60%, #fff); }
html[data-theme=dark] a, html[data-theme=dark] .link-btn, html[data-theme=dark] .cell-link { color: color-mix(in srgb, var(--blue) 55%, #fff); }
html[data-theme=dark] .btn { background: var(--gray-soft); color: var(--text); border-color: var(--input-line); }
html[data-theme=dark] .btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
html[data-theme=dark] .btn.danger { color: var(--red); }
html[data-theme=dark] table.data th { background: var(--gray-soft); color: var(--muted); }
html[data-theme=dark] table.data tr:hover td { background: var(--hover); }
html[data-theme=dark] .note-table tr:nth-child(even) td, html[data-theme=dark] .imp-col.on, html[data-theme=dark] .imp-row.st-error,
html[data-theme=dark] .imp-col.locked, html[data-theme=dark] .imp-row.st-skip { background: var(--hover); }
html[data-theme=dark] .imp-col.on { border-color: var(--line); }
html[data-theme=dark] .pill { filter: saturate(1.1); }
html[data-theme=dark] .modal-back { background: rgba(0, 0, 0, .6); }
html[data-theme=dark] .topbar .logo, html[data-theme=dark] .login-card .logo { background: #fff; }
html[data-theme=dark] .login-card { background: var(--card); }
html[data-theme=dark] .kv.editing, html[data-theme=dark] .kv.editable:hover { background: var(--hover); }
html[data-theme=dark] .toast { background: #e5ebf4; color: #0e1522; }
html[data-theme=dark] .search-wrap input { background: #1d2a3e; color: #e5ebf4; border-color: #34445e; }
html[data-theme=dark] .doc-icon.is-folder { background: #3a2e14; }

/* text size: the whole app scales a little */
html[data-size=small] body { zoom: .92; }
html[data-size=large] body { zoom: 1.1; }

/* compact spacing */
html[data-density=compact] table.data th, html[data-density=compact] table.data td { padding-top: 6px; padding-bottom: 6px; }
html[data-density=compact] .sidebar a { padding-top: 6px; padding-bottom: 6px; }
html[data-density=compact] .loc-item { padding-top: 6px; padding-bottom: 6px; }
html[data-density=compact] .kpi { padding: 10px 12px; }
html[data-density=compact] .card-pad, html[data-density=compact] .loc-body { padding: 10px; }
html[data-density=compact] .info-grid .kv { padding-top: 1px; padding-bottom: 1px; }

/* Settings page */
.settings { display: grid; gap: 14px; max-width: 860px; }
.set-card { padding: 18px 20px; display: grid; gap: 14px; }
.set-card h3 { margin: 0; font-size: 18px; }
.set-card > p { margin: -8px 0 0; }
.set-card label { display: grid; gap: 4px; max-width: 420px; }
.set-row { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 6px 16px; align-items: center; }
.set-row > .muted { grid-column: 2; }
.set-label { font-weight: 600; }
.set-row select { max-width: 340px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--gray-soft); border-radius: 10px; justify-self: start; }
.seg-btn { border: 0; background: transparent; color: var(--text); padding: 7px 14px; border-radius: 7px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 15px; }
.seg-btn .ico { width: 16px; height: 16px; }
.seg-btn.on { background: var(--card); color: var(--blue); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { display: inline-flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); background: var(--card); color: var(--text); padding: 6px 12px 6px 6px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 14px; }
.swatch span { width: 22px; height: 22px; border-radius: 50%; }
.swatch.on { border-color: var(--text); font-weight: 600; }
.sw-blue span { background: linear-gradient(135deg, #0a2e6b, #1d6ff2); }
.sw-green span { background: linear-gradient(135deg, #053d30, #059669); }
.sw-purple span { background: linear-gradient(135deg, #2e1065, #7c3aed); }
.sw-teal span { background: linear-gradient(135deg, #0f3d3b, #0d9488); }
.sw-orange span { background: linear-gradient(135deg, #6b1d0c, #ea580c); }
.sw-graphite span { background: linear-gradient(135deg, #0f172a, #475569); }
.set-actions { border-top: 1px solid var(--line-2); padding-top: 10px; }
@media (max-width: 860px) {
  .set-row { grid-template-columns: minmax(0, 1fr); }
  .set-row > .muted { grid-column: 1; }
  .set-card { padding: 14px; }
}
/* dark mode: fix text that was set to a fixed dark color */
html[data-theme=dark] .loc-head .addr, html[data-theme=dark] table.data th, html[data-theme=dark] .pill:not([class*=" "]) { color: var(--muted); }
html[data-theme=dark] .sidebar .ico { color: var(--muted); }
html[data-theme=dark] .sidebar a, html[data-theme=dark] .tabs-nav a, html[data-theme=dark] .kpi, html[data-theme=dark] a.kpi,
html[data-theme=dark] .loc-item, html[data-theme=dark] .div-card { color: var(--text); }
html[data-theme=dark] .kpi-value { color: var(--text); }
html[data-theme=dark] .div-card:hover, html[data-theme=dark] .kpi:hover { border-color: var(--input-line); }
html[data-theme=dark] .div-icon.i-hotel, html[data-theme=dark] .div-icon.i-building { color: var(--muted); }
html[data-theme=dark] .btn.danger { border-color: #5b2626; }
@media (max-width: 860px) {
  html[data-theme=dark] .topbar .logo { background: none; }
}

/* store photo: drop a picture on it */
.loc-photo { position: relative; }
.photo-drop-hint { position: absolute; inset: 8px; border: 2px dashed rgba(255,255,255,.9); border-radius: 10px; background: rgba(0,0,0,.45); color: #fff; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font-weight: 600; font-size: 16px; pointer-events: none; z-index: 2; }
.photo-drop-hint .ico { width: 30px; height: 30px; }
.loc-photo.dragging .photo-drop-hint { display: flex; }
/* number tiles: 7 tiles fit as 4 + 3 on laptops */
@media (min-width: 861px) and (max-width: 1650px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1651px) { .kpis { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
.kpi-label, .kpi-sub { overflow-wrap: anywhere; }

.ua-login { display: grid; gap: 3px; min-width: 230px; }
.ua-site, .ua-user { overflow-wrap: break-word; word-break: normal; }
.ua-user { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.ua-user .row-act { padding: 2px; }
.ua-pass { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.ua-pass .pw { font-family: ui-monospace, monospace; letter-spacing: .5px; overflow-wrap: break-word; }
@media (max-width: 860px) { .ua-login { min-width: 0; } }
.ua-pass .mini-btn { padding: 2px 8px; }

.pw-row { display: flex; gap: 6px; align-items: center; }
.pw-row input { flex: 1; min-width: 0; }
.ua-login .link-btn { justify-self: start; display: inline-flex; align-items: center; gap: 4px; }
.ua-login .link-btn .ico { width: 14px; height: 14px; }

/* Utilities: Online login (Owner only) */
.ua-reveal { white-space: nowrap; }
.ua-reveal.has-login { border-color: var(--blue); color: var(--blue); }
.ul-view { display: grid; gap: 8px; }
.ul-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 8px; }
.ul-row .k { color: var(--muted); font-size: 14px; }
.ul-row .v { overflow-wrap: anywhere; }
.ul-row .pw { font-family: ui-monospace, monospace; }
.ul-note { margin: 0; }

/* HR / Labor: Send button and page */
.send-btn { flex: none; padding: 6px 12px; gap: 6px; font-size: .9em; }
.send-btn svg { width: 16px; height: 16px; }
.hr-intro { margin: 0 0 10px; }
.hr-upload-row, .hr-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.hr-upload-row label { display: flex; flex-direction: column; gap: 4px; min-width: min(320px, 100%); flex: 1 1 260px; }
.hr-filters input[type=search] { flex: 1 1 240px; min-width: 0; }
.hr-group { margin-top: 12px; }
.hr-group .mini-head h4 a { color: inherit; text-decoration: none; }
.send-opts { display: grid; gap: 10px; }
.send-opts .btn { justify-content: flex-start; }
@media (max-width: 640px) { .send-btn span { display: none; } .send-btn { padding: 6px 10px; } }
.hr-filters select { flex: 0 1 220px; width: auto; }
.hr-filters { align-items: center; }

/* Store tabs: wrap onto a second line instead of hiding the last tabs off-screen */
@media (min-width: 701px) {
  .sub-tabs { flex-wrap: wrap; overflow: visible; row-gap: 0; }
  .sub-tabs button { padding: 10px 10px; }
}
@media (max-width: 700px) {
  .sub-tabs { scrollbar-width: thin; }
}

/* Headings: Archivo Narrow (narrow grotesque); body text is Archivo */
.page-head h2 { font-size: 28px; font-weight: 700; letter-spacing: -.1px; }
.loc-head h2 { font-size: 30px; font-weight: 700; letter-spacing: -.1px; }
.loc-list-head h3 { font-size: 22px; font-weight: 700; }
.modal-head h3 { font-size: 21px; font-weight: 700; }
.kpi-value { font-size: 33px; font-weight: 700; letter-spacing: 0; }
.brand-title { font-size: 25px; font-weight: 700; letter-spacing: 0; }
.mini-head h4 { font-family: var(--serif); font-size: 19px; font-weight: 700; }
.settings h3, .card h3 { font-family: var(--serif); }
.div-name { font-family: var(--serif); font-size: 20px; font-weight: 700; letter-spacing: 0; }
