:root {
  --bg: #f3f5f8; --card: #fff; --ink: #1c2530; --muted: #6b7785; --line: #dfe4ea;
  --brand: #0f4c81; --brand-ink: #fff; --danger: #b3261e;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); }
.pre { white-space: pre-wrap; }

.shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: #14263a; color: #dbe4ee; padding: 1.25rem 1rem; display: flex; flex-direction: column; }
.brand { font-size: 1.3rem; font-weight: 700; color: #fff; }
.brand span { color: #5fb3ff; }
.company { margin: .25rem 0 1.25rem; font-size: .85rem; color: #9fb2c6; }
.sidebar nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.sidebar nav a { color: #dbe4ee; text-decoration: none; padding: .5rem .65rem; border-radius: 6px; }
.sidebar nav a:hover { background: #1f3752; }
.sidebar nav a.cta { background: var(--brand); color: #fff; margin: .5rem 0; text-align: center; }
.logout { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; }
.content { padding: 1.5rem 2rem; max-width: 1150px; width: 100%; min-width: 0; }
.content.narrow { margin: 2rem auto; max-width: 720px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 1.1rem 1.25rem; margin-bottom: 1.1rem; }
.card.auth { max-width: 420px; margin: 3rem auto; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.actions form { margin: 0; }

.btn, button.link { font: inherit; cursor: pointer; }
.btn { display: inline-block; padding: .45rem .9rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); text-decoration: none; }
.btn:hover { background: #eef2f6; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: #0c3d68; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
button.link { background: none; border: 0; color: #9fd0ff; text-decoration: underline; padding: 0; }

.flash { padding: .65rem 1rem; border-radius: 6px; margin-bottom: 1rem; background: #e6f0fa; }
.flash.success { background: #e3f4e6; } .flash.error { background: #fbe5e3; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.num { text-align: right; }
tr.deleted td { opacity: .4; text-decoration: line-through; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #e5e9ee; }
.badge.submitted { background: #fff0c9; } .badge.approved { background: #d9f2de; } .badge.rejected { background: #fbd9d6; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1.1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .9rem 1rem; text-decoration: none; color: var(--muted); display: block; }
.stat span { display: block; font-size: 1.6rem; font-weight: 700; color: var(--ink); }

.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.field { margin-bottom: .8rem; }
.field label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: .45rem .55rem; border: 1px solid #c8d0d9; border-radius: 6px; font: inherit; background: #fff;
}
.filters input, .filters select { width: auto; }
td input, td select { min-width: 80px; }
.errorlist { list-style: none; margin: .2rem 0 0; padding: 0; color: var(--danger); font-size: .85rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.span-2 { grid-column: span 2; }

.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .8rem 1.5rem; margin: 0; }
.details dt { font-size: .75rem; text-transform: uppercase; color: var(--muted); }
.details dd { margin: 0; }

.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .8rem; margin: 1rem 0; }
.module-card { display: flex; flex-direction: column; gap: .25rem; border: 1px solid var(--line); border-radius: 8px; padding: .8rem; cursor: pointer; background: #fafbfc; }
.module-card:has(input:checked) { border-color: var(--brand); background: #eaf3fb; }
.module-card input { align-self: flex-start; }
.module-card .price { color: var(--brand); font-weight: 600; }
.total { font-size: 1.05rem; }

@media (max-width: 800px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { padding: .75rem 1rem; gap: .35rem; }
  .sidebar .brand, .sidebar .company { display: inline-block; margin: 0 .6rem 0 0; }
  .sidebar nav { flex: none; flex-direction: row; overflow-x: auto; gap: .25rem; padding-bottom: .25rem; }
  .sidebar nav { scrollbar-width: none; }
  .sidebar nav a { white-space: nowrap; }
  .sidebar nav a.cta { margin: 0; }
  .sidebar .pw { padding: 0; }
  .logout { gap: .9rem; justify-content: flex-start; }
  .content { padding: 1rem; }
  .grid-2 { grid-template-columns: 1fr; } .span-2 { grid-column: auto; }
  table { display: block; overflow-x: auto; }
}
.card.narrow-card { max-width: 560px; }
.sidebar .pw { color: #9fb2c6; font-size: .85rem; text-decoration: none; padding: 0 .65rem .5rem; }
.sidebar .pw:hover { color: #fff; }
.field small { display: block; margin-top: .2rem; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .55rem 1rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
form.inline { display: inline; margin: 0 0 0 .6rem; }
.link-danger { background: none; border: 0; color: var(--danger); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; margin: .6rem 0 1rem; }
.photo-grid:empty { display: none; }
.photo-tile { display: flex; flex-direction: column; gap: .35rem; border: 1px solid var(--line); border-radius: 8px; padding: .5rem; background: #fafbfc; }
.photo-tile img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; display: block; }
.photo-tile .remove { font-size: .85rem; color: var(--danger); }
.file-chip { display: block; padding: 1.5rem .5rem; text-align: center; background: #eef2f6; border-radius: 6px; word-break: break-all; font-size: .85rem; }
.photo-buttons .btn { padding: .7rem 1.1rem; }
.totals { margin-left: auto; max-width: 320px; }
.totals div { display: flex; justify-content: space-between; padding: .2rem 0; }
.totals .grand { border-top: 1px solid var(--line); margin-top: .3rem; padding-top: .4rem; font-size: 1.1rem; font-weight: 700; }

.sig-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.sig-slot { border: 1px solid var(--line); border-radius: 8px; padding: .8rem; background: #fafbfc; }
.sig-slot h3 { margin: 0 0 .5rem; }
.sig-img { display: block; max-width: 100%; max-height: 110px; background: #fff; border-bottom: 1px solid var(--ink); }
.sig-pad { display: block; width: 100%; height: 160px; background: #fff; border: 1px dashed #98a4b3; border-radius: 6px; touch-action: none; cursor: crosshair; margin: .5rem 0; }
.sig-form summary { cursor: pointer; color: var(--brand); font-weight: 600; margin-bottom: .3rem; }
.stale { color: var(--danger); font-size: .85rem; }
.presets { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: 1rem; }
.progress { height: 10px; background: #e5e9ee; border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--brand); }
.setup-step { display: flex; align-items: center; gap: 1rem; }
.setup-step h2 { margin: 0 0 .2rem; font-size: 1.05rem; }
.setup-step p { margin: 0; }
.setup-body { flex: 1; min-width: 0; }
.setup-mark { flex: none; width: 2rem; height: 2rem; border-radius: 50%; border: 2px solid var(--line); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.setup-step.done .setup-mark { background: #d9f2de; border-color: #7cc28a; color: #1f6b30; }
@media (max-width: 800px) { .setup-step { flex-wrap: wrap; } .setup-body { flex-basis: calc(100% - 3rem); } }
.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid #c8d0d9; border-radius: 6px; overflow: hidden; }
.segmented label { margin: 0; color: var(--ink); font-size: .9rem; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: .5rem .9rem; background: #fff; }
.segmented label + label span { border-left: 1px solid #c8d0d9; }
.segmented input:checked + span { background: var(--brand); color: var(--brand-ink); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: -2px; }

@media (max-width: 800px) {
  /* Ticket entry rows become labelled cards, so nothing scrolls sideways on a phone. */
  .formset table { overflow: visible; }
  .formset thead { display: none; }
  .formset tbody, .formset tr, .formset td { display: block; }
  .formset tr { border: 1px solid var(--line); border-radius: 8px; padding: .4rem .7rem; margin-bottom: .7rem; background: #fafbfc; }
  .formset td { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: .5rem; align-items: center; padding: .3rem 0; border: 0; }
  .formset td::before { content: attr(data-label); font-size: .8rem; color: var(--muted); }
  .formset td input[type=checkbox] { justify-self: start; width: 1.2rem; height: 1.2rem; }
  .formset td .errorlist { grid-column: 2; }
}
@media (max-width: 600px) { .hide-sm { display: none; } }
details.card > summary { cursor: pointer; font-weight: 600; font-size: 1.05rem; }
details.card[open] > summary { margin-bottom: .6rem; }
.banner { padding: .6rem 1rem; border-radius: 6px; margin-bottom: 1rem; background: #fff4d6; border: 1px solid #f0d78c; }
.banner.expired { background: #fbe5e3; border-color: #e6a8a2; }
.banner a { font-weight: 600; margin-left: .4rem; }
.site-footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }
.sidebar .logo img { display: block; max-width: 100%; max-height: 56px; }
@media print { .site-footer { display: none; } }