/* Brand colors (timatal-logo/README.txt): Primær "Stabil blå" #041333,
   Secondær "Netværk tyrkis" #05d2ae (an accent/eye-catcher color, used
   sparingly -- not a wash-everything color), Hvid #ffffff. The guide's
   two approved pairings are navy bg + white text + teal accent, and
   white bg + navy text + teal accent -- --primary/--primary-hover map
   each pairing to the theme it fits (navy in light mode, teal in dark
   mode, where a teal accent against the dark navy page is exactly the
   guide's own "eye-catcher" combo). --on-primary is the text/icon color
   for anything filled with --primary (buttons, badges, active tab) --
   white text directly on the teal fill fails contrast (~2:1), so dark
   mode's --on-primary is navy instead (~9.6:1), same as the guide's own
   navy-on-teal blocks. */
:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #041333;
  --muted: #6b7280;
  --border: #dfe3e8;
  --primary: #041333;
  --primary-hover: #0d2557;
  --on-primary: #ffffff;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  /* .success text (no button/hover variant exists for it, unlike
     --danger) -- was a hardcoded #2e7d32 with no dark-mode counterpart,
     which read poorly against the dark navy surface. */
  --success: #2e7d32;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  /* Login page corner-bleed brand mark (see .auth-watermark) -- teal
     reads more strongly against a white/light background than a navy
     one at the same opacity, so light mode uses a lower value. */
  --watermark-opacity: 0.06;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #041333;
    --surface: #0a1d42;
    --text: #e7e9ec;
    --muted: #9aa1ab;
    --border: #16305c;
    --primary: #05d2ae;
    --primary-hover: #33ddc0;
    --on-primary: #041333;
    --danger: #f87171;
    --danger-hover: #fca5a5;
    --success: #4ade80;
    --warning: #fbbf24;
    --warning-bg: #3d2b05;
    --watermark-opacity: 0.14;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #041333;
  --surface: #0a1d42;
  --text: #e7e9ec;
  --muted: #9aa1ab;
  --border: #16305c;
  --primary: #05d2ae;
  --primary-hover: #33ddc0;
  --on-primary: #041333;
  --danger: #f87171;
  --danger-hover: #fca5a5;
  --success: #4ade80;
  --warning: #fbbf24;
  --warning-bg: #3d2b05;
  --watermark-opacity: 0.14;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #041333;
  --muted: #6b7280;
  --border: #dfe3e8;
  --primary: #041333;
  --primary-hover: #0d2557;
  --on-primary: #ffffff;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #2e7d32;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --watermark-opacity: 0.06;
}

/* Self-hosted Poppins (per timatal-logo/README.txt) -- same TTFs the
   Export PDF template (backend/app/services/time_sheet_export.py)
   already uses, copied into fonts/ rather than shared cross-service. */
@font-face {
  font-family: "Poppins";
  src: url("../fonts/Poppins-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Poppins";
  src: url("../fonts/Poppins-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Poppins";
  src: url("../fonts/Poppins-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Poppins";
  src: url("../fonts/Poppins-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--primary);
}

/* ---- App shell: dark sidebar + main content area ---- */

/* Always dark regardless of theme -- unified to the exact brand navy
   (previously an unrelated invented grey, #1b1d22, that didn't quite
   match the dark theme's own #16181c background either). */
:root {
  --sidebar-bg: #041333;
  --sidebar-text: #b6bac2;
  --sidebar-text-active: #ffffff;
  --sidebar-hover: #0d2247;
  --sidebar-active-bg: #122a52;
  --sidebar-border: #16305c;
  --sidebar-accent: #05d2ae;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: #fff;
  padding: 0.5rem 0.6rem 1.25rem;
  font-size: 1rem;
}

.sidebar-logo {
  width: 100%;
  height: auto;
  max-width: 170px;
  display: block;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sidebar-version {
  margin-top: auto;
  padding: 0.5rem 0.6rem 0;
  font-size: 0.75rem;
  color: #767b85;
}

.sidebar-nav .nav-section {
  margin: 1rem 0 0.35rem;
  padding: 0 0.6rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #767b85;
  text-transform: uppercase;
}

.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.6rem 0.5rem calc(0.6rem - 3px);
  border-left: 3px solid transparent;
  border-radius: 6px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.sidebar-nav .nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-nav .nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

/* Thin teal accent bar -- the sidebar is always dark regardless of
   theme, so the brand's "eye-catcher" accent always reads well here. */
.sidebar-nav .nav-item.active {
  background: var(--sidebar-active-bg);
  border-left-color: var(--sidebar-accent);
  color: var(--sidebar-text-active);
}

/* Hidden until initProtectedPage() confirms the current user is an admin.
   The plain .admin-only rule covers non-nav uses (e.g. Analytics' filter
   selects, Projects/Customers' rate columns and Export CSV button); the
   nav-item-scoped rule is needed too since .sidebar-nav .nav-item's own
   `display: flex` above outranks a single-class selector. */
.admin-only {
  display: none;
}

.sidebar-nav .nav-item.admin-only {
  display: none;
}

/* Hidden until initProtectedPage() confirms Dinero integration is enabled
   (GET /api/dinero/status). The plain .dinero-only rule covers non-nav
   uses (e.g. the Projects page's "Sync all to Dinero" button); the
   nav-item-scoped rule is needed too since .sidebar-nav .nav-item's own
   `display: flex` above outranks a single-class selector. */
.dinero-only {
  display: none;
}

.sidebar-nav .nav-item.dinero-only {
  display: none;
}

/* Hidden until initProtectedPage() confirms the current user is an admin
   with the Billing flag -- the Invoices nav-group's gate (see
   .nav-group.billing-only below). No non-nav uses today. */
.billing-only {
  display: none;
}

/* Same nav-item-scoped override .admin-only/.dinero-only get above, and
   for the same reason: .sidebar-nav .nav-item's own `display: flex` (plus
   .nav-subitem's own display rule) outranks the plain single-class
   .billing-only rule on its own. Without this, Admin -> Financial/Dinero
   (both plain .nav-subitem.billing-only links, not a .nav-group) stayed
   visible in the sidebar for a non-billing admin regardless of what JS
   did to the class -- the CSS itself never actually hid them. */
.sidebar-nav .nav-item.billing-only {
  display: none;
}

/* Admin/Invoices sidebar groups -- a non-navigating title button that
   toggle-expands a nested list of sub-items (each its own page/URL). The
   title and sub-items reuse the .nav-item look-and-hover-and-active styles
   above; only the group-specific chrome (button reset, chevron, collapse,
   indentation) is added here. */
.sidebar-nav .nav-group {
  display: flex;
  flex-direction: column;
}

.sidebar-nav .nav-group.admin-only,
.sidebar-nav .nav-group.dinero-only,
.sidebar-nav .nav-group.billing-only {
  display: none;
}

.sidebar-nav .nav-group-title {
  width: 100%;
  margin: 0;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  appearance: none; /* opt out of native button chrome -- background/border alone don't
                        reliably unhook a <button> from its own intrinsic sizing */
  font-family: inherit; /* browsers default <button> to a UA font (e.g. Arial), not the page's */
  text-align: left;
  cursor: pointer;
}

.sidebar-nav .nav-group-title .nav-group-chevron {
  width: 16px;
  height: 16px;
  margin-left: auto;
  flex-shrink: 0;
  transition: transform .15s ease;
}

.nav-group.expanded .nav-group-chevron {
  transform: rotate(180deg);
}

.nav-group-items {
  display: flex;
  flex-direction: column;
}

.nav-group:not(.expanded) .nav-group-items {
  display: none;
}

.sidebar-nav .nav-item.nav-subitem {
  padding-left: calc(0.6rem - 3px + 1.5rem);
  font-size: 0.85rem;
}

.admin-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 10px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 0.75rem;
}

/* Deactivated user marker in the Admin users list -- same shape as
   .admin-badge but a muted outline instead of a filled primary color, so
   it doesn't compete with the Admin role badge for attention. */
.inactive-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
}

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  margin: 0;
  flex: 1;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* "username ▾" dropdown in the topbar (markup in js/nav.js, behaviour in
   js/auth.js initUserMenu). */
.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  color: var(--muted);
}

.user-menu-trigger:hover,
.user-menu-trigger:focus-visible {
  color: var(--primary);
}

.user-menu-caret {
  width: 14px;
  height: 14px;
  transition: transform 0.15s;
}

.user-menu-trigger[aria-expanded="true"] .user-menu-caret {
  transform: rotate(180deg);
}

.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  min-width: 230px;
  max-width: calc(100vw - 2rem);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  z-index: 50;
}

.user-menu-panel[hidden] {
  display: none;
}

.user-menu-panel > a,
.user-menu-panel > button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
  background: none;
  border: 0;
  cursor: pointer;
}

.user-menu-panel > a:hover,
.user-menu-panel > button:hover {
  background: rgba(127, 127, 127, 0.12);
}

.user-menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.15rem;
}

.user-menu-row label {
  font-size: 0.9rem;
  color: var(--muted);
}

.user-menu-row select {
  width: auto;
}

main {
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  margin-top: 0;
  margin-right: 0.75rem;
  padding: 0.4rem;
  background: transparent;
  color: var(--text);
}

.sidebar-toggle:hover {
  background: var(--bg);
}

.sidebar-toggle svg {
  width: 22px;
  height: 22px;
}

.sidebar-backdrop {
  display: none;
}

/* Clips the watermark's corner bleed at the viewport edge instead of
   creating scrollbars, and centers the login card in the viewport
   (previously a fixed top margin left a large empty gap below it). */
body.auth-page {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-page main {
  position: relative;
  z-index: 1;
  max-width: 400px;
}

.auth-theme-toggle {
  position: fixed;
  z-index: 1;
  top: 1rem;
  right: 1rem;
  width: auto;
}

/* Decorative corner-bleed brand mark -- same two-corner watermark
   treatment as the Export PDF template's _draw_watermarks(): the
   Timatal clock mark (ring, arc, hand), large, bled off two opposite
   corners. Purely background-level (low opacity, behind everything, no
   pointer events) -- see --watermark-opacity above for the per-theme
   value. Stroke-based (not filled), matching the mark's own artwork --
   fill is explicitly none so only the stroked ring/arc/hand show. */
.auth-watermark {
  position: fixed;
  width: 55vmin;
  height: 55vmin;
  fill: none;
  stroke: #05d2ae;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: var(--watermark-opacity);
  z-index: 0;
  pointer-events: none;
}

.auth-watermark-tl {
  top: -20vmin;
  left: -20vmin;
}

.auth-watermark-br {
  bottom: -20vmin;
  right: -20vmin;
}

.auth-logo-wrap {
  display: flex;
  justify-content: center;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.auth-logo {
  width: 100%;
  max-width: 220px;
  height: auto;
  display: block;
}

/* The auth card sits on --surface, which flips white (light theme) <->
   dark navy (dark theme) -- so unlike the sidebar (always navy), it needs
   both logo variants, swapped the same way --surface itself is swapped. */
.auth-logo-dark {
  display: none;
}

@media (prefers-color-scheme: dark) {
  .auth-logo-light {
    display: none;
  }

  .auth-logo-dark {
    display: block;
  }
}

:root[data-theme="dark"] .auth-logo-light {
  display: none;
}

:root[data-theme="dark"] .auth-logo-dark {
  display: block;
}

:root[data-theme="light"] .auth-logo-light {
  display: block;
}

:root[data-theme="light"] .auth-logo-dark {
  display: none;
}

.placeholder-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  color: var(--muted);
  font-size: 1.1rem;
  text-align: center;
}

/* Two-factor enrolment / challenge (login.html #auth-step and the topbar
   #two-factor-dialog). */
.totp-qr {
  display: block;
  width: 200px;
  height: 200px;
  margin: 0.5rem auto 0.75rem;
  background: #fff; /* keep the QR readable in dark mode */
  padding: 8px;
  border-radius: 6px;
}

.totp-secret {
  text-align: center;
  word-break: break-all;
}

.totp-secret code {
  font-size: 1rem;
  letter-spacing: 1px;
}

.twofa-links {
  margin-top: 1rem;
  text-align: center;
}

/* login.html: the "or / Sign in with a passkey" block under the password
   form. The button is hidden until js/auth.js confirms WebAuthn support. */
.auth-alt {
  margin-top: 1rem;
  text-align: center;
}

.auth-alt-divider {
  display: block;
  margin-bottom: 0.75rem;
  color: var(--muted, #888);
  font-size: 0.9rem;
}

.auth-alt button {
  width: 100%;
}

ul.recovery-codes {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.35rem 1rem;
}

ul.recovery-codes code {
  font-size: 0.95rem;
  letter-spacing: 1px;
}

/* Trusted-device list in the topbar 2FA dialog. */
#trusted-devices-section h3 {
  margin-bottom: 0.5rem;
}

ul.trusted-device-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem;
}

ul.trusted-device-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

ul.trusted-device-list li .muted {
  font-size: 0.85rem;
}

.device-current-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  font-size: 0.75rem;
  background: var(--surface-alt, rgba(127, 127, 127, 0.15));
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
}

/* Guide: "Store overskrifter i medium og regular" -- large headlines use
   medium weight, not the browser's bold default. */
h1 {
  font-size: 1.4rem;
  font-weight: 500;
}

h2 {
  font-size: 1.15rem;
  font-weight: 500;
  margin-top: 0;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
  margin-top: 0.75rem;
}

input, select, textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color .15s ease;
}

textarea {
  resize: vertical;
  min-height: 3rem;
}

/* Native checkboxes inherit the block `input` rule above (width: 100%,
   padding, border-radius, ...), which stretches them into an odd bar
   rather than a small box -- every checkbox in the app has historically
   patched this with an inline `style="width:auto; ..."`. Style them
   properly instead: a compact box using the same border/radius language
   as text inputs, tinted with the brand color when checked. */
input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  padding: 0;
  flex-shrink: 0;
  border-radius: 4px;
  accent-color: var(--primary);
  cursor: pointer;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
  color: var(--text);
  cursor: pointer;
}

/* Brand-colored focus ring instead of the browser's default blue --
   :focus-visible (not :focus) so buttons don't show a ring on mouse
   click, only keyboard navigation; text inputs still show it on click,
   which is expected there. */
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  background: var(--primary);
  color: var(--on-primary);
  margin-top: 1rem;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

button:not(:disabled):hover {
  background: var(--primary-hover);
}

/* Pinned to white regardless of theme -- unlike --on-primary (which
   flips for the teal fill in dark mode), --danger's red fill has good
   white-text contrast in both themes, so it doesn't need the flip. */
button.danger {
  background: var(--danger);
  color: #fff;
}

button.danger:not(:disabled):hover {
  background: var(--danger-hover);
}

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

/* No disabled styling existed at all before this (only the .week-nav
   pager had its own scoped rule) -- a disabled button fell back to
   whatever the browser does by default, which is inconsistent and, for
   .secondary buttons specifically, imperceptible against the dark
   theme (same --text color as an enabled one). */
button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button.secondary:disabled {
  color: var(--muted);
  border-color: var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  /* Digits render at a fixed width so numbers in a column (totals,
     hours, amounts) line up vertically -- no effect on letters. */
  font-variant-numeric: tabular-nums;
}

th, td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

th {
  color: var(--muted);
  font-weight: 600;
}

/* Numeric columns (hours, rates, amounts, totals) -- applied via JS to
   the <td> (and matching <th>) since these tables are built dynamically.
   Right-alignment is the standard convention for numeric data; most
   numeric columns app-wide were plain left-aligned before this. */
.col-num {
  text-align: right;
}

.row-actions button {
  margin-top: 0;
  margin-right: 0.35rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}

.filters {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.filters > div {
  min-width: 160px;
}

.filters .export-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
  min-width: 0;
}

.filters .export-actions button {
  margin-top: 0;
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
  margin-top: 0.75rem;
  min-height: 1.2rem;
}

/* Inline warning/over-threshold text (Projects' Tracked/Budget columns,
   Contracts' near-expiry End date column) -- plain color, no margin/
   font-size changes, since these sit inline inside an existing table cell
   rather than as their own block. */
.text-warning {
  color: var(--warning);
}

.budget-over {
  color: var(--danger);
  font-weight: 600;
}

/* One-line budget forecast under the progress bar -- see projects.js forecastNote(). */
.budget-forecast {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  white-space: nowrap;
}

/* Progress bar under a Projects budget figure -- see projects.js budgetBar(). */
.budget-bar {
  height: 4px;
  margin-top: 0.25rem;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.budget-bar-fill {
  height: 100%;
  background: var(--success);
}

.budget-bar-fill.warn {
  background: var(--warning);
}

.budget-bar-fill.over {
  background: var(--danger);
}

.success {
  color: var(--success);
  font-size: 0.9rem;
  margin-top: 0.75rem;
  min-height: 1.2rem;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Matches tr.total-row td below -- same font size/color, for summary
   lines (e.g. the invoice preview dialog's Customer/Date/Due date)
   that should read at the same weight as a table's total row rather
   than de-emphasized `.muted` text. Only the label (a <strong>, set via
   setSummaryLine()) is bold; the value after it stays regular weight. */
.dialog-summary-line {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text);
  margin: 0.3rem 0;
}

/* The invoice comment can be several lines (built from a template) --
   set off from the single-line Customer/Date/Due date facts above it
   as its own bordered note box, same border/radius language as inputs,
   rather than crammed into one inline "Comment: ..." paragraph. */
.comment-preview {
  margin-top: 0.35rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}

.comment-preview-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.comment-preview-text {
  font-size: 0.9rem;
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.5;
}

/* Proactive warning banner (e.g. Admin -> Contracts' "customers missing a
   contract" nudge) -- same bordered-box shape as .comment-preview, tinted
   amber instead of neutral so it reads as "needs attention" without being
   as alarming as .error's --danger red. */
.notice-warning {
  margin-bottom: 1rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--warning);
  border-radius: 6px;
  background: var(--warning-bg);
  color: var(--warning);
}

.notice-warning ul {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

.notice-warning li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.section-gap {
  margin-top: 2rem;
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.card-header-row h2 {
  margin: 0;
}

.card-header-row button {
  margin-top: 0;
}

dialog.modal {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  background: var(--surface);
  color: var(--text);
  max-width: 680px;
  width: 90vw;
}

dialog.modal#invoice-preview-dialog,
dialog.modal#draft-dialog {
  max-width: 800px;
}

dialog.modal::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

/* ---- Time Sheets grid ---- */

.timesheet-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.timesheet-toolbar .spacer {
  flex: 1;
}

.timesheet-toolbar select {
  width: auto;
  min-width: 160px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  margin-top: 0;
  transition: background-color .15s ease;
}

.icon-btn:hover {
  background: var(--bg);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.week-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  background: var(--surface);
}

/* Inside a card header the pill would otherwise blend into the card's own
   var(--surface) background — match the other filter inputs' fill instead. */
.card-header-row .week-nav {
  background: var(--bg);
}

.week-nav button {
  margin: 0;
  padding: 0.2rem 0.5rem;
  background: transparent;
  color: var(--text);
  border: none;
  transition: background-color .15s ease;
}

.week-nav button:hover {
  background: var(--bg);
}

.week-nav button:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.week-nav button:disabled:hover {
  background: transparent;
}

.week-nav .week-label {
  font-size: 0.9rem;
  min-width: 120px;
  text-align: center;
}

/* The items-per-page select rides along in the same row as the
   prev/next/label pager controls -- override the block `label` and
   full-width `select` rules above (meant for stacked form fields) so
   both stay inline and compact here instead. */
.week-nav select {
  width: auto;
  margin: 0;
  font-size: 0.9rem;
}

.week-nav label {
  display: inline;
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 0 0.5rem;
}

.timesheet-table {
  width: 100%;
  border-collapse: collapse;
}

.timesheet-table th, .timesheet-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.4rem;
  font-size: 0.85rem;
}

.timesheet-table th {
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}

.timesheet-table th.col-date {
  white-space: nowrap;
}

.timesheet-table th.col-project,
.timesheet-table td.col-project {
  text-align: left;
  width: 320px;
  max-width: 320px;
  white-space: normal;
  word-break: break-word;
}

.project-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.5rem;
}

.project-label .customer-name {
  color: var(--muted);
}

.timesheet-table td.col-day {
  text-align: center;
  padding: 0.3rem;
}

.timesheet-table td.col-total,
.timesheet-table th.col-total {
  text-align: right;
  font-weight: 600;
  white-space: nowrap;
}

tr.total-row td {
  font-weight: 700;
  border-top: 2px solid var(--border);
  border-bottom: none;
}

.timesheet-footer {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* ---- Time Sheets grid: mobile day-picker view (see js/time-sheets.js
   renderMobileView()) -- the desktop 9-column grid (project + 7 days +
   total) doesn't fit a phone width even scrolling, so under the mobile
   breakpoint it's replaced with one selected day at a time instead. */
.timesheet-mobile {
  display: none;
}

.timesheet-day-tabs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.timesheet-day-tab {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  margin-top: 0;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
}

.timesheet-day-tab-date {
  font-weight: 600;
}

.timesheet-day-tab.active {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}

.timesheet-day-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.timesheet-day-row-label {
  display: flex;
  align-items: center;
  min-width: 0;
}

.timesheet-day-row-value {
  flex-shrink: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.timesheet-day-summary {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

/* ---- Time Logs ---- */

.time-tracker-add-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.time-tracker-add-row input,
.time-tracker-add-row select {
  width: auto;
}

.time-tracker-add-row #description {
  flex: 1;
  min-width: 200px;
}

.time-tracker-add-row #project-picker {
  min-width: 180px;
}

.tt-show-hidden {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--muted);
}

.tt-show-hidden input {
  margin: 0;
}

.time-tracker-add-row #project-picker .project-combobox-input {
  width: 100%;
}

.time-tracker-add-row #start-time,
.time-tracker-add-row #end-time {
  width: 76px;
}

.tt-duration-display {
  font-weight: 600;
  min-width: 60px;
  text-align: center;
}

.time-tracker-add-row button {
  margin-top: 0;
}

.time-tracker-week-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

.tt-week-section {
  margin-top: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 0.75rem 1rem;
}

.tt-week-section:first-child {
  margin-top: 0;
}

.tt-week-header {
  display: flex;
  justify-content: space-between;
  padding-bottom: 0.5rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.day-group {
  margin-top: 0.9rem;
}

.tt-week-header + .day-group {
  margin-top: 0.5rem;
}

.day-group-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 -1rem;
  padding: 0.45rem 1rem;
  background: var(--sidebar-bg);
  color: var(--sidebar-text-active);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
}

.day-group-header .muted {
  color: var(--sidebar-text);
  font-weight: 400;
}

.day-group-entries {
  display: flex;
  flex-direction: column;
  padding: 0.2rem 0 0.4rem;
}

.day-group-entries .tt-entry:last-child {
  border-bottom: none;
}

.tt-entry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.tt-entry input.tt-desc {
  flex: 0 0 auto;
  min-width: 120px;
  max-width: 400px;
}

.tt-entry input.tt-date-input {
  width: 134px;
}

/* Time input + its AM/PM <select> rendered as one merged field, so picking
   a meridiem reads as "part of the same box" instead of a second control. */
.tt-time-field {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}

.tt-time-field input.tt-time-input {
  width: 60px;
  text-align: center;
  border: none;
  background: transparent;
  padding: 0.5rem 0.3rem;
}

.tt-time-field select.tt-meridiem-select {
  all: unset;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  width: auto;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  padding: 0.5rem 1.15rem 0.5rem 0.4rem;
  /* Hand-drawn chevron (no native select chrome) so it themes via --muted
     instead of a hardcoded icon color. */
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 13px) calc(50% - 2px),
    calc(100% - 9px) calc(50% - 2px);
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}

.tt-time-field input.tt-time-input:focus,
.tt-time-field select.tt-meridiem-select:focus {
  outline: none;
}

.tt-time-field:focus-within {
  border-color: var(--primary);
}

/* Inside entry rows the field stays invisible until hovered/edited, like
   the row's other inline-editable fields. */
.tt-entry .tt-time-field {
  border-color: transparent;
  background: transparent;
}

.tt-entry .tt-time-field:hover,
.tt-entry .tt-time-field:focus-within {
  border-color: var(--border);
  background: var(--bg);
}

.tt-entry .tt-time-field input.tt-time-input {
  padding: 0.3rem 0.3rem;
}

.tt-inline-field {
  border-color: transparent;
  background: transparent;
  padding: 0.3rem 0.4rem;
}

.tt-inline-field:hover,
.tt-inline-field:focus {
  border-color: var(--border);
  background: var(--bg);
}

.project-combobox {
  position: relative;
}

.tt-entry .project-combobox.tt-project-combobox {
  flex: 1;
  min-width: 140px;
}

.project-combobox-input {
  width: 100%;
}

.tt-entry .project-combobox-input {
  color: var(--muted);
}

.project-combobox-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  margin-top: 2px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.project-combobox-option {
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background-color .15s ease, color .15s ease;
}

.project-combobox-option:hover,
.project-combobox-option.active {
  background: var(--primary);
  color: var(--on-primary);
}

/* Shown when a search match came from the project's description rather
   than its name/customer -- see filterProjects(). */
.project-combobox-option-desc {
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-combobox-option:hover .project-combobox-option-desc,
.project-combobox-option.active .project-combobox-option-desc {
  color: inherit;
  opacity: 0.85;
}

.project-combobox-empty {
  padding: 0.4rem 0.6rem;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Generic counterpart of .project-combobox-* above, for
   createSearchableCombobox() (api.js) -- same shape, for a flat list of
   strings (e.g. Admin -> General's timezone picker) rather than Project
   objects, so no *-option-desc secondary line here. */
.combobox {
  position: relative;
}

.combobox-input {
  width: 100%;
}

.combobox-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  margin-top: 2px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.combobox-option {
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background-color .15s ease, color .15s ease;
}

.combobox-option:hover,
.combobox-option.active {
  background: var(--primary);
  color: var(--on-primary);
}

.combobox-empty {
  padding: 0.4rem 0.6rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.tt-entry .error {
  margin-top: 0;
  min-height: 0;
}

.tt-duration {
  font-weight: 600;
  min-width: 50px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.tt-select {
  margin: 0 0.1rem 0 0;
  flex: 0 0 auto;
}

.audit-change {
  font-size: 0.8rem;
  color: var(--muted);
  max-width: 40ch;
}

.audit-change div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bulk-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt, rgba(127, 127, 127, 0.08));
}

/* `display: flex` above would otherwise beat the UA [hidden] rule (equal
   specificity, later in the cascade), leaving the bar visible with nothing
   selected -- same explicit override the user menu panel uses. */
.bulk-bar[hidden] {
  display: none;
}

.bulk-bar-count {
  font-size: 0.9rem;
  white-space: nowrap;
}

.bulk-bar-fields {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.bulk-bar input,
.bulk-bar select {
  width: auto;
}

.bulk-bar input#bulk-note {
  min-width: 140px;
}

.bulk-bar #bulk-result {
  flex-basis: 100%;
  font-size: 0.85rem;
}

.tt-billable-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.tt-billable-toggle input {
  margin: 0;
}

/* A non-billable entry still shows every field, just dimmed so it reads as
   "logged but off the invoice" at a glance. */
.tt-entry.tt-entry-nonbillable .tt-desc,
.tt-entry.tt-entry-nonbillable .tt-duration {
  opacity: 0.55;
}

.tt-entry.tt-entry-pending {
  border-left: 3px solid var(--warning, #d19a00);
}

.tt-entry.tt-entry-rejected {
  border-left: 3px solid var(--danger, #c0392b);
}

.tt-status-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  white-space: nowrap;
}

.tt-status-badge.tt-status-pending {
  background: var(--warning, #d19a00);
  color: #1b1b1b;
}

.tt-status-badge.tt-status-rejected {
  background: var(--danger, #c0392b);
  color: #fff;
  cursor: help;
}

.tt-delete {
  margin: 0;
  padding: 0.2rem 0.5rem;
  background: transparent;
  color: var(--muted);
  border: none;
}

.tt-delete:hover {
  color: var(--danger);
}

.tt-edit-row input {
  width: 90px;
}

/* ---- Charts ---- */

.chart-axis-label {
  font-size: 9px;
  fill: var(--muted);
}

.chart-total-label {
  font-size: 9px;
  fill: var(--text);
  font-variant-numeric: tabular-nums;
}

.report-charts {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.report-chart-col {
  flex: 1;
  min-width: 280px;
}

.donut-chart-wrapper {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.donut-center-label {
  font-size: 14px;
  font-weight: 700;
  fill: var(--text);
  font-variant-numeric: tabular-nums;
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.donut-legend-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.donut-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
  flex-shrink: 0;
}

.donut-legend-value {
  color: var(--muted);
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

/* ---- Overview ---- */

.stat-cards {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1;
  min-width: 180px;
}

.stat-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  margin-top: 0.35rem;
  font-variant-numeric: tabular-nums;
}

.stat-value-text {
  font-size: 1.1rem;
}

.dashboard-main-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: flex-start;
}

.dashboard-charts-col {
  flex: 2;
  min-width: 320px;
}

.dashboard-activities-col {
  flex: 1;
  min-width: 260px;
}

.activity-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

/* ---- Mobile layout: off-canvas sidebar, scrollable/reduced tables ----
   No layout breakpoints existed before this -- the app previously assumed
   a desktop-width viewport everywhere. Kept at the end of the file (not
   next to the rules it overrides) so its declarations always win the
   cascade regardless of where else a given selector is later re-declared
   at the same specificity -- an earlier attempt placed it right after the
   sidebar/topbar rules and got silently overridden by unrelated
   `.timesheet-mobile`/`.timesheet-table` rules declared further down. */
@media (max-width: 768px) {
  .sidebar-toggle {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.3);
  }

  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 19;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .app-shell.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  /* Let the "username ▾" menu drop onto its own row below the
     title+hamburger rather than get clipped at the viewport edge on a
     narrow screen. The dropdown panel is absolute + max-width-capped, so it
     never widens the page. */
  .topbar {
    flex-wrap: wrap;
    row-gap: 0.5rem;
    padding: 0.75rem 1rem;
  }

  .topbar h1 {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 1.2rem;
  }

  .topbar-right {
    justify-content: flex-end;
  }

  main {
    padding: 1rem;
  }

  /* Fallback for any table that doesn't get a bespoke mobile layout --
     scrolls within its own card instead of breaking the page width. */
  .card {
    overflow-x: auto;
  }

  .report-chart-col {
    min-width: 240px;
  }

  /* Time Logs' per-entry row (description, project, start/end time,
     date, duration, delete -- all inline-editable) never had to share a
     narrow row before and overflows the viewport without this; wrapping
     is a plainer result than the timesheet grid's bespoke day-picker
     but keeps every field reachable and editable without a rewrite. */
  .tt-entry {
    flex-wrap: wrap;
    row-gap: 0.4rem;
  }

  /* Secondary columns on the widest tables (invoices list, time entries,
     export preview) -- dropped instead of relying purely on the .card
     scroll fallback above, since 8-9 columns of horizontal scroll on a
     phone is unusable for the primary "glance at the list" use case. */
  .col-hide-mobile {
    display: none;
  }

  .timesheet-table {
    display: none;
  }

  .timesheet-mobile {
    display: block;
  }
}

/* Fields locked by "Update from CVR" -- values come from the CVR registry only. */
input.cvr-locked, textarea.cvr-locked {
  opacity: 0.6;
  cursor: not-allowed;
}

.cvr-status-ok { color: var(--muted); }
.cvr-status-warn { color: var(--danger); }

/* Admin -> Proxy check rows. */
.proxy-check { margin-top: 1rem; }
.proxy-check p { margin: 0.2rem 0 0; }
.proxy-ok { color: var(--muted); }
.proxy-warn { color: var(--danger); }

/* Month submit + lock (time-logs.js, approvals.js) */
.month-status-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.month-status-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.month-status-badge.month-status-submitted {
  color: var(--warning);
  border-color: var(--warning);
}

.month-status-badge.month-status-locked {
  color: var(--success);
  border-color: var(--success);
}

/* A submitted/locked month: entries can't change, so grey the controls. */
.month-readonly input,
.month-readonly select,
.month-readonly textarea,
.month-readonly button {
  pointer-events: none;
  opacity: 0.55;
}
