:root {
  --bg: #f5f6f2;
  --panel: #ffffff;
  --ink: #121821;
  --muted: #647065;
  --line: #d9e0d6;
  --navy: #0b1528;
  --green: #4e7a3d;
  --gold: #c99332;
  --blue: #2d78b7;
  --red: #b42318;
  --shadow: 0 18px 44px rgba(16, 20, 16, 0.09);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #f6f7f3 0%, #fbfcf8 44%, #f2f5ef 100%);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid var(--navy);
  border-radius: 6px;
  background: var(--navy);
  color: #ffffff;
  font-weight: 900;
  cursor: pointer;
}

button.ghost {
  background: #ffffff;
  color: var(--navy);
}

.admin-page {
  min-height: 100vh;
  padding: clamp(18px, 4vw, 48px);
}

.login-panel,
.panel,
.stats article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-panel {
  width: min(520px, 100%);
  margin: 8vh auto 0;
  padding: clamp(24px, 5vw, 38px);
  border-top: 6px solid var(--green);
}

.login-panel img {
  width: min(100%, 330px);
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  color: var(--navy);
  font-size: clamp(34px, 5vw, 54px);
  line-height: 1;
}

h2 {
  color: var(--navy);
}

p,
.message {
  color: var(--muted);
  line-height: 1.45;
}

form {
  display: grid;
  gap: 12px;
}

.login-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 800;
}

.password-input-wrap {
  position: relative;
  width: 100%;
}

.password-input-wrap input {
  padding-right: 76px;
}

.password-input-wrap .password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  width: auto;
  min-height: 28px;
  padding: 4px 9px;
  transform: translateY(-50%);
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbfcf8;
  color: var(--navy);
  font-size: 12px;
  line-height: 1;
  font-weight: 900;
}

.password-input-wrap .password-toggle:hover {
  border-color: var(--green);
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.admin-shell {
  display: grid;
  gap: 18px;
}

.admin-header,
.panel-head,
.actions,
menu {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 1100px) {
  .admin-shell .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.stats article {
  padding: 18px;
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.stats strong {
  display: block;
  margin-top: 6px;
  color: var(--navy);
  font-size: 32px;
}

.panel {
  padding: clamp(18px, 3vw, 28px);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

a {
  color: var(--blue);
  font-weight: 800;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid #bfd6b9;
  border-radius: 999px;
  background: #e7f2e7;
  color: #315326;
  font-size: 12px;
  font-weight: 900;
}

.badge.warn {
  background: #fff6df;
  color: #9a6216;
  border-color: #ead19a;
}

.badge.danger {
  background: #fff1f0;
  color: var(--red);
  border-color: #ffc7c2;
}

tr.overdue td {
  background: #fff1f0;
}

.inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

dialog {
  width: min(720px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(11, 21, 40, 0.55);
}

.modal-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: min(calc(100svh - 24px), var(--visible-height, 100vh));
  border-top: 6px solid var(--green);
}

dialog { overflow: hidden; max-height: none; }
.modal-head, .modal-card footer { flex: none; padding: 12px 18px; }
.modal-card .modal-head { display: flex; justify-content: space-between; align-items: center; margin: 0; }
.modal-head h2, .modal-card menu { margin: 0; }
.modal-body { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 4px 18px 14px; }
.modal-card footer { border-top: 1px solid var(--line); padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.modal-card fieldset { margin: 0 0 12px; border: 1px solid var(--line); }
#editMessage { margin: 0; color: var(--red); }
#leadHistory li { margin-bottom: 10px; }
#leadDetails:not(:empty) { margin-bottom: 12px; overflow-wrap: anywhere; }
html:has(dialog[open]), body:has(dialog[open]) { overflow: hidden; overscroll-behavior: none; }
.stats [aria-pressed="true"] { border-color: var(--green); background: #edf4e9; }
.panel, .admin-shell { min-width: 0; }
#ownerTools details + details { margin-top: 12px; }
#ownerTools summary { font-weight: bold; cursor: pointer; padding: 8px 0; }
#billingDetails { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; }
#billingDetails dd { margin: 0; font-weight: bold; }
#billingActions { justify-content: flex-start; }
@media (max-width: 760px) {
  .admin-shell .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats button { padding: 8px 3px; font-size: 13px; }
  .table-wrap table { min-width: 0; }
  .table-wrap thead { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
  .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; }
  .table-wrap td { border: 0; padding: 3px; overflow-wrap: anywhere; }
  .table-wrap tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .table-wrap td[data-label]::before { content: attr(data-label) " "; font-weight: bold; }
}

.modal-head {
  margin-bottom: 16px;
}

.modal-head button {
  width: 34px;
  min-height: 34px;
  padding: 0;
}

.detail-grid,
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.detail-grid div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcf8;
}

.detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.detail-grid strong {
  display: block;
  margin-top: 4px;
}

.full-span {
  grid-column: 1 / -1;
}

menu {
  margin: 18px 0 0;
  padding: 0;
  justify-content: flex-end;
}

@media (max-width: 760px) {
  .stats,
  .detail-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }
}

#restaurantWork { margin-bottom: 1rem; }
#restaurantWork summary, #funnel summary { cursor: pointer; font-weight: bold; }
#restaurantWork label { display: grid; gap: 4px; }
#restaurantWork [hidden], [data-overview][hidden] { display: none; }
#workFields { margin: .65rem 0; }
#reportMetrics { display: grid; grid-template-columns: minmax(0,max-content) auto; gap: .3rem 1rem; }
#reportMetrics dd { margin: 0; font-weight: bold; }
#leadHistory ul { padding-left: 1.25rem; overflow-wrap: anywhere; }

.unread { display: inline-block; color: #214b2b; background: #e0f0df; border-radius: .4em; padding: .1em .45em; font-size: .78em; font-weight: 700; }
#employeeList { padding-left: 0; list-style: none; }
#employeeList li { padding: .65rem 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
#employeeList .inline-actions { margin-top: .4rem; flex-wrap: wrap; }
#dayRows li { margin-block: .5rem; overflow-wrap: anywhere; }
