:root {
  --ink: #162033;
  --muted: #647085;
  --line: #d6dde8;
  --soft: #f4f7fb;
  --surface: #ffffff;
  --brand: #0f766e;
  --brand-dark: #0b5f59;
  --accent: #e85d4f;
  --gold: #b7791f;
  --side: #253041;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(15, 118, 110, .12), transparent 25%),
    radial-gradient(circle at 84% 16%, rgba(232, 93, 79, .10), transparent 26%),
    linear-gradient(180deg, #eef2f7 0, #f8fafc 42%, #eef2f7 100%);
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.client-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  grid-template-rows: 62px minmax(0, 1fr);
}

.client-command {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 240px minmax(260px, 640px) auto;
  gap: 18px;
  align-items: center;
  padding: 10px 18px;
  color: white;
  background: #1d2735;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .18);
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  color: white;
  text-decoration: none;
}

.brand-mark,
.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: white;
  font-weight: 900;
  border-radius: 8px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #0f766e, #3b82f6);
}

.brand strong,
.brand small,
.identity-card strong,
.identity-card small {
  display: block;
}

.brand small {
  color: rgba(255, 255, 255, .68);
}

.client-search {
  position: relative;
  display: grid;
  grid-template-columns: 112px minmax(120px, 1fr);
  align-items: center;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  background: rgba(255, 255, 255, .1);
}

.client-search span {
  padding: 0 13px;
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.client-search input {
  min-height: 40px;
  margin: 0;
  border: 0;
  border-radius: 0 7px 7px 0;
  border-left: 1px solid rgba(255, 255, 255, .16);
  padding: 9px 12px;
}

.client-search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: 112px;
  z-index: 45;
  max-height: min(520px, calc(100vh - 92px));
  overflow: auto;
  display: grid;
  gap: 6px;
  padding: 8px;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 46px rgba(15, 23, 42, .28);
}

.client-search-results.hidden {
  display: none;
}

.client-search-result,
.client-search-empty {
  width: 100%;
  display: grid;
  gap: 3px;
  padding: 10px;
  text-align: left;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.client-search-result {
  cursor: pointer;
}

.client-search-result:hover,
.client-search-result:focus {
  outline: 2px solid rgba(15, 118, 110, .22);
  background: #f2fbfa;
}

.client-search-result strong,
.client-search-empty strong {
  color: var(--ink);
  font-size: 14px;
}

.client-search-result span,
.client-search-empty span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.client-search-result small {
  color: var(--muted);
  font-size: 12px;
}

.header-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 8px 13px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  color: white;
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: 0 8px 18px rgba(15, 118, 110, .18);
}

.btn-primary:hover { background: var(--brand-dark); }

.btn-outline {
  color: #254056;
  background: white;
  border-color: #cfd8e5;
}

.client-side {
  grid-column: 1;
  grid-row: 2;
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 14px 12px;
  color: white;
  background: linear-gradient(180deg, #2b3748, #202a39);
}

.client-card {
  background: rgba(255, 255, 255, .95);
  border: 1px solid rgba(148, 163, 184, .38);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(31, 44, 61, .06);
}

.identity-card {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
  color: white;
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .12);
}

.identity-card small {
  margin-top: 2px;
  color: rgba(255, 255, 255, .68);
}

.avatar {
  width: 38px;
  height: 38px;
  background: var(--accent);
}

.client-nav {
  display: grid;
  gap: 7px;
}

.client-nav button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 11px;
  color: rgba(255, 255, 255, .82);
  background: transparent;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.client-nav button.active,
.client-nav button:hover {
  color: white;
  background: var(--brand);
}

.client-content {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  padding: 18px;
}

.page-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  min-height: 70px;
  margin: -18px -18px 16px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, .86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.page-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: #111827;
  font-size: 28px;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric-card {
  position: relative;
  overflow: hidden;
  min-height: 94px;
  padding: 14px;
  background: linear-gradient(180deg, #fff, #f8fafc);
  border: 1px solid rgba(148, 163, 184, .38);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(31, 44, 61, .06);
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--accent), var(--gold));
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin: 8px 0 2px;
  color: #111827;
  font-size: 26px;
}

.metric-card small {
  font-weight: 600;
  text-transform: none;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(330px, .75fr);
  gap: 14px;
}

.card-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  background: linear-gradient(180deg, #fff, #f8fafc);
  border-bottom: 1px solid var(--line);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #254056;
  background: white;
  font-weight: 900;
  cursor: pointer;
}

.help-button {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #cfd8e5;
  border-radius: 999px;
  padding: 0;
  color: #254056;
  background: white;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
}

.help-button:hover,
.help-button:focus-visible {
  color: white;
  background: var(--brand);
  border-color: var(--brand);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  color: white;
  background: #344055;
  font-size: 12px;
  text-align: left;
  text-transform: uppercase;
}

td,
th {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tbody tr:hover td {
  background: #f2fbfa;
}

.num { text-align: right; }

.mini-btn,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.mini-btn {
  border: 1px solid var(--line);
  color: #254056;
  background: white;
  cursor: pointer;
}

.status-pill {
  color: #064e3b;
  background: #dff8ef;
}

.status-pill.warn {
  color: #92400e;
  background: #fef3c7;
}

.planner-list,
.person-list,
.submittal-grid {
  display: grid;
  gap: 9px;
  padding: 14px;
}

.planner-item,
.person-card,
.submittal-card {
  display: grid;
  gap: 4px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.planner-item {
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.planner-item > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.planner-item > div > span {
  color: var(--muted);
  font-size: 13px;
}

.planner-item time,
.person-card span,
.submittal-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr)) auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(148, 163, 184, .38);
  border-radius: 8px;
}

label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--ink);
  background: white;
}

input[type="checkbox"] {
  width: auto;
  min-height: auto;
  margin: 0;
}

.report-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.report-tiles button {
  min-height: 132px;
  padding: 18px;
  text-align: left;
  background: white;
  border: 1px solid rgba(148, 163, 184, .38);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(31, 44, 61, .06);
  cursor: pointer;
}

.report-tiles button.active,
.report-tiles button:hover {
  border-color: rgba(18, 132, 116, .5);
  box-shadow: 0 12px 28px rgba(18, 132, 116, .12);
}

.report-tiles strong,
.report-tiles span {
  display: block;
}

.report-tiles strong {
  margin-bottom: 8px;
  color: #111827;
  font-size: 18px;
}

.report-tiles span {
  color: var(--muted);
}

.report-viewer {
  overflow: hidden;
}

.report-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.report-summary div {
  display: grid;
  gap: 4px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.report-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.report-summary strong {
  color: #111827;
  font-size: 22px;
}

.schedule-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  gap: 10px;
  padding: 14px;
}

.schedule-day {
  min-height: 300px;
  padding: 10px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.schedule-day h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.schedule-shift {
  margin-bottom: 8px;
  padding: 9px;
  background: white;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
}

.form-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 35, 58, .48);
}

.modal-backdrop.hidden { display: none; }

.modal {
  width: min(760px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  display: grid;
  gap: 14px;
  padding: 18px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 55px rgba(23, 35, 58, .28);
}

.help-modal {
  width: min(680px, 100%);
}

.modal header,
.modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-grid div {
  display: grid;
  gap: 4px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.detail-grid span,
.stack-list span,
.stack-list small,
.modal-note {
  color: var(--muted);
}

.detail-grid span {
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.stack-list {
  display: grid;
  gap: 10px;
}

.stack-list article {
  display: grid;
  gap: 5px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stack-list .mini-btn {
  justify-self: start;
}

.modal-note {
  margin: 8px 0 0;
  line-height: 1.45;
}

.help-content {
  display: grid;
  gap: 12px;
}

.help-content section {
  padding: 13px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.help-content h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.help-content p,
.help-content ul {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.help-content ul {
  padding-left: 19px;
}

.help-content li + li {
  margin-top: 6px;
}

.invoice-lines {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.invoice-lines .card-heading {
  padding: 0;
  border: 0;
}

.invoice-lines .card-heading span {
  color: var(--muted);
  font-weight: 800;
}

.invoice-lines table {
  min-width: 780px;
}

.invoice-lines tfoot th {
  background: #f8fafc;
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  color: white;
  background: #1d2735;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(23, 35, 58, .28);
  font-weight: 800;
}

.toast.hidden {
  display: none;
}

.client-shell.is-locked {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

.client-login-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(15, 23, 42, .58);
}

.client-login-backdrop.hidden {
  display: none;
}

.client-login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 22px;
  color: var(--ink);
  background: white;
  border: 1px solid rgba(148, 163, 184, .45);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
}

.client-login-card .brand {
  color: var(--ink);
}

.client-login-card .brand small {
  color: var(--muted);
}

.client-login-card h1 {
  font-size: 24px;
}

.client-login-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.client-login-card input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
  color: var(--ink);
}

.login-error {
  min-height: 18px;
  margin: 0;
  color: #b42318;
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 1080px) {
  .client-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .client-command,
  .client-search,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .client-search input {
    border-top: 1px solid rgba(255, 255, 255, .16);
    border-left: 0;
    border-radius: 0 0 7px 7px;
  }

  .client-search-results {
    left: 0;
  }

  .client-side {
    grid-row: 2;
    grid-column: 1;
  }

  .client-nav {
    display: flex;
    overflow-x: auto;
  }

  .client-nav button {
    white-space: nowrap;
  }

  .client-content {
    grid-row: 3;
    grid-column: 1;
  }
}

@media (max-width: 760px) {
  .header-actions,
  .page-actions,
  .page-title,
  .modal header,
  .modal-actions {
    display: grid;
    justify-content: stretch;
  }

  .metric-grid,
  .toolbar,
  .schedule-grid,
  .form-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

/* Keep staff context visible while navigating client tabs. */
.staff-view-banner { position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 20px; background: #fff4d6; color: #493514; border-bottom: 2px solid #c4932c; }
.staff-view-banner strong, .staff-view-banner span { display: block; }
.staff-view-banner strong span { display: inline; }
.staff-client-view #newOrderButton, .staff-client-view #approveSelectedButton, .staff-client-view #sendSupportButton, .staff-client-view #saveAccountButton, .staff-client-view #requestMoreCandidatesButton, .staff-client-view [data-approve-one], .staff-client-view [data-submittal-action] { opacity: .5; cursor: not-allowed; }
@media (max-width: 600px) { .staff-view-banner { align-items: flex-start; flex-direction: column; padding: 10px 12px; } }
