:root {
  --red: #c8102e;
  --red-dark: #9f0d25;
  --ink: #17201d;
  --muted: #63706b;
  --line: #d9dfdc;
  --soft: #f2f5f3;
  --white: #ffffff;
  --green: #177a4d;
  --shadow: 0 18px 50px rgba(24, 34, 30, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--soft);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; }
a { color: var(--red-dark); text-underline-offset: 3px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(1.8rem, 3vw, 2.45rem); line-height: 1.1; letter-spacing: 0; }
h2 { letter-spacing: 0; }

.messages { position: fixed; top: 18px; right: 18px; z-index: 50; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 36px)); }
.message { padding: 12px 16px; border: 1px solid var(--line); border-left: 4px solid var(--green); background: var(--white); box-shadow: var(--shadow); }
.message-error { border-left-color: var(--red); }

.brand-mark { width: 58px; height: 58px; display: grid; place-items: center; flex: 0 0 auto; background: var(--red); color: white; font-weight: 800; font-size: 1.65rem; }
.brand-mark.small { width: 40px; height: 40px; font-size: 1.15rem; }
.brand-name { margin: 0; color: white; font-size: 1.65rem; font-weight: 760; text-transform: uppercase; }
.brand-product { margin: 2px 0 0; color: rgba(255,255,255,.72); }
.eyebrow { margin: 0 0 8px; color: var(--red); font-size: .77rem; font-weight: 760; text-transform: uppercase; }

.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(300px, 38%) 1fr; }
.brand-panel { display: flex; align-items: flex-end; gap: 18px; padding: 52px; background: #18211e; border-bottom: 10px solid var(--red); }
.auth-content { display: grid; place-content: center; padding: 42px 24px; }
.auth-card { width: min(460px, 100%); padding: 38px; border: 1px solid var(--line); background: var(--white); box-shadow: var(--shadow); border-radius: 6px; }
.auth-footer { margin: 20px 0 0; color: var(--muted); font-size: .78rem; text-align: center; }
.form-header { margin-bottom: 28px; }
.form-header > p:last-child { margin-bottom: 0; color: var(--muted); line-height: 1.55; }
.stack { display: grid; gap: 18px; }
.field { display: grid; gap: 7px; color: #37423e; font-size: .86rem; font-weight: 680; }
.field input, .auth-card form p input { width: 100%; height: 48px; padding: 0 13px; border: 1px solid #aeb8b4; border-radius: 4px; background: white; color: var(--ink); outline: none; }
.field input:focus, .auth-card form p input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(200, 16, 46, .11); }
.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 76px; }
.password-toggle { position: absolute; right: 5px; top: 5px; height: 38px; border: 0; background: transparent; color: var(--red-dark); cursor: pointer; font-size: .8rem; font-weight: 700; }
.form-actions { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 4px; }
.form-actions a, .center-link { font-size: .86rem; }
.center-link { display: block; text-align: center; }
.button { min-height: 44px; display: inline-flex; justify-content: center; align-items: center; padding: 0 19px; border: 1px solid transparent; border-radius: 4px; font-weight: 730; text-decoration: none; cursor: pointer; }
.button:disabled { cursor: not-allowed; opacity: .46; }
.button-primary { background: var(--red); color: white; }
.button-primary:not(:disabled):hover { background: var(--red-dark); }
.button-secondary { border-color: var(--line); background: white; color: var(--ink); }
.button-full { width: 100%; }
.form-error, .errorlist { margin: 0; padding: 11px 13px; border-left: 3px solid var(--red); background: #fff0f2; color: #771024; font-size: .85rem; list-style: none; }
.error-text { color: #9b1830; font-weight: 500; }
.token-field input { font-size: 1.55rem; letter-spacing: .34em; text-align: center; }
.mfa-setup { display: grid; justify-items: center; gap: 12px; margin: -10px 0 24px; }
.qr-code { width: 190px; height: 190px; image-rendering: pixelated; }
.mfa-setup details { width: 100%; font-size: .82rem; color: var(--muted); text-align: center; }
.secret-code { display: block; margin-top: 9px; padding: 9px; overflow-wrap: anywhere; background: var(--soft); color: var(--ink); }

.workspace-page { display: grid; place-items: center; padding: 40px 20px; background: #e9eeeb; }
.workspace-picker { width: min(720px, 100%); }
.workspace-picker > header { margin-bottom: 30px; }
.workspace-picker .brand-mark { margin-bottom: 24px; }
.workspace-picker header > p:last-child { color: var(--muted); }
.workspace-options { display: grid; gap: 12px; }
.workspace-option { width: 100%; min-height: 92px; display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 17px; padding: 16px 20px; border: 1px solid var(--line); border-radius: 5px; background: white; color: var(--ink); text-align: left; cursor: pointer; }
.workspace-option:hover { border-color: var(--red); box-shadow: 0 8px 24px rgba(24,34,30,.08); }
.workspace-option strong, .workspace-option small { display: block; }
.workspace-option strong { margin-bottom: 5px; font-size: 1.05rem; }
.workspace-option small { color: var(--muted); }
.workspace-code { color: var(--red); font-size: .8rem; font-weight: 800; }
.link-button { margin-top: 22px; padding: 0; border: 0; background: transparent; color: var(--red-dark); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 16px; background: #18211e; color: white; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; }
.sidebar-brand strong, .sidebar-brand small { display: block; }
.sidebar-brand small { margin-top: 2px; color: rgba(255,255,255,.6); font-size: .72rem; }
.sidebar nav { display: grid; gap: 4px; margin-top: 42px; }
.sidebar nav a, .sidebar nav span { padding: 11px 12px; color: rgba(255,255,255,.74); border-radius: 3px; text-decoration: none; font-size: .9rem; }
.sidebar nav a.active { background: rgba(255,255,255,.1); color: white; border-left: 3px solid var(--red); }
.sidebar nav .disabled { opacity: .38; }
.sidebar-user { display: grid; gap: 5px; margin-top: auto; padding: 14px 10px 2px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-user small { color: rgba(255,255,255,.55); }
.sidebar-user a, .sidebar-user button { width: fit-content; margin-top: 6px; padding: 0; border: 0; background: transparent; color: rgba(255,255,255,.78); font-size: .78rem; cursor: pointer; }
.app-main { min-width: 0; padding: 42px clamp(24px, 5vw, 72px); }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding-bottom: 30px; border-bottom: 1px solid var(--line); }
.page-header p:last-child { margin-bottom: 0; color: var(--muted); }
.metric-strip { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
.metric-strip div { padding: 25px 0; }
.metric-strip div + div { padding-left: 25px; border-left: 1px solid var(--line); }
.metric-strip span, .metric-strip strong { display: block; }
.metric-strip span { margin-bottom: 6px; color: var(--muted); font-size: .74rem; text-transform: uppercase; }
.empty-state { display: grid; grid-template-columns: 50px 1fr; gap: 20px; max-width: 690px; margin-top: 62px; }
.empty-index { color: var(--red); font-size: .76rem; font-weight: 800; }
.empty-state p { color: var(--muted); line-height: 1.6; }

.content-section { margin-top: 36px; }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; margin-bottom: 15px; }
.section-heading h2 { margin: 0; font-size: 1.15rem; }
.section-heading a { font-size: .84rem; }
.data-table-wrap { overflow-x: auto; margin-top: 28px; border: 1px solid var(--line); background: var(--white); }
.data-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.data-table th { padding: 11px 14px; border-bottom: 1px solid var(--line); background: #edf1ef; color: #55615c; font-size: .7rem; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 14px; border-bottom: 1px solid #e7ebe9; vertical-align: top; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fafcfb; }
.data-table td a { color: var(--ink); text-decoration: none; }
.data-table td a:hover strong { color: var(--red); }
.data-table strong, .data-table small { display: block; }
.data-table small { margin-top: 4px; color: var(--muted); }
.table-empty { padding: 34px !important; color: var(--muted); text-align: center; }
.table-action { width: 1%; white-space: nowrap; }
.status, .priority { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 8px; border: 1px solid #cbd3cf; background: #f5f7f6; color: #4b5853; font-size: .7rem; font-weight: 750; white-space: nowrap; }
.status-assigned, .status-accepted, .status-in_progress, .status-active { border-color: #9dcab5; background: #edf8f2; color: #116641; }
.status-signed { border-color: #8daf9f; background: #e2f1e9; color: #0b5936; }
.status-waiting, .status-signature_pending { border-color: #dcc68d; background: #fff8e5; color: #72550b; }
.status-canceled { opacity: .65; }
.priority-high { border-color: #e2b07f; background: #fff2e6; color: #8a4300; }
.priority-urgent { border-color: #dd93a0; background: #fff0f2; color: #92172d; }
.filter-bar { display: grid; grid-template-columns: minmax(240px, 2fr) minmax(150px, 1fr) minmax(150px, 1fr) auto; align-items: end; gap: 12px; margin-top: 26px; }
.filter-bar label, .form-field { display: grid; gap: 7px; }
.filter-bar label > span, .form-field > label { color: #4d5a55; font-size: .74rem; font-weight: 720; }
.filter-bar input, .filter-bar select, .form-field input, .form-field select, .form-field textarea, .compact-form select, .compact-form input { width: 100%; min-height: 43px; padding: 8px 11px; border: 1px solid #acb7b2; border-radius: 3px; background: white; color: var(--ink); }
.form-field textarea { min-height: 100px; resize: vertical; }
.filter-bar input:focus, .filter-bar select:focus, .form-field input:focus, .form-field select:focus, .form-field textarea:focus, .compact-form select:focus, .compact-form input:focus { border-color: var(--red); outline: 0; box-shadow: 0 0 0 3px rgba(200,16,46,.1); }
.filter-simple { grid-template-columns: minmax(240px, 520px) auto; }
.record-form { margin-top: 28px; padding: 26px; border: 1px solid var(--line); background: white; }
.narrow-form { max-width: 850px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.form-field-wide { grid-column: 1 / -1; }
.form-field small { color: var(--muted); }
.form-field input[type="checkbox"] { width: 20px; min-height: 20px; }
.form-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.header-badges { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 28px; margin-top: 28px; }
.detail-main { display: grid; gap: 18px; }
.detail-section, .detail-aside section { padding: 24px; border: 1px solid var(--line); background: white; }
.detail-section h2, .detail-aside h2 { margin-bottom: 19px; font-size: 1rem; }
.detail-section h3 { margin: 24px 0 8px; font-size: .8rem; text-transform: uppercase; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; margin: 0; }
.detail-grid div, .detail-aside dl { margin: 0; }
.detail-grid dt, .detail-aside dt { margin-bottom: 5px; color: var(--muted); font-size: .7rem; text-transform: uppercase; }
.detail-grid dd, .detail-aside dd { margin: 0; font-weight: 650; }
.detail-grid dd small { display: block; margin-top: 4px; color: var(--muted); font-weight: 400; }
.preserve-lines { white-space: pre-line; line-height: 1.6; }
.internal-note { padding: 14px; border-left: 3px solid #d4a830; background: #fff9e9; }
.detail-aside { display: grid; align-content: start; gap: 18px; }
.detail-aside p { color: var(--muted); font-size: .85rem; line-height: 1.5; }
.detail-aside dd + dt { margin-top: 14px; }
.compact-form { gap: 13px; }
.attachment-list { margin: 0; padding: 0; list-style: none; }
.attachment-list li { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.attachment-list small { color: var(--muted); }
.inline-form { display: flex; align-items: center; gap: 10px; margin-top: 17px; }
.inline-form input { min-width: 0; }
.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { display: grid; grid-template-columns: 14px 1fr; gap: 12px; padding-bottom: 18px; }
.timeline li > span { width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px #f8dce1; }
.timeline strong, .timeline small { display: block; }
.timeline small { margin-top: 4px; color: var(--muted); }
.timeline p { margin: 5px 0 0; }
.tabs { display: flex; gap: 0; margin-top: 25px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs a { padding: 11px 16px; color: var(--muted); font-size: .84rem; text-decoration: none; white-space: nowrap; }
.tabs a.active { color: var(--red-dark); font-weight: 750; border-bottom: 3px solid var(--red); }

.field-page { background: #f4f6f5; }
.field-shell { min-height: 100vh; padding-bottom: 76px; }
.field-header { min-height: 72px; display: flex; justify-content: space-between; align-items: center; padding: 12px clamp(16px, 4vw, 30px); background: #18211e; color: white; }
.field-user { display: flex; align-items: center; gap: 15px; font-size: .82rem; }
.field-user button { min-height: 38px; padding: 0 13px; border: 1px solid rgba(255,255,255,.25); border-radius: 4px; background: transparent; color: white; }
.field-main { width: min(920px, 100%); margin: 0 auto; padding: 34px clamp(18px, 5vw, 44px); }
.field-main h1 { font-size: clamp(2rem, 7vw, 3.2rem); }
.field-lead { color: var(--muted); font-size: 1.05rem; }
.field-status { display: grid; grid-template-columns: 1fr 1fr; margin-top: 32px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.field-status div { padding: 18px 0; }
.field-status div + div { padding-left: 20px; border-left: 1px solid var(--line); }
.field-status span, .field-status strong { display: block; }
.field-status span { margin-bottom: 5px; color: var(--muted); font-size: .75rem; }
.field-status strong { color: var(--green); }
.field-status strong.offline { color: var(--red); }
.field-empty { margin-top: 46px; padding: 28px 0; }
.field-empty h2 { margin: 15px 0 8px; font-size: 1.3rem; }
.field-empty p { color: var(--muted); }
.job-list { display: grid; gap: 10px; margin-top: 32px; }
.job-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; min-height: 104px; padding: 17px 18px; border: 1px solid var(--line); border-left: 4px solid var(--red); background: white; color: var(--ink); text-decoration: none; }
.job-item > div:first-child { min-width: 0; }
.job-item strong, .job-item small { display: block; }
.job-item > div:first-child > strong { margin: 9px 0 5px; font-size: 1rem; }
.job-item small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.job-time { text-align: right; }
.job-time strong { margin-bottom: 6px; font-size: .82rem; }
.field-header > div > strong, .field-header > div > small { display: block; }
.field-header > div > small { margin-top: 3px; color: rgba(255,255,255,.65); font-size: .7rem; }
.field-back { display: grid; width: 42px; height: 42px; place-items: center; color: white; font-size: 1.5rem; text-decoration: none; }
.field-detail h1 { margin-top: 18px; font-size: clamp(1.7rem, 6vw, 2.5rem); }
.field-info { display: grid; grid-template-columns: 1fr 1fr; margin-top: 28px; border-top: 1px solid var(--line); }
.field-info > div { min-height: 102px; padding: 18px 12px 18px 0; border-bottom: 1px solid var(--line); }
.field-info > div:nth-child(even) { padding-left: 20px; border-left: 1px solid var(--line); }
.field-info span, .field-info strong, .field-info a { display: block; }
.field-info span { margin-bottom: 6px; color: var(--muted); font-size: .72rem; text-transform: uppercase; }
.field-info a { margin-top: 8px; }
.field-description { margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--line); }
.field-description h2 { font-size: 1rem; }
.field-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 10; display: grid; grid-template-columns: repeat(3, 1fr); min-height: 66px; border-top: 1px solid var(--line); background: rgba(255,255,255,.96); }
.field-nav a, .field-nav span { display: grid; place-items: center; color: var(--muted); font-size: .75rem; text-decoration: none; }
.field-nav .active { color: var(--red); font-weight: 760; border-top: 3px solid var(--red); }

@media (max-width: 760px) {
  .auth-layout { grid-template-columns: 1fr; }
  .brand-panel { align-items: center; min-height: 118px; padding: 22px 24px; border-bottom-width: 6px; }
  .brand-mark { width: 45px; height: 45px; font-size: 1.2rem; }
  .brand-name { font-size: 1.1rem; }
  .brand-product { font-size: .78rem; }
  .auth-content { padding: 24px 16px 34px; }
  .auth-card { padding: 28px 22px; box-shadow: none; }
  .form-actions { align-items: stretch; flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; width: 100%; height: auto; padding: 14px 18px; }
  .sidebar nav { display: none; }
  .sidebar-user { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 14px 0 0; padding: 10px 0 0; }
  .sidebar-user small { flex: 1 1 100%; }
  .app-main { padding: 28px 18px; }
  .page-header { display: block; }
  .page-header .button { width: 100%; margin-top: 18px; }
  .metric-strip { grid-template-columns: 1fr; }
  .metric-strip div + div { padding-left: 0; border-top: 1px solid var(--line); border-left: 0; }
  .filter-bar { grid-template-columns: 1fr; }
  .form-grid, .detail-grid, .detail-layout { grid-template-columns: 1fr; }
  .record-form, .detail-section, .detail-aside section { padding: 19px; }
  .inline-form { align-items: stretch; flex-direction: column; }
  .inline-form .button { width: 100%; }
}

@media (max-width: 430px) {
  .workspace-option { grid-template-columns: 36px 1fr auto; padding: 14px; }
  .field-user > span { display: none; }
  .field-status { grid-template-columns: 1fr; }
  .field-status div + div { padding-left: 0; border-top: 1px solid var(--line); border-left: 0; }
  .job-item { grid-template-columns: 1fr; }
  .job-time { text-align: left; }
  .field-info { grid-template-columns: 1fr; }
  .field-info > div:nth-child(even) { padding-left: 0; border-left: 0; }
}
