/* ── SKOOP MEASURE — standalone stylesheet (no dependency on styles.css) ──
   Same palette as the dashboard / inventory page, re-declared here so measure.html
   never has to load styles.css (which carries the whole dashboard). Mobile-first:
   the measurer holds a phone in one hand and a tape in the other, so every tap
   target is ≥44px and the Save button is thumb-height. */

:root {
  --bg: #f4f5f7;
  --sidebar: #0f172a;
  --nav: #1e293b;
  --surface: #ffffff;
  --surface2: #f9fafb;
  --border: #e5e7eb;
  --border2: #d1d5db;
  --accent: #1d4ed8;
  --accent2: #1e40af;
  --accent-light: #eff6ff;
  --green: #15803d;
  --green2: #16a34a;
  --green-bg: #dcfce7;
  --green-border: #bbf7d0;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --red-border: #fecaca;
  --gold: #d97706;
  --gold-bg: #fef3c7;
  --gold-border: #fde68a;
  --gold-text: #92400e;
  --text: #111827;
  --text2: #6b7280;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);
}
/* Dark mode is a class on <html>, set before paint by the head script — from the
   shared skoop_theme key if the user ever chose, else from prefers-color-scheme. */
html.dark-mode {
  --bg: #111827;
  --surface: #1e293b;
  --surface2: #152032;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);
  --text: #f1f5f9;
  --text2: #94a3b8;
  --accent-light: rgba(59,130,246,0.12);
  --green-bg: rgba(21,128,61,0.18);
  --green-border: rgba(34,197,94,0.25);
  --red-bg: rgba(185,28,28,0.18);
  --red-border: rgba(239,68,68,0.25);
  --gold-bg: rgba(217,119,6,0.18);
  --gold-border: rgba(253,230,138,0.2);
  --gold-text: #fbbf24;
  --shadow: 0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --shadow-md: 0 4px 6px rgba(0,0,0,.4), 0 2px 4px rgba(0,0,0,.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Poppins', system-ui, sans-serif; background: var(--bg); color: var(--text);
  min-height: 100vh; -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font-family: inherit; -webkit-tap-highlight-color: transparent; }
input, select { font-family: inherit; }

/* ── AUTH ── */
#m-auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); padding: 20px; }
html.restoring #m-auth { display: none; }
.auth-card { background: var(--surface); border: 1px solid var(--border2); border-radius: 20px; padding: 32px 24px; width: 100%; max-width: 360px; box-shadow: var(--shadow-md); text-align: center; }
.auth-logo { width: 130px; height: auto; display: block; margin: 0 auto 14px; }
.auth-title { font-family: 'Nunito', sans-serif; font-size: 22px; font-weight: 800; margin-bottom: 4px; color: var(--text); }
.auth-sub { font-size: 13px; color: var(--text2); margin-bottom: 22px; }
.auth-label { font-size: 12px; color: var(--text2); text-align: left; margin-bottom: 5px; font-weight: 500; letter-spacing: 0.5px; text-transform: uppercase; }
.auth-input { width: 100%; min-height: 48px; padding: 11px 14px; background: var(--surface2); border: 1.5px solid var(--border2); border-radius: var(--radius-sm); color: var(--text); font-size: 16px; margin-bottom: 14px; outline: none; transition: border-color 0.15s; }
.auth-input:focus { border-color: var(--accent); }
.auth-btn { width: 100%; min-height: 50px; padding: 13px; background: var(--accent); color: white; border: none; border-radius: var(--radius-sm); font-family: 'Nunito', sans-serif; font-size: 17px; font-weight: 800; cursor: pointer; transition: background 0.2s; margin-top: 4px; }
.auth-btn:hover { background: var(--accent2); }
.auth-btn:disabled { opacity: .6; cursor: default; }
.auth-error { color: var(--red); font-size: 13px; margin-top: 12px; display: none; line-height: 1.4; }
.auth-note { color: var(--text2); font-size: 12px; margin-top: 14px; line-height: 1.4; display: none; }

/* ── APP SHELL ── */
#m-app { display: none; min-height: 100vh; }
html.restoring #m-app { display: block; }

.m-header {
  background: var(--sidebar); color: white;
  padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.m-header-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.m-logo { height: 28px; width: auto; flex: none; }
.m-title { font-family: 'Nunito', sans-serif; font-size: 16px; font-weight: 900; line-height: 1.1; }
.m-school-name { font-size: 12px; color: rgba(255,255,255,0.65); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
#m-school {
  display: none; min-height: 36px; padding: 6px 28px 6px 10px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.08) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center;
  color: white; border: 1px solid rgba(255,255,255,0.15); font-size: 13px; font-weight: 500;
  appearance: none; -webkit-appearance: none; max-width: 48vw;
}
#m-school option { color: #111; }
body.m-can-switch #m-school { display: block; }
body.m-can-switch .m-school-name { display: none; }
.m-header-right { display: flex; align-items: center; gap: 8px; }
.icon-btn { background: none; border: 1px solid rgba(255,255,255,0.14); color: rgba(255,255,255,0.7); width: 36px; height: 36px; border-radius: var(--radius-sm); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { border-color: rgba(255,255,255,0.4); color: white; }
.icon-btn.logout:hover { border-color: #f87171; color: #f87171; }
.m-user { font-size: 12px; color: rgba(255,255,255,0.7); background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.12); border-radius: 20px; padding: 4px 10px; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── SYNC PILL ── exactly one of two states; never a bare spinner */
.m-sync { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px 16px 28px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.m-sync.ok { color: var(--text2); }
.m-sync.wait { color: var(--gold-text); }
.m-sync .m-sync-retry { display: none; border: 1px solid currentColor; background: transparent; color: inherit; border-radius: 14px; padding: 3px 10px; font-size: 12px; font-weight: 700; cursor: pointer; min-height: 24px; }
.m-sync.wait .m-sync-retry { display: inline-block; }
.m-sync .m-sync-retry:disabled { opacity: .5; }

/* ── DISABLED / ERROR NOTICE ── */
#m-disabled { display: none; margin: 40px auto; max-width: 420px; padding: 0 20px; text-align: center; color: var(--text2); font-size: 15px; line-height: 1.5; }
#m-disabled .m-notice-icon { font-size: 40px; margin-bottom: 10px; }
#m-disabled button { margin-top: 16px; }

/* ── TABS ── */
.m-tabs { display: none; background: var(--nav); padding: 0 14px; }
.m-tab { flex: 1; padding: 13px 10px; font-size: 14px; font-weight: 600; color: rgba(255,255,255,0.5); cursor: pointer; border: none; background: none; border-bottom: 3px solid transparent; transition: color 0.15s; min-height: 48px; }
.m-tab:hover { color: rgba(255,255,255,0.85); }
.m-tab.active { color: white; border-bottom-color: #3b82f6; }
body.m-ready .m-tabs { display: flex; }
.m-tab-content { display: none; padding: 16px 14px 30px; max-width: 640px; margin: 0 auto; }
.m-tab-content.active { display: block; }

/* ── MEASURE FORM ── */
.m-field { margin-bottom: 16px; }
.m-label { font-size: 12px; text-transform: uppercase; color: var(--text2); font-weight: 600; letter-spacing: 0.4px; margin-bottom: 7px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.m-label .m-label-val { text-transform: none; letter-spacing: 0; color: var(--accent); font-weight: 700; }
.m-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.m-pill {
  min-height: 44px; min-width: 52px; padding: 0 14px; border-radius: 22px;
  border: 1.5px solid var(--border2); background: var(--surface); color: var(--text);
  font-size: 15px; font-weight: 600; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; justify-content: center; transition: background 0.1s, border-color 0.1s;
}
.m-pill:active { transform: scale(0.97); }
.m-pill.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.m-pills.m-pills-empty { font-size: 13px; color: var(--text2); font-style: italic; }
.m-input { width: 100%; min-height: 50px; font-size: 17px; padding: 10px 14px; background: var(--surface); border: 1.5px solid var(--border2); border-radius: var(--radius-sm); color: var(--text); outline: none; transition: border-color 0.15s; }
.m-input:focus { border-color: var(--accent); }
.m-input-row { display: grid; grid-template-columns: 1fr 120px; gap: 10px; }
.m-dup { display: none; margin-top: 8px; background: var(--gold-bg); border: 1px solid var(--gold-border); color: var(--gold-text); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13px; line-height: 1.4; }
.m-dup.show { display: block; }
.m-dup a { color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
.m-product { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; box-shadow: var(--shadow); }
.m-product .m-label { margin-bottom: 9px; }
.m-edit-banner { display: none; align-items: center; justify-content: space-between; gap: 10px; background: var(--accent-light); border: 1px solid var(--accent); color: var(--accent); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; font-weight: 600; margin-bottom: 14px; }
.m-edit-banner.show { display: flex; }
.m-edit-banner button { border: 1px solid currentColor; background: transparent; color: inherit; border-radius: 14px; padding: 5px 12px; font-size: 12px; font-weight: 700; cursor: pointer; min-height: 32px; }
.m-save { width: 100%; min-height: 56px; font-family: 'Nunito', sans-serif; font-size: 18px; font-weight: 800; background: var(--green2); color: #fff; border: none; border-radius: var(--radius); cursor: pointer; margin-top: 4px; box-shadow: var(--shadow-md); }
.m-save:disabled { opacity: 0.4; cursor: default; box-shadow: none; }
.m-save:not(:disabled):active { transform: scale(0.99); }
.m-last { display: none; margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; line-height: 1.45; background: var(--surface2); border: 1px solid var(--border); color: var(--text2); }
.m-last.show { display: block; }
.m-last b { color: var(--text); }
.m-last.synced { background: var(--green-bg); border-color: var(--green-border); color: var(--green); }
.m-last.synced b { color: inherit; }
.m-last.waiting { background: var(--gold-bg); border-color: var(--gold-border); color: var(--gold-text); }
.m-last.waiting b { color: inherit; }
.m-form-lock { display: none; font-size: 13px; color: var(--text2); padding: 12px; text-align: center; }

/* ── RECORDS ── */
.m-search { margin-bottom: 8px; }
.m-rec-summary { font-size: 12px; color: var(--text2); margin-bottom: 12px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.m-rec-note { font-size: 12px; color: var(--gold-text); background: var(--gold-bg); border: 1px solid var(--gold-border); border-radius: var(--radius-sm); padding: 8px 10px; margin-bottom: 12px; display: none; }
.m-rec-note.show { display: block; }
.rec-class { margin-top: 18px; }
.rec-class:first-child { margin-top: 0; }
.rec-class-title { font-family: 'Nunito', sans-serif; font-size: 15px; font-weight: 800; display: flex; justify-content: space-between; align-items: baseline; }
.rec-class-title span { font-family: 'Poppins', sans-serif; font-size: 12px; font-weight: 500; color: var(--text2); }
.rec-section-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text2); margin: 10px 0 6px; }
.rec-row { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; display: flex; gap: 10px; align-items: flex-start; box-shadow: var(--shadow); }
.rec-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex-shrink: 0; }
.rec-edit { min-height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.rec-edit:active { background: var(--border); }
.rec-main { flex: 1; min-width: 0; }
.rec-name { font-weight: 600; font-size: 15px; word-break: break-word; }
.rec-roll { color: var(--text2); font-size: 12px; font-weight: 500; }
.rec-sizes { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 6px; }
.rec-size { font-size: 12px; font-weight: 600; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; }
.rec-size.empty { color: var(--text2); font-weight: 400; font-style: italic; }
.rec-meta { font-size: 11px; color: var(--text2); margin-top: 5px; line-height: 1.4; }
.rec-err { color: var(--red); font-size: 12px; margin-top: 5px; font-weight: 500; }
.rec-status { flex: none; font-size: 15px; line-height: 1; padding-top: 2px; }
.rec-status.ok { color: var(--green); }
.rec-status.wait { color: var(--gold); }
.rec-status.err { color: var(--red); }
.m-empty { text-align: center; padding: 40px 20px; color: var(--text2); font-size: 14px; line-height: 1.5; }
.m-empty .m-empty-icon { font-size: 34px; margin-bottom: 10px; }

/* ── BUTTONS ── */
.btn-primary { padding: 10px 18px; min-height: 44px; background: var(--accent); color: white; border: none; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-primary:hover { background: var(--accent2); }

/* ── TOAST (id matches js/utils.js showToast) ── */
#toast { position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: #1e293b; color: white; padding: 12px 20px; border-radius: 10px; font-size: 14px; font-weight: 500; box-shadow: 0 4px 20px rgba(0,0,0,0.25); opacity: 0; pointer-events: none; transition: opacity 0.25s; z-index: 9999; max-width: 92vw; text-align: center; line-height: 1.4; }
#toast.show { opacity: 1; }
#toast.ok { background: var(--green); }
#toast.err { background: var(--red); }

@media (min-width: 640px) {
  .m-header { padding: 12px 24px; }
  .m-tabs { padding: 0 24px; }
  .m-tab { flex: none; padding: 14px 22px; }
  .m-tab-content { padding: 22px 24px 40px; }
  .m-school-name { max-width: none; }
}
