:root {
  --ink: #16222c;
  --muted: #687783;
  --line: #dce3e7;
  --paper: #fff;
  --canvas: #f3f5f6;
  --deep: #112f3a;
  --deep-2: #0b222b;
  --warm: #0f8f91;
  --warm-soft: #e8f4f3;
  --green: #178565;
  --green-soft: #e4f4ed;
  --amber: #b7770e;
  --amber-soft: #fff4d9;
  --red: #b74738;
  --red-soft: #fbe8e3;
  --blue: #28708e;
  --blue-soft: #e7f2f7;
  --shadow: 0 24px 70px rgba(14, 37, 46, 0.12);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  background: var(--canvas);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 93% 3%, rgba(15, 143, 145, 0.08), transparent 27rem),
    var(--canvas);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--warm);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow.light {
  color: #ffd4ba;
}

.owner-brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.035em;
  text-decoration: none;
  white-space: nowrap;
}

.owner-brand strong {
  color: var(--warm);
}

.owner-brand-mark,
.loading-mark {
  display: inline-grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  background: var(--warm);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.08em;
  box-shadow: 0 10px 30px rgba(18, 168, 176, 0.26);
}

.portal-loading {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: #c8d6d3;
  background: var(--deep);
}

.portal-loading .loading-mark,
.auth-complete-card .loading-mark {
  animation: load-pulse 1.4s ease-in-out infinite;
}

.portal-loading p {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

@keyframes load-pulse {
  50% {
    transform: translateY(-4px);
    box-shadow: 0 18px 42px rgba(18, 168, 176, 0.34);
  }
}

.login-view {
  display: block;
  min-height: 100vh;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    radial-gradient(circle at 50% -10%, rgba(30, 128, 132, 0.28), transparent 34rem),
    linear-gradient(145deg, var(--deep-2), var(--deep));
  background-size: 54px 54px, 54px 54px, auto, auto;
}

.login-panel {
  display: grid;
  min-height: 100vh;
  padding: clamp(24px, 5vw, 60px);
  place-items: center;
}

.login-frame {
  width: min(100%, 560px);
}

.login-header,
.login-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.login-header {
  margin-bottom: 24px;
  color: #fff;
}

.private-badge {
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: #b9cccf;
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-card {
  width: 100%;
  padding: clamp(32px, 6vw, 52px);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.login-card-heading {
  display: flex;
  gap: 17px;
  align-items: center;
}

.secure-icon {
  display: grid;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 15px;
  color: #fff;
  background: var(--deep);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.login-card h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 680;
  letter-spacing: -0.05em;
}

.login-card > p {
  margin: 22px 0 28px;
  color: var(--muted);
  line-height: 1.7;
}

label {
  display: grid;
  gap: 8px;
  color: #405457;
  font-size: 0.77rem;
  font-weight: 800;
}

label span small {
  margin-left: 6px;
  color: #899593;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid #d5dedb;
  border-radius: 12px;
  outline: 0;
  color: var(--ink);
  background: #fff;
  font-size: 0.88rem;
  transition: border-color 150ms, box-shadow 150ms;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--deep);
  box-shadow: 0 0 0 4px rgba(16, 58, 66, 0.1);
}

.primary-button,
.quiet-button {
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}

.primary-button {
  width: 100%;
  padding: 13px 18px;
  color: #fff;
  background: var(--deep);
  box-shadow: 0 12px 28px rgba(16, 58, 66, 0.18);
}

.primary-button:hover {
  background: #0b4650;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.primary-button.small {
  width: auto;
  padding-inline: 20px;
}

#owner-login-form {
  display: grid;
  gap: 14px;
}

.form-message {
  margin-top: 17px;
  padding: 13px 15px;
  border-radius: 11px;
  color: #17644f;
  background: var(--green-soft);
  font-size: 0.8rem;
  line-height: 1.5;
}

.form-message.is-error {
  color: var(--red);
  background: var(--red-soft);
}

.security-note {
  display: flex;
  gap: 8px;
  margin-top: 22px;
  color: #758481;
  line-height: 1.5;
}

.security-note span {
  color: var(--green);
  font-weight: 900;
}

.back-link {
  color: #c5d4d6;
  font-size: 0.72rem;
  font-weight: 700;
  text-decoration: none;
}

.login-footer {
  margin-top: 22px;
  padding: 0 4px;
  color: #829ca1;
  font-size: 0.7rem;
}

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

.portal-sidebar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  padding: 30px 24px;
  color: #c6d4d1;
  background: var(--deep);
}

.sidebar-brand {
  padding: 0 10px 27px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
}

.sidebar-brand > span:last-child {
  display: block;
}

.sidebar-brand small {
  display: block;
  margin-top: 2px;
  color: #789a99;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.portal-sidebar nav {
  display: grid;
  gap: 5px;
  margin-top: 27px;
}

.portal-sidebar nav > p {
  margin: 22px 13px 8px;
  color: #6f9696;
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.17em;
}

.portal-sidebar nav button {
  display: flex;
  width: 100%;
  min-height: 48px;
  gap: 12px;
  align-items: center;
  padding: 11px 14px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  color: #bdceca;
  background: transparent;
  font-size: 0.84rem;
  font-weight: 800;
  text-align: left;
}

.portal-sidebar nav button span {
  display: grid;
  width: 24px;
  color: #7ea09e;
  place-items: center;
}

.portal-sidebar nav button b {
  min-width: 22px;
  margin-left: auto;
  padding: 3px 7px;
  border-radius: 999px;
  color: #fcd7c2;
  background: rgba(18, 168, 176, 0.18);
  font-size: 0.66rem;
  text-align: center;
}

.portal-sidebar nav button:hover,
.portal-sidebar nav button.is-active {
  color: var(--deep);
  background: #fff;
}

.portal-sidebar nav button.is-active span {
  color: var(--warm);
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding: 25px 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-footer a,
.sidebar-footer button {
  padding: 0;
  border: 0;
  color: #9db3af;
  background: transparent;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
}

.portal-main {
  min-width: 0;
}

.portal-header {
  position: sticky;
  z-index: 8;
  top: 0;
  display: flex;
  min-height: 88px;
  align-items: center;
  justify-content: space-between;
  padding: 17px clamp(24px, 4vw, 54px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
}

.portal-header > div:first-of-type p,
.portal-header > div:first-of-type h2 {
  margin: 0;
}

.portal-header > div:first-of-type p {
  margin-bottom: 4px;
  color: var(--warm);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.portal-header > div:first-of-type h2 {
  font-size: 1rem;
}

.owner-identity {
  display: flex;
  gap: 11px;
  align-items: center;
}

.owner-identity > span {
  display: grid;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: #fff;
  background: var(--deep);
  font-size: 0.72rem;
  font-weight: 900;
  place-items: center;
}

.owner-identity p,
.owner-identity b,
.owner-identity small {
  display: block;
  margin: 0;
}

.owner-identity b {
  font-size: 0.77rem;
}

.owner-identity small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.66rem;
}

.mobile-nav-button {
  display: none;
}

.portal-content {
  padding: clamp(28px, 4vw, 56px);
}

.portal-section {
  display: none;
  max-width: 1480px;
  margin: 0 auto;
}

.portal-section.is-active {
  display: block;
}

.page-intro {
  display: flex;
  gap: 24px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-intro h1 {
  margin: 0 0 6px;
  font-size: clamp(1.6rem, 2.4vw, 2.15rem);
  font-weight: 670;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.page-intro > div > p:last-child {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.quiet-button {
  flex: 0 0 auto;
  padding: 12px 18px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.metric-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-card {
  position: relative;
  min-height: 118px;
  padding: 16px 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 12px 34px rgba(23, 43, 43, 0.05);
}

.metric-card::after {
  position: absolute;
  right: -24px;
  bottom: -30px;
  width: 84px;
  height: 84px;
  border-radius: 999px;
  background: var(--metric-soft, var(--blue-soft));
  content: "";
}

.metric-card p,
.metric-card strong,
.metric-card small {
  position: relative;
  z-index: 1;
  display: block;
}

.metric-card p {
  margin: 0;
  /* 5.40:1 on white. Was #768482 at 3.89:1 — and this is small, uppercase,
     letter-spaced text, which needs more contrast than body copy, not less. */
  color: #5f6d6b;
  font-size: 0.67rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.metric-card strong {
  margin: 10px 0 5px;
  font-size: clamp(1.6rem, 2.4vw, 2.1rem);
  font-weight: 650;
  letter-spacing: -0.04em;
}

.metric-card small {
  color: var(--muted);
  font-size: 0.72rem;
}

.metric-card.green {
  --metric-soft: var(--green-soft);
}

.metric-card.amber {
  --metric-soft: var(--amber-soft);
}

.metric-card.red {
  --metric-soft: var(--red-soft);
}

.metric-card.warm {
  --metric-soft: var(--warm-soft);
}

.metric-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.overview-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 12px 34px rgba(23, 43, 43, 0.05);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 26px 21px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 680;
  letter-spacing: -0.04em;
}

.panel-heading > span {
  display: grid;
  min-width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  color: var(--warm);
  background: var(--warm-soft);
  font-size: 0.75rem;
  font-weight: 900;
}

.attention-list,
.activity-list,
.notice-list {
  display: grid;
}

.attention-item,
.activity-item,
.notice-item {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid #eef1ef;
}

.attention-item:last-child,
.activity-item:last-child,
.notice-item:last-child {
  border-bottom: 0;
}

.item-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  color: var(--amber);
  background: var(--amber-soft);
  font-weight: 900;
}

.item-icon.red {
  color: var(--red);
  background: var(--red-soft);
}

.item-icon.green {
  color: var(--green);
  background: var(--green-soft);
}

.attention-item p,
.activity-item p,
.notice-item p {
  min-width: 0;
  margin: 0;
}

.attention-item b,
.attention-item small,
.activity-item b,
.activity-item small,
.notice-item b,
.notice-item small {
  display: block;
}

.attention-item b,
.activity-item b,
.notice-item b {
  margin-bottom: 4px;
  font-size: 0.82rem;
}

.attention-item small,
.activity-item small,
.notice-item small {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.45;
}

.item-action {
  margin-left: auto;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  color: var(--deep);
  background: #fff;
  font-size: 0.68rem;
  font-weight: 800;
}

.empty-state {
  padding: 36px 24px;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.search-field {
  position: relative;
  display: block;
  width: min(520px, 100%);
}

.search-field span {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 15px;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-field input {
  padding-left: 42px;
}

.toolbar select {
  width: auto;
  min-width: 175px;
}

.restaurant-list {
  display: grid;
  gap: 18px;
}

.restaurant-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 12px 34px rgba(23, 43, 43, 0.05);
}

.restaurant-card-top {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.restaurant-avatar {
  display: grid;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  background: var(--deep);
  font-size: 1.25rem;
}

.restaurant-title {
  min-width: 0;
}

.restaurant-title h2,
.restaurant-title p {
  margin: 0;
}

.restaurant-title h2 {
  margin-bottom: 4px;
  font-size: 1.28rem;
  font-weight: 680;
}

.restaurant-title p {
  color: var(--muted);
  font-size: 0.72rem;
}

.status-badge {
  display: inline-flex;
  margin-left: auto;
  padding: 7px 12px;
  border-radius: 999px;
  color: var(--green);
  background: var(--green-soft);
  /* This badge is the whole answer to "is this restaurant in trouble?" and
     it was the smallest text on the card. */
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: capitalize;
}

.status-badge.past_due,
.status-badge.suspended {
  color: var(--red);
  background: var(--red-soft);
}

.status-badge.grace,
.status-badge.due_soon {
  color: var(--amber);
  background: var(--amber-soft);
}

/* The existing modifiers are account-status VALUES. The collection worksheet
   needs to say "12 days late" or "Due in 3 days", which are computed, not
   stored — without these it fell through to the default green, so an overdue
   account was painted as healthy. */
.status-badge.red {
  color: var(--red);
  background: var(--red-soft);
}

.status-badge.amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.status-badge.green {
  color: var(--green);
  background: var(--green-soft);
}

/* No tone at all means "nothing to report", not "healthy". */
.status-badge.neutral {
  color: #5f6d6b;
  background: #eef1f0;
}

.restaurant-card-body {
  display: grid;
  gap: 22px;
  padding: 24px;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.8fr) minmax(260px, 0.8fr);
}

.control-group {
  min-width: 0;
}

.control-group h3 {
  margin: 0 0 14px;
  color: #60716f;
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.field-pair {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.field-pair + .field-pair,
.field-pair + label,
.control-group > label + label {
  margin-top: 11px;
}

.toggle-row {
  display: flex;
  min-height: 48px;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #e1e7e4;
  border-radius: 12px;
  color: var(--ink);
  cursor: pointer;
}

.toggle-row + .toggle-row {
  margin-top: 9px;
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--green);
}

.toggle-row span {
  display: grid;
  gap: 2px;
}

.toggle-row b {
  font-size: 0.78rem;
}

.toggle-row small {
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 600;
}

.restaurant-card-footer {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: #fbfcfb;
}

.restaurant-card-footer a,
.restaurant-card-footer button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink);
  background: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  text-decoration: none;
}

.restaurant-card-footer button.save-restaurant {
  border-color: var(--deep);
  color: #fff;
  background: var(--deep);
}

.restaurant-card-footer button.record-payment {
  border-color: #f2c6aa;
  color: #a6491c;
  background: var(--warm-soft);
}

.restaurant-card[hidden] {
  display: none;
}

.table-panel {
  overflow: hidden;
}

.responsive-table {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 15px 18px;
  border-bottom: 1px solid #e9eeeb;
  font-size: 0.73rem;
  text-align: left;
}

.data-table th {
  /* 5.21:1 on the #fafbfa header band. Was #71817e at 3.94:1. */
  color: #5f6d6b;
  background: #fafbfa;
  font-size: 0.62rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table td strong,
.data-table td small {
  display: block;
}

.data-table td small {
  margin-top: 3px;
  color: var(--muted);
}

.notice-item {
  align-items: flex-start;
}

.notice-copy {
  flex: 1;
}

.notice-copy > small {
  margin-top: 8px;
}

.notice-meta {
  min-width: 150px;
  margin-left: auto;
  color: var(--muted);
  font-size: 0.68rem;
  text-align: right;
}

.portal-dialog {
  width: min(94vw, 650px);
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: transparent;
}

.portal-dialog::backdrop {
  background: rgba(7, 35, 39, 0.72);
  backdrop-filter: blur(5px);
}

.dialog-card {
  position: relative;
  display: grid;
  gap: 16px;
  max-height: 88vh;
  padding: clamp(26px, 5vw, 42px);
  overflow-y: auto;
  border-radius: 24px;
  background: #fff;
}

.dialog-card h2,
.dialog-card > p {
  margin: 0;
}

.dialog-card h2 {
  font-size: 2rem;
  font-weight: 680;
  letter-spacing: -0.04em;
}

.dialog-card > p:not(.eyebrow) {
  color: var(--muted);
}

.dialog-close {
  position: absolute;
  top: 18px;
  right: 18px;
  display: grid;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  color: var(--muted);
  background: #f1f3f1;
  font-size: 1.35rem;
  place-items: center;
}

.form-grid {
  display: grid;
  gap: 13px;
  grid-template-columns: 1fr 1fr;
}

.portal-toast {
  position: fixed;
  z-index: 200;
  right: 24px;
  bottom: 24px;
  max-width: min(400px, calc(100vw - 48px));
  padding: 14px 18px;
  border-radius: 12px;
  color: #fff;
  background: var(--deep);
  box-shadow: var(--shadow);
  font-size: 0.78rem;
  font-weight: 750;
}

.portal-toast.is-error {
  background: var(--red);
}

.auth-complete-page {
  display: grid;
  padding: 24px;
  place-items: center;
  background: var(--deep);
}

.auth-complete-card {
  width: min(100%, 520px);
  padding: clamp(34px, 7vw, 60px);
  border-radius: 28px;
  background: #fff;
  box-shadow: var(--shadow);
}

.auth-complete-card .loading-mark {
  margin-bottom: 30px;
}

.auth-complete-card h1 {
  margin: 0 0 15px;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 680;
  letter-spacing: -0.05em;
}

.auth-complete-card > p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.65;
}

.auth-complete-card a {
  display: inline-flex;
  margin-top: 18px;
  color: var(--deep);
  font-size: 0.8rem;
  font-weight: 800;
}

@media (max-width: 1180px) {
  .portal-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .portal-sidebar {
    padding-inline: 18px;
  }

  .restaurant-card-body {
    grid-template-columns: 1fr 1fr;
  }

  .restaurant-card-body .control-group:last-child {
    grid-column: 1 / -1;
  }

  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 900px) {
  .login-panel {
    min-height: 100vh;
    padding: 32px 18px;
  }

  .portal-shell {
    display: block;
  }

  .portal-sidebar {
    position: fixed;
    z-index: 30;
    inset: 0 auto 0 0;
    width: 280px;
    transform: translateX(-102%);
    transition: transform 180ms ease;
  }

  .portal-shell.nav-open .portal-sidebar {
    transform: translateX(0);
    box-shadow: 20px 0 60px rgba(4, 27, 30, 0.28);
  }

  .mobile-nav-button {
    display: grid;
    width: 42px;
    height: 42px;
    margin-right: 12px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fff;
    place-items: center;
  }

  .portal-header {
    justify-content: flex-start;
  }

  .owner-identity {
    margin-left: auto;
  }

  .overview-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .login-panel {
    padding-inline: 12px;
  }

  .login-header {
    align-items: flex-start;
  }

  .private-badge {
    font-size: 0.58rem;
  }

  .login-card {
    padding: 30px 24px;
    border-radius: 20px;
  }

  .login-footer {
    padding-inline: 2px;
  }

  .portal-header {
    min-height: 72px;
    padding: 12px 16px;
  }

  .portal-header > div:first-of-type p {
    display: none;
  }

  .owner-identity p {
    display: none;
  }

  .portal-content {
    padding: 26px 14px 50px;
  }

  .page-intro {
    display: grid;
    align-items: start;
  }

  .page-intro h1 {
    font-size: 2.75rem;
  }

  .quiet-button,
  .primary-button.small {
    width: 100%;
  }

  .metric-grid,
  .metric-grid.compact {
    grid-template-columns: 1fr 1fr;
  }

  .metric-card {
    min-height: 142px;
    padding: 18px;
  }

  .metric-card strong {
    margin-top: 18px;
    font-size: 2rem;
  }

  .toolbar {
    display: grid;
  }

  .toolbar select {
    width: 100%;
  }

  .restaurant-card-top {
    align-items: flex-start;
    padding: 18px;
  }

  .restaurant-card-body {
    padding: 18px;
    grid-template-columns: 1fr;
  }

  .restaurant-card-body .control-group:last-child {
    grid-column: auto;
  }

  .restaurant-card-footer {
    flex-wrap: wrap;
    padding: 14px 18px;
  }

  .restaurant-card-footer a,
  .restaurant-card-footer button {
    flex: 1 1 calc(50% - 8px);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .notice-item {
    flex-wrap: wrap;
  }

  .notice-meta {
    width: 100%;
    margin-left: 56px;
    text-align: left;
  }
}

@media (max-width: 420px) {
  .metric-grid,
  .metric-grid.compact,
  .field-pair {
    grid-template-columns: 1fr;
  }

  .status-badge {
    margin-left: 0;
  }

  .restaurant-card-top {
    flex-wrap: wrap;
  }
}

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

/* Zero-code onboarding dialog */
.primary-action {
  padding: 10px 18px;
  border: 0;
  border-radius: 10px;
  background: var(--deep, #112f3a);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.primary-action:hover {
  opacity: 0.92;
}

.dialog-note {
  margin: 4px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 143, 145, 0.08);
  font-size: 12px;
  line-height: 1.5;
}

/* Access & Security */
.access-dialog {
  width: min(94vw, 860px);
}

.access-grid {
  display: grid;
  gap: 16px;
  margin-top: 8px;
  grid-template-columns: 1fr 1fr;
}

.access-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfcfb;
}

.access-card-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 18px 14px;
}

.access-card-head h3 {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 750;
}

.access-card-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.status-pill {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--canvas);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-pill.green {
  color: var(--green);
  background: var(--green-soft);
}

.status-pill.red {
  color: var(--red);
  background: var(--red-soft);
}

.status-pill.amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.access-card-body {
  display: grid;
  gap: 10px;
  padding: 0 18px 16px;
}

.access-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.76rem;
}

.access-meta span {
  color: var(--muted);
}

.access-meta b {
  min-width: 0;
  font-weight: 700;
  text-align: right;
  /* Owner emails and generated codes have no spaces to break at, and would
     otherwise push the dialog wider than a 320px viewport. */
  overflow-wrap: anywhere;
}

.access-note {
  margin: 4px 0 0;
  padding: 9px 11px;
  border-radius: 9px;
  color: #7c4a12;
  background: var(--amber-soft);
  font-size: 0.7rem;
  line-height: 1.5;
}

.access-note.demo-note {
  grid-column: 1 / -1;
  margin: 0 0 4px;
  color: #1d5c63;
  background: var(--warm-soft);
}

.masked-value {
  letter-spacing: 0.18em;
}

.access-card-actions {
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

.access-card-actions button {
  flex: 1 1 0;
}

.danger-outline {
  border-color: #f0cec8 !important;
  color: var(--red) !important;
  background: var(--red-soft) !important;
}

.access-activity {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.access-activity h3 {
  margin: 0;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.access-activity .activity-list {
  max-height: 260px;
  overflow-y: auto;
}

.mode-choice {
  display: grid;
  gap: 10px;
}

.dialog-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 6px;
}

.dialog-actions .primary-button.small,
.dialog-actions .quiet-button {
  width: auto;
}

.danger-button {
  color: #fff !important;
  background: var(--red) !important;
  box-shadow: 0 12px 28px rgba(183, 71, 56, 0.24) !important;
}

.credential-reveal-box {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  border: 1px dashed #c9d6d3;
  border-radius: 14px;
  background: var(--canvas);
}

.credential-reveal-box div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.credential-reveal-box span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.credential-reveal-box b {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 1.05rem;
  letter-spacing: 0.03em;
  user-select: all;
}

@media (max-width: 680px) {
  .access-grid {
    grid-template-columns: 1fr;
  }

  .access-card-actions {
    flex-direction: column;
  }

  .dialog-actions {
    flex-direction: column-reverse;
  }

  .dialog-actions .primary-button.small,
  .dialog-actions .quiet-button {
    width: 100%;
  }

  .access-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .access-meta b {
    text-align: left;
  }
}

/* The collection worksheet: the list the owner works down when chasing
   money. Overdue rows are meant to be findable at a glance from across a
   desk, not read carefully. */
.worksheet-table td small {
  display: block;
  color: var(--muted, #6b7a78);
  font-size: 12px;
}

.worksheet-table tr.is-overdue td {
  background: color-mix(in srgb, #b3423f 6%, transparent);
}

.worksheet-table tr.is-overdue td:first-child {
  box-shadow: inset 3px 0 0 #b3423f;
}

.worksheet-flag {
  display: inline-block;
  padding: 2px 8px;
  border: 1px dashed currentcolor;
  border-radius: 999px;
  font-size: 12px;
  opacity: 0.75;
}

.worksheet-action {
  padding: 7px 12px;
  border: 1px solid var(--line, #dfe5e2);
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.worksheet-action:hover {
  border-color: currentcolor;
}

.portal-dialog label small {
  display: block;
  margin-top: 4px;
  color: var(--muted, #6b7a78);
  font-size: 12px;
}

/* Whether the restaurant has actually read a notice — the fact that matters
   when the notice is a request for payment. */
.notice-state {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
}

.notice-state.seen {
  color: #258563;
}

.notice-state.waiting {
  color: #ba7614;
}

/* Recent uploads. Shown as pictures because the owner is judging pictures —
   a table of filenames would tell him nothing about whether a photo makes
   the restaurant look good. */
.photo-grid {
  display: grid;
  gap: 16px;
  padding: 18px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.photo-card {
  display: grid;
  overflow: hidden;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.photo-card img {
  display: block;
  width: 100%;
  /* The same 3:2 the guest menu uses, so he judges what a guest sees. */
  aspect-ratio: 3 / 2;
  object-fit: cover;
}

.photo-card figcaption {
  display: grid;
  gap: 6px;
  padding: 12px 14px 14px;
}

.photo-card small {
  color: var(--muted);
  font-size: 12px;
}

.photo-card .danger-action {
  justify-self: start;
  margin-top: 4px;
}

/* Already superseded by a newer photo: kept visible so he can see it was
   dealt with, dimmed so he does not chase it. */
.photo-card.is-replaced {
  opacity: 0.55;
}

.photo-replaced {
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

/* --- Restaurant enquiries (public onboarding form leads) --- */

.enquiry-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 14px;
  /* A light checkable surface so a transparent logo reads against anything. */
  background: #f2f6fc;
  margin-bottom: 12px;
}

.enquiry-contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.enquiry-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 22px;
}

.enquiry-detail-grid > div > span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
}

.enquiry-detail-grid > div > p {
  margin: 3px 0 0;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.enquiry-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.enquiry-photos img {
  width: 110px;
  height: 110px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.enquiry-actions {
  align-items: center;
  flex-wrap: wrap;
  margin-top: 18px;
}

.enquiry-status-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.enquiry-status-control select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font: inherit;
}

@media (max-width: 680px) {
  .enquiry-detail-grid { grid-template-columns: 1fr; }
}
