/* Flybusters office - screen and print styles */
:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --ink: #1d2420;
  --muted: #5f6b64;
  --line: #d9ded9;
  --brand: #2f6b3a;
  --brand-ink: #ffffff;
  --brand-soft: #e5f0e6;
  --warn: #8a5a00;
  --warn-soft: #fff4dc;
  --danger: #a12a2a;
  --danger-soft: #fbe9e9;
  --info-soft: #e8f0fa;
  --mark: #fff7c2;
  --radius: 6px;
  font-size: 15px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
}
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pre { white-space: pre-line; }

/* Header and navigation */
.topbar {
  background: var(--brand);
  color: var(--brand-ink);
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem;
  padding: .5rem 1rem;
}
.topbar a { color: var(--brand-ink); text-decoration: none; }
.topbar .brand { font-weight: 700; letter-spacing: .02em; }
.topbar nav { display: flex; flex-wrap: wrap; gap: .25rem; }
.topbar nav a { padding: .3rem .6rem; border-radius: var(--radius); }
.topbar nav a:hover, .topbar nav a.active { background: rgba(255,255,255,.18); }
.topbar form.search { margin-left: auto; display: flex; gap: .25rem; }
.topbar form.search input { width: 14rem; max-width: 50vw; border: 0; }
.topbar .user { font-size: .85rem; display: flex; gap: .75rem; align-items: center; }
.topbar .user button { background: none; border: 0; color: inherit; padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }
.marked-pill { background: var(--mark); color: var(--ink) !important; border-radius: 999px; padding: .05rem .55rem; font-size: .8rem; }

main { max-width: 1280px; margin: 0 auto; padding: 1rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head .subtitle { color: var(--muted); }

/* Cards and layout */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.with-sidebar { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 1rem; align-items: start; }
@media (max-width: 900px) { .with-sidebar { grid-template-columns: 1fr; } }

dl.details { display: grid; grid-template-columns: max-content 1fr; gap: .2rem 1rem; margin: 0; }
dl.details dt { color: var(--muted); }
dl.details dd { margin: 0; }

/* Buttons */
.btn, button, input[type=submit] {
  display: inline-block; font: inherit; cursor: pointer;
  padding: .4rem .8rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  text-decoration: none; line-height: 1.3;
}
.btn:hover, button:hover { border-color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-small { padding: .2rem .5rem; font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.stack { display: flex; flex-direction: column; gap: .4rem; }
.stack > form, .stack > form > button, .stack > .btn { width: 100%; text-align: left; }
form.inline { display: inline; }

/* Forms */
label { font-weight: 500; }
input[type=text], input[type=email], input[type=number], input[type=password], input:not([type]), select, textarea {
  font: inherit; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.field { margin-bottom: .7rem; }
.field label { display: block; margin-bottom: .15rem; font-size: .9rem; }
.field .help { color: var(--muted); font-size: .8rem; }
.field .errors, .errorlist { color: var(--danger); font-size: .85rem; margin: .2rem 0 0; padding: 0; list-style: none; }
.field.checkbox label { display: flex; gap: .4rem; align-items: center; }
.field.checkbox input { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 1rem; }
.form-grid .wide { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; margin: 0 0 1rem; }
legend { font-weight: 600; padding: 0 .3rem; }
.sentence { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.sentence select, .sentence input { width: auto; }
ul.checkboxes { list-style: none; padding: 0; margin: 0; columns: 2; }
ul.checkboxes label { font-weight: normal; }

/* Messages */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .6rem .8rem; border-radius: var(--radius); margin-bottom: .4rem; background: var(--info-soft); }
.messages li.success { background: var(--brand-soft); }
.messages li.warning { background: var(--warn-soft); color: var(--warn); }
.messages li.error { background: var(--danger-soft); color: var(--danger); }
.notice { padding: .6rem .8rem; border-radius: var(--radius); background: var(--warn-soft); color: var(--warn); margin-bottom: 1rem; }
.notice.danger { background: var(--danger-soft); color: var(--danger); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; background: var(--surface); }
table.data th, table.data td { padding: .35rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { font-size: .85rem; color: var(--muted); font-weight: 600; background: #fafbfa; position: sticky; top: 0; }
table.data th a { color: inherit; }
table.data th.sorted { color: var(--ink); }
table.data tr:hover td { background: #f8faf8; }
table.data tr.inactive td { color: var(--muted); }
table.data tr.marked td { background: var(--mark); }
table.data tr.highlight td { background: var(--brand-soft); }
table.data tr.upcoming td:first-child { border-left: 3px solid var(--brand); }
table.data tfoot td { font-weight: 600; border-top: 2px solid var(--ink); }
.tag { display: inline-block; font-size: .75rem; padding: 0 .4rem; border-radius: 999px; background: var(--line); color: var(--ink); }
.tag.inactive { background: var(--danger-soft); color: var(--danger); }
.tag.quote { background: var(--info-soft); }
.tag.marked { background: var(--mark); }

.pagination { display: flex; gap: .5rem; align-items: center; margin: .75rem 0; }
.record-nav { display: flex; gap: .5rem; align-items: center; font-size: .9rem; color: var(--muted); }

/* Printable pages */
.print-toolbar { display: flex; gap: .5rem; align-items: center; padding: .6rem 1rem; background: var(--brand-soft); border-bottom: 1px solid var(--line); }
.paper { background: #fff; max-width: 210mm; margin: 1rem auto; padding: 14mm 12mm; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.paper h1 { font-size: 1.3rem; }
.paper table.data th { position: static; }
.page-break { break-after: page; }
.envelope { width: 220mm; height: 110mm; position: relative; border: 1px dashed var(--line); margin: 1rem auto; background: #fff; break-after: page; padding: 8mm; font-size: 11pt; }
.envelope .return { position: absolute; top: 8mm; left: 8mm; font-size: 8.5pt; line-height: 1.3; }
.envelope .return img { max-height: 16mm; max-width: 50mm; display: block; margin-bottom: 2mm; }
.envelope .to { position: absolute; top: 52mm; left: 105mm; line-height: 1.35; }
.report-group td { background: #f0f3f0; font-weight: 600; }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 10pt; }
  .topbar, .print-toolbar, .no-print, .messages { display: none !important; }
  main { padding: 0; max-width: none; }
  .paper { box-shadow: none; margin: 0; padding: 0; max-width: none; }
  table.data th { background: none; }
  table.data tr:hover td { background: none; }
  .envelope { border: 0; margin: 0; }
  a { color: inherit; text-decoration: none; }
}
@page envelope { size: 220mm 110mm; margin: 0; }
.envelope { page: envelope; }
