* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  background: var(--page);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
i { font-style: italic; }
code { font-family: ui-monospace, Menlo, monospace; background: var(--tone-1); padding: 1px 5px; border-radius: 4px; font-size: .9em; }

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 6px; z-index: 50; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 24px 20px 64px; }
.muted { color: var(--text-quiet); }
.fine { color: var(--text-quiet); font-size: 12.5px; }
.page-title { font-family: var(--font-display); font-weight: 700; font-size: 30px; margin: 4px 0 20px; }

/* ---- App bar ---- */
.appbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--text); }
.brand i { color: var(--red); font-weight: 500; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav-link { padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; }
.nav-link:hover { background: var(--tone-1); text-decoration: none; }
.nav-link.is-active { color: var(--red); background: var(--active-tint); }
.appbar-right { display: flex; align-items: center; gap: 14px; }
.user { display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600; }
.user-name { font-size: 14px; }
.theme-toggle { font-size: 18px; line-height: 1; }

/* ---- Buttons ---- */
.btn, .btn-primary, .btn-quiet { font-family: inherit; font-size: 14px; font-weight: 500; border-radius: var(--radius-sm); padding: 8px 14px; cursor: pointer; border: 1px solid var(--rule-strong); background: var(--surface); color: var(--text); transition: background var(--t); }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-hover); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-quiet:hover { background: var(--tone-1); }
.btn[disabled], .btn-primary[disabled] { opacity: .5; cursor: not-allowed; }
.sm { padding: 5px 10px; font-size: 13px; }
.btn-x { border: none; background: transparent; color: var(--text-quiet); font-size: 18px; cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 4px; }
.btn-x:hover { background: var(--active-tint); color: var(--danger); }

/* ---- Fields ---- */
.sel, input[type="date"], input[type="number"], input[type="text"] {
  font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--field); border: 1px solid var(--field-border); border-radius: var(--radius-sm); padding: 7px 9px;
}
.sel { max-width: 100%; }
.sel:focus, input:focus { outline: none; box-shadow: var(--focus); border-color: var(--red); }
label { font-size: 13px; color: var(--text-2); }

/* ---- Toolbar / subnav / weekbar ---- */
.toolbar { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar label { display: flex; flex-direction: column; gap: 4px; }
.subnav { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 20px; }
.subnav-link { padding: 8px 12px; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subnav-link:hover { text-decoration: none; color: var(--text); }
.subnav-link.is-active { color: var(--red); border-bottom-color: var(--red); }
.weekbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.week-nav { display: flex; align-items: center; gap: 8px; }
.week-title { font-family: var(--font-display); font-weight: 700; font-size: 20px; min-width: 240px; }
.viewas { display: flex; align-items: center; gap: 8px; }

/* ---- Tables ---- */
.tbl { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.tbl th, .tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--rule); }
.tbl thead th { background: var(--surface-2); font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-quiet); }
.tbl tfoot td { font-weight: 600; background: var(--surface-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 8px; }

/* ---- The weekly grid ---- */
.grid-scroll { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); }
table.grid { width: 100%; border-collapse: collapse; min-width: 900px; }
table.grid th, table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.grid thead th { background: var(--surface-2); position: sticky; top: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-quiet); }
.col-cust { min-width: 180px; } .col-item { min-width: 220px; } .col-bill { width: 110px; }
.col-day { width: 68px; text-align: center; }
.col-date { display: block; font-size: 10px; color: var(--text-quiet); font-weight: 400; }
.col-total { width: 70px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.col-x { width: 36px; }
input.hr { width: 56px; text-align: center; padding: 6px 4px; }
.day-total, .grand { font-variant-numeric: tabular-nums; }
table.grid tfoot td { background: var(--surface-2); font-weight: 600; }
.foot-label { text-align: right; color: var(--text-quiet); text-transform: uppercase; font-size: 12px; letter-spacing: .03em; }
.class-tag { display: block; font-size: 11px; color: var(--text-quiet); margin-top: 2px; }
.auto { font-style: italic; }
.bill { font-size: 12px; padding: 2px 8px; border-radius: 20px; display: inline-block; }
.bill.yes { background: var(--ok-tint); color: var(--ok); }
.bill.no { background: var(--tone-1); color: var(--text-quiet); }
.sel-bill { width: 100%; }
.grid-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.grid-actions .spacer { flex: 1; }

/* ---- Banners / state ---- */
.banner { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 14px; }
.banner.info { background: var(--info-tint); color: var(--info); }
.banner.ok { background: var(--ok-tint); color: var(--ok); }
.banner.warn { background: var(--warn-tint); color: var(--warn); }

/* ---- Editors (admin) ---- */
.editor { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; transition: box-shadow var(--t); }
.editor.saved { box-shadow: 0 0 0 2px var(--ok); }
.editor h3 { margin: 0 0 12px; font-size: 16px; }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 16px; margin-bottom: 14px; }
.checklist label { display: flex; align-items: center; gap: 8px; color: var(--text); }
.assigned { max-width: 360px; }

/* ---- Placeholder / loading / signin / toast ---- */
.placeholder { text-align: center; padding: 64px 20px; color: var(--text-quiet); }
.placeholder h2 { font-family: var(--font-display); color: var(--text); }
.loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 64px; color: var(--text-quiet); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--rule-strong); border-top-color: var(--red); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.signin { min-height: 70vh; display: grid; place-items: center; }
.signin-card { text-align: center; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 48px 56px; box-shadow: var(--shadow); }
.brand-lg { font-family: var(--font-display); font-weight: 700; font-size: 34px; margin: 0 0 4px; }
.brand-lg i { color: var(--red); font-weight: 500; }
.signin-card .btn-primary { margin-top: 18px; font-size: 15px; padding: 10px 20px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--page); padding: 10px 18px; border-radius: 20px; font-size: 14px; box-shadow: var(--shadow); z-index: 60; }

/* ---- Footer ---- */
.footer { border-top: 1px solid var(--rule); padding: 20px; text-align: center; color: var(--text-quiet); font-size: 13px; }
.footer-mark { font-family: var(--font-display); }
.footer-mark i { color: var(--red); }
