:root {
  --ink: var(--text-color, #142033);
  --muted: #63738a;
  --line: #e4eaf2;
  --card: #ffffff;
  --surface: #f7f9fc;
  --primary-rgb: 37, 99, 235;
  --accent-rgb: 20, 184, 166;
  --primary-soft: rgba(var(--primary-rgb), .10);
  --accent-soft: rgba(var(--accent-rgb), .11);
  --success: #138a4a;
  --danger: #c83535;
  --warning: #b86b04;
  --shadow: 0 16px 44px rgba(15, 23, 42, .10);
  --radius: 18px;
  --radius-sm: 12px;
}

html[data-theme="dark"] {
  --ink: #edf3fc;
  --muted: #a8b5c8;
  --line: #2b3850;
  --card: #162033;
  --surface: #0c1422;
  --page: #0b1320;
  --primary-soft: rgba(var(--primary-rgb), .22);
  --accent-soft: rgba(var(--accent-rgb), .18);
  --shadow: 0 20px 50px rgba(0, 0, 0, .26);
}

* { box-sizing: border-box; min-width: 0; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--page, #f4f7fb);
  color: var(--ink);
  font-family: var(--font, Inter, Arial, sans-serif);
  font-size: 15px;
  line-height: 1.55;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
h1,h2,h3,p { margin-top: 0; }
h1,h2,h3 { line-height: 1.18; letter-spacing: -.02em; }
h1 { font-size: clamp(1.85rem, 3vw, 2.65rem); }
h2 { font-size: clamp(1.25rem, 2vw, 1.65rem); }
h3 { font-size: 1.04rem; }
small { color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }

.container { width: min(1180px, calc(100% - 34px)); margin-inline: auto; }
.eyebrow { display: inline-flex; color: var(--primary); text-transform: uppercase; font-size: .72rem; letter-spacing: .12em; font-weight: 800; }
.muted { color: var(--muted); }
.danger-text { color: var(--danger); }
.required-star { color: var(--danger); font-size: .75rem; margin-left: .25rem; }

/* Base controls */
.button, .text-button, .icon-button, .theme-toggle {
  border: 0; transition: .18s ease; white-space: normal;
}
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .42rem;
  border-radius: 10px; min-height: 42px; padding: .66rem 1rem;
  color: #fff; background: var(--primary); font-weight: 750; box-shadow: 0 7px 16px rgba(var(--primary-rgb), .16);
}
.button:hover { transform: translateY(-1px); filter: brightness(.97); }
.button:focus-visible, .text-button:focus-visible, input:focus, select:focus, textarea:focus, .icon-button:focus-visible { outline: 3px solid rgba(var(--primary-rgb), .26); outline-offset: 2px; }
.button-small { min-height: 34px; padding: .42rem .7rem; font-size: .84rem; }
.button-light { background: #fff; color: var(--header); box-shadow: none; }
.button-ghost { background: transparent; color: var(--primary); border: 1px solid rgba(var(--primary-rgb), .36); box-shadow: none; }
.button-danger { background: var(--danger); box-shadow: none; }
.text-button { padding: 0; background: transparent; color: var(--primary); font-weight: 750; }
.text-button.danger { color: var(--danger); }
.icon-button, .theme-toggle {
  display: inline-grid; place-items: center; padding: 0; background: transparent; color: inherit;
}
.icon-button { width: 38px; height: 38px; border-radius: 10px; }
.icon-button:hover, .theme-toggle:hover { background: rgba(255,255,255,.12); }
.theme-toggle { min-height: 35px; border-radius: 9px; padding: 0 .6rem; gap: .25rem; font-weight: 700; }

/* Forms */
label { display: grid; gap: .38rem; color: var(--ink); font-weight: 700; font-size: .87rem; }
label small { font-weight: 500; }
input, select, textarea {
  width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); padding: .65rem .72rem;
}
input[type="color"] { padding: .2rem; min-height: 40px; cursor: pointer; }
input[type="file"] { padding: .5rem; }
textarea { resize: vertical; min-height: 92px; }
input[readonly] { opacity: .78; }
input:disabled, select:disabled, textarea:disabled { opacity: .6; cursor: not-allowed; }
.check { display: flex; align-items: flex-start; gap: .55rem; font-weight: 600; }
.check input { width: 17px; min-height: 17px; margin: .15rem 0 0; accent-color: var(--primary); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 1rem; }
legend { padding: 0 .35rem; color: var(--muted); font-weight: 800; font-size: .82rem; }
.checkbox-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .65rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .9rem; }
.form-grid.compact { gap: .65rem; }
.span-2 { grid-column: span 2; }
.stack-form { display: grid; gap: .85rem; }
.form-section { padding: 1.15rem 0; border-top: 1px solid var(--line); }
.form-section:first-child { padding-top: 0; border-top: 0; }
.form-section h2 { margin-bottom: .35rem; }
.form-section > p { color: var(--muted); }
.form-actions { display: flex; align-items: center; gap: .85rem; flex-wrap: wrap; margin-top: 1.2rem; }
.form-actions p { margin: 0; color: var(--muted); font-size: .86rem; }
.form-actions.inline { margin: 0; }
.inline-form, .decline-form, .inline-search { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; min-width: 105px; min-height: 34px; padding: .4rem .5rem; }
.decline-form input { min-width: 200px; min-height: 34px; padding: .4rem .5rem; }
.inline-search { margin-bottom: 1rem; }
.inline-search input { flex: 1 1 240px; }

/* General panels and table */
.panel, .auth-card, .payment-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel { padding: clamp(1rem, 2vw, 1.35rem); }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); }
.data-table { width: 100%; min-width: 620px; border-collapse: collapse; }
.data-table th, .data-table td { text-align: left; padding: .78rem .85rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table th { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table td small, .data-table td strong { display: block; }
.table-empty { text-align: center !important; color: var(--muted); padding: 1.8rem !important; }
.status-badge { display: inline-flex; align-items: center; min-height: 24px; max-width: 100%; border-radius: 999px; padding: .2rem .55rem; font-size: .73rem; font-weight: 800; background: var(--surface); color: var(--ink); }
.status-badge.status-active, .status-badge.status-approved, .status-badge.status-paid, .status-badge.status-signed, .status-badge.status-hired { background: rgba(19,138,74,.13); color: var(--success); }
.status-badge.status-pending, .status-badge.status-pending_review, .status-badge.status-sent, .status-badge.status-viewed, .status-badge.status-contract_sent { background: rgba(184,107,4,.14); color: var(--warning); }
.status-badge.status-declined, .status-badge.status-overdue, .status-badge.status-terminated, .status-badge.status-suspended, .status-badge.status-rejected { background: rgba(200,53,53,.13); color: var(--danger); }

/* Public header/home */
.public-header { position: sticky; z-index: 30; top: 0; background: var(--header); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.08); }
.header-inner { min-height: 69px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .65rem; flex: 0 1 auto; font-weight: 850; font-size: 1.04rem; }
.brand img { width: 42px; height: 42px; border-radius: 10px; object-fit: contain; background: rgba(255,255,255,.92); padding: .16rem; }
.logo-mark { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; background: var(--primary); color: #fff; font-weight: 900; }
.public-nav { display: flex; align-items: center; gap: .9rem; }
.public-nav > a:not(.button) { font-weight: 700; font-size: .9rem; opacity: .92; }
.public-nav > a:not(.button):hover { opacity: 1; }
.public-menu-button { display: none; }
.hero-section { padding: 1.15rem 0 0; }
.hero-slider { border-radius: 22px; overflow: hidden; box-shadow: var(--shadow); min-height: 440px; background: var(--slide-bg, var(--header)); position: relative; }
.hero-slide { display: none; min-height: 440px; align-items: center; padding: clamp(1.5rem, 6vw, 5rem); background-color: var(--slide-bg, var(--header)); background-position: center; background-size: cover; color: #fff; }
.hero-slide.is-active { display: flex; animation: heroFade .35s ease; }
.hero-content { max-width: 650px; }
.hero-content h1 { margin: .55rem 0 .8rem; color: #fff; font-size: clamp(2rem, 5vw, 4rem); }
.hero-content p { font-size: clamp(1rem, 2vw, 1.18rem); max-width: 570px; color: rgba(255,255,255,.88); }
.pill { display: inline-flex; border-radius: 999px; background: rgba(255,255,255,.16); padding: .34rem .65rem; font-weight: 750; font-size: .78rem; backdrop-filter: blur(4px); }
.slider-dots { position: absolute; bottom: 1rem; left: 50%; transform: translateX(-50%); display: flex; gap: .45rem; }
.slider-dots button { width: 9px; height: 9px; border: 0; border-radius: 50%; background: rgba(255,255,255,.45); padding: 0; }
.slider-dots button.active { background: #fff; transform: scale(1.17); }
.feature-section { padding: 5rem 0; }
.section-intro { max-width: 760px; margin-bottom: 1.5rem; }
.section-intro h2 { margin: .35rem 0 .65rem; }
.section-intro p { color: var(--muted); }
.feature-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 1rem; }
.feature-grid article { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.feature-grid article > span { display: grid; place-items: center; width: 42px; height: 42px; color: var(--primary); background: var(--primary-soft); border-radius: 12px; font-size: 1.2rem; }
.feature-grid h3 { margin: .8rem 0 .35rem; }
.feature-grid p { margin: 0; color: var(--muted); }
.callout { display: flex; align-items: center; justify-content: space-between; gap: 1.4rem; border-radius: 20px; padding: clamp(1.3rem,4vw,2.2rem); background: var(--header); color: #fff; margin-bottom: 5rem; }
.callout h2 { margin: .35rem 0 .55rem; color: #fff; }
.callout p { margin: 0; color: rgba(255,255,255,.82); max-width: 720px; }
.public-footer { background: var(--footer); color: rgba(255,255,255,.88); padding: 2.5rem 0 1rem; }
.footer-grid { display: flex; justify-content: space-between; gap: 2rem; padding-bottom: 1.5rem; }
.footer-grid p { color: rgba(255,255,255,.63); max-width: 440px; margin: .35rem 0 0; }
.footer-grid div:last-child { display: grid; gap: .55rem; align-content: start; }
.footer-copy { padding-top: 1rem; border-top: 1px solid rgba(255,255,255,.12); color: rgba(255,255,255,.55); font-size: .82rem; }

/* Public forms/auth */
.form-page { padding: 3.2rem 0 5rem; }
.form-page-heading { max-width: 720px; margin-bottom: 1.5rem; }
.form-page-heading h1 { margin: .38rem 0 .65rem; }
.form-page-heading p { color: var(--muted); }
.form-panel { max-width: 100%; }
.section-row { display: flex; gap: 1rem; align-items: center; justify-content: space-between; }
.section-row p { margin: .2rem 0 0; color: var(--muted); }
.shift-list { display: grid; gap: .8rem; }
.shift-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .9rem; }
.shift-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
.auth-section { min-height: calc(100vh - 180px); display: grid; place-items: center; padding: 3rem 1rem; }
.auth-card { width: min(100%, 460px); padding: clamp(1.25rem, 4vw, 2rem); }
.auth-card h1 { margin: .4rem 0 .65rem; }
.auth-card > p, .auth-note { color: var(--muted); }
.auth-note { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 1rem; font-size: .88rem; }
.status-page { max-width: 700px; padding: 5rem 0; text-align: center; }
.status-page h1 { margin: .75rem 0 .5rem; }
.status-page p { color: var(--muted); }
.status-icon { display: inline-grid; place-items: center; width: 68px; height: 68px; border-radius: 50%; background: rgba(19,138,74,.13); color: var(--success); font-size: 1.8rem; font-weight: 900; }
.status-icon.danger { background: rgba(200,53,53,.13); color: var(--danger); }

/* Quote/payment */
.quote-page, .payment-page, .contract-page, .content-page { padding: 3rem 0 5rem; }
.quote-top { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: 1rem; }
.quote-top h1 { margin: .35rem 0 .4rem; }
.quote-top p { margin: 0; color: var(--muted); }
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1rem; }
.detail-list { display: grid; gap: .75rem; }
.detail-list div { padding-bottom: .75rem; border-bottom: 1px solid var(--line); }
.detail-list div:last-child { border-bottom: 0; padding-bottom: 0; }
.detail-list span { display: block; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 800; }
.detail-list strong { display: block; margin-top: .15rem; }
.detail-list p { margin: .18rem 0 0; color: var(--muted); }
.tag-list { display: flex; flex-wrap: wrap; gap: .45rem; }
.tag-list span { background: var(--primary-soft); color: var(--primary); border-radius: 999px; padding: .28rem .55rem; font-size: .8rem; font-weight: 700; }
.quote-lines { display: grid; gap: .65rem; margin-bottom: .85rem; }
.quote-lines > div, .summary-row, .summary-total { display: flex; gap: 1rem; justify-content: space-between; align-items: flex-start; }
.quote-lines small { display: block; }
.summary-row { padding: .6rem 0; border-top: 1px solid var(--line); }
.summary-total { margin-top: .3rem; border-radius: var(--radius-sm); background: var(--primary-soft); padding: .78rem; font-size: 1.05rem; }
.terms-panel { margin-top: 1rem; }
.terms-panel p { color: var(--muted); }
.terms-check { margin: 1rem 0; }
.payment-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; }
.payment-card { padding: 1.35rem; }
.payment-card h2 { margin: .6rem 0 .2rem; }
.payment-card > strong { display: block; font-size: 1.65rem; color: var(--primary); }
.payment-card > p { color: var(--muted); }
.payment-card form { display: grid; gap: .7rem; margin-top: 1rem; }
.payment-icon { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); }
.secure-note { color: var(--muted); text-align: center; margin-top: 1rem; }
.contract-card { max-width: 850px; margin-inline: auto; }
.contract-content { white-space: pre-line; color: var(--ink); padding: 1rem; background: var(--surface); border-radius: var(--radius-sm); border: 1px solid var(--line); margin: 1rem 0; }
.signature-form { max-width: 550px; }

/* Portal layout */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0,1fr); }
.sidebar { position: sticky; top: 0; align-self: start; height: 100vh; display: flex; flex-direction: column; background: var(--sidebar); color: #eff7ff; padding: 1rem .75rem; overflow-y: auto; }
.brand-side { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .3rem .45rem 1rem; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-side .brand { color: #fff; }
.brand-side .brand img { width: 35px; height: 35px; }
.side-close { display: none; color: #fff; }
.sidebar-nav { display: grid; gap: .18rem; padding: 1rem 0; }
.nav-item { display: flex; align-items: center; gap: .75rem; min-height: 40px; padding: .55rem .65rem; border-radius: 10px; color: rgba(235,244,255,.80); font-weight: 700; font-size: .88rem; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.12); color: #fff; }
.nav-icon { width: 19px; text-align: center; font-size: 1rem; }
.sidebar-bottom { margin-top: auto; display: grid; gap: .3rem; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,.1); }
.nav-warning { background: rgba(184,107,4,.2); color: #ffe7b2; }
.main-area { display: flex; flex-direction: column; min-width: 0; }
.topbar { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem clamp(1rem,3vw,2.1rem); background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.menu-button { display: none; }
.topbar-title { display: grid; }
.topbar-title strong { line-height: 1.2; }
.topbar-actions { display: flex; align-items: center; gap: .55rem; }
.topbar .theme-toggle, .topbar .icon-button { color: var(--ink); border: 1px solid var(--line); }
.notification-link { position: relative; }
.notification-count { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; border-radius: 99px; background: var(--danger); color: #fff; font-size: .62rem; display: grid; place-items: center; font-weight: 800; }
.profile-chip { display: flex; align-items: center; gap: .5rem; padding-left: .35rem; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; background: var(--primary); font-weight: 850; }
.profile-chip-copy { display: grid; line-height: 1.2; font-size: .8rem; }
.profile-chip-copy small { font-size: .68rem; }
.page-content { width: min(1480px, 100%); margin: 0 auto; padding: clamp(1rem, 3vw, 2rem); flex: 1; }
.portal-footer { padding: 1.2rem clamp(1rem,3vw,2rem); color: var(--muted); font-size: .82rem; border-top: 1px solid var(--line); }
.page-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: 1.3rem; }
.page-heading h1 { margin: .3rem 0 .35rem; }
.page-heading p { margin: 0; color: var(--muted); max-width: 750px; }
.heading-action { flex: 0 0 auto; }
.metric-grid { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: .85rem; margin-bottom: 1rem; }
.metric-card { position: relative; overflow: hidden; min-height: 130px; padding: 1rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); }
.metric-card:before { content:""; position:absolute; inset:0 auto 0 0; width: 4px; background: var(--primary); }
.metric-card.metric-accent:before { background: var(--accent); }
.metric-card.metric-warning:before { background: var(--warning); }
.metric-card.metric-danger:before { background: var(--danger); }
.metric-card span { display: block; color: var(--muted); font-size: .78rem; font-weight: 800; }
.metric-card strong { display: block; margin: .35rem 0; font-size: 1.4rem; line-height: 1.1; overflow-wrap: anywhere; }
.metric-card small { display: block; }
.dashboard-grid, .admin-two { align-items: start; }
.stack-section { display: grid; gap: 1rem; }
.quick-actions { display: grid; gap: .55rem; }
.quick-actions h2 { margin-bottom: .2rem; }
.quick-actions a { border: 1px solid var(--line); border-radius: 10px; padding: .66rem .75rem; color: var(--primary); font-weight: 750; }
.timeline { display: grid; gap: .7rem; }
.timeline > div { position: relative; padding-left: 1rem; }
.timeline > div > span { position: absolute; left: 0; top: .45rem; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.timeline p { margin: 0; }
.timeline small { display: block; margin-top: .1rem; }
.flash { max-width: 1480px; margin: 0 auto 1rem; border-radius: 12px; padding: .75rem .9rem; font-weight: 700; }
.flash-success { background: rgba(19,138,74,.13); color: var(--success); }
.flash-danger { background: rgba(200,53,53,.12); color: var(--danger); }

/* Portal modules */
.doc-row { display: flex; gap: 1rem; justify-content: space-between; border-bottom: 1px solid var(--line); padding: .9rem 0; }
.doc-row:last-child { border-bottom: 0; }
.doc-row > div:first-child { flex: 1 1 250px; }
.doc-row strong { display: block; }
.doc-row small { display: block; margin-top: .15rem; }
.doc-row p { margin: .3rem 0 0; }
.doc-actions { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; flex: 0 1 auto; }
.mini-row { border-top: 1px solid var(--line); padding: .75rem 0; }
.mini-row:first-child { border-top: 0; }
.mini-row strong { display: block; }
.mini-row small { display: block; }
.document-upload-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .85rem; }
.document-upload { padding: .9rem; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); }
.document-upload h3 { font-size: .94rem; margin-bottom: .75rem; }
.document-upload > label { margin-bottom: .7rem; }
.notification-list { display: grid; gap: .75rem; }
.notification-card { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); }
.notification-card.unread { border-left: 4px solid var(--primary); }
.notification-card h3 { margin: 0 0 .22rem; font-size: 1rem; }
.notification-card p { margin: 0 0 .3rem; color: var(--muted); }
.site-card, .sop-card { border: 1px solid var(--line); padding: 1rem; border-radius: var(--radius-sm); background: var(--card); }
.site-grid, .sop-list { display: grid; gap: .85rem; }
.sop-content { background: var(--surface); border-radius: 10px; padding: .75rem; margin-top: .65rem; color: var(--ink); }
.invoice-detail { align-self: start; }
.settings-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; }
.settings-grid > section { display: grid; gap: .75rem; align-content: start; padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.settings-grid h2 { margin: 0; }
.settings-logo-preview { width: 80px; height: 80px; object-fit: contain; padding: .2rem; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.smtp-test-form { max-width: 630px; margin-top: 1rem; }
.cms-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; }
.cms-list { display: grid; gap: .7rem; }
.content-page { max-width: 900px; }
.cms-content { color: var(--ink); }
.cms-content img { max-width: 100%; }
.empty-state { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty-icon { color: var(--primary); font-size: 1.8rem; }
.empty-state h3 { color: var(--ink); margin: .3rem 0; }

@keyframes heroFade { from { opacity: .28; transform: scale(1.01); } to { opacity: 1; transform: scale(1); } }

@media (max-width: 1260px) {
  .metric-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 1040px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 60; left: 0; top: 0; width: min(300px, 86vw); transform: translateX(-105%); transition: transform .22s ease; box-shadow: 20px 0 50px rgba(0,0,0,.22); }
  .sidebar.open { transform: translateX(0); }
  .side-close, .menu-button { display: inline-grid; }
  .topbar { position: sticky; }
  .feature-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .shift-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 760px) {
  body { font-size: 14px; }
  .container { width: min(100% - 24px, 1180px); }
  .public-menu-button { display: inline-grid; color: #fff; }
  .public-nav { display: none; position: absolute; z-index: 50; top: 69px; left: 12px; right: 12px; background: var(--header); border: 1px solid rgba(255,255,255,.12); padding: .9rem; border-radius: 0 0 14px 14px; box-shadow: var(--shadow); }
  .public-nav.open { display: grid; justify-items: stretch; }
  .public-nav > a { padding: .45rem 0; }
  .public-nav .button { width: 100%; }
  .hero-section { padding-top: .7rem; }
  .hero-slider, .hero-slide { min-height: 380px; }
  .hero-slide { padding: 1.4rem; }
  .feature-section { padding: 3rem 0; }
  .feature-grid, .payment-grid, .two-column, .settings-grid, .cms-grid, .document-upload-grid { grid-template-columns: 1fr; }
  .callout, .footer-grid, .page-heading, .quote-top { flex-direction: column; align-items: stretch; }
  .callout { margin-bottom: 3rem; }
  .checkbox-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .form-page, .quote-page, .payment-page, .contract-page, .content-page { padding: 2rem 0 3.5rem; }
  .profile-chip-copy { display: none; }
  .topbar-title .eyebrow { display: none; }
  .topbar { padding: .6rem .75rem; }
  .topbar-actions { gap: .3rem; }
  .theme-toggle span { display: none; }
  .page-content { padding: 1rem .75rem; }
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .metric-card { min-height: 112px; }
  .doc-row, .notification-card { flex-direction: column; }
  .doc-actions { justify-content: flex-start; width: 100%; }
  .inline-form, .decline-form { width: 100%; }
  .inline-form input, .inline-form select, .decline-form input { flex: 1 1 130px; width: 100%; min-width: 0; }
  .inline-form .button, .decline-form .button { flex: 1 1 auto; }
  .data-table { min-width: 560px; }
}
@media (max-width: 460px) {
  .metric-grid { grid-template-columns: 1fr; }
  .hero-slider, .hero-slide { min-height: 345px; }
  .hero-content h1 { font-size: 2rem; }
  .section-row { align-items: flex-start; flex-direction: column; }
  .section-row .button { width: 100%; }
  .form-actions .button { width: 100%; }
  .button { width: 100%; }
  .inline-form .button, .decline-form .button, .button-small { width: auto; }
}

/* Staff, payroll and contract workflow refinements */
.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 5.25rem; }
.password-toggle { position: absolute; top: 50%; right: .42rem; transform: translateY(-50%); min-height: 30px; padding: .25rem .5rem; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--primary); font-weight: 800; font-size: .73rem; }
.password-toggle:hover { background: var(--primary-soft); }
.auth-links { margin-top: 1rem; text-align: center; font-size: .88rem; color: var(--primary); font-weight: 750; }
.expiry-warning, .field-warning { display: block; color: var(--danger); font-weight: 700; font-size: .76rem; line-height: 1.45; }
.expiry-warning { display: none; margin-top: .45rem; }
.expiry-warning.is-visible { display: block; padding: .55rem .65rem; border-left: 3px solid var(--danger); border-radius: 6px; background: rgba(200,53,53,.08); }
.quick-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 1rem; }
.quick-actions a { border-radius: 999px; padding: .36rem .68rem; background: var(--primary-soft); color: var(--primary); font-size: .78rem; font-weight: 800; }
.employee-hero { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; margin-bottom: 1rem; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); }
.employee-identity { display: flex; align-items: center; gap: .9rem; min-width: 0; }
.profile-photo-large, .profile-photo-placeholder { width: 60px; height: 60px; flex: 0 0 auto; border-radius: 50%; object-fit: cover; border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--line); }
.profile-photo-placeholder { display: grid; place-items: center; color: #fff; background: var(--primary); font-weight: 850; }
.profile-photo-row { display: flex; align-items: center; gap: 1rem; padding: .85rem; border: 1px dashed var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.profile-photo-row > label { flex: 1; }
.employee-actions { display: flex; gap: .55rem; flex-wrap: wrap; justify-content: flex-end; }
.doc-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--line); }
.doc-row:last-child { border-bottom: 0; }
.doc-row strong { display: block; }
.doc-row small { display: block; margin-top: .15rem; }
.doc-actions { display: flex; align-items: center; justify-content: flex-end; gap: .45rem; flex-wrap: wrap; flex: 0 0 auto; }
.document-history { margin-top: .55rem; padding: .55rem .7rem; border-radius: 8px; background: var(--surface); font-size: .79rem; color: var(--muted); }
.contract-list { display: grid; gap: .8rem; }
.contract-item { padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.contract-item > div:first-child { display: grid; gap: .2rem; }
.contract-item details { margin-top: .7rem; }
.contract-item summary { color: var(--primary); cursor: pointer; font-weight: 800; }
.contract-item .contract-content { max-height: 360px; overflow: auto; font-size: .9rem; }
.tab-nav { display: flex; flex-wrap: wrap; gap: .45rem; margin: 0 0 1rem; padding: .45rem; border-radius: 10px; background: var(--surface); }
.tab-nav a { display: inline-flex; min-height: 34px; align-items: center; border-radius: 7px; padding: .4rem .7rem; color: var(--muted); font-size: .83rem; font-weight: 800; }
.tab-nav a.active, .tab-nav a:hover { color: var(--primary); background: var(--card); box-shadow: 0 1px 4px rgba(15,23,42,.08); }
.payroll-editor { max-width: 880px; }
.delete-panel { margin-top: 1rem; display: flex; justify-content: flex-end; }
.warning-card { display: grid; gap: .55rem; padding: 1rem; margin-bottom: .8rem; border: 1px solid var(--line); border-left: 4px solid var(--warning); border-radius: var(--radius-sm); background: var(--card); }
.warning-card.warning-final { border-left-color: var(--danger); }
.warning-card .warning-meta { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: .82rem; }
.audit-value { max-width: 340px; white-space: pre-wrap; word-break: break-word; font-size: .76rem; color: var(--muted); }
.form-panel input, .form-panel select, .form-panel textarea, .stack-form input, .stack-form select, .stack-form textarea { max-width: 100%; }

@media (max-width: 900px) {
  .employee-hero { align-items: flex-start; flex-direction: column; }
  .employee-actions { justify-content: flex-start; }
}
@media (max-width: 760px) {
  .profile-photo-row { align-items: flex-start; flex-direction: column; }
  .employee-identity { align-items: flex-start; }
  .doc-actions { justify-content: flex-start; }
  .contract-item { padding: .85rem; }
  .tab-nav { overflow-x: auto; flex-wrap: nowrap; }
  .tab-nav a { white-space: nowrap; }
  .delete-panel { justify-content: stretch; }
  .delete-panel .button { width: 100%; }
}
/* PHP status renderer uses .badge; retain the legacy status-badge aliases above for compatibility. */
.badge { display: inline-flex; align-items: center; min-height: 24px; max-width: 100%; border-radius: 999px; padding: .2rem .55rem; font-size: .73rem; font-weight: 800; background: var(--surface); color: var(--ink); }
.badge-success { background: rgba(19,138,74,.13); color: var(--success); }
.badge-warning { background: rgba(184,107,4,.14); color: var(--warning); }
.badge-danger { background: rgba(200,53,53,.13); color: var(--danger); }
.badge-neutral { background: var(--surface); color: var(--ink); }

/* Admin date/time settings preview */
.time-preview {
  margin: 0;
  padding: .72rem .8rem;
  border: 1px dashed var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--ink);
  overflow-wrap: anywhere;
}
.time-preview small { display: block; margin-top: .2rem; }


/* Stability patch: prevents long dynamic values and action rows from escaping their cards. */
*, *::before, *::after { box-sizing: border-box; }
.page-content, .panel, .form-section, .doc-row, .employee-hero, .contract-item, .notification-card { min-width: 0; }
input, select, textarea, button { max-width: 100%; }
.doc-row, .employee-hero, .notification-card { gap: .75rem; }
.doc-row > *, .employee-hero > *, .notification-card > * { min-width: 0; }
.doc-row strong, .doc-row small, .detail-list strong, .detail-list span, .notification-card p { overflow-wrap: anywhere; }
.table-avatar, .profile-photo-large { object-fit: cover; max-width: 100%; }
@media (max-width: 760px) {
  .page-heading { align-items: flex-start; flex-direction: column; }
  .heading-action, .heading-action .button { width: 100%; }
  .doc-actions, .form-actions.inline, .inline-form, .decline-form { width: 100%; }
  .doc-actions .button, .doc-actions .text-button { min-height: 38px; }
  .inline-form input, .inline-form select, .decline-form input { min-width: 0; }
  .settings-grid, .dashboard-grid, .two-column { grid-template-columns: minmax(0, 1fr); }
  .hero-slider, .hero-slide { min-height: min(520px, 72vh); }
}

/* Server-side honeypot field for public forms. */
.hp-field { position: absolute !important; left: -10000px !important; width: 1px !important; height: 1px !important; overflow: hidden !important; }
