/* Office UI. Same palette as core/templates/core/base.html. */
:root {
  --ink: #1c2422;
  --ink-soft: #4b5650;
  --paper: #f7f8f4;
  --surface: #ffffff;
  --line: #cbd1c7;
  --accent: #2f6f63;
  --accent-soft: #dceae6;
  --danger: #9c3b33;
  --danger-soft: #f3dedb;
  --warn: #7a5a12;
  --warn-soft: #f6ecd2;
  --muted-soft: #eceee9;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); margin: 12px 0 4px; }
[hidden] { display: none !important; }

/* --- top bar ------------------------------------------------------------- */
.topbar { background: var(--accent); color: #fff; }
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap; min-height: 56px;
}
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.05rem; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.nav a {
  color: #fff; text-decoration: none; padding: 6px 8px; border-radius: 6px; opacity: 0.85; white-space: nowrap;
}
.nav a:hover { opacity: 1; background: rgba(255, 255, 255, 0.12); }
.nav a[aria-current="page"] { opacity: 1; background: rgba(255, 255, 255, 0.2); }
.badge {
  display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px;
  background: #fff; color: var(--accent); font-size: 0.75rem; font-weight: 700; text-align: center;
}
.signout { display: flex; align-items: center; gap: 12px; margin: 0; font-size: 0.9rem; }
.signout .who { opacity: 0.85; }
.signout .setup-link { color: #fff; opacity: 0.85; }
.link-button {
  background: none; border: 1px solid rgba(255, 255, 255, 0.5); color: #fff;
  padding: 4px 10px; margin: 0; font-size: 0.85rem;
}

/* --- layout -------------------------------------------------------------- */
.page { max-width: 1200px; margin: 0 auto; padding: 24px 16px 80px; }
.page-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 16px;
}
.head-actions, .row-actions, .form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-tools { display: flex; align-items: center; gap: 12px; }
.crumbs { font-size: 0.9rem; margin: 0 0 8px; color: var(--ink-soft); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 20px; margin-bottom: 16px;
}
.hint, .empty { color: var(--ink-soft); }
.empty { margin: 0; }
.loading { color: var(--ink-soft); }
.error { color: var(--danger); font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px;
  display: flex; flex-direction: column;
}
.stat-label { font-size: 0.85rem; color: var(--ink-soft); }
.stat-value { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* --- tables -------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 0.8rem; color: var(--ink-soft); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 700; border-bottom: none; }
tr.linked { cursor: pointer; }
tr.linked:hover td { background: var(--paper); }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }

.pill {
  display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 0.8rem; white-space: nowrap;
  background: var(--muted-soft); color: var(--ink-soft);
}
.pill.ok { background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
/* A booking still to come whose guide, vehicle or tour was removed: the row
   red, the reason flashing until the booking is changed. */
tr.flagged td, tr.flagged:hover td { background: var(--danger-soft); }
tr.flagged td:first-child { box-shadow: inset 4px 0 0 var(--danger); }
.removed-reasons { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: 4px; vertical-align: middle; }
.pill.alarm { background: var(--danger); color: #fff; font-weight: 600; animation: removed-flash 1.2s ease-in-out infinite; }
@keyframes removed-flash { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .pill.alarm { animation: none; } }
.code { font-family: ui-monospace, monospace; font-size: 1.3rem; font-weight: 700; letter-spacing: 0.15em; }

dl.details { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; }
dl.details dt { font-weight: 600; font-size: 0.9rem; }
dl.details dd { margin: 0; color: var(--ink-soft); white-space: pre-line; }

/* --- forms --------------------------------------------------------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 16px; }
.field { margin-bottom: 12px; display: flex; flex-direction: column; }
.field label, .field .label { font-weight: 600; font-size: 0.85rem; margin-bottom: 4px; }
.field .checks label { font-weight: 400; margin-bottom: 0; }
.field small { color: var(--ink-soft); font-size: 0.8rem; margin-top: 2px; }
.field small.error { color: var(--danger); }
input[type="text"], input[type="password"], input[type="number"], input[type="tel"], input[type="email"], input[type="date"], input[type="time"],
select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
  font: inherit; background: #fff; color: var(--ink);
}
[aria-invalid="true"] { border-color: var(--danger); }
textarea { resize: vertical; }
.filters { display: flex; flex-wrap: wrap; gap: 0 16px; align-items: flex-end; }
.filters .field { min-width: 160px; }
.field.actions { flex-direction: row; gap: 8px; }
.inline-form {
  display: flex; flex-wrap: wrap; gap: 0 12px; align-items: flex-end;
  border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px;
}
.inline-form .field { min-width: 180px; margin-bottom: 0; }
.inline-form .form-error { flex-basis: 100%; }
.inline-form.stacked { display: block; }
.inline-form.stacked .field { margin-bottom: 12px; }
.check { font-size: 0.9rem; display: inline-flex; align-items: center; gap: 6px; }

button, .button {
  display: inline-block; background: var(--accent); color: #fff; border: 1px solid var(--accent);
  border-radius: 6px; padding: 8px 16px; font: inherit; cursor: pointer; text-decoration: none;
  line-height: 1.4;
}
button:hover, .button:hover { opacity: 0.9; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary, .button.secondary { background: #fff; color: var(--accent); }
button.danger { background: var(--danger); border-color: var(--danger); }
button.small { padding: 3px 10px; font-size: 0.85rem; }

.flash { border-radius: 6px; padding: 10px 14px; margin-bottom: 16px; }
.flash.ok { background: var(--accent-soft); }
.flash.bad { background: var(--danger-soft); color: var(--danger); font-weight: 600; }

/* --- subscription: banner and reminder screen (office/billing_notice.py) -- */
.billing-banner { border-radius: 6px; padding: 10px 14px; margin: 0 0 16px; font-weight: 600; }
.billing-banner.info { background: var(--accent-soft); color: var(--ink); }
.billing-banner.warn { background: var(--warn-soft); color: var(--warn); }
.billing-banner.bad { background: var(--danger-soft); color: var(--danger); }
.reminder {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(28, 36, 34, 0.55); padding: 16px;
}
.reminder-box {
  background: var(--surface); border-radius: 8px; padding: 20px 22px; max-width: 460px; width: 100%;
  border-top: 6px solid var(--danger);
}
.reminder-box h2 { margin-top: 0; color: var(--danger); }
/* Read-only for non-payment: everything shows, nothing that changes data does.
   Filters, paging, marking alerts read, switching a login off and your own
   password stay (class "keep-in-read-only"; the API allows exactly those).
   The API refuses changes anyway. */
body.read-only main form:not(.filters),
body.read-only main button,
body.read-only main a.button { display: none; }
body.read-only main .filters button,
body.read-only main form.keep-in-read-only,
body.read-only main form.keep-in-read-only button,
body.read-only main button.keep-in-read-only,
body.read-only #page-prev,
body.read-only #page-next,
body.read-only #alerts-mark-all { display: revert; }
.note-warn {
  display: inline-block; background: var(--warn-soft); color: var(--warn);
  border-radius: 6px; padding: 2px 8px; white-space: pre-line;
}
.lock-note { background: var(--warn-soft); color: var(--warn); border-radius: 6px; padding: 8px 12px; }

.alert-list { list-style: none; padding: 0; margin: 0; }
.alert-list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.alert-list li:last-child { border-bottom: none; }
.alert-list li.read { opacity: 0.65; }
.alert-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.alert-head button { margin-left: auto; }
details.older { margin-top: 12px; }
details.older summary { cursor: pointer; color: var(--ink-soft); margin-bottom: 8px; }

/* --- reports ------------------------------------------------------------- */
/* minmax(0, 1fr): a wide report scrolls in its own table-wrap instead of widening the page. */
.reports-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.report-menu ul { list-style: none; margin: 0 0 8px; padding: 0; }
.report-menu a { display: block; padding: 4px 8px; border-radius: 6px; text-decoration: none; }
.report-menu a:hover { background: var(--paper); }
.report-menu a[aria-current] { background: var(--accent-soft); font-weight: 600; }
.report-group h3:first-child { margin-top: 0; }

/* --- sign-in ------------------------------------------------------------- */
.login { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; }
.login h1 { margin-bottom: 16px; }
.login button { width: 100%; margin-top: 4px; }

.menu-toggle { display: none; }
@media (max-width: 760px) {
  /* The menu folds behind one button: the page starts at the top of the screen. */
  .topbar-inner { flex-wrap: wrap; }
  .brand { width: auto; flex: 1; }
  .menu-toggle {
    display: inline-block; background: none; border: 1px solid rgba(255, 255, 255, 0.6); color: #fff;
    padding: 6px 14px; margin: 0; min-height: 40px;
  }
  .topbar:not(.menu-open) .nav, .topbar:not(.menu-open) .signout { display: none; }
  .topbar.menu-open .nav { width: 100%; }
  .nav a { padding: 10px 10px; }

  /* Tables stack: each row a card, each value under its column's name, nothing off the screen. */
  .stack-on-phone table, .stack-on-phone tbody, .stack-on-phone tr, .stack-on-phone td { display: block; width: 100%; }
  .stack-on-phone thead { display: none; }
  .stack-on-phone tr { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin-bottom: 10px; }
  .stack-on-phone td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    border: none; padding: 5px 0; text-align: right;
  }
  .stack-on-phone td::before { content: attr(data-label); font-weight: 600; color: var(--ink-soft); text-align: left; }
  .stack-on-phone td[data-label=""]::before { content: none; }
  .stack-on-phone td[data-label=""] { justify-content: flex-end; }
  .stack-on-phone .row-actions { flex-wrap: wrap; justify-content: flex-end; }
  .stack-on-phone .row-actions button { min-height: 40px; }
  /* Short add-forms (a guest, a payment): one full-width field under the other. */
  .inline-form .field { flex-basis: 100%; min-width: 0; margin-bottom: 4px; }
  .inline-form .field input, .inline-form .field select { width: 100%; }

  .topbar-inner { gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  .signout { width: 100%; justify-content: space-between; flex-wrap: wrap; row-gap: 6px; }
  dl.details { grid-template-columns: 1fr; gap: 0; }
  dl.details dd { margin-bottom: 8px; }
}
.alert-link { display: inline-block; margin-top: 4px; }

/* --- working with no internet (offline.js) -------------------------------- */
.flash.warn { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.offline-banner {
  position: sticky; top: 0; z-index: 20;
  border-radius: 6px; padding: 10px 14px; margin: 0 0 16px;
}
.offline-banner.bad { background: var(--danger-soft); color: var(--danger); }
.offline-banner.warn { background: var(--warn-soft); color: var(--warn); }
.offline-banner a { color: inherit; font-weight: 600; }
tr.not-sent td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.reminder-box.sync-report { max-width: 640px; max-height: 85vh; overflow-y: auto; border-top-color: var(--accent); }
.sync-report h2 { color: var(--ink); }
.sync-failures { padding-left: 18px; margin: 8px 0 16px; }
.sync-failures li { margin-bottom: 10px; }

/* Lists of checkboxes (office.js fillChecks): a tour's vehicle types, a guide's skills. */
.checks { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 4px 0; }
.allergy { color: var(--danger); font-weight: 600; }
.print-links { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.email-body { white-space: pre-wrap; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 12px; font-size: 0.9rem; max-height: 420px; overflow: auto; }
.photo-link img { height: 48px; width: 64px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); vertical-align: middle; }
