:root{--color-primary:#0b5aa8;--color-navy:#0f172a;--color-canvas:#f3f6fa;--color-surface:#fff;--color-text:#1e293b;--color-muted:#64748b;--color-border:#d9e2ec;--color-success:#16a34a;--color-warning:#f59e0b;--color-danger:#dc2626;--color-info:#2563eb;--priority-high:#fee2e2;--priority-normal:#dbeafe;--priority-low:#f1f5f9;--status-open:#dbeafe;--status-waiting:#fef3c7;--status-closed:#dcfce7;--space-1:4px;--space-2:8px;--space-3:12px;--space-4:16px;--space-5:24px;--radius-sm:4px;--radius-md:6px;--shadow-card:0 16px 40px rgb(15 23 42/8%);--table-row-height:42px;--breakpoint-mobile:760px}:root {
  color-scheme: light;
  font-family: Inter, Arial, sans-serif;
  color: #1e293b;
  background: #f3f6fa;
  --blue: #0b5aa8;
  --navy: #0f172a;
  --text: #1e293b;
  --muted: #64748b;
  --canvas: #f3f6fa;
  --surface: #fff;
  --border: #d9e2ec;
  --light: #f8fafc;
  --success: #166534;
  --warning: #92400e;
  --danger: #991b1b;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; min-height: 100vh; overflow-x: hidden; background: var(--canvas); }
a { color: var(--blue); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #38bdf8; outline-offset: 2px; }
[hidden] { display: none !important; }
.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 10px 14px; transform: translateY(-150%); background: #fff; color: var(--navy); }
.skip-link:focus { transform: none; }

.login-page { display: grid; place-items: center; padding: 24px; }
.login-shell { width: min(100%, 520px); }
.login-panel { padding: 40px; border: 1px solid var(--border); border-top: 5px solid var(--blue); border-radius: 6px; background: #fff; box-shadow: 0 16px 40px rgb(15 23 42 / 8%); }
.login-panel h1, .page-head h1, .record-head h1 { margin: 0; color: var(--navy); font-size: 28px; line-height: 1.2; letter-spacing: 0; }
.eyebrow { margin: 0 0 8px; color: var(--blue); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.status { font-weight: 700; }
.message, .footnote, .page-head p, .section-heading p, .record-head p, .muted { color: var(--muted); line-height: 1.55; }
.google-signin-wrapper { width: 100%; max-width: 320px; min-height: 44px; margin: 20px 0 12px; display: flex; align-items: center; }
#google-signin-button { width: 300px; max-width: 100%; min-height: 44px; }
.identity-result { margin: 20px 0; padding: 16px; border: 1px solid #bbf7d0; background: #f0fdf4; }
.identity-result h2 { margin: 0 0 12px; color: var(--success); font-size: 18px; }
.text-button { padding: 0; border: 0; background: transparent; color: var(--blue); text-decoration: underline; cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; z-index: 30; top: 0; height: 100vh; padding: 20px 14px; background: var(--navy); color: #fff; display: flex; flex-direction: column; }
.brand { display: flex; gap: 11px; align-items: center; padding: 0 8px 20px; color: #fff; text-decoration: none; font-weight: 700; }
.brand small { display: block; margin-top: 3px; color: #94a3b8; font-size: 10px; font-weight: 400; }
.brand-mark { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; background: var(--blue); font-size: 18px; }
.sidebar nav { display: grid; gap: 3px; overflow-y: auto; }
.nav-link { min-height: 40px; padding: 9px 12px; color: #cbd5e1; text-decoration: none; font-size: 13px; border-left: 3px solid transparent; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.nav-link:hover, .nav-link:focus, .nav-link.is-active { background: #172554; color: #fff; border-left-color: #38bdf8; }
.nav-link.is-disabled { color: #64748b; cursor: not-allowed; }
.nav-link.is-disabled small { font-size: 9px; white-space: nowrap; }
.user-card { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid #334155; display: grid; gap: 5px; }
.user-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.role-badge { color: #7dd3fc; font-size: 10px; font-weight: 700; }
.user-card small { color: #94a3b8; overflow-wrap: anywhere; }
.user-card button { margin-top: 8px; padding: 8px 0; border: 0; background: transparent; color: #e2e8f0; text-align: left; text-decoration: underline; cursor: pointer; }
.app-stage { min-width: 0; }
.topbar { position: sticky; z-index: 20; top: 0; min-height: 64px; padding: 10px clamp(18px, 3vw, 42px); border-bottom: 1px solid var(--border); background: rgb(255 255 255 / 96%); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar-title { display: grid; gap: 2px; }
.topbar-title strong { color: var(--navy); font-size: 14px; }
.topbar-title span { color: var(--muted); font-size: 11px; }
.topbar-badges, .page-actions, .record-meta, .link-actions, .disabled-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.environment-badge, .readonly-badge, .write-badge, .mode-chip { min-height: 26px; padding: 5px 9px; border: 1px solid #bfdbfe; background: #eff6ff; color: #1d4ed8; font-size: 10px; font-weight: 800; letter-spacing: .04em; display: inline-flex; align-items: center; }
.readonly-badge { border-color: #cbd5e1; background: #f8fafc; color: #475569; }
.write-badge { border-color: #86efac; background: #f0fdf4; color: #166534; }
.drawer-toggle { display: none; min-height: 40px; padding: 8px 10px; border: 1px solid var(--border); background: #fff; color: var(--navy); cursor: pointer; }
.drawer-backdrop { position: fixed; z-index: 25; inset: 0; border: 0; background: rgb(15 23 42 / 52%); }
.main-content { min-width: 0; max-width: 1700px; margin: 0 auto; padding: 28px clamp(18px, 3vw, 42px) 48px; }

.page-head, .record-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; margin-bottom: 22px; }
.page-head p { margin: 7px 0 0; }
.record-meta { margin-top: 12px; }
.breadcrumb { margin: 0 0 18px; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.readonly-notice, .exclusion-banner { margin-bottom: 18px; padding: 12px 14px; border: 1px solid #bfdbfe; border-left: 4px solid #2563eb; background: #eff6ff; color: #1e3a8a; font-size: 12px; }
.exclusion-banner { border-color: #fed7aa; border-left-color: #f59e0b; background: #fff7ed; color: #7c2d12; display: grid; gap: 4px; }
.secondary-action, .primary-action, .reset-link { min-height: 38px; padding: 9px 12px; border: 1px solid #bfdbfe; border-radius: 4px; background: #fff; color: var(--blue); text-decoration: none; font-weight: 700; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.primary-action { border-color: var(--blue); background: var(--blue); color: #fff; }
.reset-link { border-color: transparent; background: transparent; }
.inline-action { margin-top: 16px; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { min-height: 118px; padding: 16px; border: 1px solid var(--border); border-top: 3px solid var(--blue); border-radius: 6px; background: #fff; }
.kpi.kpi-alert { border-top-color: #f59e0b; }
.kpi span, .kpi small { display: block; color: var(--muted); font-size: 11px; }
.kpi strong { display: block; margin: 10px 0 6px; color: var(--navy); font-size: 28px; }
.indicator-grid { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 10px; margin-bottom: 22px; }
.indicator-grid article { padding: 12px 14px; border: 1px solid var(--border); border-radius: 6px; background: #fff; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.indicator-grid span { color: var(--muted); font-size: 11px; }
.indicator-grid strong { color: var(--navy); font-size: 16px; }

.section-card, .disabled-panel, .empty-state, .filter-panel { border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.section-card { margin-bottom: 16px; padding: 18px; }
.table-card { padding: 0; overflow: hidden; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 15px; }
.section-card h2, .disabled-panel h2, .empty-state h2 { margin: 0 0 6px; color: var(--navy); font-size: 15px; }
.section-heading p, .disabled-panel p { margin: 0; }
.table-wrap { max-width: 100%; overflow: auto; border: 1px solid #e2e8f0; }
.table-card .table-wrap { border: 0; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
.requests-table { min-width: 1460px; }
th { position: sticky; top: 0; z-index: 1; padding: 10px 12px; background: #f8fafc; color: #475569; text-align: left; font-size: 10px; text-transform: uppercase; white-space: nowrap; }
td { max-width: 250px; padding: 11px 12px; border-top: 1px solid #e2e8f0; vertical-align: middle; }
tbody tr:hover { background: #f8fafc; }
tr.is-excluded { background: #fff7ed; }
.nowrap { white-space: nowrap; }
.truncate { max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.id-link { font-weight: 800; text-decoration: none; }
.mini-flag { display: block; margin-top: 3px; color: #9a3412; font-size: 9px; font-weight: 700; }
.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 8px; border: 1px solid #cbd5e1; background: #f8fafc; color: #475569; font-size: 10px; font-weight: 700; white-space: nowrap; }
.badge-info { border-color: #bfdbfe; background: #eff6ff; color: #1d4ed8; }
.badge-history { border-color: #bfdbfe; background: #dbeafe; color: #1e3a8a; }
.badge-success { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }
.badge-warning { border-color: #fde68a; background: #fffbeb; color: #92400e; }
.badge-danger { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.badge-neutral { border-color: #e2e8f0; background: #f8fafc; color: #475569; }

.filter-panel { margin-bottom: 16px; padding: 16px; display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; }
.filter-panel > div { min-width: 0; }
.filter-search { grid-column: span 2; }
.filter-panel label { display: block; margin: 0 0 5px; color: #475569; font-size: 10px; font-weight: 700; }
.filter-panel input, .filter-panel select { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 4px; background: #fff; color: var(--text); }
.filter-actions { display: flex; align-items: flex-end; gap: 6px; }
.inline-filter { display: flex; align-items: end; flex-wrap: wrap; gap: 8px; }
.inline-filter label { color: var(--muted); font-size: 10px; font-weight: 700; }
.inline-filter select { min-height: 38px; padding: 7px 9px; border: 1px solid #cbd5e1; border-radius: 4px; background: #fff; color: var(--text); }
.padded-heading { padding: 18px 18px 0; }
.compact-indicators { grid-template-columns: repeat(3,minmax(120px,1fr)); max-width: 620px; }
.diagnostics-kpis { grid-template-columns: repeat(4,minmax(150px,1fr)); }
.qa-flag, .qa-note { color: #92400e; }
.source-difference, .qa-note { margin-top: 10px !important; padding-top: 8px; border-top: 1px solid #e2e8f0; font-size: 10px; }
.audit-filters { grid-template-columns: repeat(4,minmax(150px,1fr)); }
.security-users table { min-width: 1220px; }
.security-users td:first-child { min-width: 210px; }
.security-users td:first-child small { display: block; margin-top: 4px; color: var(--muted); overflow-wrap: anywhere; }
.security-user-cards .request-card p { margin-top: 8px; overflow-wrap: anywhere; }
.pagination { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.pagination div { display: flex; gap: 8px; }
.pagination a { min-height: 36px; padding: 8px 12px; border: 1px solid var(--border); background: #fff; text-decoration: none; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.detail-grid-primary { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); }
.data-list { display: grid; grid-template-columns: 165px minmax(0, 1fr); gap: 10px 14px; margin: 16px 0 0; }
.data-list dt { color: var(--muted); font-size: 11px; }
.data-list dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.data-list-wide { grid-template-columns: 190px minmax(0, 1fr); }
.message-content { max-height: 360px; overflow: auto; padding: 12px; border: 1px solid #e2e8f0; background: #f8fafc; line-height: 1.6; }
.preline { white-space: pre-line; }
.empty-inline { padding: 18px; border: 1px dashed #cbd5e1; background: #f8fafc; }
.empty-inline p { margin: 5px 0 0; color: var(--muted); }
.disabled-panel { margin-top: 16px; padding: 18px; background: #f8fafc; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.disabled-actions button { min-height: 38px; padding: 8px 11px; border: 1px solid #cbd5e1; background: #e2e8f0; color: #64748b; cursor: not-allowed; }
.empty-state { padding: 40px 22px; text-align: center; }
.empty-state h1 { margin: 0; color: var(--navy); }
.empty-state p { color: var(--muted); }
.flash { margin-bottom: 18px; padding: 13px 15px; border: 1px solid #bbf7d0; border-left: 4px solid #16a34a; background: #f0fdf4; color: #166534; }
.flash-error { border-color: #fecaca; border-left-color: #dc2626; background: #fef2f2; color: #991b1b; }
.action-workspace { margin-top: 16px; padding: 18px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.action-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.action-form { min-width: 0; padding: 16px; border: 1px solid #dbe3ec; border-radius: 6px; background: #f8fafc; display: grid; gap: 8px; align-content: start; }
.action-form h3 { margin: 0 0 5px; color: var(--navy); font-size: 14px; }
.action-form label { color: #475569; font-size: 11px; font-weight: 700; }
.action-form input, .action-form select, .action-form textarea { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 4px; background: #fff; color: var(--text); }
.action-form textarea { min-height: 84px; resize: vertical; }
.action-form .primary-action, .action-form .danger-action { margin-top: 6px; justify-self: start; }
.compact-form { display: flex; padding: 0; border: 0; background: transparent; }
.action-form-danger { border-color: #fecaca; background: #fff7f7; }
.danger-action { min-height: 38px; padding: 9px 12px; border: 1px solid #dc2626; border-radius: 4px; background: #fff; color: #b91c1c; font-weight: 700; cursor: pointer; }
.owner-notice { margin-bottom: 14px; padding: 14px; border: 1px solid #bfdbfe; background: #eff6ff; }
.owner-notice p { margin: 5px 0 0; color: #475569; }
.inline-form { display: flex; align-items: center; gap: 8px; }
.inline-form input { min-height: 36px; padding: 7px 9px; border: 1px solid #cbd5e1; }
.timeline { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.timeline li { padding: 13px 14px; border-left: 3px solid #60a5fa; background: #f8fafc; }
.timeline li > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.timeline li span, .timeline li small { color: var(--muted); font-size: 10px; }
.timeline li p { margin: 6px 0 0; overflow-wrap: anywhere; }
.mobile-records { display: none; }
.request-card { padding: 14px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.request-card.is-excluded { border-color: #fed7aa; background: #fff7ed; }
.request-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.request-card h3 { margin: 10px 0 4px; font-size: 15px; }
.request-card h3 a { color: var(--navy); text-decoration: none; }
.request-card p { margin: 0 0 10px; color: var(--muted); line-height: 1.45; }
.request-card dl { display: grid; grid-template-columns: 92px 1fr; gap: 5px 8px; margin: 0; font-size: 11px; }
.request-card dt { color: var(--muted); }
.request-card dd { margin: 0; overflow-wrap: anywhere; }
.request-card .exclusion-note { margin-top: 10px; color: #9a3412; font-weight: 700; }

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .indicator-grid { grid-template-columns: repeat(3, 1fr); }
  .filter-panel { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
}

@media (max-width: 900px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; width: min(86vw, 300px); transform: translateX(-105%); transition: transform .2s ease; box-shadow: 12px 0 30px rgb(15 23 42 / 25%); }
  body.drawer-open .sidebar { transform: translateX(0); }
  .drawer-toggle { display: inline-flex; align-items: center; gap: 7px; }
  .topbar-title { display: none; }
  .main-content { padding: 24px 18px 40px; }
  .filter-panel { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .detail-grid, .detail-grid-primary { grid-template-columns: 1fr; }
  .disabled-panel { align-items: flex-start; flex-direction: column; }
  .action-grid { grid-template-columns: 1fr; }
  .diagnostics-kpis { grid-template-columns: repeat(2,minmax(140px,1fr)); }
}

@media (max-width: 780px) {
  .desktop-table { display: none; }
  .mobile-records { display: grid; gap: 10px; }
  .table-card { padding: 12px; background: transparent; border: 0; }
  .indicator-grid { grid-template-columns: repeat(2, 1fr); }
  .page-head, .record-head { display: block; }
  .page-actions { margin-top: 14px; }
}

@media (max-width: 560px) {
  .login-page { padding: 14px; }
  .login-panel { padding: 28px 20px; }
  .topbar { padding-inline: 12px; }
  .topbar-badges { gap: 4px; }
  .environment-badge, .readonly-badge { padding-inline: 6px; font-size: 9px; }
  .main-content { padding: 20px 12px 34px; }
  .kpi-grid, .indicator-grid, .filter-panel { grid-template-columns: 1fr 1fr; }
  .filter-search, .filter-actions { grid-column: 1 / -1; }
  .kpi { min-height: 105px; padding: 13px; }
  .kpi strong { font-size: 24px; }
  .section-card { padding: 14px; }
  .data-list, .data-list-wide { grid-template-columns: 1fr; gap: 4px; }
  .data-list dd { margin-bottom: 8px; }
  .disabled-actions { align-items: stretch; flex-direction: column; width: 100%; }
  .disabled-actions button { width: 100%; }
  .action-workspace { padding: 12px; }
  .action-form { padding: 13px; }
  .inline-form { align-items: stretch; flex-direction: column; }
  .pagination { align-items: flex-start; flex-direction: column; }
  .inline-filter { width: 100%; align-items: stretch; flex-direction: column; }
  .inline-filter select, .inline-filter .secondary-action { width: 100%; }
  .compact-indicators, .diagnostics-kpis { grid-template-columns: 1fr 1fr; max-width: none; }
}

@media (max-width: 390px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .filter-panel { grid-template-columns: 1fr; }
  .filter-search, .filter-actions { grid-column: auto; }
}
