/* Circus Arts Conservatory brand: logo red and gold on warm cream; Oswald + Lato. */
@font-face {
  font-family: "Lato";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/lato-400.woff2") format("woff2");
}
@font-face {
  font-family: "Lato";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/lato-700.woff2") format("woff2");
}
@font-face {
  font-family: "Oswald";
  font-style: normal;
  font-weight: 500 600;
  font-display: swap;
  src: url("/fonts/oswald.woff2") format("woff2");
}

:root {
  --brand: #e3173e;
  --brand-dark: #c4122f;
  --gold: #fdb924;
  --gold-dark: #e6a30f;
  --gold-tint: #fff3d1;
  --bg: #fffbf3;
  --card: #ffffff;
  --text: #16161a;
  --muted: #6a675f;
  --border: #ebe4d3;
  --primary: var(--brand);
  --primary-dark: var(--brand-dark);
  --green: #16a34a;
  --green-bg: #dcfce7;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --red: var(--brand);
  --font-body: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-head: "Oswald", "Arial Narrow", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
}

button, input, select, textarea { font-family: inherit; }
a { color: var(--primary); }

.search-form button {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}
.search-form button:hover { border-color: var(--brand); }

h1, h2, h3 { font-family: var(--font-head); font-weight: 600; letter-spacing: 0.01em; }

:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.sidebar :focus-visible, .mobile-bar :focus-visible { outline-color: #fff; }

/* Sidebar navigation */
:root { --sidebar-w: 248px; --sidebar-bg: var(--brand); }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  overflow-y: auto;
  z-index: 40;
}
body:has(> .sidebar) { padding-left: var(--sidebar-w); }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 18px;
  color: #fff;
  text-decoration: none;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg);
  display: grid;
  place-items: center;
  flex: none;
}
.brand-mark img { width: 26px; height: 26px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: var(--font-head); font-weight: 600; font-size: 1.15rem; letter-spacing: 0.04em; text-transform: uppercase; }
.brand-org { font-size: 0.68rem; color: #fff; letter-spacing: 0.02em; margin-top: 3px; }
.sidebar svg, .mobile-bar svg {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sidebar-section {
  margin: 18px 10px 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
}
.side-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  margin: 2px 0;
  border-radius: 8px;
  color: #fff;
  text-decoration: none;
  font-size: 0.93rem;
}
.side-link:hover { background: rgba(0, 0, 0, 0.14); color: #fff; }
.side-link.active { background: rgba(0, 0, 0, 0.24); color: #fff; font-weight: 700; }
.side-link.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: #fff;
}
.side-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.35);
}
.user-card { display: flex; align-items: center; gap: 10px; padding: 6px 10px 10px; }
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--text);
  display: grid;
  place-items: center;
  font-weight: 700;
  text-transform: uppercase;
}
.user-name { color: #fff; font-size: 0.9rem; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.user-role { color: #fff; font-size: 0.75rem; text-transform: capitalize; }
.sidebar-footer form { margin: 0; }
.side-btn {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.inline-form { display: flex; gap: 8px; align-items: center; margin: 0; }
.inline-form input { min-width: 170px; }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; font: inherit; font-size: 0.85rem; padding: 0; }
.narrow-form { max-width: 460px; }
.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  margin: 14px 0;
  border: 1px solid #dadce0;
  border-radius: 8px;
  background: #fff;
  color: #3c4043;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
}
.google-btn:hover { background: #f8f9fa; }
.or-divider { display: flex; align-items: center; gap: 10px; margin: 6px 0 14px; color: var(--muted); font-size: 0.8rem; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.credit { margin-top: 10px; padding: 0 10px; font-size: 0.7rem; color: #fff; letter-spacing: 0.02em; }
.credit-page { text-align: center; margin: 14px 0 0; padding: 0; color: var(--muted); }

.auth-brand { text-align: center; margin: 18px 0 16px; }
.auth-brand img { display: block; margin: 0 auto 10px; }
.auth-brand-name { font-family: var(--font-head); font-weight: 600; font-size: 1.6rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--brand); line-height: 1.1; }
.auth-brand-org { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }
.scan-card { border-top: 4px solid var(--gold); }

.mobile-bar { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 860px) {
  body:has(> .sidebar) { padding-left: 0; }
  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 30;
    padding: 10px 14px;
    background: var(--sidebar-bg);
    color: #fff;
  }
  .mobile-brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
  .mobile-brand .brand-mark { width: 32px; height: 32px; }
  .mobile-brand .brand-mark img { width: 21px; height: 21px; }
  .burger {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    color: #fff;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    cursor: pointer;
  }
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: none; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, 0.45); }
  body.nav-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 35;
  }
}
@media print {
  .sidebar, .mobile-bar, .sidebar-backdrop { display: none !important; }
  body:has(> .sidebar) { padding-left: 0; }
}

.container { max-width: 960px; margin: 0 auto; padding: 20px; }
.container.narrow { max-width: 480px; }
.container.viz { max-width: 1100px; }

/* App feel: notches, touch behaviour, no accidental zoom */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: contain; }
a, button, input, select, textarea, label, summary { touch-action: manipulation; }
.sidebar, .mobile-bar, .btn, .side-link, .stat-card, .burger {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.sidebar {
  padding-top: calc(18px + env(safe-area-inset-top));
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
}
.container { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
body:not(:has(> .sidebar)) { padding-top: env(safe-area-inset-top); }
@media (max-width: 860px) {
  .mobile-bar {
    padding-top: calc(10px + env(safe-area-inset-top));
    padding-left: calc(14px + env(safe-area-inset-left));
    padding-right: calc(14px + env(safe-area-inset-right));
  }
  input, select, textarea { font-size: 16px; }
  .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .side-link { min-height: 44px; }
}

.stats-row { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.stat-card {
  flex: 1;
  min-width: 120px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  text-align: center;
}
.stat-num { font-family: var(--font-head); font-size: 1.8rem; font-weight: 600; }
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-in .stat-num { color: var(--green); }
.stat-out .stat-num { color: var(--amber); }

a.stat-card { text-decoration: none; color: inherit; }

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-form { display: flex; gap: 8px; flex: 1; }
.search-form input { flex: 1; }

input, textarea, select {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
}

.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 0.9rem; color: var(--muted); }

.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  max-height: 180px;
  overflow-y: auto;
}
.checkbox-row {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  color: var(--text) !important;
  font-size: 0.95rem !important;
}
.checkbox-row input { width: auto; }

.scan-add { display: flex; flex-direction: column; gap: 8px; }
.field-title { font-size: 0.9rem; color: var(--muted); }
#scan-msg { margin: 0; }
#scan-msg:empty, .chips:empty { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 12px;
  border-radius: 999px;
  background: var(--gold-tint);
  border: 1px solid #f3d488;
  color: #5b4200;
  font-size: 0.88rem;
}
.chip button { border: none; background: none; color: inherit; cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0 4px; }

.btn {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
}
.btn-primary { background: var(--gold); color: var(--text); }
.btn-primary:hover { background: var(--gold-dark); }
.btn-secondary { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: white; color: var(--red); border: 1px solid var(--red); }
.btn-block { width: 100%; }

.action-row { display: flex; gap: 10px; align-items: center; margin: 18px 0; }

.table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 10px; overflow: hidden; }
.table th, .table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.table th { color: var(--muted); font-weight: 700; background: #faf5e8; }
.table a { color: var(--primary); text-decoration: none; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-in { background: var(--green-bg); color: var(--green); }
.badge-out { background: var(--amber-bg); color: var(--amber); }
.badge-overdue { background: #fde3e8; color: #a30f29; }

.stat-overdue .stat-num { color: var(--red); }

.item-header { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 8px; }
.qr-box { text-align: center; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.qr-box img { display: block; margin-bottom: 8px; }
.qr-actions { display: flex; flex-direction: column; gap: 4px; }

.link-small { color: var(--primary); font-size: 0.85rem; text-decoration: none; }
.btn-link-danger { background: none; border: none; color: var(--red); font-size: 0.85rem; cursor: pointer; padding: 0; text-decoration: underline; }
.back-link { display: inline-block; margin-bottom: 12px; color: var(--muted); text-decoration: none; font-size: 0.9rem; }

.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: #a30f29; background: #fde3e8; padding: 8px 12px; border-radius: 8px; }
.success { color: var(--green); background: var(--green-bg); padding: 8px 12px; border-radius: 8px; }
.empty { color: var(--muted); padding: 30px 0; text-align: center; }

.access-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 30px;
  text-align: center;
}
.access-card img { margin: 16px auto; display: block; }
.access-url {
  font-family: monospace;
  font-size: 1rem;
  background: #f6efdc;
  padding: 6px 12px;
  border-radius: 6px;
  display: inline-block;
  word-break: break-all;
}
.access-lead { margin: 0 0 4px; color: var(--muted); }
.access-steps { text-align: left; margin-top: 24px; }
.access-steps ol { padding-left: 20px; }
.access-steps li { margin-bottom: 6px; }

@media print {
  .access-card { border: none; }
}

/* Admin inventory dashboard */
.viz {
  --viz-in: #77726a;
  --viz-out: #e3173e;
  --viz-seq: #e3173e;
  --viz-surface: #fffbf3;
}
.dash-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 760px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }
.dash-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.dash-card h2 { margin: 0 0 2px; font-size: 1rem; }
.dash-card .sub { margin: 0 0 12px; color: var(--muted); font-size: 0.82rem; }
.dash-full { grid-column: 1 / -1; }
.table-scroll { overflow-x: auto; max-width: 100%; }
.table-scroll .table { min-width: 560px; }
.stat-sub { color: var(--muted); font-size: 0.75rem; margin-top: 2px; }

.legend { display: flex; gap: 16px; margin: 0 0 10px; font-size: 0.82rem; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.swatch-in { background: var(--viz-in); }
.swatch-out { background: var(--viz-out); }

.bar-row { display: grid; grid-template-columns: 120px minmax(0, 1fr); align-items: center; gap: 10px; margin: 8px 0; }
.bar-label { font-size: 0.85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-label a { color: inherit; text-decoration: none; }
.bar-label a:hover { color: var(--primary); }
.bar-area { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar { display: flex; gap: 2px; height: 20px; }
.seg { display: block; min-width: 4px; height: 20px; outline: none; }
.seg:last-child { border-radius: 0 4px 4px 0; }
.seg-in { background: var(--viz-in); }
.seg-out { background: var(--viz-out); }
.seg-seq { background: var(--viz-seq); }
.bar-value { font-size: 0.82rem; color: var(--text); }
.seg:focus-visible { box-shadow: 0 0 0 2px var(--viz-surface), 0 0 0 4px var(--text); }

[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: var(--text);
  color: #fff;
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 5;
  pointer-events: none;
}

.dash-card details { margin-top: 10px; font-size: 0.85rem; }
.dash-card summary { cursor: pointer; color: var(--muted); }
.dash-card details table { margin-top: 8px; }
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-list li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.recent-list li:last-child { border-bottom: none; }
.recent-list .when { color: var(--muted); white-space: nowrap; font-size: 0.8rem; }

.scan-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

#reader { width: 100%; border-radius: 10px; overflow: hidden; }

.label {
  width: 260px;
  margin: 40px auto;
  text-align: center;
  border: 1px dashed #999;
  padding: 16px;
  border-radius: 8px;
}
.label-name { font-weight: 700; margin-top: 8px; }
.label-serial { font-size: 0.85rem; margin-top: 2px; }
.label-code { color: var(--muted); font-family: monospace; }

/* Adding many separately tracked units at once */
.unit-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.check-row { flex-direction: row !important; align-items: flex-start; gap: 10px !important; color: var(--text) !important; font-size: 0.95rem !important; }
.check-row input { width: auto; margin-top: 4px; }
.check-row[hidden] { display: none !important; }
.check-row .muted { display: block; font-weight: 400; }
.serial-count { margin: 0; min-height: 1.2em; }
.sub-serial { font-size: 0.75rem; color: var(--muted); margin-top: 1px; }
.serial-line { margin: 0 0 6px; }
.unit-box textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9rem; }
.unit-box textarea:disabled { background: #f6f2e7; color: var(--muted); }

.batch-table input { width: 100%; min-width: 120px; padding: 6px 8px; }
.batch-table td { vertical-align: middle; }

/* Sheet of many labels */
.label-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 0 20px 24px;
}
.label-card {
  border: 1px dashed #999;
  border-radius: 6px;
  padding: 10px 8px;
  text-align: center;
  break-inside: avoid;
  page-break-inside: avoid;
  background: #fff;
}
.label-card img { display: block; margin: 0 auto; }
@media (max-width: 700px) { .label-grid { grid-template-columns: repeat(2, 1fr); } }
@media print {
  .label-grid { padding: 0; gap: 8px; }
  .label-card { border-color: #bbb; }
  body.print-sheet { background: #fff; }
}
.print-toolbar { display: flex; justify-content: space-between; padding: 12px 20px; }
@media print {
  .no-print { display: none; }
  .label { border: none; }
}

h1 { margin-top: 4px; }

/* Item photos */
.photo-field { display: flex; flex-direction: column; gap: 8px; }
.photo-preview { max-width: 220px; max-height: 220px; border-radius: 10px; border: 1px solid var(--border); object-fit: cover; }
.photo-preview[hidden] { display: none; }
.item-photo { max-width: 100%; width: 260px; max-height: 260px; border-radius: 12px; border: 1px solid var(--border); object-fit: cover; display: block; margin: 0 0 12px; }
.scan-card .item-photo { width: 100%; max-width: 320px; }
