/* Tecon HQ — staff app. Hand-rolled, no framework. Palette from colour-palette.md. */
@font-face { font-family: "Montserrat"; src: url("/assets/fonts/Montserrat-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --red: #ED1C24; --red-ink: #C8161D; --ink: #1A1A1A; --charcoal: #333; --grey-600: #666; --grey-500: #808080;
  --grey-300: #B3B3B3; --grey-100: #E6E6E6; --mist: #F5F5F4; --paper: #fff; --teal: #11AEC0;
  --st-new: #808080; --st-scheduled: #11AEC0; --st-in_progress: #ED1C24; --st-completed: #1A1A1A;
  --font: Montserrat, "Segoe UI", system-ui, -apple-system, Helvetica, Arial, sans-serif;
  --r: 4px; --shadow: 0 6px 24px rgba(0,0,0,.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--font); color: var(--charcoal); background: var(--mist); }
[hidden] { display: none !important; }
h1, h2, h3 { color: var(--ink); line-height: 1.2; margin: 0 0 .75rem; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
a { color: var(--red-ink); }
.muted { color: var(--grey-600); } .small { font-size: .85rem; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 1rem; top: 1rem; z-index: 99; background: #fff; padding: .5rem 1rem; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

/* Buttons + forms */
.btn { font: inherit; font-weight: 700; border: 1px solid var(--grey-300); background: #fff; color: var(--ink); padding: .5rem .9rem; border-radius: var(--r); cursor: pointer; display: inline-flex; gap: .4rem; align-items: center; text-decoration: none; }
.btn:hover { border-color: var(--ink); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-ink); border-color: var(--red-ink); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-sm { padding: .25rem .55rem; font-size: .8rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--grey-300); font: inherit; cursor: pointer; text-decoration: underline; }
label { display: grid; gap: .25rem; font-size: .85rem; font-weight: 700; color: var(--ink); }
input, select, textarea { font: inherit; font-weight: 400; padding: .5rem .6rem; border: 1px solid var(--grey-300); border-radius: var(--r); background: #fff; color: var(--ink); width: 100%; }
textarea { min-height: 90px; resize: vertical; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--red); }
.field-error, .form-error { color: var(--red-ink); font-size: .8rem; font-weight: 700; margin: 0; min-height: 1em; }
.form-grid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.toolbar label { min-width: 150px; }
.spacer { flex: 1; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--ink) linear-gradient(135deg, #1A1A1A 60%, #2a0d0e); padding: 1rem; }
.login-card { background: #fff; padding: 2.25rem; width: min(420px, 100%); border-top: 6px solid var(--red); display: grid; gap: 1rem; border-radius: var(--r); box-shadow: var(--shadow); }
.login-logo { width: 220px; height: auto; }

/* Shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #fff; display: flex; flex-direction: column; padding: 1.25rem 0; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: .5rem; padding: 0 1.25rem 1.25rem; color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .1em; border-bottom: 1px solid #333; }
.brand img { width: 150px; height: auto; } .brand span { color: var(--red); font-size: .8rem; }
.nav { display: grid; padding: 1rem 0; flex: 1; align-content: start; }
.nav a { color: var(--grey-300); text-decoration: none; padding: .65rem 1.25rem; border-left: 4px solid transparent; font-weight: 700; display: flex; justify-content: space-between; }
.nav a:hover { color: #fff; background: #222; }
.nav a[aria-current="page"] { color: #fff; border-left-color: var(--red); background: #262626; }
.nav .count { background: var(--red); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 .5rem; line-height: 1.6; }
.me { padding: 1rem 1.25rem 0; border-top: 1px solid #333; display: grid; gap: .35rem; font-size: .85rem; }
.badge { display: inline-block; margin-left: .5rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; padding: .05rem .45rem; border-radius: 999px; background: #333; color: #fff; }
.main { padding: 2rem clamp(1rem, 3vw, 2.5rem); min-width: 0; }
.main:focus { outline: none; }
.nav-toggle { display: none; }

.page-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; position: relative; padding-bottom: .35rem; }
.page-head h1::after { content: ""; position: absolute; left: 0; bottom: 0; width: 40px; height: 3px; background: var(--red); }
.card { background: #fff; border: 1px solid var(--grey-100); border-radius: var(--r); padding: 1.25rem; margin-bottom: 1rem; }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }

/* Tables */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--grey-100); border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--grey-100); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--grey-600); background: #fafafa; }
tr.clickable { cursor: pointer; } tr.clickable:hover td { background: #fff7f7; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; color: var(--ink); background: #fafafa; }
.empty { padding: 2rem; text-align: center; color: var(--grey-600); }

/* Status */
.status { display: inline-flex; align-items: center; gap: .35rem; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.status::before { content: ""; width: .6rem; height: .6rem; border-radius: 50%; background: var(--c, var(--grey-500)); }
.status.new { --c: var(--st-new); } .status.scheduled { --c: var(--st-scheduled); } .status.in_progress { --c: var(--st-in_progress); } .status.completed { --c: var(--st-completed); }
.chips { display: flex; gap: .35rem; flex-wrap: wrap; }
.chip { font: inherit; font-size: .8rem; font-weight: 700; padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--grey-300); background: #fff; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* Timeline / diary */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.timeline li { border-left: 3px solid var(--grey-100); padding: .1rem 0 .1rem .75rem; }
.timeline li.status-ev { border-left-color: var(--red); }
.entry { border: 1px solid var(--grey-100); border-radius: var(--r); padding: .75rem .9rem; background: #fff; margin-bottom: .6rem; }
.entry header { display: flex; gap: .5rem; flex-wrap: wrap; font-size: .8rem; color: var(--grey-600); margin-bottom: .35rem; }
.entry header strong { color: var(--ink); }
.entry p { margin: 0; white-space: pre-wrap; }
.pill { font-size: .72rem; font-weight: 700; background: var(--mist); border-radius: 999px; padding: 0 .5rem; }
.pill.time { background: #e8f7f9; color: #0b6b77; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r); border: 1px solid var(--grey-100); }

/* Scheduler */
.sched { display: grid; grid-template-columns: 220px 1fr; gap: 1rem; }
.unscheduled { background: #fff; border: 1px solid var(--grey-100); border-radius: var(--r); padding: .75rem; align-self: start; max-height: 75vh; overflow: auto; }
.unscheduled .job-card { position: static; margin-bottom: .5rem; }
.cal { background: #fff; border: 1px solid var(--grey-100); border-radius: var(--r); overflow: auto; max-height: 75vh; }
.cal-grid { display: grid; grid-template-columns: 56px repeat(var(--days), minmax(120px, 1fr)); position: relative; min-width: calc(56px + var(--days) * 120px); }
.cal-head { position: sticky; top: 0; z-index: 3; background: #fafafa; border-bottom: 1px solid var(--grey-100); padding: .5rem; font-size: .8rem; font-weight: 700; text-align: center; }
.cal-head.today { color: var(--red-ink); box-shadow: inset 0 -3px 0 var(--red); }
.cal-times { grid-row: 2; grid-column: 1; }
.cal-times div { height: var(--slot); font-size: .7rem; color: var(--grey-500); text-align: right; padding-right: .4rem; transform: translateY(-.5em); }
.cal-col { grid-row: 2; position: relative; border-left: 1px solid var(--grey-100); background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--slot) - 1px), var(--grey-100) calc(var(--slot) - 1px), var(--grey-100) var(--slot)); }
.cal-col.drop { background-color: #fff3f3; }
.job-card { position: absolute; left: 3px; right: 3px; border-radius: var(--r); padding: .3rem .45rem; font-size: .75rem; line-height: 1.25; color: #fff; background: var(--c, var(--grey-500)); overflow: hidden; cursor: grab; box-shadow: 0 1px 3px rgba(0,0,0,.2); border: 0; text-align: left; font-family: inherit; width: auto; }
.job-card:active { cursor: grabbing; }
.job-card.new { --c: var(--st-new); } .job-card.scheduled { --c: var(--st-scheduled); } .job-card.in_progress { --c: var(--st-in_progress); } .job-card.completed { --c: var(--st-completed); }
.job-card strong { display: block; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; margin-top: .5rem; }

/* Timesheets */
.ts-tech { margin-bottom: 1.5rem; }
.ts-cell { font: inherit; background: none; border: 0; padding: .1rem .3rem; cursor: pointer; border-radius: 3px; font-variant-numeric: tabular-nums; }
.ts-cell:hover { background: var(--mist); }
.ts-cell.adjusted { color: var(--red-ink); font-weight: 700; }
.ts-cell.open::after { content: " ●"; color: var(--red); }

/* Modal + toast */
.modal { border: 0; border-radius: var(--r); padding: 0; width: min(640px, 94vw); box-shadow: var(--shadow); border-top: 5px solid var(--red); }
.modal::backdrop { background: rgba(26,26,26,.6); }
#modal-body { padding: 1.5rem; display: grid; gap: 1rem; }
.toast { position: fixed; bottom: 1.25rem; right: 1.25rem; background: var(--ink); color: #fff; padding: .75rem 1rem; border-radius: var(--r); border-left: 4px solid var(--red); box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); transition: .25s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; transform: none; }
.notice { background: #fff4e5; border-left: 4px solid #e8a33c; padding: .75rem 1rem; margin-bottom: 1rem; border-radius: var(--r); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 30% 0 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .nav-toggle { display: block; position: fixed; top: .75rem; right: .75rem; z-index: 45; font: inherit; font-weight: 700; background: var(--ink); color: #fff; border: 0; padding: .5rem .9rem; border-radius: var(--r); }
  .main { padding-top: 3.5rem; }
  .grid-2, .sched { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

td:first-child { white-space: nowrap; }
