/* Manpower Program — Refined Swiss design system.
 * Helvetica, monochrome, sharp corners. Hierarchy through type and whitespace,
 * not boxes: hairline grey rules by default, black reserved for emphasis.
 * Green appears only on Confirm; red only for danger/over-budget. */

:root {
  --black: #000;
  --white: #fff;
  --hairline: #e2e2e2;   /* default rule/border */
  --rule-mid: #c9c9c9;   /* stronger rule */
  --faint: #f7f7f7;      /* hover / zebra / weekend fill */
  --grey-text: #6b6b6b;
  --grey-soft: #9a9a9a;
  --accent: #008a3e;     /* Confirm only */
  --accent-dark: #00712f;
  --danger: #b00020;
  --gutter: 16px;
  --pad: 20px;
  --maxw: 1100px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: Helvetica, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--black);
  background: var(--white);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button { font-family: inherit; }
img { max-width: 100%; }
code { font-family: inherit; }

.icon { display: inline-block; line-height: 0; }
.icon svg,
.confirm-mark svg { width: 100%; height: 100%; display: block; }

:focus-visible { outline: 2px solid var(--black); outline-offset: 2px; }

/* ---- Header ---- */
.topbar { border-bottom: 1px solid var(--black); }
.topbar-row {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; padding: 0 var(--pad);
  max-width: var(--maxw); margin: 0 auto;
}
.topbar-brand {
  font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; font-size: 17px;
}
.topbar-logout { margin: 0; }
.btn-icon {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--black); cursor: pointer; padding: 0;
}
.btn-icon .icon { width: 22px; height: 22px; }
.btn-icon:hover { opacity: 0.55; }
.topbar-back { text-decoration: none; margin-left: -12px; }

.adminnav {
  display: flex; gap: 4px; max-width: var(--maxw); margin: 0 auto; overflow-x: auto;
  padding: 0 calc(var(--pad) - 12px);
}
.adminnav a {
  padding: 14px 12px 12px; text-decoration: none; font-size: 13px;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--grey-text);
  white-space: nowrap; border-bottom: 2px solid transparent;
}
.adminnav a:hover { color: var(--black); }
.adminnav a.is-active { border-bottom-color: var(--black); color: var(--black); font-weight: 700; }

/* ---- Layout ---- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 28px var(--pad) 64px; }

/* ---- Typography ---- */
.h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; margin: 0 0 24px; }
.h2 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--grey-text); margin: 48px 0 16px; }
.h2:first-child { margin-top: 0; }
.h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--grey-text); margin: 32px 0 10px; }
.muted { color: var(--grey-text); }
.note { border: 1px solid var(--hairline); padding: 12px 14px; font-size: 13px; color: var(--grey-text); margin-bottom: 24px; }
.alert { border-left: 3px solid var(--danger); color: var(--danger); padding: 4px 0 4px 14px; margin: 0 0 24px; font-weight: 500; }
.alert-warn { border-left-color: var(--black); color: var(--black); font-weight: 400; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--black); color: var(--white); border: 1px solid var(--black);
  padding: 12px 22px; font: inherit; font-size: 14px; font-weight: 700;
  letter-spacing: 0.02em; text-decoration: none; cursor: pointer; min-height: 44px;
}
.btn:hover { background: #2a2a2a; border-color: #2a2a2a; }
.btn-ghost { background: var(--white); color: var(--black); border-color: var(--rule-mid); font-weight: 500; }
.btn-ghost:hover { background: var(--white); border-color: var(--black); color: var(--black); }
.btn-lg { padding: 16px 28px; font-size: 16px; min-height: 56px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn .icon { width: 18px; height: 18px; }
.btn-confirm { background: var(--accent); border-color: var(--accent); color: var(--white); }
.btn-confirm:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

/* Small buttons inside table rows: quiet text style, not filled blocks. */
.btn-sm {
  background: none; border: none; color: var(--black); padding: 6px 4px;
  min-height: 36px; font-size: 13px; font-weight: 500; text-decoration: none;
}
.btn-sm:hover { background: none; border: none; text-decoration: underline; text-underline-offset: 3px; }
.btn-danger { background: none; border: none; color: var(--danger); font-weight: 500; }
.btn-danger:hover { background: none; border: none; color: var(--danger); text-decoration: underline; text-underline-offset: 3px; }
/* Larger standalone danger action (e.g. "Void this entry") */
.form .btn-danger { border: 1px solid var(--danger); padding: 12px 22px; }
.form .btn-danger:hover { text-decoration: none; background: #fdf3f4; }

/* ---- Panels & forms ---- */
.panel { border: 1px solid var(--hairline); padding: 24px; margin-bottom: 24px; }
.panel-narrow { max-width: 360px; margin: 9vh auto 0; border: none; padding: 0; }

.form { display: grid; gap: 22px; max-width: 480px; }
.field { display: grid; gap: 7px; }
.field-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--grey-text); }
.input {
  font: inherit; padding: 11px 12px; border: 1px solid var(--rule-mid); background: var(--white);
  width: 100%; min-height: 44px; color: var(--black);
}
.input:focus { outline: none; border-color: var(--black); box-shadow: inset 0 0 0 1px var(--black); }
.input[type="file"] { padding: 9px 12px; font-size: 13px; }
select.input { appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23000' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.field-check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; line-height: 1.4; }
.field-check input { width: 18px; height: 18px; flex: none; margin-top: 1px; accent-color: var(--black); }
.rule { border: none; border-top: 1px solid var(--hairline); margin: 40px 0; }
.preview { max-width: 200px; border: 1px solid var(--hairline); display: block; }
.field-hint { font-size: 12px; color: var(--grey-soft); font-weight: 400; text-transform: none; letter-spacing: 0; }

.check-list { display: grid; gap: 10px; border: 1px solid var(--hairline); padding: 14px; max-height: 280px; overflow-y: auto; }
.check-row { display: flex; align-items: center; gap: 10px; font-weight: 400; font-size: 14px; }
.check-row input { width: 17px; height: 17px; flex: none; accent-color: var(--black); }

/* ---- Login ---- */
.login-brand {
  font-size: 26px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  text-align: center; margin: 0 0 8px;
}
.login-rule { border: none; border-top: 1px solid var(--black); width: 40px; margin: 0 auto 36px; }

/* ---- Worker: tiles (projects / categories / tasks) ---- */
.context { font-weight: 700; margin: -8px 0 24px; display: flex; align-items: center; gap: 10px; font-size: 15px; }
.context-thumb { width: 28px; height: 28px; display: inline-block; flex: none; }
.context-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.tilegrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px 20px; }
.tile { display: block; text-decoration: none; }
.tile-img {
  display: block; aspect-ratio: 1 / 1; background: var(--faint); position: relative;
  overflow: hidden; border: 1px solid var(--hairline);
}
.tile-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile:active .tile-img, .tile:hover .tile-img { opacity: 0.85; }
.tile-noimg {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 44px; font-weight: 700; color: #c4c4c4;
}
.tile-caption { display: block; padding: 10px 2px 0; font-weight: 600; font-size: 15px; line-height: 1.3; }
.tile:hover .tile-caption { text-decoration: underline; text-underline-offset: 3px; }

/* ---- Worker: hours stepper ---- */
.hoursform { display: grid; gap: 36px; max-width: 420px; margin: 40px auto 0; }
.stepper { display: grid; grid-template-columns: 80px 1fr 80px; align-items: center; gap: var(--gutter); }
.step-btn {
  height: 80px; width: 80px; border: 1px solid var(--rule-mid); background: var(--white);
  display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--black);
}
.step-btn:hover { border-color: var(--black); }
.step-btn:active { background: var(--black); color: var(--white); border-color: var(--black); }
.step-btn .icon { width: 30px; height: 30px; }
.step-btn:disabled { opacity: 0.25; cursor: default; background: var(--white); color: var(--black); border-color: var(--rule-mid); }
.step-value { font-size: 60px; font-weight: 700; letter-spacing: -0.02em; text-align: center; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- Worker: confirmation / closed ---- */
.confirm { display: grid; gap: 40px; justify-items: center; padding: 10vh 0 0; }
.confirm-mark {
  width: 104px; height: 104px; background: var(--accent); color: var(--white);
  display: flex; align-items: center; justify-content: center;
}
.confirm-mark svg { width: 56px; height: 56px; }
.confirm .btn { max-width: 280px; }

.closed { display: grid; gap: 28px; justify-items: center; padding: 10vh 0 0; text-align: center; }
.closed-mark {
  width: 104px; height: 104px; border: 1px solid var(--black);
  display: flex; align-items: center; justify-content: center; font-size: 40px; font-weight: 400;
}
.closed-msg { font-size: 19px; font-weight: 700; margin: 0; }
.closed .btn { max-width: 280px; width: 100%; }

/* ---- Admin: page heads & tables ---- */
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: var(--gutter); margin-bottom: 24px; flex-wrap: wrap; }
.pagehead .h1 { margin: 0; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 13px 12px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--grey-text);
  border-bottom: 1px solid var(--black); padding-top: 0; padding-bottom: 9px;
}
.table tbody tr:hover { background: var(--faint); }
.table tr.is-archived { opacity: 0.45; }
.th-sort { color: inherit; text-decoration: none; white-space: nowrap; }
.th-sort:hover { color: var(--black); text-decoration: underline; }

/* Search bar (list pages) */
.searchbar { display: flex; gap: 10px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.searchbar .input { flex: 1 1 280px; max-width: 420px; }
.cell-actions { text-align: right; white-space: nowrap; }
.cell-actions > * { vertical-align: middle; }
.cell-actions > * + * { margin-left: 12px; }
.cell-actions form { display: inline-flex; margin: 0; }
.cell-thumb { width: 56px; min-width: 56px; }
.thumb { width: 40px; height: 40px; min-width: 40px; max-width: none; object-fit: cover; display: block; border: 1px solid var(--hairline); }
.thumb-empty { background: var(--faint); width: 40px; height: 40px; }
.thumb-round { object-position: top; }
.preview-photo { max-width: 140px; }
.nowrap { white-space: nowrap; }
.table .col-main { width: 100%; white-space: normal; font-weight: 600; }
.table-audit { font-size: 13px; }
.table-audit .detail { max-width: 360px; }
.table-audit .detail code { font-size: 12px; color: var(--grey-text); word-break: break-all; }
.table-audit .col-main { font-weight: 400; }

/* ---- Admin: dashboard stats ---- */
.statgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px 20px; margin-bottom: 32px; }
.stat { border-top: 1px solid var(--black); padding-top: 14px; display: grid; gap: 4px; }
.stat-num { font-size: 52px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--grey-text); }
.actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---- Admin: filters ---- */
.filterbar { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 28px; }
.filterbar .input { width: auto; min-width: 170px; }
.filterbar .btn { min-height: 44px; }
.filter-field { display: grid; gap: 6px; }
.filter-field > span, .filter-date { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--grey-text); }
.filter-date { display: grid; gap: 6px; }
.filter-date .input { min-width: 150px; }

/* ---- Reports ---- */
.reporthead { display: flex; align-items: baseline; justify-content: space-between; gap: var(--gutter); margin: 40px 0 4px; flex-wrap: wrap; }
.reporthead .h2 { margin: 0; font-size: 17px; text-transform: none; letter-spacing: -0.01em; color: var(--black); }
.table-bars { max-width: 720px; }
.table-bars td { border-bottom: none; padding: 7px 8px 7px 0; }
.table-bars tbody tr:hover { background: none; }
.bar-label { width: 30%; font-weight: 400; font-size: 14px; }
.bar-cell { width: 55%; }
.bar { display: block; height: 12px; background: var(--black); min-width: 2px; }
.bar-num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; width: 15%; }
.pager { display: flex; align-items: center; gap: var(--gutter); margin-top: 24px; font-size: 13px; }

/* Worker: hours-logged-today progress bar */
.today { margin: 0 0 28px; }
.today-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.today-label { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--grey-text); }
.today-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.today-goal { font-size: 14px; font-weight: 400; color: var(--grey-soft); }
.track { height: 14px; background: var(--faint); border: 1px solid var(--hairline); overflow: hidden; }
/* Width comes from data-pct via js/bars.js (the CSP blocks inline styles). */
.track-fill { display: block; width: 0; height: 100%; background: var(--black); min-width: 0; transition: width 0.4s ease; }
.track-slim { height: 8px; margin-bottom: 12px; }

/* ---- Admin entries: day view ---- */
.daynav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0 16px; }
.daynav-form { margin: 0; }
.dayhead { display: flex; align-items: baseline; justify-content: space-between; gap: var(--gutter); flex-wrap: wrap; margin: 8px 0 20px; border-bottom: 2px solid var(--black); padding-bottom: 8px; }
.dayhead-title { margin: 0; font-size: 20px; text-transform: none; letter-spacing: -0.01em; }
.worker-card { margin: 0 0 28px; }
.worker-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--gutter); margin-bottom: 6px; }
.worker-name { font-weight: 700; font-size: 16px; }
.worker-total { font-variant-numeric: tabular-nums; font-weight: 700; }
.worker-goal { font-weight: 400; color: var(--grey-soft); font-size: 13px; }
.entries-table { width: 100%; }
/* Out-of-office rows use the calendar's red, so they read the same as on Home. */
.entries-table tr.row-ooo td { background: #fbeaea; }
.entries-table tr.row-ooo td:first-child { box-shadow: inset 3px 0 0 #b00020; }
.worker-ooo { font-weight: 400; color: #7a0014; font-size: 13px; }
.entries-ooo-key { font-size: 12px; margin: -8px 0 18px; }
.swatch-ooo { display: inline-block; width: 12px; height: 12px; vertical-align: -1px; margin-right: 4px; background: #fbeaea; border-left: 3px solid #b00020; }
.tag {
  display: inline-block; color: var(--grey-text); border: 1px solid var(--hairline);
  font-size: 10px; font-weight: 700; padding: 0 5px; letter-spacing: 0.06em; text-transform: uppercase; vertical-align: 1px;
}

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---- Dashboard calendar ---- */
.cal-section { margin-top: 56px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--gutter); margin-bottom: 16px; max-width: 360px; }
.cal-title { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; text-align: center; flex: 1; }
.cal-nav {
  min-width: 44px; min-height: 40px; font-size: 18px; line-height: 1; padding: 8px 14px;
  background: var(--white); color: var(--black); border: 1px solid var(--rule-mid); font-weight: 400;
}
.cal-nav:hover { background: var(--white); border-color: var(--black); }
.cal-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-top: 1px solid var(--black); border-bottom: 1px solid var(--hairline); }
.cal { border-collapse: collapse; font-size: 13px; }
.cal th, .cal td { border: 1px solid #ececec; text-align: center; }
.cal thead th { border-top: none; }
.cal th:first-child, .cal td:first-child { border-left: none; }
.cal-name {
  position: sticky; left: 0; z-index: 2; background: var(--white);
  text-align: left; padding: 9px 14px 9px 2px; font-weight: 600; white-space: nowrap;
  min-width: 110px; border-right: 1px solid var(--black);
}
thead .cal-name { z-index: 3; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--grey-text); font-weight: 700; }
.cal-day { min-width: 36px; width: 36px; padding: 5px 0 6px; font-weight: 700; color: var(--grey-text); line-height: 1.1; font-variant-numeric: tabular-nums; }
.cal-day.cal-weekend { background: var(--faint); }
.cal-day.cal-today { background: var(--black); color: var(--white); }
.cal-day.cal-today .cal-wd { color: #999; }
.cal-wd { display: block; font-size: 9px; color: #b5b5b5; font-weight: 400; letter-spacing: 0.05em; }
.cal-cell { min-width: 36px; width: 36px; height: 36px; padding: 0; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12px; }
.cal-none { background: var(--white); }
.cal-low { background: #f3d2d2; color: #7a0014; }
.cal-good { background: #cfe7cf; color: #0c5320; }
/* Work hours green on the left, out-of-office hours red on the right. --ooo is
   the red share, set per cell by js/calendar.js; without it the cell splits evenly. */
.cal-split { background: linear-gradient(to right, #cfe7cf 0 calc(100% - var(--ooo, 50%)), #f3d2d2 0); color: #333; }
.cal-total, .cal-total-h { font-weight: 700; background: var(--faint); min-width: 44px; font-size: 12px; }
.cal-legend { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; margin-top: 12px; font-size: 12px; color: var(--grey-text); }
.cal-ooo-note { margin: 8px 0 0; font-size: 12px; color: var(--grey-text); }
.cal-legend .swatch { display: inline-block; width: 12px; height: 12px; vertical-align: -1px; margin-right: 6px; border: 1px solid var(--hairline); }

/* ---- Budget alert / badges ---- */
.budget-alert { border-left: 3px solid var(--danger); padding: 2px 0 2px 16px; color: var(--danger); margin-bottom: 28px; }
.budget-alert strong { display: block; margin-bottom: 4px; font-size: 15px; }
.budget-list { margin: 0; padding-left: 18px; font-size: 14px; }
.budget-list li { margin: 2px 0; }
.budget-list a { font-weight: 700; }
.badge-over {
  display: inline-block; color: var(--danger); border: 1px solid var(--danger);
  font-size: 10px; font-weight: 700; padding: 1px 6px; margin-left: 8px; letter-spacing: 0.08em;
}

/* ---- Small screens ---- */
@media (max-width: 560px) {
  .container { padding: 22px var(--gutter) 56px; }
  .h1 { font-size: 24px; }
  .stat-num { font-size: 40px; }
  .step-btn { width: 72px; height: 72px; }
  .stepper { grid-template-columns: 72px 1fr 72px; }
  .step-value { font-size: 46px; }
  .filterbar { gap: 10px; }
  .filterbar .input { min-width: 0; }
  .filter-field, .filter-date { flex: 1 1 46%; }
  .filterbar .btn { flex: 1 1 100%; }
  .pagehead { gap: 10px; }
  .reporthead { gap: 10px; }
  .tilegrid { gap: 20px 14px; }
}

/* ---- Scale up ---- */
@media (min-width: 600px) {
  :root { --pad: 32px; }
  .tilegrid { grid-template-columns: repeat(3, 1fr); }
  .statgrid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 900px) {
  .tilegrid { grid-template-columns: repeat(4, 1fr); }
}
