:root {
  --bg: #f4f6f9; --surface: #ffffff; --text: #1b2430; --muted: #5d6b7c; --line: #dbe1e8;
  --brand: #1f5fbf; --brand-dark: #174a96; --ok: #1d7a46; --warn: #a85b00; --bad: #b3261e;
  --radius: 8px; --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #000000; --surface: #0e0e0e; --text: #ffffff; --muted: #b3b3b3; --line: #3a3a3a; --brand: #6fb0ff; --brand-dark: #a6ceff; --ok: #4fd18b; --warn: #ffb454; --bad: #ff7b72; }
  :root:not([data-theme="light"]) button:not(.ghost), :root:not([data-theme="light"]) .btn:not(.ghost) { color: #000; }
  :root:not([data-theme="light"]) header.top img { background: #fff; padding: 4px 8px; border-radius: 6px; }
  :root:not([data-theme="light"]) .pill { background: #262626 !important; }
}
:root[data-theme="dark"] { --bg: #000000; --surface: #0e0e0e; --text: #ffffff; --muted: #b3b3b3; --line: #3a3a3a; --brand: #6fb0ff; --brand-dark: #a6ceff; --ok: #4fd18b; --warn: #ffb454; --bad: #ff7b72; }
:root[data-theme="dark"] button:not(.ghost), :root[data-theme="dark"] .btn:not(.ghost) { color: #000; }
:root[data-theme="dark"] header.top img { background: #fff; padding: 4px 8px; border-radius: 6px; }
:root[data-theme="dark"] .pill { background: #262626 !important; }

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
header.top { background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 24px; padding: 10px 24px; flex-wrap: wrap; }
header.top img { height: 34px; }
header.top nav { display: flex; gap: 18px; flex: 1; align-items: center; flex-wrap: wrap; }
header.top nav a { white-space: nowrap; }
header.top nav a { color: var(--text); font-weight: 500; }
main { max-width: 1100px; margin: 24px auto; padding: 0 16px; }
h1 { font-size: 24px; margin: 0 0 16px; } h2 { font-size: 18px; margin: 24px 0 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 140px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; }
textarea { min-height: 70px; resize: vertical; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--text); font-weight: 400; margin: 0; }
button, .btn { background: var(--brand); color: #fff; border: 0; border-radius: 6px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; display: inline-block; }
button:hover, .btn:hover { background: var(--brand-dark); text-decoration: none; }
button.ghost, .btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
button.danger { background: var(--bad); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; white-space: nowrap; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line); }
.pill.accepted { background: #d8f0e1; color: var(--ok); } .pill.sent { background: #dce8fb; color: var(--brand-dark); }
.pill.declined, .pill.expired { background: #f6dcda; color: var(--bad); }
.muted { color: var(--muted); } .stats { display: flex; gap: 16px; flex-wrap: wrap; } .stats .card { flex: 1 1 160px; margin: 0; }
.stats b { font-size: 28px; display: block; }
.line-form { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.line-form .c2 { grid-column: span 2; } .line-form .c3 { grid-column: span 3; } .line-form .c4 { grid-column: span 4; } .line-form .c6 { grid-column: span 6; } .line-form .c8 { grid-column: span 8; } .line-form .c12 { grid-column: span 12; }
.cost { color: var(--bad); }
@media (max-width: 700px) { .line-form > * { grid-column: span 12 !important; } header.top { padding: 10px 16px; } }
.login { max-width: 360px; margin: 12vh auto; } .login img { height: 48px; display: block; margin: 0 auto 16px; }
.err { color: var(--bad); font-weight: 600; }

/* top navigation */
header.top nav a.active, header.top nav details.menu.active > summary { color: var(--brand); border-bottom: 2px solid var(--brand); }
header.top nav a, header.top nav details.menu > summary { padding: 6px 2px; }
details.menu { position: relative; }
details.menu > summary { cursor: pointer; list-style: none; font-weight: 500; color: var(--text); white-space: nowrap; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu > summary::after { content: " \25BE"; font-size: 11px; color: var(--muted); }
.menu-items { position: absolute; top: 100%; left: -10px; min-width: 190px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 6px 18px rgba(0,0,0,.14); padding: 6px; z-index: 50; }
.menu-items a { display: block; padding: 8px 12px; border-radius: 6px; color: var(--text); border-bottom: 0 !important; }
.menu-items a:hover { background: var(--bg); text-decoration: none; }

/* sortable report columns */
th.sortable-col { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable-col:hover, th.sortable-col:focus { color: var(--brand); outline: none; }
th.sortable-col::after { content: " C5"; font-size: 11px; opacity: .35; }
th.sortable-col[aria-sort="ascending"]::after { content: " B2"; opacity: 1; color: var(--brand); }
th.sortable-col[aria-sort="descending"]::after { content: " BC"; opacity: 1; color: var(--brand); }
tfoot td { border-top: 2px solid var(--line); font-weight: 700; }

/* the staff header. A full menu while it fits; the menu button below 1250px (half a screen included). */
.nav-toggle { display: none; background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; cursor: pointer; flex-direction: column; gap: 4px; }
.nav-toggle span { display: block; width: 20px; height: 2px; background: var(--text); border-radius: 2px; }
.hdr-short { display: none; }
header.staff nav { flex-wrap: nowrap; }
@media (max-width: 1250px) {                                  /* too narrow for the whole menu (half a screen included): the menu button */
  header.staff { gap: 12px; padding: 8px 16px; }
  .nav-toggle { display: inline-flex; }
  header.staff nav { display: none; order: 10; flex: 1 1 100%; flex-direction: column; align-items: stretch; gap: 0; border-top: 1px solid var(--line); padding-top: 6px; }
  header.staff.nav-open nav { display: flex; }
  header.staff nav > a, header.staff nav details.menu > summary { display: block; padding: 11px 6px; border-bottom: 1px solid var(--line); }
  header.staff nav a.active, header.staff nav details.menu.active > summary { border-bottom: 1px solid var(--line); border-left: 3px solid var(--brand); padding-left: 10px; }
  header.staff nav details.menu { position: static; }
  header.staff .menu-items { position: static; box-shadow: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 0 0 4px 14px; min-width: 0; }
  header.staff .menu-items a { padding: 10px 8px; }
  header.staff #new-ticket { margin-left: auto; }
  .hdr-long { display: none; } .hdr-short { display: inline; }
  header.staff .hdr-dash { display: none; }
}
@media (max-width: 560px) {
  header.staff img { height: 28px; }
  header.staff > form { margin-left: auto; }
  header.staff #new-ticket { margin-left: 0; padding: 7px 10px; }
}
