:root {
  --pico-font-size: 95%;
  --ok: #2e7d32;
  --warn: #ef6c00;
  --bad: #c62828;
}
.container { max-width: 1100px; }
.app-header { border-bottom: 1px solid var(--pico-muted-border-color); margin-bottom: 1.5rem; background: var(--pico-card-background-color); }
.app-header nav { padding: 0.25rem 0; }
.app-header .brand { text-decoration: none; }
.main-nav a.active { text-decoration: underline; text-underline-offset: 0.4em; }
.app-footer { margin-top: 3rem; color: var(--pico-muted-color); text-align: center; }
.narrow { max-width: 480px; margin: 2rem auto; }
.inline { display: inline; margin: 0; }
button.link { background: none; border: none; color: var(--pico-primary); padding: 0; margin: 0; width: auto; font: inherit; cursor: pointer; }
.badge { display: inline-block; background: var(--bad); color: #fff; border-radius: 999px; padding: 0 0.5em; font-size: 0.75em; font-weight: 700; vertical-align: middle; }
.flash { padding: 0.75rem 1rem; border-radius: var(--pico-border-radius); margin-bottom: 1rem; border: 1px solid; }
.flash-success { background: #e8f5e9; border-color: #a5d6a7; color: #1b5e20; }
.flash-error { background: #ffebee; border-color: #ef9a9a; color: #b71c1c; }
.flash-info { background: #e3f2fd; border-color: #90caf9; color: #0d47a1; }
.flash-warning { background: #fff3e0; border-color: #ffcc80; color: #e65100; }
.error-message { white-space: pre-wrap; }

/* Budget */
.budget-card { display: grid; gap: 0.5rem; }
.budget-bar { height: 14px; background: var(--pico-muted-border-color); border-radius: 7px; overflow: hidden; }
.budget-bar > span { display: block; height: 100%; background: var(--ok); }
.budget-bar.warning > span { background: var(--warn); }
.budget-bar.exhausted > span { background: var(--bad); }
.state { font-weight: 600; }
.state.ok { color: var(--ok); }
.state.warning { color: var(--warn); }
.state.exhausted { color: var(--bad); }
.budget-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.budget-grid article { margin: 0; padding: 1rem; }
.budget-grid h4 { margin-bottom: 0.25rem; }

/* Tickets */
.status, .prio { display: inline-block; padding: 0.05em 0.55em; border-radius: 999px; font-size: 0.8em; font-weight: 600; white-space: nowrap; }
.status-open { background: #e3f2fd; color: #0d47a1; }
.status-in_progress { background: #fff8e1; color: #8d6e00; }
.status-waiting_customer { background: #f3e5f5; color: #6a1b9a; }
.status-resolved { background: #e8f5e9; color: #1b5e20; }
.prio-low { color: #607d8b; }
.prio-normal { color: #455a64; }
.prio-high { color: var(--warn); }
.prio-urgent { color: var(--bad); }
table.tickets td, table.tickets th { vertical-align: middle; }
table.compact td, table.compact th { padding: 0.4rem 0.5rem; font-size: 0.9em; }
.ticket-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 1.5rem; }
@media (max-width: 800px) { .ticket-layout { grid-template-columns: 1fr; } }
.message { border: 1px solid var(--pico-muted-border-color); border-radius: var(--pico-border-radius); padding: 0.75rem 1rem; margin-bottom: 0.75rem; }
.message.from-admin { border-left: 4px solid var(--pico-primary); }
.message.internal { background: #fffde7; border-color: #fff59d; }
.message-meta { display: flex; justify-content: space-between; gap: 1rem; color: var(--pico-muted-color); font-size: 0.85em; margin-bottom: 0.5rem; flex-wrap: wrap; }
.message-body { white-space: pre-wrap; word-wrap: break-word; }
.attachments { margin-top: 0.5rem; font-size: 0.9em; }
.attachments a { margin-right: 1rem; }
.sidebar article { padding: 1rem; margin-bottom: 1rem; }
.sidebar h4 { margin-bottom: 0.5rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1rem; font-size: 0.9em; }
.kv dt { color: var(--pico-muted-color); }
.kv dd { margin: 0; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stats article { margin: 0; padding: 0.75rem 1rem; text-align: center; }
.stats .num { font-size: 1.8em; font-weight: 700; display: block; }
.stats a { text-decoration: none; }
.muted { color: var(--pico-muted-color); }
/* Hint below a form field. It has to sit clearly under its own field and just as
   clearly apart from the next one, so the gap below is the larger of the two. */
.field-hint { display: block; margin: 0.65rem 0 1.4rem; line-height: 1.45; }
/* Checkbox list that stays readable on a phone. */
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 0 1rem; }
.check-grid label { margin-bottom: 0.35rem; }
/* Registration in steps – the progress line and its own navigation. */
.wizard-progress { margin: 0 0 1rem; font-size: 0.85em; color: var(--pico-muted-color); letter-spacing: 0.02em; }
.wizard-nav { margin-top: 0.5rem; }
.right { text-align: right; }
.toolbar { display: flex; gap: 0.5rem; align-items: end; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar label { margin: 0; }
.toolbar input, .toolbar select { margin: 0; }
form.compact-form label { margin-bottom: 0.5rem; }
form.compact-form input, form.compact-form select, form.compact-form textarea { margin-bottom: 0.5rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 600px) { .grid-2 { grid-template-columns: 1fr; } }
.hero-budget { padding: 1.25rem 1.5rem; }
.hero-budget .big { font-size: 1.6em; font-weight: 700; }
.pagination { display: flex; gap: 0.5rem; justify-content: center; margin: 1rem 0; }
.pending-note { font-size: 0.9em; }
pre.mailbody { white-space: pre-wrap; font-family: inherit; background: var(--pico-code-background-color); padding: 0.75rem; }
.mail-card h4 { margin-bottom: 0.25rem; }
.mail-card dl.kv { margin-bottom: 0.75rem; }
iframe.mail-preview { width: 100%; min-height: 8rem; border: 1px solid var(--pico-muted-border-color); border-radius: var(--pico-border-radius); background: #fff; display: block; }

/* --- Mobile --- */
html, body { overflow-x: hidden; }
.app-header nav { flex-wrap: wrap; row-gap: 0; }
.app-header nav ul { flex-wrap: wrap; }
.app-header nav > ul:last-child { margin-left: auto; }
.user-menu details.dropdown summary { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overflow-auto { overflow-x: auto; max-width: 100%; }
@media (max-width: 700px) {
  :root { --pico-font-size: 90%; }
  .app-header nav { padding: 0.25rem 0; }
  .app-header nav ul { padding: 0; }
  .app-header nav li { padding: 0.3rem 0.4rem; }
  .main-nav { order: 3; width: 100%; justify-content: flex-start; border-top: 1px solid var(--pico-muted-border-color); }
  table { display: block; overflow-x: auto; white-space: nowrap; }
  table.compact td, table.compact th { padding: 0.35rem 0.4rem; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .actions[style*="space-between"] { flex-direction: column; align-items: flex-start !important; }
  h2 { font-size: 1.4rem; }
}
.ticket-layout > * { min-width: 0; }
@media (max-width: 800px) { .ticket-layout { grid-template-columns: minmax(0, 1fr); } }
.grid-2 > * { min-width: 0; }
.app-header nav ul:first-of-type { margin-left: 0; }
.app-header nav ul:last-of-type { margin-right: 0; }
.app-header .brand { margin-left: 0; }

/* --- Help modal --- */
.help-button { background: none; border: 1px solid var(--pico-primary); color: var(--pico-primary); border-radius: 999px; padding: 0.15rem 0.7rem; font-size: 0.85em; font-weight: 600; width: auto; margin: 0; cursor: pointer; }
.help-button:hover { background: var(--pico-primary); color: #fff; }
#help-dialog article.help-article { max-width: 820px; width: 100%; max-height: 90vh; display: flex; flex-direction: column; padding-top: 1rem; }
#help-dialog header { margin: -1rem -1rem 0.75rem; padding: 0.75rem 1rem; }
#help-dialog .help-body { overflow-y: auto; flex: 1; padding-right: 0.25rem; font-size: 0.95em; }
#help-dialog footer { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin: 0.75rem -1rem -1rem; padding: 0.75rem 1rem; }
#help-dialog footer button { width: auto; margin: 0; }
#help-dialog h4 { margin: 1rem 0 0.4rem; font-size: 1.05em; }
#help-dialog h4:first-child { margin-top: 0; }
#help-dialog ol, #help-dialog ul { padding-left: 1.4rem; }
#help-dialog li { margin-bottom: 0.35rem; }
#help-dialog code { font-size: 0.9em; }
.help-tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; border-bottom: 1px solid var(--pico-muted-border-color); margin-bottom: 1rem; }
.help-tabs button { width: auto; margin: 0; padding: 0.35rem 0.75rem; background: none; border: none; border-bottom: 3px solid transparent; border-radius: 0; color: var(--pico-muted-color); font-weight: 600; font-size: 0.9em; cursor: pointer; }
.help-tabs button.active { color: var(--pico-primary); border-bottom-color: var(--pico-primary); }
.help-tab { display: none; }
.help-tab.active { display: block; }
.help-tabs { justify-content: flex-start; }
.hours-request { margin-bottom: 0.75rem; }
.hours-request legend { font-size: inherit; margin-bottom: 0.4rem; }
.hours-row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: nowrap; }
.hours-row input[type=number] { width: 5rem; flex: 0 0 auto; margin: 0; }
.hours-row .as-needed { margin: 0; font-size: 0.9em; line-height: 1.25; min-width: 0; }
input[type=number]:disabled { opacity: 0.45; }
.paused { display: inline-block; font-size: 0.78em; font-weight: 600; color: var(--bad); background: #ffebee; border-radius: 999px; padding: 0 0.5em; white-space: nowrap; vertical-align: middle; }
article.gate { padding: 1rem 1.25rem; margin: 0.5rem 0 1rem; }
article.gate h4 { margin: 0 0 0.5rem; }
article.gate-request { border-left: 4px solid var(--bad); }
article.gate-blocked { border-left: 4px solid var(--bad); }
/* Inline top-up decisions on the overview */
article.topup-row { padding: 0.75rem 1rem; margin-bottom: 0.5rem; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.75rem 1.5rem; align-items: center; }
.topup-form { display: flex; gap: 0.5rem; align-items: center; margin: 0; flex-wrap: wrap; }
.topup-form input[type=number] { width: 5.5rem; margin: 0; }
.topup-form input[type=text] { width: 16rem; margin: 0; }
.topup-form button { width: auto; margin: 0; padding: 0.4rem 0.9rem; }
@media (max-width: 900px) { article.topup-row { grid-template-columns: 1fr; } }
.toolbar button, .toolbar a[role=button] { width: auto; margin: 0; }
.toolbar input[type=search] { min-width: 14rem; }
table.tickets td, table.tickets th { white-space: nowrap; }
table.tickets td:nth-child(2) { white-space: normal; }

.page-head { margin-bottom: 1rem; }
.page-head h2 { margin-bottom: 0; }
.brand { display: inline-flex; flex-direction: column; align-items: center; text-align: center; gap: 0.15rem; }
.brand-logo { height: 28px; width: auto; max-width: 180px; display: block; }
.brand strong { font-size: 0.8em; line-height: 1.1; }
.brand:not(:has(.brand-logo)) strong { font-size: 1em; }
/* Mobile polish: no clipped nav links, breathing room at the right edge */
.main-nav a { margin-left: 0; margin-right: 0; }
@media (max-width: 700px) {
  .app-header nav { padding-left: 0.25rem; padding-right: 0.25rem; }
  .app-header nav > ul:last-child { padding-right: 0.25rem; }
  textarea { font-size: 16px; } /* prevents iOS zoom-on-focus */
  input, select { font-size: 16px; }
}
