:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #14213a;
  background: #f2f5fa;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --muted: #526179;
  --outline: #dce2ed;
  --accent: #244fb4;
  --soft-blue: #edf3ff;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button, input { touch-action: manipulation; }
:focus-visible { outline: 3px solid #6c8cea; outline-offset: 3px; }
h1, h2, p { margin: 0; }

.initial-state { color: var(--muted); padding: 3.5rem 1rem; text-align: center; }
.auth-screen { display: grid; justify-items: center; min-height: 100vh; align-content: center; gap: 1.5rem; padding: 2rem 1rem; }
.auth-brand { width: min(100%, 15rem); }
.brand-logo { display: block; width: 100%; height: auto; }
.auth-card { width: min(100%, 440px); padding: clamp(1.3rem, 6vw, 2.4rem); border-radius: 1rem; background: white; border: 1px solid var(--outline); box-shadow: 0 14px 42px #253c5c10; }
.auth-copy { margin-bottom: 1.6rem; }
.auth-copy p { margin-top: .55rem; color: var(--muted); line-height: 1.55; }
.auth-switch { border-top: 1px solid var(--outline); margin-top: 1.5rem; padding-top: 1.25rem; display: flex; gap: .45rem; flex-wrap: wrap; color: var(--muted); font-size: .92rem; }
.auth-submit { width: 100%; text-align: center; }

.workspace { display: grid; grid-template-columns: 237px minmax(0, 1fr); min-height: 100vh; }
.sidebar { display: flex; flex-direction: column; background: #101f38; color: #fff; padding: 2rem 1rem 1.15rem; min-width: 0; }
.brand { width: min(100% - 1.1rem, 11rem); margin: 0 .55rem 2.15rem; padding: .24rem .48rem; border-radius: .65rem; background: white; }
.navigation { display: grid; gap: .45rem; }
.navigation button { display: flex; gap: .8rem; align-items: center; padding: .78rem .9rem; background: transparent; color: #cdd9f1; text-align: left; border: 0; border-radius: .6rem; font-weight: 620; }
.navigation button:hover, .navigation button[aria-current] { background: #243b65; color: #fff; }
.nav-icon { display: inline-block; position: relative; width: 1.05rem; height: 1.05rem; flex: 0 0 1.05rem; color: inherit; }
.icon-audit { border: 1.5px solid currentColor; border-radius: .2rem; }
.icon-audit::before, .icon-audit::after { content: ""; position: absolute; left: .22rem; right: .22rem; border-top: 1.4px solid currentColor; }
.icon-audit::before { top: .28rem; }
.icon-audit::after { top: .55rem; }
.icon-connections::before, .icon-connections::after { content: ""; position: absolute; width: .62rem; height: .62rem; border: 1.5px solid currentColor; border-radius: 50%; }
.icon-connections::after { right: 0; bottom: 0; }
.icon-tokens { border: 1.5px solid currentColor; border-radius: 50%; }
.icon-tokens::after { content: ""; position: absolute; inset: .23rem; border: 1px solid currentColor; border-radius: 50%; }
.icon-profile::before { content: ""; position: absolute; top: 0; left: .32rem; width: .44rem; height: .44rem; border: 1.4px solid currentColor; border-radius: 50%; }
.icon-profile::after { content: ""; position: absolute; inset: .55rem .08rem 0; border: 1.4px solid currentColor; border-radius: .5rem .5rem .15rem .15rem; }
.icon-admin { border: 1.5px solid currentColor; border-radius: .2rem; }
.icon-admin::after { content: ""; position: absolute; inset: .22rem 0; border-top: 1.4px solid currentColor; border-bottom: 1.4px solid currentColor; }
.account { margin-top: auto; padding: 1.15rem .45rem 0; border-top: 1px solid #314259; }
.account-identity { display: flex; gap: .6rem; min-width: 0; align-items: center; }
.account-initial { display: grid; flex: 0 0 2rem; height: 2rem; place-items: center; color: #dfe9ff; background: #324975; border-radius: 50%; font-size: .85rem; font-weight: 700; }
.account-text { min-width: 0; }
.account-text p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#account-company { font-size: .85rem; font-weight: 680; }
#account-email { color: #aebcd5; font-size: .74rem; margin-top: .12rem; }
.logout { margin-top: .8rem; color: #cad8f2 !important; font-size: .8rem !important; }

.main-content { width: min(100%, 1375px); padding: clamp(1.15rem, 4.25vw, 3.1rem); }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: .8rem 1.25rem; flex-wrap: wrap; margin: 0 0 1.9rem; }
.page-header p { color: var(--muted); line-height: 1.55; margin-top: .45rem; }
h1 { font-size: clamp(1.65rem, 4vw, 2.3rem); letter-spacing: -.045em; line-height: 1.17; }
h2 { font-size: 1.16rem; letter-spacing: -.022em; line-height: 1.3; }
.summary-link { background: #e6eeff; color: #234278; padding: .62rem .8rem; border-radius: .55rem; border: 1px solid #d8e4fc; font-size: .85rem; white-space: nowrap; }
.summary-link:hover { background: #dbe7ff; }
.summary-link strong { padding: 0 .13rem 0 .35rem; }
.audit-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.card { background: #fff; border: 1px solid var(--outline); border-radius: .85rem; min-width: 0; padding: clamp(1rem, 3vw, 1.55rem); box-shadow: 0 5px 18px #182c4a07; }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: .55rem; flex-wrap: wrap; }
.process-card { background: #f8faff; }
.checklist { list-style: none; display: grid; gap: .7rem; padding: 0; margin: 1.05rem 0 0; }
.checklist li { position: relative; padding-left: 1.5rem; color: #384963; line-height: 1.4; font-size: .9rem; }
.checklist li::before { content: ""; position: absolute; height: .42rem; width: .68rem; border-left: 2px solid #4168bf; border-bottom: 2px solid #4168bf; transform: rotate(-45deg); left: .14rem; top: .35rem; }
.activity { margin-top: 1rem; }
form { display: grid; gap: 1.05rem; }
.card form { margin-top: 1.12rem; justify-items: start; }
label { width: 100%; display: grid; gap: .4rem; color: #293b56; font-weight: 650; font-size: .9rem; }
input, select { width: 100%; min-width: 0; padding: .7rem .75rem; background: #fff; border: 1px solid #cad4e3; border-radius: .5rem; color: #14213a; font-weight: 450; line-height: 1.3; }
input::placeholder { color: #6a7890; opacity: 1; }
.button { border: 1px solid transparent; color: white; border-radius: .55rem; padding: .7rem .95rem; font-weight: 650; line-height: 1.25; }
.button.primary { background: #2855b8; }
.button.primary:hover:not(:disabled) { background: #1d459d; }
.button.primary:disabled { color: #354664; background: #dfe6f2; }
.text-button { appearance: none; padding: 0; background: transparent; border: 0; color: var(--accent); font-weight: 650; font-size: .88rem; text-align: left; }
.text-button:hover { text-decoration: underline; }
.card-link { margin-top: .75rem; }
.availability { color: var(--muted); font-size: .88rem; line-height: 1.45; }
.card > .availability { margin-top: .55rem; }
.feedback { width: 100%; border-radius: .45rem; background: var(--soft-blue); padding: .62rem .75rem; font-size: .88rem; line-height: 1.42; color: #244681; overflow-wrap: anywhere; }
.feedback[data-kind="error"] { color: #a52933; background: #fff0f1; }
#workspace-feedback:not([hidden]) { margin-bottom: 1rem; }
.status { display: inline-block; background: #edf1f8; color: #455570; font-weight: 650; font-size: .78rem; border-radius: 2rem; padding: .28rem .58rem; }
.status[data-status="saved"], .status[data-status="completed"] { color: #20614d; background: #e5f5ef; }
.status[data-status="failed"] { color: #9a2935; background: #fcebed; }
.status[data-status="running"] { color: #234d99; background: #e9f0ff; }
.status[data-status="uncertain"] { color: #72551a; background: #fff3d7; }
.empty-state { padding: 1.25rem 1rem; color: var(--muted); margin-top: .85rem; border: 1px dashed #d1dbea; border-radius: .6rem; font-size: .9rem; }
.table-scroll { overflow-x: auto; margin-top: .85rem; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; text-align: left; }
th, td { padding: .75rem .55rem; border-bottom: 1px solid #e5eaf2; vertical-align: top; }
th { color: var(--muted); font-weight: 650; background: #f6f8fc; }
td { overflow-wrap: anywhere; }
tbody tr:last-child td { border-bottom: 0; }
.job-detail { margin-top: .55rem; font-size: .84rem; line-height: 1.4; }
.job-detail summary { cursor: pointer; color: var(--accent); }
.job-detail dl { margin: .5rem 0 0; }
.job-detail dt { font-weight: 650; margin-top: .4rem; }
.job-detail dd { margin-left: 0; }
.job-detail ul { margin: 0; padding-left: 1.15rem; }
.job-detail a { color: var(--accent); }
.audit-result-row > td { padding-top: .25rem; }
.audit-result-row .job-detail { margin-top: .2rem; }
.audit-result-section { margin-top: 1rem; }
.audit-result-section h3 { margin: 0 0 .35rem; font-size: .96rem; }
.audit-fields-table { table-layout: fixed; margin-top: .5rem; }
.audit-fields-table th:first-child { width: 27%; }
.audit-fields-table tbody th { color: #293b56; background: transparent; }
.audit-fields-table td { white-space: pre-wrap; }
.audit-fields-table [data-state="empty"], .audit-fields-table [data-state="unavailable"], .audit-fields-table [data-state="unchanged"] { color: var(--muted); }
.audit-fields-table [data-state="changed"] { color: #20614d; background: #edf7f2; font-weight: 650; }
.job-detail .audit-photo-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 7.5rem), 1fr)); gap: .65rem; list-style: none; padding: 0; }
.job-detail .audit-photo-gallery.with-ocr { grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr)); }
.audit-photo { display: block; border: 1px solid var(--outline); border-radius: .45rem; padding: .38rem; background: #f6f8fc; text-align: center; }
.audit-photo img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: contain; border-radius: .2rem; margin-bottom: .22rem; }
.photo-ocr { display: grid; justify-items: start; gap: .32rem; margin-top: .45rem; }
.photo-ocr .status { max-width: 100%; }
.photo-ocr dl { margin: 0; min-width: 0; max-width: 100%; }
.photo-ocr dd { white-space: pre-wrap; overflow-wrap: anywhere; }
.photo-ocr-message { margin-top: .35rem; }
.token-card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.token-card h2 { color: var(--muted); font-size: .93rem; font-weight: 650; }
.balance { color: var(--muted); margin-top: .35rem; }
.balance strong { font-size: 2.25rem; line-height: 1.15; letter-spacing: -.06em; color: #17305c; margin-right: .25rem; }
.profile-card { width: min(100%, 36rem); }
.profile-card form { margin-top: 0; }
.admin-feedback { margin-top: .85rem; }
.admin-credit-fields { width: 100%; min-width: 0; margin: 0; padding: 0; border: 0; display: grid; gap: 1.05rem; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.admin-credit-fields button { justify-self: start; }

@media (max-width: 860px) {
  .workspace { grid-template-columns: 192px minmax(0, 1fr); }
  .main-content { padding: 1.5rem; }
  .audit-layout { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { display: grid; grid-template-columns: 1fr auto; align-items: center; row-gap: 1rem; padding: .75rem 1rem; }
  .brand { width: min(100%, 8.25rem); margin: 0; padding: .15rem .35rem; }
  .navigation { grid-column: 1 / -1; grid-row: 2; display: flex; flex-wrap: wrap; gap: .2rem; }
  .navigation button { font-size: .86rem; padding: .63rem .55rem; gap: .43rem; }
  .nav-icon { display: none; }
  .account { border: 0; margin: 0; padding: 0; }
  .account-identity { display: none; }
  .logout { margin-top: 0; }
  .main-content { padding: 1.05rem; }
  .page-header { margin-bottom: 1.15rem; }
  .page-header p { font-size: .92rem; }
  .admin-credit-fields { grid-template-columns: 1fr; }
}
