/* SATISFACTORY-OPERATIONS-PORTAL-V2 v2.3.1 */
:root {
  --ss-bg: #eef0f1;
  --ss-surface: #ffffff;
  --ss-surface-soft: #f7f8f8;
  --ss-ink: #171a17;
  --ss-muted: #626a62;
  --ss-line: #d9ddda;
  --ss-line-strong: #c6cbc7;
  --ss-dark: #171915;
  --ss-dark-2: #242620;
  --ss-dark-3: #2f312b;
  --ss-yellow: #f3c400;
  --ss-yellow-hover: #e4b800;
  --ss-green: #249055;
  --ss-red: #a73737;
  --ss-blue-soft: #eaf4ff;
  --ss-shadow: 0 12px 28px rgba(0,0,0,.12);
  --ss-radius: 7px;
  --ss-max: 1480px;
}

html { background: var(--ss-dark); }
body.portal-body { margin: 0; min-height: 100svh; background: var(--ss-bg); color: var(--ss-ink); }
.portal-body * { box-sizing: border-box; }
.portal-body .portal-shell { width: 100%; max-width: none; margin: 0; padding: 0; }

/* Unified authenticated shell */
.portal-app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(180deg, #1b1d19 0%, #171915 100%);
  border-bottom: 1px solid #34372f;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
}
.portal-app-header-inner {
  width: min(var(--ss-max), calc(100% - 32px));
  min-height: 76px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(285px, 1fr) auto minmax(250px, .9fr);
  align-items: center;
  gap: 24px;
}
.portal-app-brand { display: grid; gap: 3px; min-width: 0; }
.portal-app-brand .portal-home {
  color: var(--ss-yellow) !important;
  font-size: clamp(16px, 1.5vw, 21px);
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: -.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.portal-app-brand span {
  color: #f1f2ee;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .28em;
}
.portal-app-header .portal-nav {
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  overflow: visible;
}
.portal-app-header .portal-nav a,
.portal-app-header .portal-nav a:link,
.portal-app-header .portal-nav a:visited,
.portal-app-header .portal-nav a:focus {
  min-height: 44px;
  padding: 12px 15px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #f4f5f2 !important;
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}
.portal-app-header .portal-nav a:hover { background: #2b2e28; }
.portal-app-header .portal-nav a.active {
  background: var(--ss-yellow) !important;
  color: #11140f !important;
}
.portal-app-account {
  justify-self: end;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
  color: #f4f5f2;
  font-size: 12px;
}
.portal-app-account .portal-user-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.portal-app-account .portal-role {
  padding-left: 10px;
  border-left: 1px solid #4b4d46;
  font-weight: 850;
}
.portal-app-account form { margin: 0; }
.portal-app-account .portal-logout {
  min-height: 32px;
  padding: 6px 9px;
  border: 0;
  border-left: 1px solid #4b4d46;
  border-radius: 0;
  background: transparent;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.portal-mobile-toggle { display: none; }

/* Common page frame */
.portal-page-head {
  background: #fff;
  border-bottom: 1px solid var(--ss-line);
}
.portal-page-head-inner {
  width: min(var(--ss-max), calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 19px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}
.portal-page-head h1 {
  margin: 0 0 5px;
  color: var(--ss-ink);
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1;
  letter-spacing: -.035em;
}
.portal-page-head p { margin: 0; color: var(--ss-muted); font-size: 14px; }
.portal-notice,.portal-alert {
  width: min(var(--ss-max), calc(100% - 32px));
  margin: 14px auto 0;
  border-radius: 4px;
}
.portal-notice { background: #e6f5eb; color: #1e653b; border: 1px solid #b9dfc8; }
.portal-alert { background: #fff1df; color: #784b00; border: 1px solid #ead1a9; }

.portal-body .metric-strip,
.portal-body .portal-grid {
  width: min(var(--ss-max), calc(100% - 32px));
  margin-left: auto;
  margin-right: auto;
}
.portal-body .metric-strip {
  margin-top: 18px;
  margin-bottom: 14px;
  grid-template-columns: repeat(5, minmax(0,1fr));
  gap: 10px;
  background: transparent;
}
.portal-body .metric-strip article {
  padding: 17px 18px;
  border: 1px solid var(--ss-line);
  border-radius: var(--ss-radius);
  background: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.portal-body .metric-strip span { font-size: clamp(24px, 2.3vw, 34px); }
.portal-body .metric-strip p { margin-top: 6px; font-size: 12px; color: var(--ss-muted); }
.portal-body .portal-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0,1fr));
  gap: 14px;
  padding: 18px 0 42px;
}
.portal-body .portal-panel {
  grid-column: span 6;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--ss-line);
  border-radius: var(--ss-radius);
  background: #fff;
  color: var(--ss-ink);
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.portal-body .portal-panel.wide { grid-column: 1 / -1; }
.portal-body .portal-panel h2 { margin: 0 0 14px; font-size: 20px; letter-spacing: -.02em; }
.portal-body .portal-panel h3 { font-size: 16px; }
.portal-panel-head { align-items: center; }
.portal-panel-head a { color: var(--ss-ink); }

/* Controls */
.portal-body input,
.portal-body select,
.portal-body textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--ss-line-strong);
  border-radius: 3px;
  background: #fff;
  color: var(--ss-ink);
  font: inherit;
  font-size: 13px;
}
.portal-body input,
.portal-body select { min-height: 38px; padding: 8px 10px; }
.portal-body textarea { padding: 9px 10px; line-height: 1.4; resize: vertical; }
.portal-body label { color: #252925; font-size: 12px; font-weight: 800; }
.portal-body .button,
.portal-body button {
  min-height: 38px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 850;
}
.portal-body .button.primary,
.portal-body button.button.primary {
  background: var(--ss-yellow);
  color: #11140f;
  border-color: var(--ss-yellow);
}
.portal-body .button.primary:hover,
.portal-body button.button.primary:hover { background: var(--ss-yellow-hover); }
.portal-body .button.secondary { background: #fff; color: var(--ss-ink); border-color: #313631; }
.portal-body .danger-inline-form button { background: #fff; color: var(--ss-red); border: 1px solid #cf8f8f; }

/* Dashboard */
.portal-view-dashboard .portal-grid { padding-top: 0; }
.portal-view-dashboard .portal-panel { padding: 18px; }
.portal-view-dashboard .stage-board {
  grid-template-columns: repeat(6, minmax(0,1fr));
  gap: 8px;
  background: transparent;
}
.portal-view-dashboard .stage-board article {
  min-height: 96px;
  padding: 14px;
  border: 1px solid var(--ss-line);
  border-radius: 5px;
  background: var(--ss-surface-soft);
}
.portal-view-dashboard .stage-board strong { color: #6d5600; font-size: 11px; }
.portal-view-dashboard .stage-board span { font-size: 12px; }

/* Quotes */
.portal-view-quotes .portal-panel { padding: 0; overflow: hidden; }
.portal-view-quotes .portal-panel-head { padding: 18px 18px 10px; }
.quote-review-table { overflow-x: auto; }
.quote-review-table table { min-width: 1080px; table-layout: fixed; }
.quote-review-table th,.quote-review-table td { padding: 13px 12px; }
.quote-review-table th { font-size: 10px; color: #697069; }
.quote-review-table th:nth-child(1){width:17%}.quote-review-table th:nth-child(2){width:19%}.quote-review-table th:nth-child(3){width:11%}.quote-review-table th:nth-child(4){width:14%}.quote-review-table th:nth-child(5){width:19%}.quote-review-table th:nth-child(6){width:20%}
.quote-review-table td { font-size: 13px; line-height: 1.35; }
.quote-review-table td span { font-size: 11px; line-height: 1.4; }
.sms-quote-state { min-width: 0; gap: 5px; }
.sms-status-badge { width: fit-content; padding: 4px 8px; border-radius: 999px; font-size: 10px; }
.v2-disclosure {
  border: 1px solid var(--ss-line);
  border-radius: 4px;
  background: var(--ss-surface-soft);
  overflow: hidden;
}
.v2-disclosure > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ss-ink);
  font-size: 12px;
  font-weight: 850;
}
.v2-disclosure > summary::-webkit-details-marker { display: none; }
.v2-disclosure > summary::after { content: '+'; font-size: 17px; line-height: 1; }
.v2-disclosure[open] > summary::after { content: '–'; }
.v2-disclosure-body { padding: 0 10px 10px; }
.v2-quote-disclosure .accept-quote-form { min-width: 0; grid-template-columns: 1fr 1fr; gap: 7px; }
.v2-quote-disclosure .accept-quote-form input,.v2-quote-disclosure .accept-quote-form textarea { min-height: 36px; padding: 7px 8px; font-size: 11px; }
.v2-quote-disclosure .accept-quote-form textarea { min-height: 72px; }
.v2-quote-disclosure .accept-quote-form button { width: 100%; }

/* Work orders */
.portal-view-work-orders .portal-panel { padding: 16px; }
.portal-view-work-orders .work-order-list { gap: 12px; }
.portal-view-work-orders .work-order-card {
  display: grid;
  grid-template-columns: minmax(250px,.72fr) minmax(0,1.28fr);
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--ss-line);
  border-radius: 6px;
  background: #fff;
}
.work-order-card > div:first-child { min-width: 0; }
.work-order-card > div:first-child h3 { margin: 2px 0 8px; font-size: 18px; }
.work-order-card > div:first-child p { font-size: 12px; line-height: 1.45; }
.portal-view-work-orders .portal-kicker { color: #785d00; font-size: 10px; }
.v2-work-sections { display: grid; gap: 8px; min-width: 0; align-content: start; }
.v2-work-sections .v2-disclosure { background: #fff; }
.v2-work-sections .v2-disclosure > summary { background: #f7f8f7; border-bottom: 1px solid transparent; }
.v2-work-sections .v2-disclosure[open] > summary { border-bottom-color: var(--ss-line); }
.v2-work-sections .work-order-form,
.v2-work-sections .invoice-create-form { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; padding: 10px; border: 0; background: transparent; }
.v2-work-sections .work-order-form label:nth-child(n+5) { grid-column: 1/-1; }
.v2-work-sections .work-order-form button,.v2-work-sections .invoice-create-form button { width: 100%; }
.v2-work-sections .work-order-checklist { border: 0; padding: 10px; background: transparent; }
.portal-view-work-orders .invoice-link-row { grid-column: 1/-1; padding: 11px 12px; border-radius: 4px; }
.portal-view-work-orders .photo-strip { grid-template-columns: repeat(auto-fill,minmax(120px,1fr)); padding: 10px; }

/* Invoices */
.portal-view-invoices .invoice-card-list { gap: 10px; }
.portal-view-invoices .invoice-edit-card {
  padding: 0;
  border: 1px solid var(--ss-line);
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}
.portal-view-invoices .invoice-edit-card > .portal-panel-head { padding: 14px 15px; background: #fafbfa; border-bottom: 1px solid var(--ss-line); }
.portal-view-invoices .invoice-edit-card > .portal-panel-head h3 { font-size: 15px; }
.portal-view-invoices .invoice-edit-card > .portal-panel-head span { font-size: 11px; }
.v2-invoice-disclosure { margin: 10px 12px; }
.v2-invoice-disclosure .invoice-edit-form { grid-template-columns: repeat(3,minmax(0,1fr)); padding: 10px; }
.v2-invoice-disclosure .invoice-add-line-form { grid-template-columns: 80px minmax(180px,1fr) 120px auto; padding: 10px; border-top: 1px solid var(--ss-line); }
.portal-view-invoices .invoice-actions-cell { padding: 0 12px 12px; }

/* Time + Profile */
.portal-view-time .portal-grid { grid-template-columns: repeat(12,minmax(0,1fr)); }
.portal-view-time .portal-panel { grid-column: 3 / span 8; }
.portal-view-time .portal-form.compact { grid-template-columns: 1fr 1fr; gap: 10px; }
.portal-view-time .portal-form.compact label:last-of-type { grid-column: 1/-1; }
.portal-view-time .portal-form.compact button { grid-column: 1/-1; width: fit-content; }
.portal-view-profile .profile-panel { grid-column: 2 / span 10; grid-template-columns: 290px minmax(0,1fr); }
.portal-view-profile .profile-card { padding: 8px; align-items: flex-start; }
.portal-view-profile .profile-form { gap: 10px; }

/* Admin: one integrated workspace */
.portal-view-admin .portal-grid {
  display: grid;
  grid-template-columns: 220px minmax(0,1fr);
  gap: 0;
  padding-top: 0;
}
.portal-view-admin > .portal-page-head { display:block; }
.v2-admin-content > .v2-admin-page-head {
  margin: -10px -10px 10px;
  width: auto;
  border-radius: 0 7px 0 0;
}
.v2-admin-content > .v2-admin-page-head .portal-page-head-inner {
  width: auto;
  padding: 18px 20px 15px;
}
.v2-admin-sidebar {
  grid-column: 1;
  grid-row: 1;
  align-self: stretch;
  background: linear-gradient(180deg,#20231f,#2a2d28);
  border-radius: 7px 0 0 7px;
  overflow: hidden;
  color: #fff;
  min-height: 720px;
}
.v2-admin-sidebar-head { padding: 20px 18px 16px; border-bottom: 1px solid #3a3d37; font-size: 18px; font-weight: 900; }
.v2-admin-sidebar nav { display: grid; }
.v2-admin-sidebar a {
  color: #f2f3ef;
  text-decoration: none;
  padding: 14px 16px;
  border-bottom: 1px solid #383b35;
  font-size: 12px;
  font-weight: 800;
}
.v2-admin-sidebar a:hover { background: #33362f; }
.v2-admin-sidebar a.is-active { margin: 6px; border: 0; border-radius: 4px; background: var(--ss-yellow); color: #11140f; }
.v2-admin-content {
  grid-column: 2;
  min-width: 0;
  background: #f4f5f5;
  border: 1px solid #34372f;
  border-left: 0;
  border-radius: 0 7px 7px 0;
  padding: 10px;
}
.v2-admin-content > .portal-panel { width: auto; margin: 0 0 10px; grid-column: auto !important; border-radius: 6px; }
.v2-admin-lower { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.v2-admin-lower > .portal-panel { margin: 0; min-width: 0; grid-column: auto !important; }
.v2-admin-section-head { display:flex; justify-content:space-between; gap:12px; align-items:center; margin-bottom:12px; padding-bottom:10px; border-bottom:1px solid var(--ss-line); }
.v2-admin-section-head h2 { margin: 0 !important; }
.v2-admin-section-head p { margin: 3px 0 0; color: var(--ss-muted); font-size: 11px; }

/* SMS workspace */
.portal-view-admin .sms-admin-panel { display: block; }
.portal-view-admin .sms-admin-head { margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--ss-line); }
.portal-view-admin .sms-admin-head .portal-kicker { display: none; }
.portal-view-admin .sms-admin-head h2 { margin: 0 0 3px; font-size: 20px; }
.portal-view-admin .sms-admin-head p { margin: 0; font-size: 12px; color: var(--ss-muted); }
.portal-view-admin .sms-health-chip { background: #e9f7ee; color: #1f7b45; border: 1px solid #bfe0ca; }
.v2-sms-workspace { display: grid; grid-template-columns: minmax(0,1.15fr) minmax(320px,.85fr); gap: 20px; align-items: start; }
.v2-sms-form-wrap { min-width: 0; padding-right: 20px; border-right: 1px solid var(--ss-line); }
.portal-view-admin .sms-config-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.portal-view-admin .sms-config-grid > label,
.portal-view-admin .sms-key-row > label {
  display: grid;
  grid-template-columns: 180px minmax(0,1fr);
  gap: 12px;
  align-items: center;
  min-width: 0;
}
.portal-view-admin .sms-config-grid > label > input,
.portal-view-admin .sms-config-grid > label > select,
.portal-view-admin .sms-key-row input { grid-column: 2; }
.portal-view-admin .sms-switch { display: grid !important; grid-template-columns: 180px 1fr; }
.portal-view-admin .sms-switch input { grid-column: 2; width: 22px; min-height: 22px; accent-color: var(--ss-yellow); }
.portal-view-admin .sms-config-grid > label .sms-device-note { grid-column: 2; margin: -2px 0 2px; font-size: 10px; color: #747b74; line-height: 1.35; }
.portal-view-admin .sms-config-grid > .sms-api-note { margin: -2px 0 2px 192px; font-size: 10px; color: #747b74; line-height: 1.35; }
.portal-view-admin .sms-key-row { display: grid; gap: 4px; }
.portal-view-admin .sms-key-state { margin-left: 192px; font-size: 10px; color: #697069; }
.portal-view-admin .sms-config-grid > div.full:last-child { margin-left: 192px; }
.v2-sms-status {
  border: 1px solid var(--ss-line);
  border-radius: 6px;
  background: #f8f9fa;
  overflow: hidden;
}
.v2-sms-status-head { padding: 13px 14px; background: #eef1f2; border-bottom: 1px solid var(--ss-line); }
.v2-sms-status-head h3 { margin: 0 0 3px; font-size: 15px; }
.v2-sms-status-head p { margin: 0; font-size: 10px; color: var(--ss-muted); }
.v2-sms-status dl { margin: 0; padding: 10px 14px; display: grid; gap: 7px; }
.v2-sms-status dl div { display: grid; grid-template-columns: 130px minmax(0,1fr); gap: 9px; font-size: 11px; }
.v2-sms-status dt { font-weight: 850; }
.v2-sms-status dd { margin: 0; overflow-wrap: anywhere; }
.v2-state-ok { color: var(--ss-green); font-weight: 850; }
.v2-test-block { padding: 12px 14px 14px; border-top: 1px solid var(--ss-line); }
.v2-test-block h3 { margin: 0 0 3px; font-size: 15px; }
.v2-test-block p { margin: 0 0 10px; font-size: 10px; color: var(--ss-muted); }
.v2-test-block .sms-admin-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.v2-test-block .sms-admin-actions form { margin: 0; }
.v2-test-block .sms-admin-actions button { width: 100%; background: #fff; color: var(--ss-ink); border: 1px solid #303530; }
.v2-test-block .sms-admin-actions form:last-child button { background: var(--ss-yellow); border-color: var(--ss-yellow); }
.v2-test-note { margin-top: 8px !important; padding: 9px 10px; background: var(--ss-blue-soft); color: #2d6496 !important; border-radius: 4px; }

/* Accounts and gallery compact management */
.v2-collapsible-create { margin-bottom: 10px; }
.v2-collapsible-create > summary { background: var(--ss-yellow); color: #11140f; width: fit-content; border-radius: 3px; }
.portal-view-admin .admin-account-grid { display: grid; gap: 6px; margin-top: 10px; }
.portal-view-admin .admin-account-card { display: block; padding: 0; border: 1px solid var(--ss-line); border-radius: 4px; overflow: hidden; background: #fff; }
.v2-account-summary { cursor: pointer; list-style: none; display: grid; grid-template-columns: minmax(150px,1fr) minmax(190px,1.35fr) 90px 54px; gap: 8px; align-items: center; padding: 9px 10px; font-size: 11px; }
.v2-account-summary::-webkit-details-marker { display: none; }
.v2-account-summary strong { font-size: 12px; }
.v2-account-summary .muted { color: var(--ss-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v2-account-summary .edit { justify-self:end; border:1px solid #9fa49f; padding:4px 7px; border-radius:2px; font-weight:800; }
.v2-account-editor { display:grid; grid-template-columns:1fr 1fr; gap:8px; padding:10px; border-top:1px solid var(--ss-line); background:#fafbfa; }
.v2-account-editor > * { min-width:0; }
.v2-account-editor button { grid-column:1/-1; width:fit-content; }
.portal-view-admin .gallery-admin-grid { grid-template-columns: 1fr; gap: 6px; margin-top: 10px; }
.portal-view-admin .gallery-admin-card { display:block; padding:0; border:0; background:transparent; }
.portal-view-admin .gallery-admin-card > img { width:82px; height:58px; object-fit:cover; border-radius:3px; }
.portal-view-admin .gallery-admin-edit { grid-template-columns: 1fr 1fr; gap: 7px; }
.portal-view-admin .gallery-admin-edit textarea { min-height: 68px; }
.portal-view-admin .gallery-admin-edit button { width: fit-content; }
.portal-view-admin .portal-list { font-size: 12px; }


.v2-gallery-details { display:block; border:1px solid var(--ss-line); border-radius:4px; overflow:hidden; background:#fff; }
.v2-gallery-summary { list-style:none; cursor:pointer; display:grid; grid-template-columns:72px minmax(130px,1fr) minmax(90px,.7fr) 54px; gap:10px; align-items:center; padding:7px 9px; font-size:11px; }
.v2-gallery-summary::-webkit-details-marker { display:none; }
.v2-gallery-summary img { width:72px; height:52px; object-fit:cover; border-radius:3px; }
.v2-gallery-summary strong { font-size:12px; }
.v2-gallery-summary .muted { color:var(--ss-muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.v2-gallery-summary .edit { justify-self:end; border:1px solid #9fa49f; padding:4px 7px; border-radius:2px; font-weight:800; }
.v2-gallery-editor { display:grid; gap:8px; padding:10px; border-top:1px solid var(--ss-line); background:#fafbfa; }
.v2-gallery-editor .gallery-admin-edit { display:grid; grid-template-columns:1fr 1fr; gap:7px; }
.v2-gallery-editor .danger-inline-form { margin:0; }

/* Login keeps same brand but cleaner */
.portal-body:not(.portal-authenticated) .portal-shell { padding: 42px 16px; background: var(--ss-dark); min-height:100svh; }
.portal-body:not(.portal-authenticated) .login-panel { border-radius: 7px; box-shadow: var(--ss-shadow); }

/* Responsive */
@media (max-width: 1220px) {
  .portal-app-header-inner { grid-template-columns: minmax(240px,1fr) auto; gap: 16px; }
  .portal-app-header .portal-nav { grid-column: 1/-1; grid-row: 2; overflow-x:auto; padding-bottom:8px; }
  .portal-app-account { grid-column:2; grid-row:1; }
  .portal-app-header-inner { padding-top: 10px; }
  .v2-sms-workspace { grid-template-columns: 1fr; }
  .v2-sms-form-wrap { border-right:0; padding-right:0; border-bottom:1px solid var(--ss-line); padding-bottom:14px; }
  .v2-admin-lower { grid-template-columns:1fr; }
  .portal-view-dashboard .stage-board { grid-template-columns: repeat(3,minmax(0,1fr)); }
}

@media (max-width: 900px) {
  .portal-app-header { position: relative; }
  .portal-app-header-inner { width:100%; min-height:68px; padding:10px 14px; display:grid; grid-template-columns:1fr auto; }
  .portal-app-brand .portal-home { font-size:16px; }
  .portal-app-brand span { font-size:9px; }
  .portal-app-account { display:none; }
  .portal-mobile-toggle { display:inline-grid; place-items:center; width:44px; height:44px; border:1px solid #4a4d45; background:#242620; color:#fff; }
  .portal-app-header .portal-nav { grid-column:1/-1; display:none; padding:8px 0 2px; overflow-x:visible; flex-wrap:wrap; }
  .portal-app-header.is-open .portal-nav { display:flex; }
  .portal-app-header .portal-nav a { flex: 1 1 calc(50% - 4px); }
  .portal-page-head-inner { width:calc(100% - 28px); padding:18px 0 15px; }
  .portal-body .metric-strip,.portal-body .portal-grid,.portal-notice,.portal-alert { width:calc(100% - 28px); }
  .portal-body .metric-strip { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .portal-body .portal-grid { grid-template-columns:1fr; }
  .portal-body .portal-panel,.portal-body .portal-panel.wide { grid-column:1; }
  .portal-view-quotes .quote-review-table { overflow: visible; }
  .portal-view-quotes .quote-review-table table { min-width:0; display:block; }
  .portal-view-quotes .quote-review-table thead { display:none; }
  .portal-view-quotes .quote-review-table tbody { display:grid; gap:10px; padding:0 10px 10px; }
  .portal-view-quotes .quote-review-table tr { display:grid; grid-template-columns:1fr 1fr; gap:0; border:1px solid var(--ss-line); border-radius:5px; overflow:hidden; }
  .portal-view-quotes .quote-review-table td { display:block; border-bottom:1px solid var(--ss-line); padding:10px; min-width:0; }
  .portal-view-quotes .quote-review-table td:nth-child(1),.portal-view-quotes .quote-review-table td:nth-child(2) { grid-column:span 1; }
  .portal-view-quotes .quote-review-table td:nth-child(n+3) { grid-column:1/-1; }
  .portal-view-quotes .quote-review-table td::before { display:block; margin-bottom:4px; color:#707770; font-size:9px; font-weight:900; text-transform:uppercase; letter-spacing:.05em; }
  .portal-view-quotes .quote-review-table td:nth-child(1)::before{content:'Company'}.portal-view-quotes .quote-review-table td:nth-child(2)::before{content:'Contact'}.portal-view-quotes .quote-review-table td:nth-child(3)::before{content:'Status'}.portal-view-quotes .quote-review-table td:nth-child(4)::before{content:'SMS'}.portal-view-quotes .quote-review-table td:nth-child(5)::before{content:'Requested'}.portal-view-quotes .quote-review-table td:nth-child(6)::before{content:'Actions'}
  .portal-view-work-orders .work-order-card { grid-template-columns:1fr; }
  .portal-view-time .portal-panel,.portal-view-profile .profile-panel { grid-column:1; }
  .portal-view-profile .profile-panel { grid-template-columns:1fr; }
  .portal-view-admin .portal-grid { grid-template-columns:1fr; }
  .v2-admin-sidebar { grid-column:1; min-height:auto; border-radius:6px 6px 0 0; }
  .v2-admin-sidebar-head { display:none; }
  .v2-admin-sidebar nav { display:flex; overflow-x:auto; }
  .v2-admin-sidebar a { white-space:nowrap; border-right:1px solid #3a3d37; border-bottom:0; }
  .v2-admin-sidebar a.is-active { margin:4px; }
  .v2-admin-content { grid-column:1; border-left:1px solid #34372f; border-top:0; border-radius:0 0 6px 6px; }
}

@media (max-width: 620px) {
  .portal-body .metric-strip { grid-template-columns:1fr 1fr; gap:7px; }
  .portal-body .metric-strip article { padding:13px; }
  .portal-view-dashboard .stage-board { grid-template-columns:1fr 1fr; }
  .portal-page-head h1 { font-size:26px; }
  .portal-page-head p { font-size:12px; }
  .portal-view-time .portal-form.compact,.portal-view-profile .profile-form { grid-template-columns:1fr; }
  .portal-view-time .portal-form.compact label:last-of-type,.portal-view-time .portal-form.compact button { grid-column:1; }
  .v2-work-sections .work-order-form,.v2-work-sections .invoice-create-form,.v2-invoice-disclosure .invoice-edit-form { grid-template-columns:1fr; }
  .v2-invoice-disclosure .invoice-add-line-form { grid-template-columns:1fr; }
  .portal-view-admin .sms-config-grid > label,.portal-view-admin .sms-key-row > label,.portal-view-admin .sms-switch { grid-template-columns:1fr; gap:4px; }
  .portal-view-admin .sms-config-grid > label > input,.portal-view-admin .sms-config-grid > label > select,.portal-view-admin .sms-key-row input,.portal-view-admin .sms-switch input { grid-column:1; }
  .portal-view-admin .sms-config-grid > label .sms-device-note,.portal-view-admin .sms-config-grid > .sms-api-note,.portal-view-admin .sms-key-state,.portal-view-admin .sms-config-grid > div.full:last-child { grid-column:1; margin-left:0; }
  .v2-test-block .sms-admin-actions { grid-template-columns:1fr; }
  .v2-admin-lower { grid-template-columns:1fr; }
  .v2-account-summary { grid-template-columns:1fr auto; }
  .v2-account-summary .muted,.v2-account-summary .role { grid-column:1; }
  .v2-account-summary .edit { grid-column:2; grid-row:1/3; }
  .v2-account-editor,.portal-view-admin .gallery-admin-edit { grid-template-columns:1fr; }
  .v2-gallery-summary { grid-template-columns:58px 1fr auto; }
  .v2-gallery-summary img { width:58px; height:44px; }
  .v2-gallery-summary .muted { grid-column:2; }
  .v2-gallery-summary .edit { grid-column:3; grid-row:1/3; }
  .v2-gallery-editor .gallery-admin-edit { grid-template-columns:1fr; }
}

@media print {
  .portal-app-header,.portal-page-head { position:static; box-shadow:none; }
}


/* =========================================================
   v2.1 Admin Workspace Architecture
   ========================================================= */
.portal-view-admin .portal-grid {
  display: block;
  padding-top: 14px;
  padding-bottom: 48px;
}
.v21-admin-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.v21-admin-sidebar {
  position: sticky;
  top: 90px;
  align-self: start;
  min-height: 0;
  border: 1px solid #34372f;
  border-radius: 7px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
}
.v21-admin-sidebar .v2-admin-sidebar-head {
  padding: 19px 18px 15px;
  background: #1f211d;
  font-size: 18px;
}
.v21-admin-sidebar nav { display: grid; }
.v21-admin-sidebar a {
  position: relative;
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 12px 15px 12px 18px;
  border-bottom: 1px solid #3a3d37;
  color: #f4f5f2;
  background: #282b26;
  font-size: 12px;
  font-weight: 850;
}
.v21-admin-sidebar a:last-child { border-bottom: 0; }
.v21-admin-sidebar a:hover { background: #32352f; }
.v21-admin-sidebar a.is-active {
  margin: 0;
  border-radius: 0;
  background: var(--ss-yellow);
  color: #11140f;
  box-shadow: inset 4px 0 #11140f;
}
.v21-admin-content {
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.v21-admin-page-head {
  margin: 0 0 12px !important;
  border: 1px solid var(--ss-line);
  border-radius: 7px !important;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.v21-admin-page-head .portal-page-head-inner {
  width: auto !important;
  min-height: 82px;
  padding: 18px 20px !important;
  align-items: center;
}
.v21-admin-page-head h1 { font-size: 30px; }
.v21-admin-page-head p { max-width: 760px; }
.v21-admin-workspace { min-width: 0; }
.v21-admin-section {
  width: 100% !important;
  margin: 0 !important;
  padding: 20px !important;
  border: 1px solid var(--ss-line) !important;
  border-radius: 7px !important;
  background: #fff !important;
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.v21-admin-section[hidden] { display: none !important; }
.v21-admin-mobile-switch { display: none; }

/* SMS becomes a focused two-column workspace. */
.portal-view-admin .v21-admin-section.sms-admin-panel { padding: 20px !important; }
.portal-view-admin .sms-admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 18px;
  padding: 0 0 14px;
}
.portal-view-admin .sms-admin-head h2 { font-size: 19px; }
.portal-view-admin .sms-admin-head p { max-width: 720px; }
.v21-admin-section .v2-sms-workspace {
  grid-template-columns: minmax(460px, 1.2fr) minmax(310px, .8fr);
  gap: 24px;
}
.v21-admin-section .v2-sms-form-wrap {
  padding-right: 24px;
}
.portal-view-admin .v21-admin-section .sms-config-grid {
  gap: 10px;
}
.portal-view-admin .v21-admin-section .sms-config-grid > label,
.portal-view-admin .v21-admin-section .sms-key-row > label,
.portal-view-admin .v21-admin-section .sms-switch {
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 14px;
}
.portal-view-admin .v21-admin-section .sms-config-grid > label .sms-device-note {
  grid-column: 2;
}
.portal-view-admin .v21-admin-section .sms-config-grid > .sms-api-note,
.portal-view-admin .v21-admin-section .sms-key-state,
.portal-view-admin .v21-admin-section .sms-config-grid > div.full:last-child {
  margin-left: 182px;
}
.v21-admin-section .v2-sms-status { position: sticky; top: 90px; }

/* Section headers share one geometry. */
.v21-admin-section .v2-admin-section-head {
  min-height: 58px;
  margin: -2px 0 16px;
  padding: 0 0 14px;
}
.v21-admin-section .v2-admin-section-head h2 {
  font-size: 19px;
}
.v21-admin-section .v2-admin-section-head p {
  max-width: 720px;
  font-size: 11px;
  line-height: 1.45;
}
.v21-admin-section .v2-admin-section-head .button { min-width: 112px; }

/* User Accounts is now a dedicated full-width workspace. */
.portal-view-admin #admin-users .v2-collapsible-create,
.portal-view-admin #admin-gallery .v2-collapsible-create {
  margin: 0 0 14px;
  border: 1px solid var(--ss-line);
  border-radius: 5px;
  overflow: hidden;
  background: #fafbfa;
}
.portal-view-admin #admin-users .v2-collapsible-create > summary,
.portal-view-admin #admin-gallery .v2-collapsible-create > summary {
  width: 100%;
  padding: 11px 13px;
  border-radius: 0;
  background: #f7f8f7;
  border-bottom: 0;
  color: var(--ss-ink);
}
.portal-view-admin #admin-users .v2-collapsible-create[open] > summary,
.portal-view-admin #admin-gallery .v2-collapsible-create[open] > summary {
  border-bottom: 1px solid var(--ss-line);
}
.portal-view-admin #admin-users .v2-collapsible-create .v2-disclosure-body,
.portal-view-admin #admin-gallery .v2-collapsible-create .v2-disclosure-body { padding: 12px; }
.portal-view-admin #admin-users .admin-account-grid {
  margin-top: 0;
  gap: 7px;
}
.portal-view-admin #admin-users .admin-account-card {
  border-color: var(--ss-line);
}
.portal-view-admin #admin-users .v2-account-summary {
  grid-template-columns: minmax(190px, 1fr) minmax(240px, 1.35fr) 100px 58px;
  min-height: 48px;
  padding: 10px 12px;
}
.portal-view-admin #admin-users .v2-account-editor {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  padding: 14px;
}

/* Gallery has its own full-width content management surface. */
.portal-view-admin #admin-gallery .gallery-admin-grid {
  margin-top: 0;
  gap: 7px;
}
.portal-view-admin #admin-gallery .v2-gallery-summary {
  grid-template-columns: 92px minmax(220px, 1.2fr) minmax(150px, .8fr) 58px;
  min-height: 66px;
  padding: 7px 10px;
}
.portal-view-admin #admin-gallery .v2-gallery-summary img {
  width: 82px;
  height: 54px;
}
.portal-view-admin #admin-gallery .v2-gallery-editor { padding: 14px; }
.portal-view-admin #admin-gallery .v2-gallery-editor .gallery-admin-edit {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

/* System uses actual current messaging configuration plus crew directory. */
.v21-system-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.v21-system-stat {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--ss-line);
  border-radius: 5px;
  background: var(--ss-surface-soft);
}
.v21-system-stat span {
  display: block;
  margin-bottom: 6px;
  color: var(--ss-muted);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.v21-system-stat strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 13px;
}
.portal-view-admin #admin-system .portal-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.portal-view-admin #admin-system .portal-list li {
  min-height: 52px;
  padding: 11px 12px;
  border: 1px solid var(--ss-line);
  border-radius: 5px;
  background: #fff;
}

@media (max-width: 1180px) {
  .v21-admin-shell { grid-template-columns: 205px minmax(0,1fr); gap: 10px; }
  .v21-admin-section .v2-sms-workspace { grid-template-columns: 1fr; }
  .v21-admin-section .v2-sms-form-wrap { padding-right: 0; padding-bottom: 16px; border-right: 0; border-bottom: 1px solid var(--ss-line); }
  .v21-admin-section .v2-sms-status { position: static; }
  .v21-system-overview { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 900px) {
  .portal-view-admin .portal-grid { width: calc(100% - 28px); padding-top: 12px; }
  .v21-admin-shell { display: block; }
  .v21-admin-sidebar { display: none; }
  .v21-admin-content { width: 100%; }
  .v21-admin-mobile-switch {
    display: grid;
    grid-template-columns: 100px minmax(0,1fr);
    align-items: center;
    gap: 10px;
    margin: 0 0 10px;
    padding: 10px 12px;
    border: 1px solid var(--ss-line);
    border-radius: 6px;
    background: #fff;
    color: var(--ss-ink);
    font-size: 11px;
    font-weight: 850;
  }
  .v21-admin-mobile-switch select { min-height: 40px; }
  .v21-admin-section { padding: 16px !important; }
  .v21-admin-page-head .portal-page-head-inner { min-height: 0; padding: 16px !important; }
  .v21-admin-page-head h1 { font-size: 26px; }
  .portal-view-admin #admin-users .v2-account-summary { grid-template-columns: 1fr auto; }
  .portal-view-admin #admin-users .v2-account-summary .muted,
  .portal-view-admin #admin-users .v2-account-summary .role { grid-column: 1; }
  .portal-view-admin #admin-users .v2-account-summary .edit { grid-column: 2; grid-row: 1 / 3; }
  .portal-view-admin #admin-gallery .v2-gallery-summary { grid-template-columns: 70px minmax(0,1fr) auto; }
  .portal-view-admin #admin-gallery .v2-gallery-summary .muted { grid-column: 2; }
  .portal-view-admin #admin-gallery .v2-gallery-summary .edit { grid-column: 3; grid-row: 1 / 3; }
}

@media (max-width: 620px) {
  .portal-view-admin .v21-admin-section .sms-config-grid > label,
  .portal-view-admin .v21-admin-section .sms-key-row > label,
  .portal-view-admin .v21-admin-section .sms-switch {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .portal-view-admin .v21-admin-section .sms-config-grid > label > input,
  .portal-view-admin .v21-admin-section .sms-config-grid > label > select,
  .portal-view-admin .v21-admin-section .sms-key-row input,
  .portal-view-admin .v21-admin-section .sms-switch input,
  .portal-view-admin .v21-admin-section .sms-config-grid > label .sms-device-note {
    grid-column: 1;
  }
  .portal-view-admin .v21-admin-section .sms-config-grid > .sms-api-note,
  .portal-view-admin .v21-admin-section .sms-key-state,
  .portal-view-admin .v21-admin-section .sms-config-grid > div.full:last-child {
    margin-left: 0;
  }
  .v21-admin-mobile-switch { grid-template-columns: 1fr; gap: 5px; }
  .v21-system-overview { grid-template-columns: 1fr; }
  .portal-view-admin #admin-system .portal-list { grid-template-columns: 1fr; }
  .portal-view-admin #admin-users .v2-account-editor,
  .portal-view-admin #admin-gallery .v2-gallery-editor .gallery-admin-edit { grid-template-columns: 1fr; }
}

/* v2.1 refinement: keep Admin as the persistent app context and make the SMS switch intentional. */
.portal-view-admin .sms-switch .v21-switch-label {
  grid-column: 1;
  align-self: center;
  color: #252925;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}
.portal-view-admin .sms-switch input[type="checkbox"] {
  grid-column: 2;
  justify-self: start;
  appearance: none;
  -webkit-appearance: none;
  width: 40px;
  height: 22px;
  min-height: 22px;
  margin: 0;
  border: 1px solid #b7bdb8;
  border-radius: 999px;
  background: radial-gradient(circle at 11px 50%, #fff 0 8px, transparent 8.5px), #d3d7d3;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}
.portal-view-admin .sms-switch input[type="checkbox"]:checked {
  border-color: #d4aa00;
  background: radial-gradient(circle at calc(100% - 11px) 50%, #fff 0 8px, transparent 8.5px), var(--ss-yellow);
}
.portal-view-admin .sms-switch input[type="checkbox"]:focus-visible {
  outline: 3px solid rgba(243,196,0,.28);
  outline-offset: 2px;
}
.v21-public-gallery-link {
  margin-left: auto;
  white-space: nowrap;
  color: var(--ss-ink) !important;
  font-size: 11px;
  font-weight: 850;
  text-decoration: underline;
}
@media (max-width: 620px) {
  .portal-view-admin .v21-admin-section .sms-switch {
    grid-template-columns: minmax(0,1fr) auto;
    align-items: center;
    gap: 10px;
  }
  .portal-view-admin .v21-admin-section .sms-switch .v21-switch-label { grid-column: 1; }
  .portal-view-admin .v21-admin-section .sms-switch input[type="checkbox"] { grid-column: 2; }
  .v21-public-gallery-link { width: 100%; margin-left: 0; }
  .v21-admin-section .v2-admin-section-head { flex-wrap: wrap; }
}

/* =========================================================
   v2.1.2 Admin Workspace Visibility Hardening
   Exactly one Admin workspace may be visible at a time.
   ========================================================= */
.portal-view-admin .v21-admin-workspace > .v21-admin-section {
  display: none !important;
}
.portal-view-admin .v21-admin-workspace > .v21-admin-section.is-active {
  display: block !important;
}
.portal-view-admin .v21-admin-workspace > .v21-admin-section[hidden] {
  display: none !important;
}


/* =========================================================
   v2.2.0 Admin Shell Polish
   Approved direction: one continuous admin application frame
   ========================================================= */
@media (min-width: 901px) {
  .portal-view-admin .portal-grid {
    width: calc(100% - 36px);
    max-width: none;
    padding-top: 16px;
    padding-bottom: 36px;
  }

  .portal-view-admin .v21-admin-shell {
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 0;
    align-items: stretch;
    overflow: hidden;
    border: 1px solid #34372f;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(0,0,0,.10);
  }

  .portal-view-admin .v21-admin-sidebar {
    position: relative;
    top: auto;
    min-height: 100%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: linear-gradient(180deg,#20231f 0%,#252822 100%);
  }

  .portal-view-admin .v21-admin-sidebar .v2-admin-sidebar-head {
    min-height: 70px;
    display: flex;
    align-items: center;
    padding: 0 18px;
    border-bottom: 1px solid #3a3d37;
    background: #1d201c;
    font-size: 20px;
    letter-spacing: -.02em;
  }

  .portal-view-admin .v21-admin-sidebar nav {
    position: sticky;
    top: 76px;
    display: grid;
  }

  .portal-view-admin .v21-admin-sidebar a {
    min-height: 54px;
    padding: 0 18px;
    border-bottom: 1px solid #3a3d37;
    font-size: 12px;
    line-height: 1.2;
  }

  .portal-view-admin .v21-admin-sidebar a.is-active {
    box-shadow: inset 4px 0 #11140f;
  }

  .portal-view-admin .v21-admin-content {
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #f4f5f5;
  }

  .portal-view-admin .v21-admin-page-head {
    flex: 0 0 auto;
    margin: 0 !important;
    border: 0;
    border-bottom: 1px solid var(--ss-line);
    border-radius: 0 !important;
    background: #fff;
    box-shadow: none;
  }

  .portal-view-admin .v21-admin-page-head .portal-page-head-inner {
    min-height: 78px;
    padding: 16px 20px !important;
  }

  .portal-view-admin .v21-admin-page-head h1 {
    margin-bottom: 4px;
    font-size: 28px;
  }

  .portal-view-admin .v21-admin-page-head p {
    font-size: 12px;
    line-height: 1.4;
  }

  .portal-view-admin .v21-admin-workspace {
    flex: 1 1 auto;
    min-width: 0;
    padding: 12px;
    background: #f4f5f5;
  }

  .portal-view-admin .v21-admin-section {
    min-height: 0;
    padding: 18px !important;
    border: 1px solid var(--ss-line) !important;
    border-radius: 5px !important;
    box-shadow: none;
  }

  .portal-view-admin .v21-admin-section.sms-admin-panel {
    padding: 18px !important;
  }

  .portal-view-admin .sms-admin-head {
    margin-bottom: 14px;
    padding-bottom: 12px;
  }

  .portal-view-admin .sms-admin-head h2,
  .portal-view-admin .v2-admin-section-head h2 {
    font-size: 18px;
    line-height: 1.2;
  }

  .portal-view-admin .sms-admin-head p,
  .portal-view-admin .v2-admin-section-head p {
    font-size: 11px;
    line-height: 1.4;
  }

  .portal-view-admin .v21-admin-section .v2-sms-workspace {
    grid-template-columns: minmax(520px, 1.18fr) minmax(340px, .82fr);
    gap: 18px;
    align-items: start;
  }

  .portal-view-admin .v21-admin-section .v2-sms-form-wrap {
    padding-right: 18px;
  }

  .portal-view-admin .v21-admin-section .sms-config-grid {
    gap: 9px;
  }

  .portal-view-admin .v21-admin-section .sms-config-grid > label,
  .portal-view-admin .v21-admin-section .sms-key-row > label,
  .portal-view-admin .v21-admin-section .sms-switch {
    grid-template-columns: 154px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
  }

  .portal-view-admin .v21-admin-section .sms-config-grid > label > input,
  .portal-view-admin .v21-admin-section .sms-config-grid > label > select,
  .portal-view-admin .v21-admin-section .sms-key-row input {
    min-height: 36px;
  }

  .portal-view-admin .v21-admin-section .sms-config-grid > label .sms-device-note {
    grid-column: 2;
  }

  .portal-view-admin .v21-admin-section .sms-config-grid > .sms-api-note,
  .portal-view-admin .v21-admin-section .sms-key-state,
  .portal-view-admin .v21-admin-section .sms-config-grid > div.full:last-child {
    margin-left: 166px;
  }

  .portal-view-admin .v21-admin-section .sms-key-row {
    min-width: 0;
  }

  .portal-view-admin .v21-admin-section .sms-key-row > label {
    min-width: 0;
  }

  .portal-view-admin .v21-admin-section .sms-key-row input {
    width: 100%;
    min-width: 0;
  }

  .portal-view-admin .v21-admin-section .sms-key-state {
    max-width: calc(100% - 166px);
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .portal-view-admin .v21-admin-section .v2-sms-status {
    position: static;
    border-radius: 5px;
    background: #f8f9fa;
  }

  .portal-view-admin .v2-sms-status-head {
    padding: 13px 14px 11px;
  }

  .portal-view-admin .v2-sms-status dl {
    padding: 11px 14px;
    gap: 8px;
  }

  .portal-view-admin .v2-sms-status dl div {
    grid-template-columns: 124px minmax(0,1fr);
  }

  .portal-view-admin .v2-test-block {
    padding: 12px 14px 13px;
  }

  .portal-view-admin #admin-users .admin-account-grid,
  .portal-view-admin #admin-gallery .gallery-admin-grid {
    gap: 6px;
  }

  .portal-view-admin #admin-users .v2-account-summary {
    min-height: 46px;
    grid-template-columns: minmax(180px,1fr) minmax(240px,1.35fr) 95px 58px;
    padding: 8px 11px;
  }

  .portal-view-admin #admin-gallery .v2-gallery-summary {
    min-height: 60px;
    grid-template-columns: 78px minmax(220px,1.25fr) minmax(140px,.8fr) 58px;
    padding: 6px 9px;
  }

  .portal-view-admin #admin-gallery .v2-gallery-summary img {
    width: 68px;
    height: 46px;
  }

  .portal-view-admin #admin-users .v2-collapsible-create,
  .portal-view-admin #admin-gallery .v2-collapsible-create {
    margin-bottom: 12px;
  }

  .portal-view-admin .v21-system-overview {
    margin-bottom: 14px;
  }
}

@media (min-width: 1280px) {
  .portal-app-header-inner {
    width: calc(100% - 36px);
    max-width: none;
  }
}

@media (max-width: 1100px) and (min-width: 901px) {
  .portal-view-admin .v21-admin-shell {
    grid-template-columns: 190px minmax(0, 1fr);
  }
  .portal-view-admin .v21-admin-section .v2-sms-workspace {
    grid-template-columns: 1fr;
  }
  .portal-view-admin .v21-admin-section .v2-sms-form-wrap {
    padding-right: 0;
    padding-bottom: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--ss-line);
  }
}

@media (max-width: 900px) {
  .portal-view-admin .portal-grid {
    padding-top: 10px;
    padding-bottom: 24px;
  }
  .portal-view-admin .v21-admin-shell {
    border: 1px solid var(--ss-line);
    border-radius: 7px;
    overflow: hidden;
    background: #fff;
  }
  .portal-view-admin .v21-admin-content {
    background: #f4f5f5;
  }
  .portal-view-admin .v21-admin-page-head {
    margin: 0 !important;
    border: 0;
    border-bottom: 1px solid var(--ss-line);
    border-radius: 0 !important;
    box-shadow: none;
  }
  .portal-view-admin .v21-admin-page-head .portal-page-head-inner {
    min-height: 0;
    padding: 15px 16px !important;
  }
  .portal-view-admin .v21-admin-mobile-switch {
    margin: 10px 10px 0;
  }
  .portal-view-admin .v21-admin-workspace {
    padding: 10px;
  }
  .portal-view-admin .v21-admin-section {
    padding: 14px !important;
    border-radius: 5px !important;
  }
  .portal-view-admin .sms-admin-head {
    align-items: flex-start;
  }
  .portal-view-admin .sms-health-chip {
    flex: 0 0 auto;
  }
  .portal-view-admin .v21-admin-section .sms-key-state {
    max-width: 100%;
    overflow-wrap: anywhere;
  }
}


/* v2.2.0 final fit corrections */
.portal-view-admin .sms-switch .v22-switch-help {
  grid-column: 2;
  margin-top: -5px;
  color: #747b74;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.35;
}
.portal-view-admin .sms-key-row {
  grid-template-columns: 1fr !important;
}
.portal-view-admin .sms-key-row > label {
  width: 100%;
}
.portal-view-admin .sms-key-row .sms-key-state {
  margin-left: 166px !important;
  max-width: calc(100% - 166px) !important;
  padding-top: 1px;
}
@media (max-width: 900px) {
  .portal-view-admin .sms-switch .v22-switch-help {
    grid-column: 1 / -1;
    margin-top: 0;
  }
  .portal-view-admin .sms-key-row .sms-key-state {
    margin-left: 0 !important;
    max-width: 100% !important;
  }
}

/* ============================================================
   v2.3.1 Quote Creator + Service Catalog
   ============================================================ */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Quotes: replace the cramped table with a readable workflow. */
.portal-view-quotes .v23-quote-workspace {
  padding: 0;
  overflow: visible;
  background: transparent;
  border: 0;
  box-shadow: none;
}
.v23-quote-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border: 1px solid var(--ss-line);
  border-radius: var(--ss-radius) var(--ss-radius) 0 0;
  background: #fff;
}
.v23-quote-toolbar h2 { margin: 0 0 3px !important; font-size: 20px; }
.v23-quote-toolbar p { margin: 0; color: var(--ss-muted); font-size: 12px; }
.v23-quote-toolbar-actions { display: flex; gap: 8px; align-items: center; }
.v23-quote-toolbar-actions .button { min-width: 112px; text-align: center; }

.v23-quote-create {
  border: 1px solid var(--ss-line);
  border-top: 0;
  background: #fff;
}
.v23-quote-create > summary {
  display: none;
  list-style: none;
}
.v23-quote-create-body { padding: 20px; border-top: 1px solid var(--ss-line); }
.v23-quote-create:not([open]) .v23-quote-create-body { display: none; }
.v23-quote-create-form { display: grid; gap: 18px; }
.v23-form-section {
  padding: 16px;
  border: 1px solid var(--ss-line);
  border-radius: 6px;
  background: var(--ss-surface-soft);
}
.v23-form-section-head { margin-bottom: 12px; }
.v23-form-section-head h3 { margin: 0 0 3px; font-size: 15px; }
.v23-form-section-head p { margin: 0; color: var(--ss-muted); font-size: 11px; }
.v23-form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px 12px; }
.v23-form-grid label { display: grid; gap: 6px; }
.v23-form-grid .wide { grid-column: 1 / -1; }
.v23-form-grid-notes { margin-top: 12px; }
.v23-service-picker {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}
.v23-service-picker label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--ss-line);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
}
.v23-service-picker input { width: auto; min-height: auto; margin: 0; accent-color: var(--ss-yellow); }
.v23-service-picker p { grid-column: 1/-1; margin: 0; color: var(--ss-muted); font-size: 12px; }
.v23-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.v23-form-actions p { margin: 0; color: var(--ss-muted); font-size: 11px; }
.v23-form-actions .button { min-width: 150px; }

.v23-quote-controls {
  display: grid;
  grid-template-columns: minmax(260px,1fr) 210px;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--ss-line);
  border-top: 0;
  background: #f8f9f8;
}
.v23-quote-controls label { display: grid; gap: 5px; }
.v23-quote-controls label > span { color: var(--ss-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }

.v23-quote-list { display: grid; gap: 10px; margin-top: 12px; }
.v23-quote-card {
  overflow: hidden;
  border: 1px solid var(--ss-line);
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.v23-quote-card[hidden] { display: none !important; }
.v23-quote-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--ss-line);
}
.v23-quote-meta {
  margin: 0 0 5px !important;
  color: #747b74;
  font-size: 10px !important;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.v23-quote-identity h3 { margin: 0 0 4px; font-size: 18px !important; }
.v23-quote-identity > p:last-child { margin: 0; color: var(--ss-muted); font-size: 12px; }
.v23-quote-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.v23-status-badge,
.v23-quote-badges .sms-status-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 850;
}
.v23-status-badge.open { background: #fff4c7; color: #6c5500; border: 1px solid #ead679; }
.v23-status-badge.converted { background: #e9f7ee; color: #1f6f42; border: 1px solid #bfe0ca; }
.v23-quote-body {
  display: grid;
  grid-template-columns: minmax(0,.8fr) minmax(0,1.2fr);
  gap: 18px;
  padding: 16px 18px;
}
.v23-quote-facts {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 8px;
}
.v23-quote-facts > div {
  min-width: 0;
  padding-right: 10px;
  border-right: 1px solid var(--ss-line);
}
.v23-quote-facts > div:last-child { border-right: 0; }
.v23-quote-facts span,
.v23-label {
  display: block;
  margin-bottom: 4px;
  color: #747b74;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.v23-quote-facts strong { display: block; overflow-wrap: anywhere; font-size: 12px; }
.v23-quote-facts p { margin: 4px 0 0; color: var(--ss-muted); font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.v23-service-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.v23-service-chips span {
  padding: 5px 8px;
  border: 1px solid #d9d2a5;
  border-radius: 999px;
  background: #fff9dc;
  color: #594700;
  font-size: 10px;
  font-weight: 800;
}
.v23-service-chips em { color: var(--ss-muted); font-size: 11px; }
.v23-quote-notes {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--ss-yellow);
  background: #fafafa;
  color: #444a44;
  font-size: 11px;
  line-height: 1.5;
}
.v23-quote-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px 15px;
  border-top: 1px solid var(--ss-line);
  background: #fafbfa;
  color: var(--ss-ink);
}
.v23-sms-detail { display: flex; align-items: center; gap: 8px; min-height: 38px; color: var(--ss-muted); }
.v23-sms-detail form { margin: 0; }
.v23-sms-detail button { min-height: 30px; padding: 5px 8px; background: #fff; border: 1px solid var(--ss-line-strong); }
.v23-quote-primary-actions { display: flex; align-items: flex-start; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.v23-quote-primary-actions form { margin: 0; }
.v23-review-quote { width: min(620px, 68vw); border: 1px solid var(--ss-line-strong); border-radius: 4px; background: #fff; }
.v23-review-quote > summary { list-style: none; cursor: pointer; padding: 10px 12px; background: #fff; color: var(--ss-ink); font-size: 12px; font-weight: 900; }
.v23-review-quote > summary::-webkit-details-marker { display: none; }
.v23-review-quote > summary::after { content: '+'; float: right; font-size: 17px; }
.v23-review-quote[open] > summary { border-bottom: 1px solid var(--ss-line); }
.v23-review-quote[open] > summary::after { content: '–'; }
.v23-accept-quote-form {
  display: grid !important;
  grid-template-columns: repeat(2,minmax(0,1fr)) !important;
  gap: 9px !important;
  padding: 12px;
}
.v23-accept-quote-form label { display: grid; gap: 5px; }
.v23-accept-quote-form .wide { grid-column: 1/-1; }
.v23-manager-review { align-self: center; color: var(--ss-muted); font-size: 11px; }
.v23-empty-state,
.v23-filter-empty {
  padding: 28px;
  border: 1px dashed var(--ss-line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--ss-muted);
  text-align: center;
  font-size: 12px;
}
.v23-empty-state h3 { margin: 0 0 5px; color: var(--ss-ink); }

/* Admin service catalog */
.portal-view-admin .service-catalog-admin-panel { min-width: 0; }
.portal-view-admin #admin-services .portal-panel-head { display: none; }
.v23-service-create {
  margin-bottom: 12px;
  border: 1px solid var(--ss-line);
  border-radius: 5px;
  background: var(--ss-surface-soft);
}
.v23-service-create > summary {
  cursor: pointer;
  list-style: none;
  padding: 11px 13px;
  font-size: 12px;
  font-weight: 900;
}
.v23-service-create > summary::-webkit-details-marker { display: none; }
.v23-service-create > summary::after { content: '+'; float: right; font-size: 17px; }
.v23-service-create[open] > summary { border-bottom: 1px solid var(--ss-line); }
.v23-service-create[open] > summary::after { content: '–'; }
.v23-service-form {
  display: grid;
  grid-template-columns: minmax(180px,.9fr) minmax(260px,1.5fr) 110px 150px 190px auto;
  gap: 8px;
  align-items: end;
  padding: 12px;
}
.v23-service-form label { display: grid; gap: 5px; }
.v23-service-form .wide { min-width: 0; }
.v23-service-form .v23-check {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 4px;
  white-space: nowrap;
}
.v23-service-form .v23-check input { width: auto; min-height: auto; accent-color: var(--ss-yellow); }
.v23-service-form button { white-space: nowrap; }
.v23-service-list { display: grid; gap: 7px; }
.v23-service-row {
  overflow: hidden;
  border: 1px solid var(--ss-line);
  border-radius: 5px;
  background: #fff;
}
.v23-service-row > summary {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 11px 12px;
  cursor: pointer;
  list-style: none;
}
.v23-service-row > summary::-webkit-details-marker { display: none; }
.v23-service-row[open] > summary { border-bottom: 1px solid var(--ss-line); background: #fafbfa; }
.v23-service-row-main { min-width: 0; display: grid; gap: 2px; }
.v23-service-row-main strong { font-size: 12px; }
.v23-service-row-main small { overflow: hidden; color: var(--ss-muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.v23-service-row-state { display: flex; align-items: center; gap: 6px; }
.v23-service-order,
.v23-service-state,
.v23-public-state { padding: 4px 7px; border-radius: 999px; font-size: 9px; font-weight: 850; }
.v23-service-order { background: #f0f2f0; color: #606760; }
.v23-service-state.on { background: #e9f7ee; color: #1f6f42; }
.v23-service-state.off { background: #f5eeee; color: #8d3b3b; }
.v23-public-state { background: #fff7d0; color: #725800; }
.v23-service-edit-form { background: var(--ss-surface-soft); }

@media (max-width: 1180px) {
  .v23-quote-body { grid-template-columns: 1fr; }
  .v23-service-picker { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .v23-service-form { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .v23-service-form button { width: fit-content; }
}

@media (max-width: 760px) {
  .v23-quote-toolbar { align-items: flex-start; padding: 14px; }
  .v23-quote-toolbar-actions { width: 100%; max-width: 250px; display: grid; grid-template-columns: 1fr 1fr; }
  .v23-quote-toolbar-actions .button { min-width: 0; }
  .v23-quote-create-body { padding: 12px; }
  .v23-form-section { padding: 12px; }
  .v23-form-grid,
  .v23-service-picker,
  .v23-quote-controls,
  .v23-quote-facts,
  .v23-accept-quote-form,
  .v23-service-form { grid-template-columns: 1fr !important; }
  .v23-form-grid .wide,
  .v23-accept-quote-form .wide { grid-column: auto; }
  .v23-form-actions { align-items: stretch; flex-direction: column; }
  .v23-form-actions .button { width: 100%; }
  .v23-quote-card-head,
  .v23-quote-actions { flex-direction: column; }
  .v23-quote-badges { justify-content: flex-start; }
  .v23-quote-body { padding: 13px; }
  .v23-quote-facts > div { padding: 0 0 9px; border-right: 0; border-bottom: 1px solid var(--ss-line); }
  .v23-quote-facts > div:last-child { border-bottom: 0; }
  .v23-quote-actions { padding: 12px 13px; }
  .v23-quote-primary-actions { width: 100%; justify-content: stretch; }
  .v23-quote-primary-actions > *,
  .v23-quote-primary-actions form,
  .v23-quote-primary-actions .button,
  .v23-review-quote { width: 100%; max-width: none; }
  .v23-manager-review { width: 100%; }
  .v23-service-form .v23-check { white-space: normal; }
  .v23-service-row > summary { grid-template-columns: 1fr; gap: 7px; }
  .v23-service-row-state { flex-wrap: wrap; }
}

@media (max-width: 520px) {
  .v23-quote-toolbar { display: grid; }
  .v23-quote-toolbar-actions { max-width: none; }
  .v23-quote-controls { padding: 10px; }
  .v23-quote-list { gap: 8px; }
  .v23-quote-card-head { padding: 13px; }
  .v23-service-picker label { min-height: 44px; }
}

/* SATISFACTORY-SMS-STATUS-POLISH v2.3.4 */
.v23-sms-detail {
  flex: 1 1 300px;
  min-width: 240px;
  align-items: stretch;
  gap: 10px;
}
.v234-sms-delivery {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--ss-line);
  border-radius: 5px;
  background: #fff;
  color: #6d746d;
}
.v234-sms-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(109,116,109,.10);
}
.v234-sms-delivery.queued { color: #6c5500; background: #fffdf1; border-color: #ead679; }
.v234-sms-delivery.sent { color: #1f6f42; background: #f3fbf6; border-color: #bfe0ca; }
.v234-sms-delivery.retry { color: #805c00; background: #fff8dc; border-color: #e6d087; }
.v234-sms-delivery.failed { color: #a12b2b; background: #fff6f6; border-color: #e4bcbc; }
.v234-sms-copy { display: grid; gap: 2px; min-width: 0; }
.v234-sms-copy strong { color: var(--ss-ink); font-size: 11px; line-height: 1.25; }
.v234-sms-copy small { color: inherit; font-size: 10px; line-height: 1.35; overflow-wrap: anywhere; }
.v234-sms-tools { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.v234-sms-tools small { color: var(--ss-muted); font-size: 9px; }
.v234-sms-tools form { margin: 0; }
.v234-sms-tools button { min-height: 30px; padding: 5px 8px; background: #fff; border: 1px solid var(--ss-line-strong); }

@media (max-width: 760px) {
  .v23-sms-detail { width: 100%; min-width: 0; flex-direction: column; }
  .v234-sms-delivery { width: 100%; }
  .v234-sms-tools { width: 100%; justify-content: space-between; }
}

