/* GateClear UI. Self-hosted, no external fonts or CDNs (DEP-06).
   Look: black, white and orange with strong contrast. Site settings (header and accent color) arrive from
   /brand.css as --header, --header-2, --on-header, --accent and --accent-dark. */
:root {
  --header: #161616;
  --header-2: #2E2E2E;
  --on-header: #FFFFFF;
  --strong: #161616;
  --strong-2: #2E2E2E;
  --ink: #1A1A1A;
  --muted: #555555;
  --line: #D4D4D4;
  --bg: #EDEDED;
  --card: #FFFFFF;
  --accent: #C94A0C;
  --accent-dark: #9C3A09;
  --accent-soft: #FFF0E6;
  --accent-line: #F2C3A6;
  --accent-hi: #D97A4A;
  --red: #B42318;
  --red-soft: #FDECEA;
  --amber: #8A5A00;
  --amber-soft: #FFF4D6;
  --green: #1E7A3C;
  --green-soft: #E5F4EA;
  --radius: 10px;
  --font: Arial, "Helvetica Neue", Helvetica, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--accent-dark); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-family: var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid #F08A4B; outline-offset: 2px; }

/* --- top bar --------------------------------------------------------- */
.topbar { background: var(--header); color: var(--on-header); border-bottom: 3px solid var(--accent); }
.topbar .wrap { display: flex; align-items: center; gap: 1.5rem; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.25rem; letter-spacing: -.01em; color: var(--on-header); text-decoration: none; }

.nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.nav a { color: var(--on-header); opacity: .85; text-decoration: none; padding: .45rem .75rem; border-radius: 8px; font-size: .95rem; }
.nav a:hover, .nav a.active { background: var(--header-2); opacity: 1; }
.nav a.active { box-shadow: inset 0 -2px 0 var(--accent-hi); }
.nav a.demo { color: var(--accent-hi); opacity: 1; }
.who { font-size: .85rem; color: var(--on-header); display: flex; gap: .75rem; align-items: center; }
.who form { margin: 0; }
.linkbtn { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; text-decoration: underline; padding: 0; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 1rem; }
main.wrap { padding-top: 1.5rem; padding-bottom: 3rem; }
.narrow { max-width: 720px; }

/* --- cards, layout ----------------------------------------------------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.card > h2:first-child { margin-bottom: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.split { display: grid; grid-template-columns: 1.6fr 1fr; gap: 1rem; align-items: start; }
@media (max-width: 760px) { .grid-2, .grid-3, .split { grid-template-columns: 1fr; } }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head p { margin: 0; }

/* --- forms ------------------------------------------------------------- */
.field { margin-bottom: 1rem; }
.field label, .label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.req { color: var(--red); font-weight: 700; }
.opt { color: var(--muted); font-weight: 400; font-size: .8rem; }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid #9E9E9E; border-radius: 8px;
  padding: .6rem .7rem; min-height: 44px;
}
textarea { min-height: 84px; resize: vertical; }
select { appearance: auto; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 3px solid #FAD3BC; outline-offset: 0; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red); }
.error { color: var(--red); font-size: .875rem; margin-top: .3rem; }
.help { color: var(--muted); font-size: .8rem; margin-top: .25rem; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.locked { padding: .6rem .8rem; background: #F2F2F2; border: 1px solid var(--line); border-radius: 8px; font-weight: 600; }
.locked small { display: block; font-weight: 400; color: var(--muted); }
fieldset { border: 0; padding: 0; margin: 0; }
.step { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--strong); color: #fff; font-size: .8rem; font-weight: 700; margin-right: .4rem; }
.section-title { display: flex; align-items: center; font-weight: 700; margin: .5rem 0 .75rem; }
.hidden { display: none !important; }
ul.errorlist { margin: .3rem 0 0; padding: 0; list-style: none; color: var(--red); font-size: .875rem; }
ul.checklist { list-style: none; padding: 0; margin: 0; }
ul.checklist li { margin: .25rem 0; }

/* --- buttons ----------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600;
  border-radius: 8px; padding: .6rem 1rem; min-height: 44px; border: 1px solid #9E9E9E; background: #fff; color: var(--ink);
  text-decoration: none; cursor: pointer; }
.btn:hover { background: #F0F0F0; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-big { font-size: 1.1rem; padding: .85rem 1.5rem; min-height: 54px; width: 100%; }
.btn-danger { color: var(--red); border-color: #E8B4AE; }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { min-height: 34px; padding: .3rem .7rem; font-size: .85rem; }
.btn[disabled] { opacity: .6; cursor: progress; }
.addlink { background: none; border: 0; color: var(--accent-dark); font: inherit; font-weight: 600; cursor: pointer; padding: .25rem 0; }

/* --- alerts and badges ------------------------------------------------- */
.alert { border-radius: var(--radius); padding: .85rem 1rem; margin-bottom: 1rem; border: 1px solid; }
.alert-success { background: var(--green-soft); border-color: #B8DFC4; color: #124D26; }
.alert-error { background: var(--red-soft); border-color: #F2C1BB; color: #7A1A12; }
.alert-warn { background: var(--amber-soft); border-color: #F0D58C; color: #5C3D00; }
.alert-info { background: #F2F2F2; border-color: var(--line); color: var(--ink); }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px;
  background: #E6E6E6; color: var(--ink); white-space: nowrap; }
.badge-issued { background: var(--accent-soft); color: var(--accent-dark); }
.badge-voided { background: var(--red-soft); color: var(--red); }
.badge-accepted { background: #E8F0FB; color: #1D4E89; }
.badge-delivered { background: var(--green-soft); color: var(--green); }
.badge-failed { background: var(--red-soft); color: var(--red); }
.badge-queued, .badge-sending, .badge-retrying { background: var(--amber-soft); color: var(--amber); }

/* --- tables ------------------------------------------------------------ */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; color: #fff; background: var(--strong);
  padding: .55rem .7rem; }
th:first-child { border-top-left-radius: 8px; }
th:last-child { border-top-right-radius: 8px; }
td { padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:nth-child(even) td { background: #F6F6F6; }
.table-wrap { overflow-x: auto; }
td.num, th.num { text-align: right; }

/* --- ticket confirmation ----------------------------------------------- */
.ticket-hero { background: var(--strong); color: #fff; border-radius: var(--radius); padding: 1.25rem 1.5rem; margin-bottom: 1rem;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.ticket-hero .label { color: #BDBDBD; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; margin: 0; }
.ticket-number { font-family: var(--mono); font-size: clamp(1.4rem, 5vw, 2.2rem); overflow-wrap: anywhere; font-weight: 800; letter-spacing: .02em; }
.ticket-hero .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.ticket-hero .btn { background: transparent; color: #fff; border-color: #6B6B6B; }
.ticket-hero .btn:hover { background: var(--strong-2); }
dl.facts { display: grid; grid-template-columns: 170px 1fr; gap: .5rem 1rem; margin: 0; }
dl.facts dt { color: var(--muted); font-size: .875rem; }
dl.facts dd { margin: 0; font-weight: 500; white-space: pre-line; }
@media (max-width: 560px) { dl.facts { grid-template-columns: 1fr; gap: .1rem; } dl.facts dd { margin-bottom: .5rem; } }
.recipient { display: flex; justify-content: space-between; align-items: center; padding: .6rem 0; border-bottom: 1px solid var(--line); gap: .5rem; }
.recipient:last-child { border-bottom: 0; }
.qr { width: 150px; }
.qr svg { width: 100%; height: auto; display: block; }
.qr-small { width: 84px; flex: none; }
.print-staff { display: flex; gap: .75rem; align-items: center; margin-top: .75rem; padding-top: .5rem; border-top: 1px dashed var(--line); }
.print-staff p { margin: 0; }
.pticket-staff { padding: .75rem 1.25rem; border-top: 1px solid var(--line); }
.pticket-staff summary { cursor: pointer; font-weight: 700; }
.pticket-staff .qr { margin: .75rem 0 .25rem; width: 180px; }
.staff-bar { display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--strong); color: #fff; padding: .6rem 1rem; border-radius: 6px; margin-bottom: .75rem; }
.linkbox { display: flex; gap: .5rem; }
.linkbox input { font-family: var(--mono); font-size: .8rem; }

/* --- reports ----------------------------------------------------------- */
.stat { font-size: 2rem; font-weight: 800; }
.stat-sm { font-size: 1.15rem; font-weight: 800; margin: .2rem 0; }
.bars { display: grid; gap: .35rem; }
.bar-row { display: grid; grid-template-columns: 160px 1fr 48px; gap: .6rem; align-items: center; font-size: .875rem; }
.bar { height: 14px; background: #E6E6E6; border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.hours { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; align-items: end; height: 120px; }
.hours div { background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.hours-axis { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; font-size: .65rem; color: var(--muted); text-align: center; }
.w-0{width:0}.w-5{width:5%}.w-10{width:10%}.w-15{width:15%}.w-20{width:20%}.w-25{width:25%}.w-30{width:30%}.w-35{width:35%}
.w-40{width:40%}.w-45{width:45%}.w-50{width:50%}.w-55{width:55%}.w-60{width:60%}.w-65{width:65%}.w-70{width:70%}.w-75{width:75%}
.w-80{width:80%}.w-85{width:85%}.w-90{width:90%}.w-95{width:95%}.w-100{width:100%}
.h-0{height:2px}.h-5{height:5%}.h-10{height:10%}.h-15{height:15%}.h-20{height:20%}.h-25{height:25%}.h-30{height:30%}.h-35{height:35%}
.h-40{height:40%}.h-45{height:45%}.h-50{height:50%}.h-55{height:55%}.h-60{height:60%}.h-65{height:65%}.h-70{height:70%}.h-75{height:75%}
.h-80{height:80%}.h-85{height:85%}.h-90{height:90%}.h-95{height:95%}.h-100{height:100%}

/* --- public ticket ----------------------------------------------------- */
.public body, body.public { background: var(--bg); }
.public-top { background: var(--header); color: var(--on-header); border-bottom: 3px solid var(--accent); padding: .9rem 1rem; text-align: center; }
.public-wrap { max-width: 560px; margin: 0 auto; padding: 1rem; }
.pticket { background: #fff; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); box-shadow: 0 2px 10px rgba(18,46,62,.06); }
.pticket-head { padding: 1.25rem 1.25rem 1rem; border-bottom: 1px dashed #BDBDBD; }
.pticket-head .op { font-weight: 700; color: var(--muted); font-size: .9rem; }
.pticket-number { font-family: var(--mono); font-size: clamp(1.25rem, 6.2vw, 2rem); overflow-wrap: anywhere; font-weight: 800; letter-spacing: .02em; margin: .2rem 0; }
.pticket-problem { padding: 1.25rem; background: var(--accent-soft); border-bottom: 1px solid var(--accent-line); }
.pticket-problem .label { color: var(--accent-dark); font-weight: 700; text-transform: uppercase; font-size: .75rem; letter-spacing: .06em; }
.pticket-problem .what { font-size: 1.35rem; font-weight: 800; margin: .15rem 0 .35rem; }
.pticket-body { padding: 1.25rem; }
.pticket-foot { padding: 1rem 1.25rem; background: #F6F6F6; font-size: .85rem; color: var(--muted); border-top: 1px solid var(--line); }
.void-banner { background: var(--red); color: #fff; text-align: center; font-weight: 800; letter-spacing: .1em; padding: .6rem; font-size: 1.1rem; }
.updated-banner { background: #F2F2F2; color: var(--ink); text-align: center; font-weight: 600; padding: .5rem; font-size: .9rem; }

/* --- print ticket ------------------------------------------------------ */
.print-page { max-width: 7.5in; margin: 1rem auto; background: #fff; padding: .5in; border: 1px solid var(--line); }
.print-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid var(--strong); padding-bottom: .75rem; margin-bottom: 1rem; }
.print-num { font-family: var(--mono); font-size: 2rem; overflow-wrap: anywhere; font-weight: 800; }
.print-grid { display: grid; grid-template-columns: 1fr 180px; gap: 1.5rem; }
.print-problem { border: 2px solid var(--strong); border-radius: 8px; padding: 1rem; margin: 1rem 0; }
.print-problem .what { font-size: 1.4rem; font-weight: 800; }
.print-disclaimer { margin-top: 1.25rem; padding-top: .75rem; border-top: 1px solid var(--line); font-size: .85rem; }
.print-tools { text-align: center; margin: 1rem; }
.print-status { margin: .75rem 0; padding: .6rem .8rem; border: 2px solid var(--strong); border-radius: 8px; font-weight: 700; }
.print-num { white-space: nowrap; }
@media screen and (max-width: 640px) {  /* a driver opening Print / PDF on a phone */
  .print-page { margin: 0; padding: 1rem; border: 0; }
  .print-head { flex-direction: column; gap: .5rem; }
  .print-num { font-size: clamp(1.1rem, 6.4vw, 2rem); }
  .print-grid { grid-template-columns: 1fr; gap: .5rem; }
  .print-grid .qr { margin: 0 auto; }
  .print-grid > div:last-child { text-align: center; }
}
/* --- ledger ------------------------------------------------------------ */
.ledger-summary { display: grid; grid-template-columns: repeat(6, 1fr); gap: .75rem; margin-bottom: 1rem; }
.ledger-summary .card { margin: 0; padding: .75rem .9rem; }
.ledger-summary .stat { font-size: 1.6rem; }
@media (max-width: 800px) { .ledger-summary { grid-template-columns: repeat(3, 1fr); } }
table.ledger td:first-child { white-space: nowrap; }
table.ledger tr.is-void td { color: var(--muted); }
table.ledger tr.is-void td strong { text-decoration: line-through; }

@media print {
  body { background: #fff; }
  .ledger-summary { grid-template-columns: repeat(6, 1fr); }
  table.ledger { font-size: 10pt; }
  table.ledger a { color: inherit; text-decoration: none; }
  .print-tools, .topbar, .no-print { display: none !important; }
  .print-page { border: 0; margin: 0; padding: 0; max-width: none; }
}

/* --- login ------------------------------------------------------------- */
.login { max-width: 400px; margin: 8vh auto; }
.login .brand { --accent-hi: var(--accent); color: var(--ink); font-size: 2rem; display: block; text-align: center; margin-bottom: .25rem; }


/* --- inbox ------------------------------------------------------------- */
.msg { border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem; background: #fff; margin-bottom: .75rem; }
.msg.sms { border-left: 4px solid var(--accent); }
.msg.email { border-left: 4px solid var(--strong); }
.msg pre { white-space: pre-wrap; font-family: var(--font); margin: .5rem 0 0; }
.msg a { word-break: break-all; }

@media (max-width: 640px) {
  .topbar .wrap { gap: .5rem; padding-top: .4rem; padding-bottom: .4rem; }
  .nav { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; }
  .nav a { white-space: nowrap; }
  .who span, .who a.me { display: none; }
  .who { margin-left: auto; }
}

/* --- lifecycle --------------------------------------------------------- */
.badge-open { background: var(--amber-soft); color: var(--amber); }
.badge-resolved { background: var(--green-soft); color: var(--green); }
.badge-turned_away { background: #EDE7F6; color: #4A2C8A; }
.badge-expired { background: #ECEFF1; color: #455A64; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; }
.timer.low { color: var(--red); }
.deadline-card { background: var(--amber-soft); border: 1px solid #F0D58C; border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.deadline-card .big { font-size: 1.6rem; font-weight: 800; }
.outcome-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.btn-resolve { background: var(--green); border-color: var(--green); color: #fff; }
.btn-resolve:hover { background: #17612F; }
.btn-away { background: #4A2C8A; border-color: #4A2C8A; color: #fff; }
.btn-away:hover { background: #3A2270; }
.status-banner { text-align: center; font-weight: 800; letter-spacing: .08em; padding: .6rem; font-size: 1.05rem; color: #fff; }
.status-banner.resolved { background: var(--green); }
.status-banner.turned_away { background: #4A2C8A; }
.status-banner.expired { background: #546E7A; }
.pdeadline { padding: 1rem 1.25rem; background: var(--strong); color: #fff; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.pdeadline .big { font-size: 1.3rem; font-weight: 800; }
.board-row { display: grid; grid-template-columns: 130px 1fr 110px auto; gap: .75rem; align-items: center; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.board-row:last-child { border-bottom: 0; }
@media (max-width: 700px) { .board-row { grid-template-columns: 1fr auto; } .board-row .hide-sm { display: none; } }
.board-actions { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
.board-actions form { margin: 0; }
.kpi { font-size: 1.6rem; font-weight: 800; }
.kpi small { font-size: .85rem; color: var(--muted); font-weight: 600; }
.bar.two i + i { background: #8E7CC3; }
.daybars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; align-items: end; height: 120px; }
.daybars .day { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
.daybars .day i { display: block; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; }
.daybars .day b { display: block; background: #4A2C8A; }
.legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--muted); margin-top: .4rem; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .35rem; vertical-align: -1px; background: var(--accent); }
.legend span.away::before { background: #4A2C8A; }

.brand-logo { height: 32px; width: auto; display: block; }
.login .brand-logo { height: 48px; margin: 0 auto; }

.pticket-next { padding: 1rem 1.25rem; background: #F6F6F6; border-bottom: 1px solid var(--line); }
.pticket-next .label { color: var(--ink); text-transform: uppercase; font-size: .75rem; letter-spacing: .06em; font-weight: 700; }

/* --- two-step sign-in ----------------------------------------------------- */
.qr-2fa svg { width: 180px; height: 180px; display: block; margin: .75rem 0; }
ol.steps li { margin-bottom: .75rem; }
ul.codes { columns: 2; list-style: none; padding: 0; font-size: 1.1rem; }
ul.codes li { padding: .2rem 0; }
.topbar .who a { color: var(--on-header); opacity: .85; text-decoration: none; }
.topbar .who a:hover { opacity: 1; text-decoration: underline; }
/* Language switch on driver pages */

/* --- brand mark: corner brackets like the Kado Systems logo ---------------------- */
.brand-mark { position: relative; display: inline-block; padding: .2em .45em; line-height: 1.1; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; width: .5em; height: .5em; border: 0 solid var(--accent-hi); }
.brand-mark::before { top: 0; left: 0; border-top-width: 2px; border-left-width: 2px; }
.brand-mark::after { bottom: 0; right: 0; border-bottom-width: 2px; border-right-width: 2px; }
.brand-mark span { font-weight: 400; }

/* --- driver page: big, easy tap targets ------------------------------------------- */
.pticket-head .row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: .5rem; }
.pticket-head .btn { min-height: 48px; font-size: .95rem; padding: .5rem .75rem; width: 100%; }
.pticket-head .btn-primary { grid-column: 1 / -1; min-height: 52px; font-size: 1.05rem; }
.pdeadline .small { color: #CCCCCC; }
.pdeadline .timer { color: #FFFFFF; font-size: 1.05rem; }
.pdeadline .timer.low { color: #FF8A80; }
.lang-switch { display: flex; justify-content: center; gap: .25rem; margin: 1rem auto 0; padding: .25rem; width: max-content;
  background: #fff; border: 1px solid var(--line); border-radius: 999px; font-size: .95rem; }
.lang-switch a, .lang-switch strong { display: inline-flex; align-items: center; min-height: 44px; padding: 0 1.25rem; border-radius: 999px; }
.lang-switch a { color: var(--ink); text-decoration: none; }
.lang-switch a:hover { background: #F0F0F0; }
.lang-switch strong { background: var(--strong); color: #fff; font-weight: 600; }

/* Ticket numbers in lists read in black, still underlined as links. */
a.mono { color: var(--ink); }
a.mono:hover { color: var(--accent-dark); }
.nowrap { white-space: nowrap; }
