/* TerraLogic Timesheets */
:root {
  --ground: #F4F1EA; --surface: #FFFFFF; --ink: #1B1F24; --ink-2: #3F444B; --muted: #5A6069;
  --line: #DDD7CB; --line-2: #ECE7DC; --accent: #B45309; --accent-hover: #92400E; --accent-tint: #FBEBDC; --accent-ink: #7A3E0C;
  --ok: #1F4A2A; --ok-bg: #E6F0E8; --info: #2E3B4E; --info-bg: #E6EAF0; --bad: #7F1D1D; --bad-bg: #FBE7E8; --bad-strong: #A11D2A;
  --radius: 16px; --font: "Instrument Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; --display: Fraunces, Georgia, serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom, 0px); }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
h1 { font-family: var(--display); font-weight: 600; font-size: 32px; letter-spacing: -0.5px; margin: 8px 0 16px; line-height: 1.15; }
h2 { font-family: var(--display); font-weight: 600; font-size: 22px; margin: 28px 0 12px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; padding-top: env(safe-area-inset-top, 0px); }
.topbar-inner { max-width: 760px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 16px; min-height: 56px; }
.topbar-inner.wide { max-width: 1240px; }
.brand { font-family: var(--display); font-weight: 600; font-size: 20px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.nav { display: flex; align-items: center; gap: 4px; overflow-x: auto; flex: 1; justify-content: flex-end; scrollbar-width: none; }
.nav a, .nav .linklike { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 10px; color: var(--ink-2);
  font-weight: 600; font-size: 15px; text-decoration: none; white-space: nowrap; }
.nav a[aria-current="page"] { background: var(--accent-tint); color: var(--accent-ink); }
.nav-form { margin: 0; }
.linklike { background: none; border: 0; font: inherit; cursor: pointer; }

/* Page */
.page { max-width: 760px; margin: 0 auto; padding: 20px 16px 48px; }
.page.wide { max-width: 1240px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--accent-ink); margin: 8px 0 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; }
.card.list { padding: 0; }
.card.empty { text-align: center; padding: 28px 16px; }
fieldset.card { margin: 0; }
legend { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0; float: left; width: 100%; margin-bottom: 8px; }
legend + * { clear: both; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span:first-child { font-size: 13px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date], input:not([type]), select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  color: var(--ink); font: inherit; font-size: 16px; }
textarea { resize: vertical; }
input[readonly] { background: var(--ground); color: var(--ink-2); }
.amount-field input { font-family: var(--display); font-size: 40px; font-weight: 500; min-height: 64px; }
.pw-wrap { display: flex; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.pw-wrap input { border: 0; }
.pw-toggle { border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; padding: 0 14px; min-width: 64px; cursor: pointer; }
.type-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.type-option { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; min-height: 64px; }
.type-option input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.type-name { font-weight: 600; font-size: 17px; }
.type-sub { font-size: 13px; color: var(--muted); }
.type-option:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #fff; }
.type-option:has(input:checked) .type-sub { color: #fff; }
.type-option:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.type-option.is-off { background: var(--ground); border-style: dashed; cursor: not-allowed; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { min-width: 52px; min-height: 44px; padding: 0 14px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); font: inherit; font-weight: 600; cursor: pointer; color: var(--ink); }
.chip.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: #B9B2A4; color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-danger { background: var(--bad-strong); border-color: var(--bad-strong); color: #fff; }
.btn-danger-outline { color: var(--bad); }
.btn-small { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-lg { min-height: 54px; font-size: 17px; }
.btn.is-disabled { background: #D6D1C6; border-color: #D6D1C6; color: #4A4F57; cursor: not-allowed; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
form.inline { display: inline; margin: 0; }

/* Flash messages and badges */
.flash { border-radius: 12px; padding: 12px 14px; margin: 0 0 16px; font-weight: 500; }
.flash-success { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--bad-bg); color: var(--bad); }
.flash-info { background: var(--info-bg); color: var(--info); }
.badge { display: inline-block; padding: 3px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.badge-approved { background: var(--ok-bg); color: var(--ok); }
.badge-pending, .badge-pm_approved { background: var(--info-bg); color: var(--info); }
.badge-declined { background: var(--bad-bg); color: var(--bad); }
.badge-inactive { background: #EFEBE3; color: #4A4F57; border: 1px dashed #9A9385; }
.tag { font-size: 12px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 1px 6px; vertical-align: middle; }
.ok-text { color: #2F5D3A; font-weight: 500; }
.warn-text { color: var(--accent-ink); font-weight: 500; }

/* My time */
.summary { background: var(--accent); color: #fff; border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.summary-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.eyebrow-light { font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }
.summary-dates { font-weight: 600; }
.summary-totals { display: flex; gap: 24px; flex-wrap: wrap; }
.summary-totals strong { font-family: var(--display); font-size: 30px; font-weight: 500; }
.pager { display: flex; gap: 6px; }
.pager-btn { width: 44px; height: 44px; border-radius: 22px; border: 1px solid rgba(255,255,255,.6); color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px; text-decoration: none; }
.pager-btn:hover { color: #fff; background: rgba(255,255,255,.15); }
.pager-btn.is-off { opacity: .45; border-style: dashed; }
.pager-btn.dark { border-color: var(--line); color: var(--ink); background: var(--surface); }
.day { margin-bottom: 18px; }
.day-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 4px 8px; }
.day-name { font-weight: 600; }
.entry { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.card.list .entry + .entry { border-top: 1px solid var(--line-2); }
.entry-main { display: flex; justify-content: space-between; gap: 12px; width: 100%; }
.entry-title { font-weight: 600; }
.entry-amount { font-weight: 600; font-size: 17px; white-space: nowrap; }
.entry-amount.big { font-family: var(--display); font-size: 24px; font-weight: 500; }
.entry-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.entry-actions form { margin: 0; }
.reason { background: #FBF7F2; border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 10px; font-size: 14px; width: 100%; }
details.decline > summary { list-style: none; }
details.decline > summary::-webkit-details-marker { display: none; }
details.decline[open] { width: 100%; }
details.decline[open] > summary { margin-bottom: 10px; }

/* Approvals & admin */
.tabs { display: flex; gap: 4px; background: #E9E4D9; border-radius: 12px; padding: 4px; margin-bottom: 16px; overflow-x: auto; }
.tabs a { flex: 1; text-align: center; white-space: nowrap; min-height: 42px; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 12px;
  border-radius: 9px; color: #4A4F57; font-weight: 600; font-size: 14px; text-decoration: none; }
.tabs a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(27,31,36,.12); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.period-nav { display: flex; align-items: center; gap: 12px; }
.export-box { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 420px; text-align: right; }
.stat-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-tabs a { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: 12px; border: 2px solid var(--line); background: #FBF9F4; text-decoration: none; color: #4A4F57; font-size: 13px; font-weight: 600; }
.stat-tabs a strong { font-family: var(--display); font-size: 28px; font-weight: 500; color: var(--ink); }
.stat-tabs a[aria-current="page"] { border-color: var(--accent); background: var(--surface); }
.table-card { padding: 0; overflow: hidden; }
.table-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line-2); }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 760px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line-2); }
.table td { padding: 10px 12px; border-bottom: 1px solid #F0ECE3; vertical-align: top; }
.table td.empty { text-align: center; color: var(--muted); padding: 28px; }
.table .num { text-align: right; white-space: nowrap; }
.table .actions-col { text-align: right; }
.table .actions-col > * { margin: 2px 0 2px 4px; }
.table .actions-col details { display: inline-block; text-align: left; }
.table .actions-col details[open] { display: block; min-width: 260px; }
.table select { min-height: 40px; padding: 6px 8px; font-size: 14px; }
.table form { margin: 0; }
.w-check { width: 40px; }
tr.is-inactive td { color: var(--muted); }
.add-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.add-row .field { flex: 1 1 160px; }
.add-row .field.grow { flex: 2 1 240px; }
.inline-edit { margin: 0; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }

/* Sign-in pages */
.auth { max-width: 420px; margin: 40px auto 0; display: flex; flex-direction: column; gap: 16px; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 600; color: var(--muted); font-size: 14px; }
.logo-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--accent) url("icons/icon-192.png") center/cover; }
.auth h1 { margin: 8px 0 0; }
.rules { list-style: none; margin: 0; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; gap: 8px; }
.rules li::before { content: "○"; display: inline-block; width: 22px; color: var(--muted); }
.rules li.ok::before { content: "✓"; color: #2F5D3A; font-weight: 700; }
.checks { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.checks .ok { color: #2F5D3A; }
.checks .bad { color: var(--bad-strong); font-weight: 600; }

@media (max-width: 720px) {
  .stat-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .export-box { align-items: flex-start; text-align: left; }
  .brand { display: none; }
  .nav { justify-content: flex-start; }
}

/* Overtime reminder */
dialog.sheet { border: 0; border-radius: 20px; padding: 22px 20px 20px; max-width: 440px; width: calc(100% - 32px); background: var(--ground); color: var(--ink); }
dialog.sheet::backdrop { background: rgba(27,31,36,.45); }
dialog.sheet h2 { margin: 0 0 10px; font-size: 24px; }
dialog.sheet p { margin: 0 0 16px; color: var(--ink-2); line-height: 1.5; }

/* Administration */
.admin-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:20px; }
.admin-grid .card { margin:0; }
.admin-grid h2, .card > h2:first-child { margin-top:0; }
.admin-number { font-size:36px; font-weight:600; margin:12px 0; }
.settings-toolbar { display:flex; justify-content:space-between; align-items:center; gap:16px; margin-bottom:20px; }
#settings-form > .btn { margin-top:20px; }
.settings-secondary { margin-top:28px; }
.admin-grid + .card { margin-top:24px; }
@media(max-width:700px) { .admin-grid { grid-template-columns:1fr; } }
