/* Additions on top of base.css (the approved demo stylesheet). */

a { color: inherit; text-decoration: none; }
.nav a, .mobile a { text-decoration: none; }
.mobile a { display: grid; place-items: center; }
a.btn, a.ghost { display: inline-block; text-decoration: none; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.toolbar select { border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 9px 10px; color: var(--ink); }

/* The demo toggled .view with JavaScript; here every route renders one view. */
.view { display: block; }

.pilot { background: #eef5ff; color: #2b5491; border: 1px solid #cedef5; padding: 6px 9px; border-radius: 8px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.profile-menu { position: relative; }
.profile-menu summary { list-style: none; cursor: pointer; }
.profile-menu summary::-webkit-details-marker { display: none; }
.profile-card { position: absolute; right: 0; top: 46px; width: 230px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 13px; z-index: 6; }
.profile-card b { display: block; font-size: 13px; }
.profile-card small { display: block; color: var(--muted); font-size: 11px; margin-bottom: 10px; overflow-wrap: anywhere; }
.profile-card button { width: 100%; }

.tier { font-size: 10px; font-weight: 800; border-radius: 5px; padding: 3px 6px; display: inline-block; }
.tier.A { background: #e8f6ef; color: #14714e; }
.tier.B { background: #fff1df; color: #9c570f; }
.tier.C { background: #fff0f0; color: #a83838; }
.status.pending { background: #eef5ff; color: #2b5491; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th.num { text-align: right; }
.stack { display: grid; gap: 14px; }
.note { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.target-card .fact { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 3px; }
.target-card .fact b { color: var(--ink); font-weight: 700; }
.pending-box { border: 1px solid #cedef5; background: #f5f9ff; border-radius: 10px; padding: 12px; margin-top: 14px; font-size: 13px; }
.pending-box dl { display: grid; grid-template-columns: 130px 1fr; gap: 4px 10px; margin: 8px 0 0; font-size: 12px; }
.pending-box dt { color: var(--muted); }
.pending-box dd { margin: 0; }
.history { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 14px; }
.history div { background: #f7f9fc; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }
.history span { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.history strong { font-size: 15px; }
.ticket-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.exceptions { margin: 8px 0 0; padding-left: 16px; font-size: 11px; color: #85510e; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* Sign-in */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, #07162f, #123d7a); padding: 20px; }
.login-card { width: min(410px, 100%); background: #fff; border-radius: 18px; box-shadow: 0 25px 70px #0006; overflow: hidden; }
.login-head { background: var(--navy); color: #fff; padding: 22px 24px; display: flex; gap: 12px; align-items: center; }
.login-head b { display: block; letter-spacing: 0.07em; }
.login-head small { color: #94acd0; font-size: 12px; }
.login-body { padding: 22px 24px 24px; display: grid; gap: 13px; }
.login-body .btn { padding: 11px 12px; font-size: 14px; }
.error { background: #fff0f0; border: 1px solid #f1c7c7; color: #a83838; border-radius: 9px; padding: 9px 11px; font-size: 13px; }

@media (max-width: 1023px) {
  .pilot { display: none; }
  .history { grid-template-columns: repeat(2, 1fr); }
}

td input { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 6px 8px; color: var(--ink); max-width: 100%; }
td input:disabled { background: #f7f9fc; color: var(--muted); }
td select { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 6px 8px; color: var(--ink); max-width: 100%; }
.field label input[type="checkbox"] { margin-right: 6px; }
.metric > span + strong + span { display: block; margin-top: 2px; }

/* Fields are <label class="field"><span>…</span><input/></label> so every control has an accessible name. */
.field > span { font-size: 12px; color: #59677d; font-weight: 700; }
.status { white-space: nowrap; }
.source-card footer { gap: 8px; }
.target-card .fact { gap: 8px; }
.target-card .fact b { white-space: nowrap; }
.target-card .fact-head { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 10px; padding-top: 8px; border-top: 1px solid #edf1f5; }

.card .rows table { min-width: 0; }
.card .rows th { background: transparent; padding: 8px 6px; }
.card .rows td { padding: 8px 6px; }

/* Phone: bottom bar "More" sheet */
.mobile button { border: 0; background: #fff; color: #657187; font-size: 10px; display: grid; place-items: center; gap: 2px; }
.mobile button.active { color: #153d75; font-weight: 800; }
.more-sheet { display: none; }
@media (max-width: 1023px) {
  .more-sheet { display: block; position: fixed; inset: 0; background: #07152f80; z-index: 9; }
  .more-sheet nav { position: absolute; left: 0; right: 0; bottom: 54px; background: #fff; border-radius: 16px 16px 0 0; padding: 10px 12px 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; box-shadow: 0 -12px 40px #0003; }
  .more-sheet a { display: flex; align-items: center; gap: 9px; padding: 12px 10px; border-radius: 10px; font-size: 14px; color: var(--ink); }
  .more-sheet a.active { background: #edf3ff; color: #164c96; font-weight: 700; }
  .more-sheet form { grid-column: 1 / -1; margin-top: 4px; }
  .more-sheet form button { width: 100%; padding: 11px; }
}

/* ---------- Responsive hardening (phones 320+, tablets, laptops, large desktops) ---------- */

/* A grid or flex child may shrink below its content, so one long word can never widen the page. */
.page :where(div, section, article, form, header, footer, fieldset) { min-width: 0; }
.page :where(p, small, b, strong, h2, h3, h4, dd, li):not(:where(table *)) { overflow-wrap: anywhere; }
.top > div:first-child { min-width: 0; }
.top h1 { overflow-wrap: anywhere; }
.top { gap: 12px; }
.tools { flex-shrink: 0; }

/* Rows of a heading and a button wrap instead of squeezing each other. */
.section-head, .card-head, .chat-head, .pager, .source-card footer { gap: 10px; flex-wrap: wrap; }
.section-head > :first-child, .card-head > :first-child { flex: 1 1 200px; }
.actions { flex-wrap: wrap; }
.rows, .wa-chart { overflow-x: auto; }
.segment { grid-template-columns: 150px 55px 1fr max-content; }
.field input[type="checkbox"] { width: 18px; height: 18px; vertical-align: middle; }

/* Short laptop screens: the side menu scrolls rather than cutting off its last items. */
.side { overflow-y: auto; }

/* Side menu plus content leaves no room for two cards side by side until the screen is wide. */
@media (max-width: 1180px) {
  .two { grid-template-columns: minmax(0, 1fr); }
  th, td { padding: 9px 8px; }
  th.num { white-space: normal; }
}

/* From tablets up, tables fit the screen instead of scrolling sideways. */
@media (min-width: 768px) {
  .table-wrap table { min-width: 0; }
}

/* Tablets and landscape phones: bottom bar, full-width content, two or three cards per row. */
@media (min-width: 641px) and (max-width: 1023px) {
  .lang { display: block; }
  .top-sub { display: block; }
  .goal-cards, .review-grid, .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .full { grid-column: 1 / -1; }
  .scoreboard, .target-grid, .wa-summary, .grid6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .more-sheet nav { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1023px) {
  .segment { grid-template-columns: 120px 50px 1fr; }
  /* Bottom bar: every item is a full-height tap target. */
  .mobile { padding: 0 2px env(safe-area-inset-bottom, 0); }
  .mobile a, .mobile button { flex: 1 1 0; min-height: 52px; padding: 6px 2px; }
  .page { padding-bottom: calc(82px + env(safe-area-inset-bottom, 0px)); }
  .more-sheet nav { max-height: calc(100vh - 70px); max-height: calc(100dvh - 70px); overflow-y: auto; }
  .more-sheet .sheet-lang { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px 4px; font-size: 13px; color: var(--muted); }
  .more-sheet .sheet-lang select { border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 9px 10px; color: var(--ink); min-height: 40px; }
  /* Messages sit above the bottom bar, not on top of it. */
  .toast { left: 12px; right: 12px; bottom: calc(66px + env(safe-area-inset-bottom, 0px)); text-align: center; }
  .modal { padding: 10px; }
  .panel { max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); }
}

/* Phones: each table row becomes a card with its column headings beside the values
   (DataTable in src/components/table.tsx puts the headings on the cells). */
@media (max-width: 767px) {
  .section-head { align-items: flex-start; }
  .toolbar > * { flex: 1 1 150px; min-width: 0; }
  .toolbar .search { min-width: 0; }
  .table-wrap { overflow: visible; }
  .table-wrap table { min-width: 0; display: block; }
  .table-wrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .table-wrap tbody { display: block; }
  .table-wrap tr { display: block; padding: 10px 13px; border-bottom: 1px solid var(--line); }
  .table-wrap tbody tr:last-child { border-bottom: 0; }
  .table-wrap td { display: flow-root; padding: 4px 0; border: 0; text-align: right; white-space: normal; overflow-wrap: anywhere; }
  .table-wrap td::before { content: attr(data-label); float: left; width: 36%; margin-right: 12px; padding-top: 3px; text-align: left; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #56647a; overflow-wrap: anywhere; }
  .table-wrap td:not([data-label])::before, .table-wrap td[data-label=""]::before { content: none; }
  .table-wrap td .mini-bar { display: inline-block; width: 50%; vertical-align: middle; margin-right: 6px; }
  .table-wrap td ul { list-style: none; padding: 0; }
  .table-wrap td[colspan] { display: block; text-align: left; }
  .table-wrap td input { min-width: 0; max-width: 62%; }
  .table-wrap td form { justify-content: flex-end; }
  .table-wrap td .chip-row { justify-content: flex-end; }
  .pending-box dl { grid-template-columns: 1fr; }
  .pending-box dt { margin-top: 6px; }
}

/* Tablets: the booth table gives its longest column room so it does not wrap to five lines. */
@media (min-width: 768px) and (max-width: 1023px) {
  .booth-table td:nth-child(8) { min-width: 168px; }
  .booth-table td.num { white-space: normal; }
  .booth-table th, .booth-table td { padding: 9px 6px; }
}

/* Small phones (320-360px wide). */
@media (max-width: 380px) {
  .card .rows { padding-left: 10px; padding-right: 10px; }
  .card .rows th, .card .rows td { padding: 7px 3px; font-size: 12px; }
  .card .rows th { font-size: 10px; letter-spacing: 0.02em; }
  .top { padding: 10px 12px; }
  .top h1 { font-size: 15px; }
  .silence { padding: 7px 8px; font-size: 12px; }
  .page { padding-left: 10px; padding-right: 10px; }
  .history { grid-template-columns: 1fr; }
  .more-sheet a { font-size: 13px; padding: 11px 8px; }
}

/* Small laptops: six segment cards in one row leave no room for longer (translated) labels. */
@media (min-width: 1181px) and (max-width: 1400px) {
  .target-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.target-card .fact { flex-wrap: wrap; }

/* Laravel version: the phone "More" sheet is shown and hidden with the hidden attribute. */
.more-sheet[hidden] { display: none !important; }
.sheet-lang { margin: 0; }

/* The 18px "Mark complete" boxes are hard to hit with a finger: keep the look, widen the touch area. */
button.check { position: relative; }
button.check::before { content: ""; position: absolute; inset: -13px; }

/* Public home page (/) and the language links shown before sign-in. */
.home-wrap { min-height: 100vh; display: flex; flex-direction: column; background: linear-gradient(160deg, #07162f, #123d7a); color: #fff; }
.home-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 28px; }
.home-brand { display: flex; align-items: center; gap: 11px; }
.home-brand b { display: block; letter-spacing: 0.07em; }
.home-brand small { color: #94acd0; font-size: 12px; }
.home-signin { padding: 10px 16px; font-size: 14px; text-decoration: none; }
.home-main { flex: 1; width: min(1040px, 100%); margin: 0 auto; padding: 48px 28px 32px; text-align: center; }
.home-main .eyebrow { color: #ffb25c; }
.home-title { font-size: clamp(32px, 6vw, 58px); line-height: 1.08; letter-spacing: -0.03em; margin: 10px 0 14px; }
.home-title span { color: #ffb25c; display: block; }
.home-lead { color: #c5d4e9; font-size: 17px; max-width: 680px; margin: 0 auto 34px; }
.home-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; text-align: left; margin-bottom: 34px; }
.home-card { background: #ffffff10; border: 1px solid #ffffff22; border-radius: 14px; padding: 18px; }
.home-card h2 { font-size: 16px; margin: 0 0 6px; }
.home-card p { color: #bfd0e8; font-size: 14px; margin: 0; }
.home-cta { display: inline-block; padding: 13px 34px; font-size: 16px; text-decoration: none; }
.home-note { color: #9db2d2; font-size: 13px; margin: 14px auto 0; max-width: 520px; }
.home-foot { padding: 18px 28px 26px; display: flex; justify-content: center; }
.guest-langs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; font-size: 14px; }
.guest-langs a { color: #c5d4e9; padding: 8px 4px; }
.guest-langs b { color: #fff; padding: 8px 4px; border-bottom: 2px solid var(--orange); }
.login-wrap { align-content: center; gap: 18px; }
@media (max-width: 767px) {
  .home-top { padding: 14px 16px; }
  .home-brand small { display: none; }
  .home-main { padding: 28px 16px 24px; }
  .home-lead { font-size: 15px; }
  .home-cards { grid-template-columns: 1fr; }
  .home-cta { display: block; }
}

/* View-only demo (/demo): a label and a sign-in button take the place of the account menu. */
.demo-pill { background: #eef5ff; color: #164c96; border-color: #cedef5; }
.demo-signin { text-decoration: none; padding: 8px 12px; }
@media (max-width: 767px) { .demo-pill { display: none; } }
