/* ─── Variables ──────────────────────────────────────────────────── */
:root {
  --bg:           #0d0f12;
  --surface:      #161a20;
  --surface-2:    #1e232b;
  --border:       #2a3040;
  --border-light: #353d50;
  --text:         #e8eaf0;
  --text-muted:   #7a8499;
  --text-dim:     #4a5568;
  --accent:       #3b82f6;
  --accent-glow:  rgba(59,130,246,.18);
  --success:      #10b981;
  --font:         'DM Sans', sans-serif;
  --mono:         'DM Mono', monospace;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 4px 24px rgba(0,0,0,.45);
  --header-h:     60px;
}

/* ─── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; }

/* ─── Header ─────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(13,15,18,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 32px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -.01em;
}
.logo-mark {
  color: var(--accent);
  font-size: 1.1rem;
  line-height: 1;
}
.logo-mark.large {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 4px;
}
.logo-text { color: #000000; }
.header-nav { flex: 1; display: flex; gap: 4px; }
.nav-link {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: #000000;
  transition: color .15s, background .15s;
}
.nav-link:hover, .nav-link.active {
  color: var(--text);
  background: var(--surface-2);
}
.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--border-light);
  object-fit: cover;
}
.user-name {
  font-size: .85rem;
  color: var(--text-muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-logout {
  font-size: .8rem;
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: color .15s, border-color .15s, background .15s;
}
.btn-logout:hover {
  color: var(--text);
  border-color: var(--border-light);
  background: var(--surface-2);
}

/* ─── Main ───────────────────────────────────────────────────────── */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

/* ─── Footer ─────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 20px;
  font-size: .78rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
}

/* ─── Dashboard ──────────────────────────────────────────────────── */
.dashboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 40px;
}
.dashboard-greeting {
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: -.02em;
  color: var(--text);
  margin-bottom: 4px;
}
.dashboard-sub {
  font-size: .9rem;
  color: var(--text-muted);
}
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .78rem;
  color: var(--success);
  background: rgba(16,185,129,.1);
  border: 1px solid rgba(16,185,129,.25);
  padding: 5px 12px;
  border-radius: 99px;
  font-family: var(--mono);
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .35; }
}

/* ─── App Cards Grid ─────────────────────────────────────────────── */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.app-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform .2s, border-color .2s, box-shadow .2s;
  overflow: hidden;
}
.app-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 0% 50%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%);
  opacity: 0;
  transition: opacity .25s;
}
.app-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: 0 8px 32px rgba(0,0,0,.4), 0 0 0 1px color-mix(in srgb, var(--accent) 15%, transparent);
}
.app-card:hover::before { opacity: 1; }

.app-card-icon {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  position: relative;
  z-index: 1;
}
.app-card-body {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}
.app-card-title {
  font-size: .975rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -.01em;
}
.app-card-desc {
  font-size: .82rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.app-card-arrow {
  flex-shrink: 0;
  color: var(--text-dim);
  font-size: 1.1rem;
  transition: color .2s, transform .2s;
  position: relative;
  z-index: 1;
}
.app-card:hover .app-card-arrow {
  color: var(--accent);
  transform: translateX(3px);
}

/* ─── Auth Screen ────────────────────────────────────────────────── */
.auth-body {
  --surface:      #ffffff;
  --surface-2:    #f7f8fa;
  --border:       #dde1ea;
  --border-light: #c4cad6;
  --text:         #1a1f28;
  --text-muted:   #5a6478;
  --text-dim:     #8a93a4;
  --shadow:       0 4px 24px rgba(0,0,0,.08);
  background:
    radial-gradient(ellipse 70% 50% at 20% 80%, rgba(59,130,246,.06) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 20%, rgba(124,58,237,.04) 0%, transparent 60%),
    #f4f6fa;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.auth-body .logo-mark { color: var(--accent); }
.auth-body .btn-google:hover {
  background: #edf0f5;
  border-color: var(--border-light);
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
}
.auth-screen { width: 100%; display: flex; justify-content: center; }
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 40px 36px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  animation: fadeUp .4s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
.auth-logo { text-align: center; }
.auth-logo-img { width: 140px; height: auto; border-radius: 6px; }
.auth-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -.03em;
  margin-top: 4px;
}
.auth-subtitle {
  font-size: .8rem;
  color: var(--text-muted);
  font-family: var(--mono);
  margin-top: 4px;
}
.auth-divider {
  width: 100%;
  text-align: center;
  font-size: .78rem;
  color: var(--text-dim);
  position: relative;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after  { right: 0; }

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 12px 20px;
  background: var(--surface-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
  color: var(--text);
  transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
}
.btn-google:hover {
  background: var(--border);
  border-color: #4a5568;
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
  transform: translateY(-1px);
}
.btn-google:active { transform: translateY(0); }
.google-icon { width: 18px; height: 18px; flex-shrink: 0; }
.auth-note {
  font-size: .75rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.5;
}

/* ─── Alerts ─────────────────────────────────────────────────────── */
.alert {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  line-height: 1.5;
}
.alert-error {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  color: #fca5a5;
}

/* ─── Stub page ──────────────────────────────────────────────────── */
.stub-page { max-width: 640px; }
.back-link {
  display: inline-block;
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  transition: color .15s;
}
.back-link:hover { color: var(--text); }
.stub-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}
.stub-title {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.stub-body { color: var(--text-muted); font-size: .9rem; }

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .apps-grid { grid-template-columns: 1fr; }
  .dashboard-header { flex-direction: column; gap: 16px; }
  .header-inner { gap: 16px; }
  .user-name { display: none; }
}

/* ─── Buttons (shared) ───────────────────────────────────────────── */
.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover  { background: #2563eb; }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { background: var(--border); cursor: not-allowed; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-light);
}
.btn-secondary:hover  { background: var(--border); border-color: #4a5568; }
.btn-secondary:active { transform: translateY(1px); }
.btn-secondary:disabled { color: var(--text-dim); cursor: not-allowed; }

/* ─── Misc Shipments page ────────────────────────────────────────── */
.ms-page { max-width: 1600px; }
.ms-page-header {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}
.ms-page-header-col { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ms-page-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
  grid-column: 3;
}
.ms-title {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -.02em;
  margin: 0;
}
.ms-sub { color: var(--text-muted); font-size: .9rem; margin: 0; }
@media (max-width: 1100px) {
  .ms-page-header { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .ms-page-header { grid-template-columns: 1fr; }
}

.ms-form { display: block; }

.ms-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 1100px) {
  .ms-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .ms-grid { grid-template-columns: 1fr; }
}

.ms-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.ms-card.ms-card--accent {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent);
}

.ms-col-3 {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.ms-col-3 .ms-bypass-row {
  margin: auto 0;
  padding: 8px 4px;
}
.ms-col-3 .ms-bypass-row small {
  display: block;
  margin-top: 2px;
  font-size: .8rem;
}

.ms-field.ms-field--accent {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  margin: -2px -4px;
  transition: background .2s;
}
.ms-field.ms-field--accent .ms-label { color: var(--accent); font-weight: 600; }
.ms-card-title {
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.ms-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}
.ms-card-header .ms-card-title { margin-bottom: 0; }
.ms-card-header .btn-secondary {
  padding: 3px 12px;
  font-size: .85rem;
  white-space: nowrap;
}
.ms-card-sub {
  font-size: .82rem;
  color: var(--text-muted);
  margin-top: -4px;
  margin-bottom: 2px;
}

.ms-field {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 26px;
}
.ms-field[hidden] { display: none; }
.ms-field.ms-field--stacked {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-height: 0;
}
.ms-field.ms-field--stacked .ms-label { text-align: left; }
.ms-label {
  font-size: .83rem;
  font-weight: 500;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: .04em;
  line-height: 1.15;
  text-align: right;
  word-break: break-word;
}
.ms-req { color: var(--accent); }

.ms-form input[type="text"],
.ms-form input[type="email"],
.ms-form select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: .95rem;
  font-family: var(--font);
  color: var(--text);
  transition: border-color .15s, background .15s;
  min-height: 24px;
}
.ms-form input[type="text"]:focus,
.ms-form input[type="email"]:focus,
.ms-form select:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  background: #1a1f28;
}

.ms-input-row {
  display: flex;
  gap: 6px;
  min-width: 0;
}
.ms-input-row input { flex: 1; min-width: 0; }
.ms-input-row .btn-secondary {
  padding: 3px 10px;
  font-size: .75rem;
  white-space: nowrap;
}

.ms-output {
  font-size: 1rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  min-height: 24px;
  display: block;
}
.ms-output-multi {
  white-space: pre-wrap;
  min-height: 24px;
  max-height: 320px;
  overflow-y: auto;
}
.ms-output-dim   { color: var(--text-muted); }

.ms-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .9rem;
  color: var(--text);
  cursor: pointer;
  padding: 2px 0;
}
.ms-checkbox input { margin-top: 0; }
.ms-checkbox small { color: var(--text-muted); }

.ms-checkbox--field {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 26px;
  padding: 0;
}
.ms-checkbox--field > span {
  order: 1;
  text-align: right;
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  line-height: 1.15;
}
.ms-checkbox--field > input {
  order: 2;
  justify-self: start;
  margin: 0;
}

.ms-products {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: start;
  column-gap: 8px;
  row-gap: 4px;
  border: none;
  padding: 0;
  margin: 0;
  background: transparent;
  min-width: 0;
}
.ms-products > legend { display: none; }
.ms-products > .ms-products-row { grid-column: 2; }
.ms-products::before {
  content: 'Products';
  grid-column: 1;
  grid-row: 1 / span 4;
  text-align: right;
  padding-top: 4px;
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  line-height: 1.15;
}
.ms-products-row {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 6px;
  align-items: start;
}
.ms-products-row [data-product-qty],
.ms-products-row [data-rq-qty],
.ms-products-row [data-sng-qty] {
  text-align: center;
  min-height: 22px;
  padding: 2px 4px;
}
.ms-products-row textarea[data-product-title],
.ms-products-row textarea[data-rq-title],
.ms-products-row textarea[data-sng-title] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: .9rem;
  font-family: var(--font);
  color: var(--text);
  transition: border-color .15s, background .15s;
  resize: none;
  line-height: 1.25;
  field-sizing: content;
  max-height: calc(2 * 1.25em + 8px);
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 22px;
}
.ms-products-row textarea[data-product-title]:focus,
.ms-products-row textarea[data-rq-title]:focus,
.ms-products-row textarea[data-sng-title]:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  background: #1a1f28;
}
.ms-products-head { display: none; }

.ms-warnings {
  list-style: none;
  padding: 6px 10px;
  background: rgba(217, 119, 6, .12);
  border: 1px solid rgba(217, 119, 6, .35);
  border-left: 3px solid rgba(217, 119, 6, .8);
  border-radius: var(--radius-sm);
  color: #fbbf24;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.3;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ms-warnings li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.ms-warnings:empty { display: none; }
.ms-warnings li:not(:empty)::before {
  content: '⚠️';
  font-size: 1rem;
  flex-shrink: 0;
  line-height: 1.3;
}
.ms-warn-text {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 1rem;
  font-weight: 500;
  color: #fbbf24;
  padding: 3px 8px;
  background: rgba(217, 119, 6, .12);
  border-left: 3px solid rgba(217, 119, 6, .8);
  border-radius: var(--radius-sm);
}
.ms-field > .ms-warn-text { grid-column: 1 / -1; }
.ms-warn-text[hidden] { display: none; }
.ms-warn-text:empty { display: none; }
.ms-warn-text:not(:empty)::before {
  content: '⚠️';
  font-size: .85rem;
}

.ms-validation { display: flex; flex-direction: column; gap: 6px; margin-top: 2px; }
.ms-validation-result {
  font-size: .9rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ms-validation-result small { font-size: inherit; color: #ef4444; }
.ms-validation-ok {
  background: rgba(16, 185, 129, .08);
  border-color: rgba(16, 185, 129, .25);
  color: #6ee7b7;
}
.ms-validation-error {
  background: rgba(239, 68, 68, .08);
  border-color: rgba(239, 68, 68, .25);
  color: #fca5a5;
}

.ms-status {
  font-size: .78rem;
  color: var(--danger, #c0392b);
}

.ms-result {
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--success) 35%, var(--border));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}
.ms-result[hidden] { display: none; }
.ms-result-label {
  font-size: .9rem;
  font-weight: 500;
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
  flex-shrink: 0;
}
.ms-result-file {
  font-size: 1rem;
  color: var(--accent);
  text-decoration: underline;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.ms-result-file > span { display: inline; }

.ms-error {
  margin-top: 20px;
  padding: 12px 16px;
  background: rgba(239, 68, 68, .1);
  border: 1px solid rgba(239, 68, 68, .3);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: 1rem;
}

/* ─── Dashboard — light theme ────────────────────────────────────── */
body:has(.dashboard) {
  background: #f0f4f8;
  color: #1a1f28;
}
body:has(.dashboard) .site-header {
  background: rgba(240,244,248,.9);
  border-bottom-color: #dde3ec;
}
body:has(.dashboard) .site-footer {
  border-top-color: #dde3ec;
  color: #8a93a4;
}
body:has(.dashboard) .user-name,
body:has(.dashboard) .btn-logout { color: #475569; }
body:has(.dashboard) .btn-logout:hover { color: #1a1f28; }
body:has(.dashboard) .nav-link {
  color: #374151;
  background: rgba(255,255,255,.75);
  border: 1px solid #dde3ec;
}
body:has(.dashboard) .nav-link:hover,
body:has(.dashboard) .nav-link.active {
  color: #1a1f28;
  background: #ffffff;
  border-color: #c8d0de;
}

.dashboard {
  --surface:      #ffffff;
  --surface-2:    #f7f9fc;
  --border:       #dde3ec;
  --border-light: #c8d0de;
  --text:         #1a1f28;
  --text-muted:   #5a6478;
  --text-dim:     #8a93a4;
  --shadow:       0 4px 24px rgba(0,0,0,.07);
}
.dashboard .app-card { box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.dashboard .app-card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,.10), 0 0 0 1px color-mix(in srgb, var(--accent) 20%, transparent);
}

/* ─── Misc Shipments — light theme override ──────────────────────── */
/* Only when this page is rendered: lighten the page background and swap
   the surface/border/text variables that the sub-app uses. The dashboard
   and other sub-apps keep the dark theme. */

body:has(.ms-page),
body:has(.sik-page) {
  background: #f4f6fa;
  color: #1a1f28;
}
body:has(.ms-page) .site-header,
body:has(.ms-page) .site-footer,
body:has(.sik-page) .site-header,
body:has(.sik-page) .site-footer { display: none; }
body:has(.ms-page) .main-content {
  max-width: 1600px;
  padding: 16px 20px 24px;
}

.ms-page,
.sik-page {
  --surface:      #ffffff;
  --surface-2:    #f7f8fa;
  --border:       #dde1ea;
  --border-light: #c4cad6;
  --text:         #1a1f28;
  --text-muted:   #5a6478;
  --text-dim:     #8a93a4;
}

.ms-page .ms-card {
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 12px rgba(15, 23, 42, .04);
}

.ms-page .ms-form input[type="text"]:focus,
.ms-page .ms-form input[type="email"]:focus,
.ms-page .ms-form select:focus,
.ms-page .ms-form textarea:focus {
  background: #ffffff;
}

.ms-page .ms-warnings {
  background: #fff8eb;
  border-color: #f3d28a;
  border-left-color: #d97706;
  color: #8a5a06;
}
.ms-page .ms-warn-text {
  background: #fff8eb;
  border-left-color: #d97706;
  color: #8a5a06;
}

.ms-page .ms-validation-ok {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.ms-page .ms-validation-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.ms-page .ms-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.ms-page .ms-result {
  border-color: #a7f3d0;
  background: #ecfdf5;
}
.ms-page .ms-result-label {
  color: #047857;
}

/* ─── Retakes & Questions page ────────────────────────────────────── */

body:has(.rq-page) .site-header,
body:has(.rq-page) .site-footer { display: none; }

/* 3-column grid for the retake form */
.rq-grid {
  grid-template-columns: 1fr 1fr 1fr;
}
.rq-grid > section {
  grid-row: 2;
}

/* Col 3 card: same card style but may scroll */
.rq-col3 {
  min-width: 0;
}

/* Page header: same as ms but result panel has multiple items */
.rq-page-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 12px 20px;
  margin-bottom: 18px;
}

.rq-results {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 2;
  grid-row: 1;
  align-self: stretch;
}
.rq-results[hidden] { display: none; }

.rq-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: .84rem;
}
.rq-result-item[hidden] { display: none; }

.rq-result-msg {
  display: flex;
  align-items: center;
  background: #d1fae5;
  color: #065f46;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: .84rem;
  grid-column: 1;
  grid-row: 1;
  align-self: stretch;
}
.rq-result-msg[hidden] { display: none; }

/* Action buttons column */
.rq-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  grid-column: 2;
}

.rq-action-buttons {
  display: flex;
  flex-direction: row;
  gap: 6px;
  align-items: center;
}
.rq-action-buttons button {
  min-width: 110px;
}

/* Flags row */
.rq-flags {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

/* Tray fieldsets */
.rq-tray-set,
.rq-instr-set,
.rq-q-set {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px 6px;
  margin-bottom: 12px;
}

.rq-tray-legend,
.rq-q-set legend {
  font-size: .85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  padding: 0 4px;
}

.rq-tray-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 15px;
  margin: 8px 0 6px;
}

.rq-tray-item,
.rq-instr-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .9rem;
  cursor: pointer;
  user-select: none;
}
.rq-tray-item input,
.rq-instr-item input { cursor: pointer; }

.rq-instr-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 10px;
  margin: 8px 0 6px;
}

.rq-other-field {
  margin-top: 4px;
  margin-left: 0;
  padding-left: 0;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.rq-other-field .ms-label {
  font-size: .78rem;
  color: var(--text-muted);
  min-width: unset;
  white-space: nowrap;
}

/* Question sub-options */
.rq-q-set .ms-checkbox {
  margin-top: 2px;
}
.rq-q-indent {
  margin-left: 20px;
  opacity: .9;
}
.rq-q-indent[hidden] { display: none; }
.rq-q-separator {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

/* Light-theme overrides (same as ms-page) */
body:has(.rq-page) {
  --bg:           #f3f4f6;
  --surface:      #ffffff;
  --surface-2:    #f9fafb;
  --border:       #e2e6ed;
  --border-light: #d1d5db;
  --text:         #111827;
  --text-muted:   #6b7280;
  --text-dim:     #9ca3af;
  --shadow:       0 2px 12px rgba(0,0,0,.08);
}

.rq-page .ms-result-label { color: #047857; }

/* ── Preview modal ────────────────────────────────────────────────────────── */
.rq-preview-modal[open] {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 24px;
  width: min(680px, 95vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.rq-preview-modal::backdrop {
  background: rgba(0, 0, 0, 0.5);
}
.rq-preview-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--text);
}
.rq-preview-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.rq-preview-section { display: flex; flex-direction: column; gap: 4px; }
.rq-preview-section--email { flex: 1; min-height: 0; }
.rq-preview-textarea,
.rq-preview-subject {
  font-family: var(--font);
  font-size: .85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 6px 10px;
  width: 100%;
  box-sizing: border-box;
}
.rq-preview-textarea { resize: vertical; }
.rq-preview-email {
  font-family: var(--font);
  font-size: .82rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 12px;
  min-height: 260px;
  max-height: 360px;
  overflow-y: auto;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.rq-preview-email:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.rq-preview-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ─── Lab Slips page ─────────────────────────────────────────────── */

body:has(.ls-page) .site-header,
body:has(.ls-page) .site-footer { display: none; }

body:has(.ls-page) {
  background: #f0f2f5;
  color: #1a1a1a;
}

.ls-page .back-link { color: #555; margin-bottom: 14px; }
.ls-page .back-link:hover { color: #1a1a1a; }
.ls-page .ms-title { color: #1a1a1a; }
.ls-page .ms-sub   { color: #555; }
.ls-page .ms-page-header { margin-bottom: 18px; }
.ls-page .ms-status--working { color: #c0392b; }

.ls-layout {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ls-info-card {
  flex-direction: row;
  align-items: right;
  flex-wrap: wrap;
  gap: 15px;
  background: #fff;
  border: 1px solid #d0d5dd;
  border-radius: var(--radius-sm);
  padding: 4px 1px 5px ;
}

.ls-info-card .ms-card-title { display: none; }
.ls-info-card .ms-field { margin-bottom: 0; }

.ls-bottom-row {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.ls-page .ms-card-title { color: #1a1a1a; font-size: 1rem; font-weight: 600; margin-bottom: 12px; }
.ls-page .ms-label      { color: #444; font-size: 1rem; }
.ls-page .ms-field      { margin-bottom: 10px; }
.ls-page select,
.ls-page input[type="text"],
.ls-page input[type="email"],
.ls-page input[type="number"],
.ls-page input[type="date"] {
  background: #fff;
  border: 1px solid #ccc;
  color: #1a1a1a;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 1rem;
}
.ls-page select:focus,
.ls-page input:focus {
  outline: none;
  border-color: #3b82f6;
}

/* Orders section */
.ls-orders-section {
  flex: 1;
  min-width: 0;
}

.ls-orders-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.ls-orders-count {
  font-size: 1.38rem;
  font-weight: 600;
  color: #1a1a1a;
  background: #e8f0fe;
  border: 1px solid #c7d7fc;
  border-radius: 6px;
  padding: 4px 12px;
}

.ls-orders-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Individual order row */
.ls-order-row {
  background: #fff;
  border: 1px solid #d0d5dd;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.ls-order-row--current {
  background: #fffbeb;
  border-color: #f59e0b;
}

.ls-order-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ls-order-top .ms-input-row { flex: 1; }

.ls-remove-btn {
  background: none;
  border: none;
  color: #999;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  flex-shrink: 0;
}
.ls-remove-btn:hover { color: #c0392b; }

.ls-order-details {
  margin-top: 10px;
  border-top: 1px solid #e5e7eb;
  padding-top: 10px;
}

.ls-order-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.ls-initials-badge {
  font-size: 1.13rem;
  font-weight: 400;
  color: #1a1a1a;
}

.ls-meta-sep {
  font-size: 1.13rem;
  color: #9ca3af;
}

.ls-customer-name {
  font-size: 1.13rem;
  font-weight: 600;
  color: #1a1a1a;
}

.ls-ngs-group {
  display: flex;
  flex-direction: row;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.ls-ng-slot {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ls-ng-slot select { width: auto; }

.ls-special-notes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.ls-page .ms-checkbox { display: flex; align-items: center; gap: 5px; font-size: 1.03rem; color: #444; cursor: pointer; }
.ls-page .ms-checkbox input { cursor: pointer; }
.ls-page .ms-checkbox span { user-select: none; }

.ls-other-note {
  flex: 1;
  min-width: 140px;
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1.03rem;
  background: #fff;
  color: #1a1a1a;
}

/* Notes panel */
.ls-notes-panel {
  flex: 0.6;
  min-width: 0;
  background: #fff;
  border: 1px solid #d0d5dd;
  border-radius: var(--radius-sm);
  padding: 16px;
}

.ls-notes-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ls-notes-placeholder {
  font-size: 0.98rem;
  color: #9ca3af;
  font-style: italic;
  margin: 0;
}

.ls-note-entry {
  border-left: 3px solid #d1d5db;
  padding: 6px 8px;
  background: #f8fafc;
  border-radius: 0 4px 4px 0;
}

.ls-note-entry.has-notes {
  border-left-color: #f59e0b;
  background: #fffbeb;
}

.ls-note-header {
  font-size: 1.19rem;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 6px;
}

.ls-note-text {
  font-size: 1.13rem;
  color: #374151;
  white-space: pre-wrap;
  word-break: break-word;
}

.ls-note-empty {
  font-size: 1.1rem;
  color: #9ca3af;
  font-style: italic;
}

.ls-note-entry.is-warning {
  border-color: #ef4444;
}
.ls-note-warning {
  font-size: 2rem;
  color: #ef4444;
  font-weight: 600;
  margin-bottom: 6px;
}

/* Result panel */
.ls-result[hidden] { display: none; }
.ls-result {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: var(--radius-sm);
}
.ls-result .ms-result-label { font-size: 1rem; font-weight: 600; color: #047857; }
.ls-result .ms-result-file  { font-size: 1.06rem; color: #1d4ed8; text-decoration: none; }
.ls-result .ms-result-file:hover { text-decoration: underline; }

/* Error and status */
.ls-page .ms-error {
  background: #fff1f2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 1.1rem;
}

/* ─── Ship Impression Kits — light theme ─────────────────────────── */
body:has(.sik-page) .main-content {
  max-width: none;
  padding: 16px 20px 24px;
}

.sik-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.sik-top-bar .back-link { margin-bottom: 0; }
.sik-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sik-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 16px;
  flex-wrap: wrap;
}
.sik-title {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--text);
  margin: 0;
}
.sik-sub {
  font-size: .9rem;
  color: var(--text-muted);
  margin: 0;
}
.sik-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sik-print-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.man-queued-info {
  display: block;
  font-size: .875rem;
  color: #065f46;
  margin-bottom: 6px;
}
.sik-count {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.sik-status {
  font-size: 1rem;
  color: #991b1b;
}
.sik-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: .98rem;
}

.sik-qs-result[hidden] { display: none; }
.sik-qs-result {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  background: #f0fdf4;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}
.sik-qs-result-main {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: .95rem;
  font-weight: 500;
  color: #065f46;
}
.sik-qs-pdf-link {
  font-size: .875rem;
  font-weight: 500;
  color: #1d4ed8;
  text-decoration: underline;
}
.sik-qs-pdf-link:hover { color: #1e40af; }
.sik-qs-errors[hidden] { display: none; }
.sik-qs-errors {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 6px;
  border-top: 1px solid #a7f3d0;
}
.sik-qs-errors li {
  font-size: .85rem;
  color: #991b1b;
}

.sik-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 4px 12px rgba(15,23,42,.04);
}
.sik-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
  /* table-layout: fixed; */
}
.sik-table thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 500;
  font-size: .84rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.sik-table thead th.sik-col-highlight {
  background: #fef9c3;
  color: #854d0e;
}
.sik-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.sik-table tbody tr:last-child { border-bottom: none; }
.sik-table td {
  padding: 9px 12px;
  vertical-align: top;
  color: var(--text);
}
.sik-table td.sik-cell-highlight {
  background: #fef9c3;
}
.sik-warn-row td { color: #991b1b; }
.sik-table tbody tr:has(.sik-row-check:checked) { background: #e2e5ea !important; }
.sik-table tbody tr:has(.sik-row-check:checked) td { color: var(--text) !important; }
.sik-table tbody tr:has(.sik-row-check:checked) td.sik-cell-highlight { background: inherit !important; }
.sik-table td.sik-country-warn { color: #991b1b; font-weight: 600; }
.sik-table td.sik-country-canada { color: #991b1b; }
.sik-table td.sik-priority { color: #991b1b; }
.sik-table td.sik-addr-invalid   { color: #991b1b; font-weight: 500; background-color: #fee2e2; }
.sik-table td.sik-addr-shipped   { color: #166534; font-weight: 500; background-color: #dcfce7; }
.sik-table td.sik-addr-rl-failed { color: #92400e; font-weight: 500; background-color: #fee2e2; }
.sik-table td.sik-addr-pulled    { color: #166534; font-weight: 500; background-color: #dcfce7; }
.sik-row--ok { background: #f0fdf4; }
.sik-row--ok td.sik-cell-highlight { background: inherit; }
.sik-row--pull { background: #fff7ed; }
.sik-row--pull td.sik-cell-highlight { background: inherit; }

.sik-loading-row td,
.sik-empty-row td {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
}

/* column widths */
.sik-col-check  { width: 36px; text-align: center; }
.sik-col-date   { width: 120px; white-space: nowrap; }
.sik-col-order  { width: 80px; white-space: nowrap; }
.sik-col-name   { width: 102px; }
.sik-col-items  { width: 50px; text-align: center; }
.sik-col-notes  { min-width: 200px; white-space: pre-wrap; }
.sik-col-msg    { width: 110px; white-space: pre-wrap; }
.sik-col-country { width: 120px; }
.sik-col-method { width: 110px; }
.sik-col-email  { width: 136px; }

/* Date picker dialog */
.sik-date-dialog { border: 1px solid var(--border); border-radius: 10px; padding: 24px; min-width: 280px; box-shadow: 0 8px 32px rgba(0,0,0,.18); position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); margin: 0; }
.sik-date-dialog::backdrop { background: rgba(0,0,0,.35); }
.sik-date-dialog-form { display: flex; flex-direction: column; gap: 20px; }
.sik-date-dialog-label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: .95rem; }
.sik-date-dialog-label input[type="date"] { font-size: 1rem; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; width: 100%; }
.sik-date-dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }

.ls-page .ms-status { font-size: 1.06rem; color: var(--danger, #c0392b); }

/* ── Night Guard Scans page ─────────────────────────────────────────────── */
body:has(.sng-scans-page) .site-header,
body:has(.sng-scans-page) .site-footer { display: none; }

body:has(.sng-scans-page) {
  background: #f0f2f5;
  color: #1a1a1a;
}

.sng-scans-page .back-link  { color: #555; margin-bottom: 14px; }
.sng-scans-page .back-link:hover { color: #1a1a1a; }
.sng-scans-page .ms-title   { color: #1a1a1a; }
.sng-scans-page .ms-sub     { color: #555; }
.sng-scans-page .ms-page-header { margin-bottom: 18px; }

.sng-scans-col-header {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 8px;
  padding: 0 14px 4px;
  margin-bottom: 4px;
}

.sng-scans-col-h-entry,
.sng-scans-col-h-done {
  font-size: 0.78rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sng-scans-col-h-done { text-align: center; }

.sng-scans-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sng-scans-row {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 8px;
  align-items: center;
  padding: 7px 14px;
  background: #fff;
  border: 1px solid #d0d5dd;
  border-radius: var(--radius-sm);
  transition: opacity 0.2s;
}

.sng-scans-row--done {
  opacity: 0.4;
  background: #f8fafc;
}

.sng-scans-row--active {
  border-color: #3b82f6;
  background: #f8fbff;
}

.sng-scans-entry-col {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sng-scans-text {
  flex: 1;
  font-family: var(--mono);
  font-size: 1rem;
  color: #1a1a1a;
  padding: 5px 9px;
  word-break: break-all;
}

.sng-scans-row--done .sng-scans-text {
  text-decoration: line-through;
  color: #9ca3af;
}

.sng-scans-input {
  flex: 1;
  border: 1px solid #ccc;
  border-radius: 6px;
  color: #1a1a1a;
  font-size: 1rem;
  padding: 5px 9px;
  background: #fff;
  font-family: var(--mono);
}

.sng-scans-input:focus {
  outline: none;
  border-color: #3b82f6;
}

.sng-scans-row--done .sng-scans-input {
  text-decoration: line-through;
  color: #9ca3af;
}

.sng-scans-remove-btn {
  color: #ccc;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0 4px;
  flex-shrink: 0;
  transition: color 0.15s;
}

.sng-scans-remove-btn:hover { color: #c0392b; }

.sng-scans-done-col {
  display: flex;
  justify-content: center;
}

.sng-scans-done-btn {
  font-size: 0.85rem;
  padding: 5px 14px;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  color: #555;
  background: #f8fafc;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.sng-scans-done-btn:hover {
  border-color: #047857;
  color: #047857;
  background: #f0fdf4;
}

.sng-scans-row--done .sng-scans-done-btn {
  border-color: #047857;
  color: #047857;
  background: #f0fdf4;
}

/* ── Manual Shipment ────────────────────────────────────────────────────── */
/* Tabs */
.man-tab-nav { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.man-tab { background: none; border: none; border-bottom: 3px solid transparent; margin-bottom: -2px; padding: 8px 18px; font-size: .9rem; font-weight: 500; color: var(--text-muted); cursor: pointer; border-radius: 4px 4px 0 0; transition: color .15s, border-color .15s; }
.man-tab:hover { color: var(--text); background: var(--bg-alt); }
.man-tab.active { color: var(--accent); border-bottom-color: var(--accent); background: none; }
.man-panel { display: none; }
.man-panel.active { display: block; }

/* Products display (read-only rows) */
.man-product-row { display: grid; grid-template-columns: 36px 1fr; gap: 6px; font-size: .875rem; padding: 2px 0; }
.man-product-qty { text-align: center; font-weight: 600; }

/* Split order */
.man-split { border: none; padding: 0; margin: 12px 0 0; }
.man-split > legend { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 8px; }
.man-split-header { display: grid; grid-template-columns: 28px 0.75fr 50px 1fr 22px; gap: 5px; font-size: .72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; border-bottom: 1px solid var(--border); padding-bottom: 4px; margin-bottom: 6px; }
.man-split-row { display: grid; grid-template-columns: 28px 0.75fr 50px 1fr 22px; gap: 5px; align-items: center; margin-bottom: 3px; }
.man-split-sub { display: grid; grid-template-columns: 28px 0.75fr 50px 1fr 22px; gap: 5px; align-items: center; margin-bottom: 4px; }
.man-split-sub[hidden] { display: none; }
.man-split-add { width: 22px; height: 22px; padding: 0; background: none; border: 1px solid var(--border-light); border-radius: 4px; color: var(--text-muted); font-size: 1rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.man-split-add:hover { background: var(--bg-alt); color: var(--text); }
.man-split-po { display: flex; align-items: center; gap: 6px; padding-left: 33px; margin-bottom: 10px; }
.man-split-po-info { flex: 2; }
.man-split-po-date { flex: 1; }
.man-split-po-label { font-size: .72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; white-space: nowrap; }
.man-split-toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.man-split-row input[type="text"],
.man-split-sub input[type="text"] { width: 100%; box-sizing: border-box; }
.man-split-product { width: 100%; box-sizing: border-box; }
.man-split-idx { font-size: .8rem; color: var(--text-muted); text-align: right; }

/* Actions */
.man-actions { margin-top: 20px; display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.man-status { font-size: .9rem; color: var(--error, #e11d48); }

body:has(.man-page) .main-content { max-width: 2000px; }
.man-page { max-width: 2000px; }
.man-page .ms-grid { grid-template-columns: 0.75fr 0.75fr 1fr; }

/* ── App dialog (replaces native alert/confirm) ───────────────────────────── */
#app-dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 28px 22px;
  max-width: 420px;
  width: 90%;
  box-shadow: var(--shadow);
  margin: auto;
}
#app-dialog::backdrop { background: rgba(0,0,0,.55); }
#app-dialog-msg { white-space: pre-wrap; line-height: 1.6; margin-bottom: 22px; }
.app-dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Adj-Ref Slips ───────────────────────────────────────────────────────── */
.ars-page { max-width: 1400px; }

.ars-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}
@media (max-width: 900px) {
  .ars-layout { grid-template-columns: 1fr; }
}

/* Tab nav */
.ars-tab-nav {
  display: flex;
  gap: 2px;
  margin-bottom: 8px;
}
.ars-tab {
  padding: 7px 28px;
  font-size: .9rem;
  font-weight: 500;
  font-family: var(--font);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.ars-tab:hover { background: var(--border); color: var(--text); }
.ars-tab--active {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  position: relative;
}
.ars-tab--active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0; right: 0;
  height: 1px;
  background: var(--surface);
}

/* Form column wrapper */
.ars-form-col { display: flex; flex-direction: column; min-width: 0; }

/* Form */
.ars-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* Rows */
.ars-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 3px 14px;
  border-bottom: 1px solid var(--border);
}
.ars-row:last-child { border-bottom: none; }

.ars-row--accent {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-bottom-color: color-mix(in srgb, var(--accent) 25%, var(--border));
}
.ars-row--accent .ars-label { color: var(--accent); font-weight: 600; }

.ars-row--multi {
  grid-template-columns: 160px auto;
  gap: 6px;
  flex-wrap: wrap;
}
.ars-row--multi { display: flex; align-items: center; }
.ars-row--multi > .ars-label:first-child { width: 160px; flex-shrink: 0; }
.ars-row--multi > .ars-label { flex-shrink: 0; }
.ars-row--multi > .ars-label:not(:first-child) { margin-left: 20px; }

.ars-row--tall { align-items: flex-start; padding-top: 6px; padding-bottom: 6px; }

.ars-row--section-header {
  background: var(--surface-2);
  padding-top: 6px;
  padding-bottom: 6px;
}

/* Labels */
.ars-label {
  font-size: .9rem;
  font-weight: 500;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: .04em;
  text-align: right;
  line-height: 1.2;
  padding-right: 4px;
  flex-shrink: 0;
}
.ars-label--section {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
}

.ars-sublabel {
  font-size: .85rem;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}

.ars-hint {
  font-size: .85rem;
  color: var(--text);
  font-style: italic;
  white-space: nowrap;
}

/* Inputs inside the form */
.ars-form input[type="text"],
.ars-form input[type="email"],
.ars-form select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 1rem;
  font-family: var(--font);
  color: var(--text);
  transition: border-color .15s, background .15s;
  min-height: 24px;
}
.ars-form input[type="text"]:focus,
.ars-form input[type="email"]:focus,
.ars-form select:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  background: #ffffff;
  color: #1a1f28;
}
.ars-form .ars-row:not(.ars-row--multi) input[type="text"],
.ars-form .ars-row:not(.ars-row--multi) input[type="email"],
.ars-form .ars-row:not(.ars-row--multi) select { width: 100%; }

.ars-textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 1rem;
  font-family: var(--font);
  color: var(--text);
  width: 100%;
  resize: vertical;
  transition: border-color .15s, background .15s;
}
.ars-textarea:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  background: #ffffff;
  color: #1a1f28;
}

.ars-input-sm { width: 80px !important; flex-shrink: 0; }
.ars-input-md { width: 110px !important; flex-shrink: 0; }
.ars-input-xs { width: 52px !important; flex-shrink: 0; }
.ars-select   { width: 180px !important; }

.ars-input-row { display: flex; gap: 6px; align-items: center; min-width: 0; }
.ars-input-row input { flex: 1; min-width: 0; }
.ars-input-row .btn-secondary { padding: 3px 10px; font-size: .75rem; white-space: nowrap; }

.ars-inline-check { display: flex; align-items: center; cursor: pointer; }
.ars-inline-check input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent); }

.ars-row-inline { display: flex; align-items: center; gap: 8px; }
.ars-stripe-link { flex: 1; word-break: break-all; font-size: 12px; }

/* Pending page */
.ars-pending-empty { color: var(--text-muted); padding: 32px 0; text-align: center; }
.ars-pending-table { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: .875rem; }
.ars-pending-table th { text-align: left; padding: 8px 12px; color: var(--text-muted); font-weight: 500; border-bottom: 1px solid var(--border); }
.ars-pending-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ars-pending-table tr:last-child td { border-bottom: none; }
.ars-pending-actions { display: flex; gap: 6px; }
.ars-type-badge { font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.ars-type-badge--adj { background: rgba(59,130,246,.15); color: #60a5fa; }
.ars-type-badge--ref { background: rgba(239,68,68,.15);  color: #f87171; }

/* Separators */
.ars-sep { border: none; border-bottom: 3px solid var(--border); margin: 0; }
.ars-sep--dark  { border-bottom-color: #1a1f28; border-bottom-width: 4px; }
.ars-sep--light { border-bottom-color: var(--border-light); }

/* Sidebar */
.ars-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: calc(var(--header-h) + 12px);
}
.ars-sidebar-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}
.ars-sidebar-body { display: flex; flex-direction: column; gap: 6px; }
.ars-sidebar .ms-field { grid-template-columns: 90px 1fr; }
.ars-sidebar .ms-label { font-size: .75rem; }
.ars-sidebar .ms-output-multi { max-height: 500px; }
.ars-priority-hint { border-color: #ef4444 !important; color: #ef4444 !important; font-weight: 600; }
#ars-panel-ref .ars-label { color: #ef4444; }
#ars-panel-ref .ars-row--accent .ars-label { color: #ef4444; }

