/* RW Aerospace employee portal */
:root {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --line: #dbe1ec;
  --line-2: #eef1f6;
  --text: #121a2b;
  --muted: #5d6b84;
  --navy: #0b1221;
  --navy-2: #141f36;
  --gold: #f2b134;
  --gold-text: #8a5d00;
  --blue: #1f5fbf;
  --green: #1d7f4d;
  --green-bg: #e6f5ec;
  --red: #b4261e;
  --red-bg: #fbe9e7;
  --amber-bg: #fff4d6;
  --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.5; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; font-variation-settings: 'wdth' 106; }
h1 { font-size: 1.5rem; font-weight: 650; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 0.8rem; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }

/* Shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #d7deea; padding: 1.2rem 0.9rem; display: flex; flex-direction: column; gap: 0.3rem; position: sticky; top: 0; height: 100vh; overflow: auto; }
.side .brand { color: #fff; font-weight: 700; font-variation-settings: 'wdth' 116; padding: 0.3rem 0.6rem 1rem; display: block; font-size: 1.05rem; }
.side .brand small { display: block; font-weight: 400; color: #8e9bb4; font-size: 0.75rem; font-variation-settings: 'wdth' 100; }
.side .group { color: #7f8ca6; font-size: 0.74rem; padding: 0.9rem 0.6rem 0.25rem; }
.side a.item { color: #d7deea; display: flex; justify-content: space-between; align-items: center; padding: 0.45rem 0.6rem; border-radius: 6px; font-size: 0.95rem; }
.side a.item:hover { background: var(--navy-2); text-decoration: none; }
.side a.item.active { background: var(--gold); color: #1a1200; font-weight: 600; }
.side .badge { background: rgba(255,255,255,0.14); color: #fff; border-radius: 999px; padding: 0 0.5rem; font-size: 0.75rem; }
.side a.item.active .badge { background: rgba(0,0,0,0.18); color: #1a1200; }
.side .me { margin-top: auto; padding: 0.8rem 0.6rem 0; border-top: 1px solid var(--navy-2); font-size: 0.88rem; color: #9fabc2; }
.side .me strong { color: #fff; display: block; }
.side .me a { color: #c9d2e3; }
.main { padding: 1.6rem 2rem 4rem; max-width: 1200px; width: 100%; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.topbar .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.btn.menu-btn { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 30; transform: translateX(-100%); transition: transform 0.2s; }
  .side.open { transform: none; }
  .main { padding: 1rem; }
  .btn.menu-btn { display: inline-block; }
}

/* Auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; background: var(--navy); }
.auth .box { background: var(--panel); border-radius: 12px; padding: 2rem; width: min(440px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,0.35); }
.auth .box h1 { margin-bottom: 0.3rem; }
.auth .brand { color: var(--muted); font-size: 0.85rem; margin-bottom: 1.2rem; display: block; }
.auth .or { text-align: center; color: var(--muted); margin: 1rem 0; font-size: 0.85rem; }
.qr { display: flex; gap: 1.2rem; align-items: flex-start; margin: 1rem 0; flex-wrap: wrap; }
.qr svg { width: 180px; height: 180px; border: 1px solid var(--line); border-radius: 8px; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem 1rem; font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--bg); padding: 1rem; border-radius: 8px; margin: 1rem 0; }

/* Components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1.2rem 1.3rem; margin-bottom: 1.2rem; }
.card h2 { margin-bottom: 0.8rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.2rem; }
.stat .n { font-size: 1.9rem; font-weight: 700; line-height: 1.1; font-variation-settings: 'wdth' 110; }
.stat .l { color: var(--muted); font-size: 0.9rem; }
.stat.warn { border-color: var(--gold); background: var(--amber-bg); }
.stat a { color: inherit; }
.btn { display: inline-block; background: var(--panel); border: 1px solid var(--line); color: var(--text); padding: 0.5rem 0.9rem; border-radius: 6px; font: inherit; font-size: 0.92rem; cursor: pointer; line-height: 1.2; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1a1200; font-weight: 600; }
.btn.danger { color: var(--red); border-color: #e8b4af; }
.btn.sm { padding: 0.3rem 0.6rem; font-size: 0.85rem; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn.wide { width: 100%; text-align: center; }
.chip { display: inline-block; border-radius: 999px; padding: 0.1rem 0.6rem; font-size: 0.78rem; font-weight: 600; background: var(--line-2); color: var(--muted); white-space: nowrap; }
.chip.draft { background: var(--line-2); }
.chip.pending_review, .chip.submitted, .chip.new, .chip.sent, .chip.viewed, .chip.queued { background: var(--amber-bg); color: var(--gold-text); }
.chip.published, .chip.approved, .chip.active, .chip.completed, .chip.hired, .chip.handled { background: var(--green-bg); color: var(--green); }
.chip.closed, .chip.rejected, .chip.declined, .chip.suspended, .chip.offboarded, .chip.failed, .chip.error, .chip.voided { background: var(--red-bg); color: var(--red); }
.chip.invited, .chip.open, .chip.reviewing, .chip.contacted, .chip.interview, .chip.offer { background: #e7eefc; color: var(--blue); }
.alert { border-radius: 8px; padding: 0.8rem 1rem; margin: 0 0 1rem; border: 1px solid var(--line); background: var(--panel); }
.alert.ok { background: var(--green-bg); border-color: #b5e0c6; color: var(--green); }
.alert.err { background: var(--red-bg); border-color: #efc3bf; color: var(--red); }
.alert.warn { background: var(--amber-bg); border-color: #f1d79a; color: var(--gold-text); }
.empty { border: 1px dashed var(--line); border-radius: 10px; padding: 1.6rem; color: var(--muted); text-align: center; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; font-size: 0.92rem; }
th, td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 0.82rem; background: #fafbfd; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f7f9fd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; margin-bottom: 1.2rem; }

/* Forms */
label.f { display: block; margin-bottom: 0.9rem; font-size: 0.86rem; color: var(--muted); }
label.f > span { display: block; margin-bottom: 0.25rem; }
label.f b { color: var(--gold-text); font-weight: 500; }
input[type='text'], input[type='email'], input[type='tel'], input[type='url'], input[type='password'], input[type='number'], input[type='date'], input[type='file'], select, textarea {
  width: 100%; background: #fff; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 0.55rem 0.7rem; font: inherit; font-size: 0.95rem;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31,95,191,0.12); }
textarea { min-height: 7rem; resize: vertical; }
input[type='checkbox'] { width: 1rem; height: 1rem; vertical-align: -2px; margin-right: 0.4rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 1rem; }
@media (max-width: 700px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.split { display: grid; grid-template-columns: 1.5fr 1fr; gap: 1.2rem; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.help { color: var(--muted); font-size: 0.85rem; }
.inline-code { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--bg); padding: 0.1rem 0.4rem; border-radius: 4px; word-break: break-all; }

/* Timesheet grid */
.ts-grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.ts-grid th, .ts-grid td { padding: 0.45rem 0.4rem; border-bottom: 1px solid var(--line-2); }
.ts-grid th.day { text-align: center; font-size: 0.8rem; }
.ts-grid th.day small { display: block; color: var(--muted); font-weight: 400; }
.ts-grid th.today, .ts-grid td.today { background: var(--amber-bg); }
.ts-grid td.code strong { display: block; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; }
.ts-grid td.code span { color: var(--muted); font-size: 0.8rem; }
.ts-grid input[type='number'] { width: 4.2rem; text-align: right; padding: 0.35rem 0.4rem; }
.ts-grid input[type='number']:disabled { background: var(--bg); color: var(--muted); }
.ts-grid td.tot, .ts-grid th.tot { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.ts-grid tfoot td { background: #fafbfd; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.ts-grid td.future { background: #f6f7fa; }
.progress { height: 8px; background: var(--line-2); border-radius: 999px; overflow: hidden; min-width: 120px; }
.progress span { display: block; height: 100%; background: var(--green); }
.progress.warn span { background: var(--gold); }
.progress.over span { background: var(--red); }

/* Thread */
.thread { display: flex; flex-direction: column; gap: 0.7rem; }
.msg { border: 1px solid var(--line); border-radius: 8px; padding: 0.7rem 0.9rem; background: #fff; }
.msg.internal { background: #fbfcfe; border-style: dashed; }
.msg.outbound { border-left: 3px solid var(--gold); }
.msg .meta { color: var(--muted); font-size: 0.8rem; margin-bottom: 0.3rem; display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.msg pre { white-space: pre-wrap; font: inherit; margin: 0; }
details.ann { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 0.6rem 0.9rem; margin-bottom: 0.6rem; }
details.ann summary { cursor: pointer; font-weight: 600; display: flex; justify-content: space-between; gap: 1rem; }
details.ann pre { white-space: pre-wrap; font: inherit; margin: 0.6rem 0; }
#toasts { position: fixed; bottom: 1.2rem; right: 1.2rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 50; }
.toast { background: var(--navy); color: #fff; padding: 0.7rem 1rem; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.25); max-width: 360px; }
.toast.err { background: var(--red); }
dialog { border: 0; border-radius: 12px; padding: 1.4rem; width: min(520px, 92vw); box-shadow: 0 30px 80px rgba(0,0,0,0.35); }
dialog::backdrop { background: rgba(6,10,18,0.5); }
.hidden { display: none !important; }
