:root {
  --bg: #f2f2f2;
  --surface: #ffffff;
  --surface-alt: #f7f7f7;
  --text: #0a0a0a;
  --muted: #666666;
  --primary: #111111;
  --primary-dark: #000000;
  --sidebar: #050505;
  --border: #d4d4d4;
  --danger: #111111;
  --success: #111111;
  --warning: #111111;
  --focus: #111111;
  --unpaid: #b42318;
  --shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { color-scheme: light; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.6; }
body[data-role="worker"] .admin-only { display: none !important; }

:focus-visible {
  outline: 3px solid rgba(0, 0, 0, 0.3);
  outline-offset: 2px;
}

.auth-view {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
  background: #ededed;
}

.auth-panel {
  width: min(430px, 100%);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
}

.auth-brand { display: flex; align-items: center; margin-bottom: 22px; }
.auth-brand .brand-mark { display: block; width: min(100%, 240px); height: auto; }
.auth-language { margin-bottom: 18px; }
.auth-language label { color: var(--muted); font-size: 11px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.auth-tab { min-height: 42px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); font-weight: 700; }
.auth-tab.active { border-bottom-color: var(--primary); color: var(--primary); }
.auth-panel .form-group { margin-bottom: 14px; }
.auth-submit { width: 100%; margin-top: 4px; }
.text-button { padding: 6px 0; border: 0; background: transparent; color: var(--primary); font-weight: 700; }
.auth-panel .text-button { display: block; margin: 8px auto 0; }
.auth-note { margin: 18px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; text-align: center; }
.auth-loading { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 120px; color: var(--muted); }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
.account-state { padding: 8px 0; text-align: center; }
.account-state h2 { margin: 0 0 9px; font-size: 21px; }
.account-state p { margin: 0 0 14px; color: var(--muted); line-height: 1.5; }
.account-state strong { display: block; margin-bottom: 20px; overflow-wrap: anywhere; }
@keyframes spin { to { transform: rotate(360deg); } }

.app-shell {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 16px;
  background: var(--sidebar);
  color: #fff;
}

.brand {
  display: flex;
  align-items: flex-start;
  margin-bottom: 28px;
}

.brand-mark {
  display: block;
  width: min(100%, 190px);
  height: auto;
}

.sidebar-brand-mark { width: min(100%, 190px); }
.mobile-brand-mark { width: 110px; }

.nav-button {
  display: flex;
  width: 100%;
  align-items: center;
  min-height: 42px;
  margin-bottom: 5px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #cccccc;
  text-align: left;
}

.nav-button:hover,
.nav-button.active { background: rgba(255, 255, 255, 0.09); color: #fff; }

.storage-note {
  position: absolute;
  right: 18px;
  bottom: 20px;
  left: 18px;
  margin: 0;
  color: #aaaaaa;
  font-size: 11px;
  line-height: 1.45;
}

.session-summary { position: absolute; right: 18px; bottom: 82px; left: 18px; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.12); }
.session-summary strong, .session-summary span { display: block; overflow-wrap: anywhere; }
.session-summary strong { font-size: 12px; }
.session-summary span { margin-top: 3px; color: #aaaaaa; font-size: 11px; }
.session-summary .session-role { color: #ffffff; font-weight: 700; }
.text-button.light { color: #dddddd; font-size: 11px; }
.session-summary .text-button { margin-right: 12px; }

main { min-width: 0; padding: 24px; }

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.page-heading { min-width: 230px; }
.topbar h2 { margin: 0; font-size: 27px; line-height: 1.2; }
.topbar p { max-width: 610px; margin: 5px 0 0; color: var(--muted); line-height: 1.45; }

.workspace-tabs {
  display: none;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  background: var(--surface);
}
.workspace-tab { min-height: 42px; padding: 8px 18px; border: 0; border-right: 1px solid var(--border); background: transparent; color: var(--muted); font-weight: 750; }
.workspace-tab:last-child { border-right: 0; }
.workspace-tab.active { background: var(--primary); color: #ffffff; }

.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.action-menu { display: contents; }
.action-menu > summary { display: none; }
.action-menu-panel { display: contents; }
.action-menu-icon { font-size: 18px; line-height: 1; }
.sync-status { display: inline-flex; align-items: center; min-height: 40px; color: var(--muted); font-size: 11px; font-weight: 700; }
.sync-status[hidden] { display: none; }
.sync-status.pending { color: var(--warning); }
.sync-status.offline { color: var(--danger); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
}

.btn:hover { border-color: #bcbcbc; background: var(--surface-alt); }
.btn.primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.btn.primary:hover { border-color: var(--primary-dark); background: var(--primary-dark); }
.btn.danger { color: var(--danger); }
.btn.primary.danger { border-color: #111111; background: #111111; color: #ffffff; }
.btn.primary.danger:hover { border-color: #333333; background: #333333; }
.btn.small { min-height: 33px; padding: 0 9px; font-size: 12px; }

.language-control { min-width: 120px; margin: 0; }
.language-control span { display: block; margin: 0 0 3px 2px; color: var(--muted); font-size: 11px; font-weight: 700; }
.language-control select { min-height: 40px; padding-block: 7px; }

.input, select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  background: #fff;
  color: var(--text);
}

textarea { min-height: 78px; resize: vertical; }
.input:focus, select:focus, textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.14); }
.input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }

.settings-panel {
  margin-bottom: 16px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.settings-grid { display: grid; grid-template-columns: 150px minmax(220px, 1fr) 210px auto; gap: 12px; align-items: end; }
.settings-save { min-width: 120px; }

label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 700; }

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 15px;
}

.metric {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-label { margin-bottom: 9px; color: var(--muted); font-size: 13px; }
.metric-value { overflow-wrap: anywhere; font-size: 24px; font-weight: 800; line-height: 1.15; }
.metric-note { margin-top: 7px; color: var(--muted); font-size: 12px; }

.finance-tracker { margin-bottom: 15px; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.finance-tracker-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; padding: 15px 16px; }
.finance-tracker-head h3 { margin: 0; font-size: 17px; }
.finance-tracker-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.finance-tracker-head label { width: min(220px, 100%); margin: 0; }
.finance-tracker-head label span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.finance-report-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; padding: 13px 16px; border-top: 1px solid var(--border); background: var(--surface-alt); }
.finance-report-copy { min-width: 170px; }
.finance-report-copy h4 { margin: 0; font-size: 13px; }
.finance-report-copy p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.finance-report-fields { display: flex; align-items: flex-end; gap: 8px; }
.finance-report-fields label { width: 145px; margin: 0; }
.finance-report-fields label span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; font-weight: 700; }
.finance-report-fields .input { min-height: 36px; padding-block: 6px; font-size: 11px; }
.finance-report-fields .btn { min-height: 36px; white-space: nowrap; }
.finance-tracker-table { border-top: 1px solid var(--border); }
.finance-tracker-row { display: grid; grid-template-columns: minmax(120px, 1fr) repeat(4, minmax(110px, 0.8fr)); gap: 14px; align-items: center; min-height: 50px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
#financeTrackerRows .finance-tracker-row:last-child { border-bottom: 0; }
.finance-tracker-labels { min-height: 36px; background: #eeeeee; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.finance-tracker-row span { min-width: 0; overflow-wrap: anywhere; }
.finance-tracker-row > span:not(:first-child) { text-align: right; }
.finance-stat::before { display: none; }
.finance-outstanding { color: var(--unpaid); font-weight: 800; }

.today-tasks {
  margin-bottom: 15px;
  padding: 0 16px;
  scroll-margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.today-tasks-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 0 12px; }
.today-tasks-head h3 { margin: 0; font-size: 17px; }
.today-tasks-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.task-count { display: grid; flex: 0 0 36px; width: 36px; height: 36px; place-items: center; border: 1px solid #111111; border-radius: 6px; background: #111111; color: #ffffff; font-size: 15px; font-weight: 800; }
.task-head-controls { display: flex; align-items: center; gap: 12px; }
.task-notification-toggle { display: flex; align-items: center; min-height: 36px; gap: 7px; margin: 0; color: var(--muted); font-size: 12px; white-space: nowrap; }
.task-notification-toggle input { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); }
.task-view-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.task-view-tab { display: flex; min-width: 0; min-height: 42px; align-items: center; justify-content: center; gap: 8px; padding: 7px 10px; border: 0; border-right: 1px solid var(--border); background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; }
.task-view-tab:last-child { border-right: 0; }
.task-view-tab strong { display: grid; min-width: 22px; height: 22px; padding: 0 5px; place-items: center; border: 1px solid var(--border); border-radius: 999px; background: #ffffff; color: var(--text); font-size: 10px; }
.task-view-tab.active { background: #111111; color: #ffffff; }
.task-view-tab.active strong { border-color: #ffffff; }
.task-date-filter { display: flex; min-height: 58px; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.task-date-filter label { display: flex; min-width: 0; align-items: center; gap: 10px; margin: 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.task-date-filter .input { width: 165px; min-height: 38px; background: #ffffff; color: var(--text); }
.task-date-filter p { margin: 0; color: var(--muted); font-size: 12px; text-align: right; }
.task-date-filter.active { background: #f5f5f5; box-shadow: 16px 0 #f5f5f5, -16px 0 #f5f5f5; }
.task-date-filter.active label { color: var(--text); }
.today-task-list { border-top: 1px solid var(--border); }
.task-date-filter + .today-task-list { border-top: 0; }
.today-task { display: grid; grid-template-columns: minmax(160px, 1.3fr) minmax(100px, 0.6fr) minmax(150px, 1fr) auto; gap: 18px; align-items: center; min-height: 72px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.today-task:last-child { border-bottom: 0; }
.today-task-identity,
.today-task-due,
.today-task-place { min-width: 0; }
.today-task-identity > span,
.today-task-due > span,
.today-task-place > span { display: block; margin-top: 4px; overflow-wrap: anywhere; }
.today-task-due > strong { font-size: 12px; }
.today-task-actions { display: flex; justify-content: flex-end; gap: 7px; }
.today-tasks-empty { margin: 0; padding: 0 0 15px; color: var(--muted); font-size: 13px; }

.toolbar {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) 190px 210px 150px auto;
  gap: 9px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
}

.customer-panel { overflow: hidden; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); box-shadow: var(--shadow); }
.customer-table-head,
.customer-summary {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr) minmax(0, 0.9fr) minmax(0, 1.05fr) minmax(0, 0.85fr) minmax(0, 0.95fr) minmax(0, 1.1fr) 24px;
  gap: 12px;
}
.customer-table-head { align-items: center; min-height: 42px; padding: 9px 16px; border-bottom: 1px solid var(--border); background: #eeeeee; color: #333333; font-size: 10px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.customer-list { display: grid; }
.customer-record { min-width: 0; border-bottom: 1px solid var(--border); }
.customer-record.payment-alert { border-left: 4px solid var(--unpaid); }
.customer-record.payment-alert .customer-summary-identity strong { color: var(--unpaid); }
.customer-record:last-child { border-bottom: 0; }
.customer-record.expanded { background: var(--surface-alt); }
.customer-summary {
  width: 100%;
  min-height: 62px;
  align-items: center;
  padding: 11px 16px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
}
.customer-summary:hover { background: #f4f4f4; }
.customer-summary:focus-visible { position: relative; z-index: 1; outline: 2px solid var(--primary); outline-offset: -2px; }
.customer-summary-identity,
.customer-summary-cell { display: block; min-width: 0; overflow-wrap: anywhere; }
.customer-summary-identity strong,
.customer-summary-identity span { display: block; overflow-wrap: anywhere; }
.customer-summary-identity strong { font-size: 14px; }
.customer-summary-identity .muted { margin-top: 3px; }
.customer-summary-cell { font-size: 12px; line-height: 1.35; }
.customer-summary-payment { display: block; min-width: 0; overflow-wrap: anywhere; }
.customer-summary-payment strong,
.customer-summary-payment .muted { display: block; overflow-wrap: anywhere; }
.customer-summary-payment strong { font-size: 12px; }
.customer-summary-payment .muted { margin-top: 3px; }
.customer-summary-payment .badge { max-width: 100%; margin-top: 2px; line-height: 1.1; text-align: center; white-space: normal; }
.customer-expand-indicator { display: block; color: var(--muted); font-size: 25px; line-height: 1; text-align: center; transition: transform 0.16s ease; }
.customer-expand-indicator.expanded { transform: rotate(90deg); }
.customer-details { padding: 0 16px 16px; border-top: 1px solid var(--border); }
.customer-detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px 24px; padding: 17px 0; }
.customer-detail { min-width: 0; }
.customer-detail-label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.customer-detail-value { overflow-wrap: anywhere; font-size: 13px; line-height: 1.45; }
.customer-detail-wide { grid-column: 1 / -1; }
.customer-details .row-actions { display: flex; justify-content: flex-end; padding-top: 13px; border-top: 1px solid var(--border); }

.customer-name-button { padding: 0; border: 0; background: transparent; color: var(--primary); font-weight: 750; text-align: left; }
.customer-name-button:hover { text-decoration: underline; }
.muted { color: var(--muted); font-size: 12px; }
.nowrap { white-space: nowrap; }
.refill-due { font-weight: 800; text-decoration: underline; text-decoration-thickness: 2px; }
.link { color: var(--primary); font-weight: 650; text-decoration: none; }
.link:hover { text-decoration: underline; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.badge { border: 1px solid #777777; }
.badge.paid { border-color: #111111; background: #ffffff; color: #111111; }
.badge.partial { border-style: dashed; background: #dddddd; color: #111111; }
.badge.unpaid { border-color: var(--unpaid); background: var(--unpaid); color: #ffffff; }
.badge.overdue { border-color: var(--unpaid); background: var(--unpaid); color: #ffffff; text-decoration: underline; }
.badge.inactive { border-color: #aaaaaa; background: #eeeeee; color: #555555; }
.row-actions { gap: 6px; min-width: 0; }
.row-actions .btn { min-width: 0; padding-inline: 7px; overflow-wrap: anywhere; white-space: normal; }

.empty-state { padding: 54px 20px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 6px; color: var(--text); font-size: 16px; }

.modal-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.58);
}

.modal-backdrop.open { display: flex; }
.modal { width: min(760px, 100%); max-height: calc(100vh - 36px); overflow: auto; border-radius: 8px; background: #fff; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22); }
.compact-modal { width: min(600px, 100%); }
.import-modal { width: min(720px, 100%); }
.modal-head, .modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; }
.modal-head { position: sticky; z-index: 1; top: 0; border-bottom: 1px solid var(--border); background: #fff; }
.modal-head h3 { margin: 0; font-size: 19px; }
.modal-subtitle { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.modal-foot { position: sticky; bottom: 0; justify-content: flex-end; border-top: 1px solid var(--border); background: #fff; }
.icon-btn { display: grid; width: 36px; height: 36px; padding: 0; place-items: center; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-alt); color: var(--text); font-size: 22px; }
.form-body { padding: 18px; }
#customerModal .modal { display: flex; height: min(760px, calc(100vh - 36px)); flex-direction: column; overflow: hidden; }
#customerModal .modal-head { flex: 0 0 auto; }
#customerForm { display: flex; flex: 1 1 auto; min-height: 0; flex-direction: column; overflow: hidden; }
#customerForm .form-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
#customerForm .modal-foot { position: relative; z-index: 2; flex: 0 0 auto; padding-bottom: calc(15px + env(safe-area-inset-bottom)); box-shadow: 0 -5px 16px rgba(0, 0, 0, 0.06); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group.full { grid-column: 1 / -1; }
.hint { margin-top: 5px; color: var(--muted); font-size: 12px; }
.hint.warning { color: var(--warning); font-weight: 650; }
.required::after { content: " *"; color: var(--danger); }
.form-error { margin-bottom: 14px; padding: 10px 12px; border-left: 3px solid var(--danger); background: #f1f1f1; color: #111111; font-size: 13px; }

.import-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 14px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.import-summary > div { min-width: 0; padding: 14px; border-right: 1px solid var(--border); }
.import-summary > div:last-child { border-right: 0; }
.import-summary span,
.import-summary strong { display: block; }
.import-summary span { color: var(--muted); font-size: 11px; font-weight: 700; }
.import-summary strong { margin-top: 4px; font-size: 22px; }
.import-summary-text { margin: 0 0 10px; font-size: 13px; }
.import-issues { max-height: 230px; overflow-y: auto; border-top: 1px solid var(--border); }
.import-issues:empty { display: none; }
.import-issues p { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 12px; overflow-wrap: anywhere; }

.update-prompt { position: fixed; z-index: 55; right: 18px; bottom: 18px; display: grid; width: min(520px, calc(100vw - 36px)); grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 14px; border: 1px solid #111111; border-radius: 7px; background: #ffffff; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.24); }
.update-prompt strong,
.update-prompt span { display: block; overflow-wrap: anywhere; }
.update-prompt strong { font-size: 14px; }
.update-prompt span { margin-top: 3px; color: var(--muted); font-size: 12px; }

.toast {
  position: fixed;
  z-index: 40;
  right: 18px;
  bottom: 18px;
  max-width: min(380px, calc(100vw - 36px));
  padding: 11px 14px;
  border-radius: 7px;
  background: #111111;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show { opacity: 1; transform: translateY(0); }
.mobile-header { display: none; }

.users-modal { width: min(800px, 100%); }
.staff-create { padding: 16px 18px; border-bottom: 1px solid var(--border); background: var(--surface-alt); }
.staff-create h4 { margin: 0 0 12px; font-size: 15px; }
.staff-create .form-error { margin-bottom: 12px; }
.staff-create-grid { display: grid; grid-template-columns: minmax(130px, 0.9fr) minmax(190px, 1.2fr) minmax(150px, 1fr) auto; gap: 10px; align-items: end; }
.staff-create-grid .form-group { min-width: 0; }
.account-modal { width: min(720px, 100%); }
.account-body { padding: 0 18px; }
.account-current { padding: 16px 0; border-bottom: 1px solid var(--border); }
.account-current span,
.account-current strong { display: block; overflow-wrap: anywhere; }
.account-current span { margin-bottom: 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
.account-section { padding: 18px 0; border-bottom: 1px solid var(--border); }
.account-section:last-child { border-bottom: 0; }
.account-section-copy { margin-bottom: 14px; }
.account-section-copy h4 { margin: 0; font-size: 16px; }
.account-section-copy p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.account-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; gap: 10px; align-items: end; }
.account-form-grid.password-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.account-form-grid.password-grid .account-submit { grid-column: 3; justify-self: end; }
.account-form-grid .form-group { min-width: 0; }
.account-form-grid .form-error { grid-column: 1 / -1; margin-bottom: 0; }
.account-submit { min-width: 150px; }
.users-list { padding: 6px 18px 18px; }
.user-row { display: grid; grid-template-columns: minmax(180px, 1fr) 160px 150px; gap: 14px; align-items: end; padding: 14px 0; border-bottom: 1px solid var(--border); }
.user-row:last-child { border-bottom: 0; }
.user-identity { align-self: center; min-width: 0; }
.user-identity strong, .user-identity span { display: block; overflow-wrap: anywhere; }
.user-identity span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.user-identity .owner-label { color: var(--primary); font-weight: 750; }
.access-toggle { display: flex; align-items: center; min-height: 40px; gap: 8px; margin: 0; font-weight: 650; }
.access-toggle input { width: 18px; height: 18px; accent-color: var(--primary); }
.empty-state.compact { padding: 28px 18px; }

.profile-modal { width: min(960px, 100%); }
.profile-head { align-items: flex-start; }
.profile-head > div { min-width: 0; }
.profile-head h3 { overflow-wrap: anywhere; }
.profile-close-btn { flex: 0 0 auto; white-space: nowrap; }
.profile-body { padding: 0 22px 24px; }
.profile-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 0; }
.profile-foot { justify-content: flex-end; }
.profile-section { padding: 19px 0; border-top: 1px solid var(--border); }
.profile-section h4 { margin: 0; font-size: 16px; }
.profile-section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.profile-section-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.profile-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 28px; margin-top: 16px; }
.profile-detail { min-width: 0; }
.profile-detail:last-child { grid-column: 1 / -1; }
.profile-detail span,
.profile-finance-grid span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.profile-detail strong,
.profile-detail a { display: block; overflow-wrap: anywhere; font-size: 13px; }
.profile-finance-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 16px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.profile-finance-grid > div { min-width: 0; padding: 14px 16px; border-right: 1px solid var(--border); }
.profile-finance-grid > div:first-child { padding-left: 0; }
.profile-finance-grid > div:last-child { padding-right: 0; border-right: 0; }
.profile-finance-grid strong { display: block; overflow-wrap: anywhere; font-size: 18px; }
.profile-overdue { margin-top: 12px; padding: 10px 12px; background: var(--unpaid); color: #ffffff; font-size: 13px; font-weight: 750; }
.profile-payment-alert #profileName,
.profile-payment-alert #profileOutstanding { color: var(--unpaid); }
.payment-form { margin-top: 14px; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.payment-form-grid { display: grid; grid-template-columns: 130px 150px 180px auto; gap: 10px; align-items: end; }
.payment-form-grid .form-group { min-width: 0; margin: 0; }
.payment-form .form-error { grid-column: 1 / -1; }
#quickPaymentModal .modal { display: flex; flex-direction: column; overflow: hidden; }
#quickPaymentModal .modal-head { flex: 0 0 auto; }
#quickPaymentForm { display: flex; flex: 1 1 auto; min-height: 0; flex-direction: column; }
#quickPaymentForm .form-body { flex: 1 1 auto; overflow-y: auto; }
#quickPaymentForm .modal-foot { position: relative; z-index: 2; flex: 0 0 auto; box-shadow: 0 -5px 16px rgba(0, 0, 0, 0.06); }
.delete-customer-modal .form-body { padding-block: 24px; }
.delete-customer-message { margin: 0; font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
.history-list { margin-top: 5px; }
.history-entry { display: grid; grid-template-columns: minmax(120px, 0.8fr) minmax(180px, 1.5fr) auto; gap: 18px; align-items: center; min-height: 60px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.history-entry:last-child { border-bottom: 0; }
.history-entry strong,
.history-entry span { display: block; overflow-wrap: anywhere; }
.history-entry strong { font-size: 13px; }
.history-entry span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.history-amount { text-align: right; }
.history-amount strong { font-size: 15px; }
.empty-history { margin: 14px 0 0; color: var(--muted); font-size: 13px; }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics .metric:first-child { grid-column: 1 / -1; }
  .metric {
    display: grid;
    min-height: 84px;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "label value" "note value";
    column-gap: 16px;
    align-items: center;
    padding: 14px 16px;
  }
  .metric-label { grid-area: label; align-self: end; margin: 0 0 3px; }
  .metric-value { grid-area: value; overflow-wrap: normal; white-space: nowrap; }
  .metric-note { grid-area: note; align-self: start; margin: 0; }
  .finance-tracker-labels { display: none; }
  #financeTrackerRows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 12px; }
  #financeTrackerRows .finance-tracker-row {
    display: grid;
    min-width: 0;
    min-height: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 18px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-alt);
  }
  #financeTrackerRows .finance-tracker-row:last-child { border-bottom: 1px solid var(--border); }
  #financeTrackerRows .finance-tracker-row > strong { grid-column: 1 / -1; padding-bottom: 10px; border-bottom: 1px solid var(--border); font-size: 17px; }
  #financeTrackerRows .finance-tracker-row > span:not(:first-child) { text-align: left; }
  .finance-stat::before { display: block; margin-bottom: 4px; color: var(--muted); content: attr(data-label); font-size: 10px; font-weight: 700; }
  .toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar #searchInput { grid-column: 1 / -1; }
  .settings-grid { grid-template-columns: 140px 1fr 190px; }
  .settings-save { grid-column: 1 / -1; justify-self: end; }
  .payment-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .payment-form-grid .btn { align-self: stretch; }
  .customer-table-head,
  .customer-summary { gap: 8px; }
  .customer-detail-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .topbar { display: block; }
  .actions { align-items: center; margin-top: 14px; }
  .action-menu { display: block; position: relative; }
  .action-menu > summary { display: inline-flex; gap: 8px; cursor: pointer; list-style: none; }
  .action-menu > summary::-webkit-details-marker { display: none; }
  .action-menu-panel { display: none; }
  .action-menu[open] .action-menu-panel {
    position: absolute;
    z-index: 30;
    top: calc(100% + 8px);
    right: 0;
    display: grid;
    width: min(290px, calc(100vw - 24px));
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    box-shadow: 0 14px 34px rgba(0, 0, 0, .16);
  }
  .action-menu-panel .language-control { width: 100%; }
  .action-menu-panel .language-control select,
  .action-menu-panel .btn { width: 100%; }
  .action-menu-panel .btn { justify-content: flex-start; }
  .action-menu-signout { margin-top: 4px; border-top-color: var(--text); }
}

@media (max-width: 800px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .mobile-header { display: flex; position: sticky; z-index: 10; top: 0; align-items: center; justify-content: space-between; min-height: 58px; padding: 9px 14px; background: var(--sidebar); color: #fff; }
  .mobile-header .brand-mark { display: block; width: 96px; height: auto; }
  .mobile-controls { display: flex; flex: 0 0 auto; align-items: center; gap: 7px; }
  .mobile-settings { width: 34px; height: 34px; border-color: rgba(255, 255, 255, 0.28); background: transparent; color: #fff; }
  main { padding: 16px 12px 24px; }
  .topbar { display: block; }
  .topbar h2 { font-size: 23px; }
  .topbar p { font-size: 14px; }
  .actions { display: flex; align-items: center; justify-content: flex-end; margin-top: 15px; }
  .actions .btn { min-width: 0; min-height: 42px; padding: 7px 8px; overflow-wrap: anywhere; white-space: normal; }
  #addBtn { display: none; }
  .sync-status { justify-content: center; }
  .settings-grid, .toolbar { grid-template-columns: 1fr; }
  .workspace-tabs { display: grid; width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics { grid-template-columns: 1fr; }
  .metrics .metric:first-child { grid-column: auto; }
  #financeTrackerRows { grid-template-columns: 1fr; }
  .customer-panel { scroll-margin-top: 70px; }
  .toolbar #searchInput,
  .finance-tracker-head { align-items: stretch; flex-direction: column; }
  .finance-tracker-head label { width: 100%; }
  .finance-report-bar { align-items: stretch; flex-direction: column; }
  .finance-report-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .finance-report-fields label { width: auto; }
  .finance-report-fields .btn { grid-column: 1 / -1; }
  .today-task { grid-template-columns: minmax(150px, 1fr) minmax(100px, 0.65fr); gap: 10px 16px; }
  .today-task-place { grid-column: 1; }
  .today-task-actions { grid-column: 2; grid-row: 2; align-self: end; }
  .today-tasks-head { align-items: flex-start; }
  .task-head-controls { align-items: flex-end; flex-direction: column-reverse; }
  .settings-save { grid-column: auto; justify-self: stretch; }
  .user-row { grid-template-columns: 1fr; gap: 8px; }
  .staff-create-grid { grid-template-columns: 1fr; }
  .account-form-grid,
  .account-form-grid.password-grid { grid-template-columns: 1fr; }
  .account-form-grid.password-grid .account-submit { grid-column: auto; justify-self: stretch; }
  .account-submit { width: 100%; }
  .profile-finance-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-finance-grid > div:nth-child(2) { border-right: 0; }
  .profile-finance-grid > div:nth-child(3),
  .profile-finance-grid > div:nth-child(4) { border-top: 1px solid var(--border); }
  .history-entry { grid-template-columns: 1fr auto; gap: 10px; }
  .history-entry > div:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .customer-table-head { display: none; }
  .customer-summary { grid-template-columns: minmax(0, 1fr) auto 24px; gap: 10px; padding: 13px 14px; }
  .customer-summary-aroma,
  .customer-summary-device,
  .customer-summary-invoice,
  .customer-summary-phone,
  .customer-summary-location { display: none; }
  .customer-summary-payment { grid-column: 2; grid-row: 1; justify-self: end; }
  .customer-expand-indicator { grid-column: 3; grid-row: 1; }
  .customer-details { padding: 0 14px 14px; }
  .customer-detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
}

@media (max-width: 520px) {
  .metrics { grid-template-columns: 1fr; }
  .metric { padding: 14px; }
  .metric-value { font-size: 22px; }
  .metrics { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .task-view-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .task-view-tab:nth-child(2) { border-right: 0; }
  .task-view-tab:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .task-notification-toggle { white-space: normal; }
  .task-date-filter { align-items: stretch; flex-direction: column; gap: 7px; padding: 10px 0; }
  .task-date-filter label { align-items: stretch; flex-direction: column; gap: 5px; }
  .task-date-filter .input { width: 100%; }
  .task-date-filter p { font-size: 11px; text-align: left; }
  .customer-summary-payment { align-items: flex-end; flex-direction: column; gap: 4px; }
  .customer-detail-grid { grid-template-columns: 1fr; gap: 14px; }
  .customer-detail-wide { grid-column: auto; }
  .customer-details .row-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .customer-details .row-actions .btn:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .today-tasks { padding: 0 14px; }
  .today-tasks-head { align-items: flex-start; }
  .today-task { grid-template-columns: 1fr; gap: 8px; padding: 14px 0; }
  .today-task-place,
  .today-task-actions { grid-column: auto; grid-row: auto; }
  .today-task-actions { display: grid; grid-template-columns: 1fr 1fr; margin-top: 3px; }
  .today-task-actions .btn { min-width: 0; min-height: 42px; padding-inline: 7px; white-space: normal; }
  .form-group.full { grid-column: auto; }
  .modal-backdrop { padding: 0; }
  .modal { width: 100%; max-height: 100vh; min-height: 100vh; border-radius: 0; }
  #customerModal .modal { width: 100%; height: 100vh; height: 100dvh; min-height: 100vh; min-height: 100dvh; max-height: 100vh; max-height: 100dvh; }
  #profileModal .profile-modal { display: flex; width: 100%; height: 100vh; height: 100dvh; min-height: 100vh; min-height: 100dvh; max-height: 100vh; max-height: 100dvh; flex-direction: column; overflow: hidden; }
  #profileModal .profile-head { position: relative; flex: 0 0 auto; padding-top: calc(15px + env(safe-area-inset-top)); }
  #profileModal .profile-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  #profileModal .profile-foot { position: relative; z-index: 2; flex: 0 0 auto; padding-bottom: calc(16px + env(safe-area-inset-bottom)); box-shadow: 0 -5px 16px rgba(0, 0, 0, 0.06); }
  #quickPaymentModal .modal-head { padding-top: calc(15px + env(safe-area-inset-top)); }
  #quickPaymentForm .modal-foot { padding-bottom: calc(15px + env(safe-area-inset-bottom)); }
  #quickPaymentForm .modal-foot .btn { flex: 1 1 0; min-width: 0; min-height: 44px; white-space: normal; }
  #customerModal .modal-foot .btn { flex: 1 1 0; min-width: 0; min-height: 44px; white-space: normal; }
  .auth-view { padding: 0; place-items: stretch; }
  .auth-panel { width: 100%; min-height: 100vh; padding: 24px 18px; border: 0; border-radius: 0; box-shadow: none; }
  .profile-body { padding: 0 16px 20px; }
  .profile-actions { display: grid; grid-template-columns: 1fr; }
  .profile-actions .btn { width: 100%; white-space: normal; }
  .profile-foot { padding: 12px 16px 16px; }
  .profile-foot .profile-close-btn { width: 100%; }
  .profile-detail-grid,
  .profile-finance-grid,
  .payment-form-grid { grid-template-columns: 1fr; }
  .profile-detail:last-child { grid-column: auto; }
  .profile-finance-grid > div { padding: 12px 0; border-top: 1px solid var(--border); border-right: 0; }
  .profile-finance-grid > div:first-child { border-top: 0; }
  .payment-form-grid .btn { min-height: 44px; }
  .import-summary { grid-template-columns: 1fr; }
  .import-summary > div { padding: 10px 0; border-right: 0; border-bottom: 1px solid var(--border); }
  .import-summary > div:last-child { border-bottom: 0; }
  .update-prompt { right: 12px; bottom: 12px; width: calc(100vw - 24px); grid-template-columns: 1fr 1fr; }
  .update-prompt > div { grid-column: 1 / -1; }
  .update-prompt .btn { min-width: 0; white-space: normal; }
}

@media (min-width: 801px) {
  .dashboard-active .topbar { margin-bottom: 14px; }
  .dashboard-active .topbar h2 { font-size: 23px; }
  .dashboard-active .topbar p { margin-top: 3px; font-size: 13px; }
  .dashboard-active .actions { margin-top: 10px; }
  .dashboard-active .actions .btn { min-height: 36px; padding-inline: 11px; font-size: 12px; }
  .dashboard-active .sync-status { min-height: 36px; font-size: 10px; }

  #dashboardView .metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0;
    overflow: hidden;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  #dashboardView .metrics .metric,
  #dashboardView .metrics .metric:first-child {
    display: block;
    min-height: 70px;
    grid-column: auto;
    padding: 11px 13px;
    border: 0;
    border-right: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  #dashboardView .metrics .metric:last-child { border-right: 0; }
  #dashboardView .metric-label {
    margin: 0 0 7px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .045em;
    line-height: 1.25;
    text-transform: uppercase;
  }
  #dashboardView .metric-value {
    overflow: hidden;
    font-size: 18px;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #dashboardView .metric-note { display: none; }

  #dashboardView .finance-tracker,
  #dashboardView .today-tasks { margin-bottom: 12px; }
  #dashboardView .finance-tracker-head { gap: 14px; padding: 11px 14px; }
  #dashboardView .finance-tracker-head h3,
  #dashboardView .today-tasks-head h3 { font-size: 15px; }
  #dashboardView .finance-tracker-head p,
  #dashboardView .today-tasks-head p { margin-top: 2px; font-size: 10px; }
  #dashboardView .finance-tracker-head label { width: min(190px, 100%); font-size: 10px; }
  #dashboardView .finance-tracker-head label span { margin-bottom: 3px; font-size: 9px; }
  #dashboardView .finance-tracker-head select { min-height: 34px; padding-block: 5px; font-size: 11px; }
  #dashboardView .finance-report-bar { gap: 12px; padding: 9px 14px; }
  #dashboardView .finance-report-copy h4 { font-size: 11px; }
  #dashboardView .finance-report-copy p { font-size: 9px; }
  #dashboardView .finance-report-fields label { width: 132px; }
  #dashboardView .finance-report-fields label span { font-size: 8px; }
  #dashboardView .finance-report-fields .input,
  #dashboardView .finance-report-fields .btn { min-height: 32px; font-size: 10px; }
  #dashboardView .finance-tracker-row { min-height: 42px; gap: 10px; padding: 8px 14px; font-size: 12px; }
  #dashboardView .finance-tracker-labels { min-height: 30px; font-size: 8px; }
  #dashboardView #financeTrackerRows .finance-tracker-row > strong { font-size: 13px; }
  #dashboardView .finance-stat { font-size: 12px; }
  #dashboardView .finance-stat::before { margin-bottom: 3px; font-size: 8px; }

  #dashboardView .today-tasks { padding-inline: 14px; }
  #dashboardView .today-tasks-head { gap: 12px; padding: 11px 0 9px; }
  #dashboardView .task-head-controls { gap: 9px; }
  #dashboardView .task-notification-toggle { min-height: 30px; gap: 5px; font-size: 10px; }
  #dashboardView .task-notification-toggle input { width: 15px; height: 15px; }
  #dashboardView .task-count { flex-basis: 30px; width: 30px; height: 30px; font-size: 12px; }
  #dashboardView .task-view-tab { min-height: 36px; gap: 6px; padding: 5px 8px; font-size: 10px; }
  #dashboardView .task-view-tab strong { min-width: 18px; height: 18px; padding-inline: 4px; font-size: 8px; }
  #dashboardView .task-date-filter { min-height: 48px; padding-block: 7px; }
  #dashboardView .task-date-filter label,
  #dashboardView .task-date-filter p { font-size: 10px; }
  #dashboardView .task-date-filter .input { min-height: 32px; font-size: 11px; }
  #dashboardView .today-task { min-height: 58px; gap: 12px; padding: 9px 0; font-size: 12px; }
  #dashboardView .today-task-identity > span,
  #dashboardView .today-task-due > span,
  #dashboardView .today-task-place > span { margin-top: 2px; font-size: 10px; }
  #dashboardView .today-task-actions { gap: 5px; }
  #dashboardView .today-task-actions .btn { min-height: 32px; padding-inline: 9px; font-size: 10px; }
  #dashboardView .today-tasks-empty { padding-bottom: 11px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
