:root {
  --ink: #1f2328;
  --muted: #4b5563;
  --paper: #f7f9fc;
  --surface: #ffffff;
  --line: #d9dee5;
  --forest: #df1a22;
  --forest-dark: #a51218;
  --mint: #fce8e9;
  --coral: #c62828;
  --amber: #c27a00;
  --blue: #286888;
  --shadow: 0 8px 24px rgba(9, 30, 66, 0.14);
}

* { box-sizing: border-box; letter-spacing: 0; }
body { margin: 0; color: var(--ink); background: var(--paper); min-height: 100vh; overflow-x: hidden; font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.bg-orb { position: fixed; border-radius: 50%; opacity: .08; pointer-events: none; z-index: 0; }
.orb-1 { width: 400px; height: 400px; right: -200px; top: -200px; background: radial-gradient(circle, rgba(223,26,34,.2), transparent 70%); }
.orb-2 { width: 300px; height: 300px; left: -150px; bottom: -150px; background: radial-gradient(circle, rgba(31,35,40,.12), transparent 70%); }
.app-header { padding: 16px 32px; position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 3px solid var(--forest); box-shadow: 0 4px 12px rgba(9,30,66,.12); }
.header-content { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand-lockup { display: flex; align-items: center; gap: 16px; }
.brand-logo { width: 116px; height: 44px; padding: 5px 8px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: white; box-shadow: 0 1px 2px rgba(9,30,66,.12); }
.brand-logo img { width: 100%; height: 100%; display: block; object-fit: contain; }
.brand-text h1 { margin: 0; font: 700 24px/1.12 inherit; }
.brand-kicker { margin: 0 0 2px; color: var(--forest); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.tagline { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.auth-controls, .user-identity { display: flex; align-items: center; gap: 12px; }
.identity-text { min-width: 0; display: flex; flex-direction: column; text-align: right; }
.identity-text span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 36px; border: 1px solid var(--line); border-radius: 50%; background: #f2f5f8; color: var(--muted); font-size: 12px; font-weight: 700; }
.app-shell { min-height: calc(100vh - 91px); display: grid; grid-template-columns: 272px minmax(0, 1fr); position: relative; z-index: 1; }
.sidebar { padding: 32px 24px; border-right: 1px solid var(--line); background: rgba(247,249,252,.88); }
.sidebar nav { position: sticky; top: 123px; }
.nav-group { display: flex; flex-direction: column; }
.nav-group-header { width: 100%; padding: 10px 12px; border: 0; border-radius: 6px; display: flex; justify-content: space-between; align-items: center; background: transparent; color: var(--muted); text-align: left; text-transform: uppercase; font-size: 12px; font-weight: 700; letter-spacing: .06em; }
.nav-group-header:hover { color: var(--forest-dark); background: #f2f5f8; }
.nav-group-chevron { width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .2s ease; }
.nav-group.collapsed .nav-group-chevron { transform: rotate(-45deg); }
.nav-group-items { display: grid; gap: 6px; margin-top: 6px; }
.nav-group.collapsed .nav-group-items { display: none; }
.nav-item { width: 100%; min-height: 44px; padding: 0 14px; border: 0; border-left: 3px solid transparent; border-radius: 0 6px 6px 0; color: var(--muted); background: transparent; display: flex; align-items: center; gap: 12px; text-align: left; font-weight: 600; }
.nav-item:hover { color: var(--forest-dark); background: var(--mint); }
.nav-item.active { color: var(--forest-dark); border-left-color: var(--forest); background: rgba(223,26,34,.05); }
.nav-item svg, button svg { width: 18px; height: 18px; flex: none; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); background: transparent; color: inherit; display: grid; place-items: center; }
main { min-width: 0; padding: 32px clamp(24px, 4vw, 64px) 64px; }
.topbar { min-height: 76px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 3px; color: var(--forest); text-transform: uppercase; font-size: 12px; font-weight: 700; }
h1, h2 { margin: 0; }
h1 { font-size: clamp(29px, 3vw, 40px); }
h2 { font-size: 24px; }
.topbar-actions, .toolbar, .form-actions, .dialog-actions { display: flex; align-items: center; gap: 10px; }
.system-status { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #0f8a3c; box-shadow: 0 0 0 4px rgba(15,138,60,.14); }
.last-updated { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.primary-button, .secondary-button, .danger-button { min-height: 40px; border: 1px solid transparent; padding: 0 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; }
.primary-button, .secondary-button, .danger-button, input, select, .table-wrap, .form-layout { border-radius: 8px; }
.primary-button { background: var(--forest); color: white; }
.primary-button:hover { background: var(--forest-dark); }
.secondary-button { border-color: var(--forest-dark); background: var(--surface); color: var(--forest-dark); }
.secondary-button:hover { background: var(--mint); }
.danger-button { background: var(--coral); color: white; }
.primary-button:disabled, .secondary-button:disabled, .danger-button:disabled { opacity: .55; cursor: wait; }
.auth-panel { max-width: 760px; padding: 28px; border-left: 5px solid var(--forest); background: var(--surface); box-shadow: var(--shadow); align-items: center; justify-content: space-between; gap: 24px; }
.auth-panel:not([hidden]) { display: flex; }
/* Hiding the sidebar removes it as a grid item, so the shell must drop to one column or main lands in the 272px track. */
.app-shell.single-column { grid-template-columns: minmax(0, 1fr); }
.app-shell.single-column main { padding-top: 48px; }
.notice-panel { max-width: 720px; padding: 32px; border-left: 5px solid var(--forest); background: var(--surface); box-shadow: var(--shadow); gap: 16px; justify-items: start; }
.notice-panel:not([hidden]) { display: grid; }
.notice-panel h2 { font-size: clamp(22px, 2.4vw, 28px); line-height: 1.25; }
.notice-panel p { margin: 0; max-width: 62ch; color: var(--muted); line-height: 1.6; }
.notice-panel p strong { color: var(--ink); }
.notice-panel ul { margin: 0; padding-left: 20px; max-width: 62ch; color: var(--muted); line-height: 1.7; }
.notice-panel li strong { color: var(--ink); }
.notice-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--mint); color: var(--forest-dark); }
.notice-icon svg { width: 22px; height: 22px; }
.notice-actions { margin-top: 4px; }
.auth-panel p:last-child, .form-heading p:last-child { color: var(--muted); margin-bottom: 0; }
.summary-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-block: 1px solid var(--line); background: rgba(255,255,255,.68); }
.summary-strip div { padding: 18px 22px; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.summary-strip div:last-child { border: 0; }
.summary-strip span { color: var(--muted); font-size: 13px; }
.summary-strip strong { font-size: 28px; }
.toolbar { padding: 24px 0 15px; }
.search-field { min-width: 260px; flex: 1; position: relative; }
.search-field svg { position: absolute; width: 17px; left: 12px; top: 11px; color: var(--muted); }
input, select { width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.search-field input { padding-left: 38px; }
input:focus, select:focus, button:focus-visible { outline: 3px solid rgba(127,17,22,.24); outline-offset: 1px; border-color: var(--forest-dark); }
.toolbar select { width: 190px; }
.table-wrap { background: var(--surface); border: 1px solid var(--line); box-shadow: 0 5px 20px rgba(24,35,32,.05); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th { color: var(--muted); background: #f0f3ef; font-size: 12px; text-transform: uppercase; text-align: left; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); }
tbody tr:hover { background: #fafbf8; }
.employee-cell { display: flex; flex-direction: column; }
.employee-cell span { color: var(--muted); font-size: 13px; }
.status-badge { display: inline-flex; align-items: center; min-height: 25px; padding: 2px 9px; border: 1px solid; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-ready { color: #0f8a3c; background: rgba(15,138,60,.12); border-color: rgba(15,138,60,.3); }
.status-sent { color: var(--blue); background: #e1eef4; border-color: #b4d1df; }
.status-failed { color: #8d2e22; background: #fae6e1; border-color: #e5b2a8; }
.status-running { color: var(--amber); background: #fff1d2; border-color: #e5c983; }
.row-actions { text-align: right; }
.row-actions .actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.restore-note { margin: 0 0 16px; max-width: 72ch; color: var(--muted); line-height: 1.5; }
#dialogBody .restore-note { margin-top: 16px; }
.form-notice { margin: 16px 0 0; max-width: 72ch; padding: 12px 14px; border-left: 4px solid var(--blue); background: #e1eef4; color: var(--ink); line-height: 1.5; font-weight: 400; }
.form-heading .form-notice { color: var(--ink); margin-bottom: 0; }
#archivedRestorePrompt { margin: 0 0 16px; }
.restore-confirm { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 8px; max-width: 72ch; font-weight: 600; }
.restore-confirm input { width: auto; min-height: 0; margin-top: 3px; }
.empty-state { padding: 72px 20px; text-align: center; color: var(--muted); }
.empty-state svg { width: 32px; height: 32px; }
.empty-state h2 { color: var(--ink); margin-top: 10px; }
.form-layout { max-width: 820px; background: var(--surface); border: 1px solid var(--line); border-top: 5px solid var(--forest); box-shadow: 0 1px 2px rgba(9,30,66,.12); overflow: hidden; }
.form-heading { padding: 28px 30px 18px; border-bottom: 1px solid var(--line); }
.field-grid { padding: 26px 30px; display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.field-grid label { display: grid; gap: 6px; align-content: start; font-weight: 600; }
.field-grid input { height: 40px; }
.field-grid small { color: var(--muted); font-weight: 400; }
.field-grid .wide { grid-column: 1 / -1; }
.form-actions { justify-content: flex-end; padding: 18px 30px; background: #f5f7f4; border-top: 1px solid var(--line); }
dialog { width: min(620px, calc(100vw - 32px)); border: 0; padding: 0; box-shadow: 0 25px 80px rgba(12,29,23,.28); }
dialog::backdrop { background: rgba(13,35,29,.55); }
.dialog-header { padding: 22px 24px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 20px; }
#dialogBody { padding: 22px 24px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.detail-grid div { min-width: 0; }
.detail-grid span { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.detail-grid strong, .detail-grid a { overflow-wrap: anywhere; }
.dialog-actions { padding: 16px 24px; justify-content: flex-end; background: #f5f7f4; }
.toast-region { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 20; }
.toast { max-width: 380px; padding: 13px 16px; color: white; background: var(--ink); box-shadow: var(--shadow); }
.toast.error { background: #8d2e22; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (max-width: 820px) {
  .app-header { padding: 14px 18px; }
  .header-content { align-items: flex-start; }
  .brand-text h1 { font-size: 19px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { padding: 16px 18px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { position: static; }
  .nav-group-items { display: flex; overflow-x: auto; }
  .nav-item { width: auto; flex: 1 0 auto; border-left: 0; border-bottom: 2px solid transparent; border-radius: 6px; justify-content: center; }
  .nav-item.active { border-left: 0; border-bottom-color: var(--forest); }
  main { padding: 24px 18px 48px; }
  .summary-strip { grid-template-columns: 1fr 1fr; }
  .summary-strip div:nth-child(2) { border-right: 0; }
  .summary-strip div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 580px) {
  .header-content { flex-direction: column; }
  .auth-controls { width: 100%; justify-content: space-between; }
  .identity-text { text-align: left; }
  .topbar, .toolbar, .auth-panel { align-items: stretch; flex-direction: column; }
  .topbar-actions { justify-content: space-between; }
  .toolbar select, .search-field { width: 100%; min-width: 0; }
  .field-grid { grid-template-columns: 1fr; padding-inline: 20px; }
  .field-grid .wide { grid-column: auto; }
  .form-heading, .form-actions { padding-inline: 20px; }
  .detail-grid { grid-template-columns: 1fr; }
  .brand-logo { width: 100px; height: 38px; }
}