:root {
  --bg: #f3f6f8;
  --surface: #ffffff;
  --soft: #f7f9fb;
  --line: #dde5ec;
  --ink: #26313d;
  --muted: #73808f;
  --brand: #0781df;
  --brand-dark: #0568b5;
  --brand-soft: #e8f3fd;
  --rail: #087fe0;
  --danger: #b43f2f;
  --warn: #a16a00;
  --ok: #24734f;
  --shadow: 0 20px 46px rgba(34, 48, 64, 0.10);
  --shadow-soft: 0 9px 22px rgba(34, 48, 64, 0.07);
  --font-sans: "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-sans); margin: 0; text-rendering: optimizeLegibility; }
a { color: inherit; }
input, select, textarea, button { font: inherit; }
input, select, textarea { background: #fff; border: 1px solid var(--line); border-radius: 4px; max-width: 100%; min-height: 42px; min-width: 0; padding: 10px 12px; width: 100%; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(7,129,223,0.14); outline: none; }

.app-shell { display: grid; grid-template-columns: 48px 190px minmax(0, 1fr); min-height: 100vh; }
.icon-rail { align-items: center; background: var(--rail); color: #fff; display: flex; flex-direction: column; gap: 24px; min-height: 100vh; padding: 16px 8px; position: sticky; top: 0; }
.icon-rail nav { display: grid; gap: 12px; width: 100%; }
.icon-rail a { align-items: center; border-radius: 4px; color: rgba(255,255,255,.78); display: flex; height: 32px; justify-content: center; text-decoration: none; width: 32px; }
.icon-rail a:hover, .icon-rail a.active { background: rgba(255,255,255,.16); color: #fff; }
.rail-brand { margin-bottom: 18px; }
.rail-brand img { border-radius: 50%; height: 26px; width: 26px; }
.rail-bottom { margin-top: auto; }
.sidebar { background: #fff; border-right: 1px solid var(--line); color: var(--ink); height: 100vh; overflow: auto; padding: 52px 20px 20px; position: sticky; top: 0; }
.sidebar-mobile-header { display: block; }
.mobile-nav-toggle { align-items: center; background: var(--brand); border: 1px solid var(--brand); border-radius: 4px; color: #fff; cursor: pointer; display: none; font-weight: 800; gap: 7px; justify-content: center; min-height: 44px; padding: 8px 12px; }
.mobile-nav-toggle i { font-size: 1.25rem; }
.brand { align-items: center; display: flex; gap: 12px; margin-bottom: 28px; padding: 0; text-decoration: none; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.18rem; font-weight: 700; }
.brand small { color: var(--muted); font-size: .78rem; margin-top: 3px; }
.sidebar nav { display: grid; gap: 4px; }
.nav-section { color: var(--muted); display: block; font-size: .68rem; font-weight: 800; letter-spacing: .08em; margin: 18px 0 8px; text-transform: uppercase; }
.nav-section:first-child { margin-top: 0; }
.sidebar nav a { align-items: center; border-radius: 4px; color: #596675; display: flex; font-size: .88rem; font-weight: 600; gap: 10px; padding: 9px 0; text-decoration: none; transition: color .15s ease; }
.sidebar nav a i { color: #8a98a8; font-size: .98rem; width: 18px; }
.sidebar nav a:hover, .sidebar nav a.active { color: #101820; }
.sidebar nav a.active i { color: var(--brand); }
.sidebar nav a.nav-category { color: #263849; font-size: .86rem; font-weight: 800; padding-top: 10px; }
.sidebar nav a.nav-subitem { font-size: .82rem; font-weight: 600; padding: 7px 0 7px 12px; }
.sidebar nav a.nav-subitem i { font-size: .9rem; width: 16px; }

.workspace { min-width: 0; padding: 32px 36px; }
.topbar, .panel, .search-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; box-shadow: var(--shadow-soft); }
.topbar { align-items: center; background: transparent; border: 0; box-shadow: none; display: flex; gap: 16px; justify-content: space-between; padding: 0 0 18px; }
.topbar p, .eyebrow { color: var(--brand); font-size: .76rem; font-weight: 800; letter-spacing: .08em; margin: 0 0 5px; text-transform: uppercase; }
h1, h2 { letter-spacing: 0; margin: 0; }
h1 { font-size: 1.55rem; font-weight: 500; }
h2 { font-size: 1.15rem; }
.hint { color: var(--muted); margin: 6px 0 0; }
.session, .toolbar, .form-actions, .inline-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; }
.session-name { color: var(--ink); font-size: .86rem; font-weight: 700; }
.notification-bell { align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); display: inline-flex; height: 38px; justify-content: center; position: relative; text-decoration: none; width: 38px; }
.notification-bell:hover, .notification-bell.has-unread { border-color: var(--brand); color: var(--brand); }
.notification-bell > span { align-items: center; background: var(--brand); border: 2px solid #fff; border-radius: 999px; color: #fff; display: flex; font-size: .62rem; font-weight: 800; height: 19px; justify-content: center; min-width: 19px; padding: 0 4px; position: absolute; right: -7px; top: -7px; }

.panel, .search-panel { margin-top: 18px; min-width: 0; padding: 18px; }
.panel-heading, .action-panel { align-items: start; display: flex; gap: 14px; justify-content: space-between; }
.action-panel { align-items: center; }
.document-heading-content { align-items: start; display: grid; flex: 1 1 auto; grid-template-columns: minmax(260px, 1.35fr) minmax(130px, .65fr) minmax(40px, .7fr); width: 100%; }
.document-heading-number { text-align: center; }
.button { align-items: center; border: 1px solid var(--line); border-radius: 3px; cursor: pointer; display: inline-flex; font-size: .82rem; font-weight: 800; justify-content: center; max-width: 100%; min-height: 36px; padding: 8px 14px; text-align: center; text-decoration: none; text-transform: uppercase; white-space: nowrap; }
.button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.button.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.button.secondary { background: #fff; color: var(--ink); }
.button.small { font-size: .84rem; min-height: 32px; padding: 6px 10px; }

.stats-grid, .details-grid, .report-grid, .module-strip { display: grid; gap: 14px; margin-top: 18px; }
.stats-grid { grid-template-columns: repeat(4, minmax(140px, 1fr)); }
.dashboard-stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.details-grid { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
.report-grid { grid-template-columns: repeat(2, minmax(280px, 1fr)); }
.module-strip { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
.module-card { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; box-shadow: var(--shadow-soft); display: grid; gap: 6px; min-height: 92px; padding: 16px; text-decoration: none; transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.module-card:hover { border-color: var(--brand); box-shadow: var(--shadow); transform: translateY(-1px); }
.module-card.active { background: var(--brand-soft); border-color: rgba(18,97,93,.35); }
.module-card span { color: var(--brand); font-size: .76rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.module-card strong { color: var(--ink); line-height: 1.25; }
.config-overview { display: grid; gap: 14px; }
.config-overview .button { justify-self: start; }
.stats-grid article { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; box-shadow: var(--shadow-soft); padding: 18px; }
.stats-grid span { color: var(--muted); display: block; font-size: .82rem; font-weight: 700; text-transform: uppercase; }
.stats-grid strong { display: block; font-size: 2rem; margin-top: 6px; }
.metric { align-items: center; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; padding: 10px 0; }
.metric:last-child { border-bottom: 0; }
.process-log { display: grid; gap: 8px; }
.process-step { align-items: center; border-bottom: 1px solid var(--line); display: flex; gap: 12px; padding: 8px 0; }
.process-step:last-child { border-bottom: 0; }
.process-step strong { color: var(--brand); font-size: .78rem; min-width: 64px; }

.filters, .form-grid { display: grid; gap: 12px; }
.filters { align-items: end; grid-template-columns: minmax(220px, 1fr) 220px auto auto; }
.filters.compact-filters { grid-template-columns: minmax(260px, 420px); }
.form-grid { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
.filters > *, .form-grid > *, .details-grid > *, .report-grid > *, .module-strip > * { min-width: 0; }
.details-grid > article .form-grid { grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); }
.compact-config { grid-template-columns: minmax(220px, 1fr) 120px 120px auto; }
.provenance-config-row { border-top: 1px solid var(--border); padding: 18px 0; }
.number-year-grid { display: grid; gap: 10px; grid-template-columns: 96px 96px; }
.form-grid label, .filters label { color: var(--muted); display: grid; gap: 7px; font-size: .88rem; font-weight: 700; }
.form-grid .wide, .form-grid .form-actions, .form-grid .check-row { grid-column: 1 / -1; }
.entity-create-step { margin-top: 16px; }
.step-number { align-items: center; background: var(--brand); border-radius: 50%; color: #fff; display: inline-flex; flex: 0 0 38px; font-size: 1rem; font-weight: 900; height: 38px; justify-content: center; }
.entity-create-summary, .entity-create-notice { background: var(--soft); border: 1px solid var(--line); border-radius: 4px; box-sizing: border-box; display: flex; flex-wrap: wrap; gap: 10px 24px; padding: 14px; }
.entity-create-summary strong, .entity-create-notice strong { color: var(--ink); }
.entity-create-summary code { color: var(--brand-dark); font-weight: 800; }
.entity-create-notice { display: block; }
.entity-create-notice p { margin: 6px 0 0; }
.label-title { color: var(--muted); display: block; font-size: .88rem; font-weight: 700; margin-bottom: 8px; }
.check { align-items: center; color: var(--ink); display: flex !important; gap: 8px; }
.check input, .tag-check input { min-height: auto; width: auto; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; min-width: 880px; width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: 12px 10px; text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; }
tbody tr:hover { background: #f8fafc; }
.clickable-row { cursor: pointer; }
.clickable-row:hover .row-link { color: var(--brand); }
.row-link { color: var(--ink); text-decoration: none; }
.row-link:hover { color: var(--brand); text-decoration: underline; text-underline-offset: 3px; }
.row-link.strong { font-weight: 800; }
.row-link.muted { color: var(--muted); }
.thumb { border: 1px solid var(--line); border-radius: 4px; display: block; height: 54px; margin-bottom: 8px; object-fit: cover; width: 74px; }
.table-wrap input[type="file"] { min-width: 180px; }
.table-wrap td > form { display: inline-flex; margin: 2px 6px 2px 0; vertical-align: middle; }
.inline-actions > form { display: inline-flex; margin: 0; }
.compact-table table { min-width: 620px; }
.centers-table table { min-width: 1120px; }
.centers-table td { vertical-align: top; }
.centers-table td input + input { margin-top: 8px; }
.centers-table td select { min-width: 170px; }
.status { background: var(--soft); border-radius: 999px; color: var(--ink); display: inline-flex; font-size: .72rem; font-weight: 800; padding: 5px 9px; white-space: nowrap; }
.notification-list { display: grid; margin-top: 14px; }
.notification-item { align-items: center; border-top: 1px solid var(--line); display: grid; gap: 14px; grid-template-columns: 40px minmax(0, 1fr) auto; padding: 16px 10px; }
.notification-item.unread { background: var(--brand-soft); border-left: 3px solid var(--brand); padding-left: 12px; }
.notification-item-icon { align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 50%; color: var(--brand); display: flex; height: 38px; justify-content: center; width: 38px; }
.notification-title-row { align-items: center; display: flex; gap: 8px; }
.notification-item p { color: var(--ink); line-height: 1.45; margin: 4px 0; }
.notification-item small { color: var(--muted); }
.notification-dot { background: var(--brand); border-radius: 50%; display: inline-block; height: 7px; width: 7px; }
.notification-empty { color: var(--muted); padding: 44px 16px; text-align: center; }
.notification-empty i { display: block; font-size: 1.6rem; margin-bottom: 8px; }
.notification-empty p { margin: 0; }
.access-denied-panel { align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); display: flex; flex-direction: column; margin: clamp(24px, 9vh, 96px) auto 0; max-width: 620px; padding: clamp(28px, 5vw, 52px); text-align: center; }
.access-denied-icon { align-items: center; background: #fcecea; border: 1px solid #f1cbc5; border-radius: 50%; color: var(--danger); display: flex; font-size: 2rem; height: 72px; justify-content: center; margin-bottom: 20px; width: 72px; }
.access-denied-panel h2 { font-size: clamp(1.35rem, 3vw, 1.8rem); }
.access-denied-message { color: var(--ink); font-size: 1rem; font-weight: 700; line-height: 1.5; margin: 16px 0 0; }
.access-denied-panel .hint { line-height: 1.55; max-width: 500px; }
.access-denied-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 24px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.profile-options-row { align-items: center; display: flex; flex-wrap: nowrap; gap: 12px; max-width: 100%; min-width: 0; overflow-x: auto; padding-bottom: 4px; width: 100%; }
.profile-options-row .tag-check { flex: 0 0 auto; white-space: nowrap; }
.inline-option-grid.full-width-option-grid { display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; }
.full-width-option-grid > article { box-sizing: border-box; min-width: 0; width: 100%; }
.tag-check { background: var(--soft); border: 1px solid var(--line); border-radius: 999px; color: var(--ink) !important; display: inline-flex !important; gap: 6px !important; padding: 7px 10px; }
.tag-chip { background: var(--brand-soft); border: 1px solid rgba(7,129,223,.18); border-radius: 999px; color: var(--brand-dark); display: inline-flex; font-size: .82rem; font-weight: 800; padding: 7px 10px; }
.file-priority { background: var(--brand-soft); border: 1px solid rgba(7,129,223,.18); border-radius: 4px; padding: 12px; }
.keyword-field { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 10px; }
.keyword-field .keyword-input { border: 0; box-shadow: none; min-height: 30px; padding: 4px 0; }
.keyword-field .keyword-input:focus { box-shadow: none; }
.keyword-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.keyword-chip { background: var(--brand-soft); border: 1px solid rgba(7,129,223,.2); border-radius: 999px; color: var(--brand-dark); cursor: pointer; font-size: .82rem; font-weight: 800; padding: 6px 10px; }
.inline-option-grid { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
.inline-option-grid article { background: var(--soft); border: 1px solid var(--line); border-radius: 4px; padding: 12px; }
.option-list { border: 1px solid var(--line); border-radius: 4px; display: grid; gap: 6px; max-height: 320px; overflow: auto; padding: 10px; }
.option-check { align-items: flex-start; background: var(--soft); border: 1px solid var(--line); border-radius: 4px; color: var(--ink) !important; display: flex !important; gap: 9px !important; padding: 9px 10px; }
.option-check input { margin-top: 3px; min-height: auto; width: auto; }
.option-check strong, .option-check small { display: block; }
.option-check small { color: var(--muted); font-weight: 400; margin-top: 3px; }
.deficiency-selector { border: 1px solid var(--line); border-radius: 4px; padding: 12px; }
.deficiency-toolbar { align-items: center; display: grid; gap: 10px; grid-template-columns: minmax(240px, 1fr) auto auto; }
.deficiency-selected-count { color: var(--brand-dark); font-size: .84rem; font-weight: 800; white-space: nowrap; }
.deficiency-search-hint { margin: 8px 0; }
.deficiency-search-results { border: 1px solid var(--line); border-radius: 4px; display: grid; gap: 6px; margin: 10px 0; max-height: 360px; overflow: auto; padding: 10px; }
.deficiency-tree { border-top: 1px solid var(--line); margin-top: 10px; }
.deficiency-group { border-bottom: 1px solid var(--line); }
.deficiency-group-header { align-items: center; display: grid; gap: 8px; grid-template-columns: 30px 22px 1fr; padding: 8px 2px; }
.deficiency-expand, .deficiency-group-title { background: transparent; border: 0; color: var(--ink); cursor: pointer; text-align: left; }
.deficiency-expand { font-size: 1.6rem; line-height: 1; padding: 0; transform: rotate(0deg); transition: transform .15s ease; }
.deficiency-expand[aria-expanded="true"] { transform: rotate(90deg); }
.deficiency-group-title { display: grid; gap: 2px; padding: 4px; }
.deficiency-group-title small { color: var(--muted); }
.deficiency-group-children { background: #f8fafc; border-top: 1px solid var(--line); padding: 8px 12px 12px 44px; }
.deficiency-subgroup { border-bottom: 1px dashed var(--line); padding: 10px 0; }
.deficiency-subgroup:last-child { border-bottom: 0; }
.deficiency-subgroup-header, .deficiency-n2-header { align-items: center; color: var(--ink) !important; display: flex !important; gap: 8px !important; margin-bottom: 8px; }
.deficiency-subgroup-items, .deficiency-n2-items { display: grid; gap: 6px; padding-left: 24px; }
.deficiency-n2 { border-left: 3px solid var(--line); margin: 6px 0; padding: 8px 0 8px 10px; }
.deficiency-error { margin-bottom: 0; }
.deficiency-group-check, .deficiency-subgroup-check, .deficiency-n2-check { min-height: auto; width: auto; }
.permission-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.tag-check small { color: var(--muted); font-weight: 400; }

.alert { border-radius: 4px; margin-top: 18px; padding: 12px 14px; }
.alert.success { background: #e8f4ec; color: var(--ok); }
.alert.error { background: #f5e8e6; color: var(--danger); }
.button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.danger-zone { border-color: rgba(180,63,47,.35); }
.danger-zone form + form { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; }
.pagination-bar { margin-top: 22px; padding: 18px 14px 8px; }
.pagination-actions { gap: 12px; }
.button.pagination-button { background: #111; border-color: #111; color: #fff; padding-left: 18px; padding-right: 18px; }
.button.pagination-button:hover { background: #2c2c2c; border-color: #2c2c2c; color: #fff; }
.documents-list-table th:nth-child(1),
.documents-list-table td:nth-child(1) { width: 32%; }
.documents-list-table th:nth-child(5),
.documents-list-table td:nth-child(5) { width: 12%; }
footer { color: var(--muted); font-size: .86rem; padding: 22px 4px 4px; text-align: center; }

.login-page { background: radial-gradient(circle at 12% 14%, rgba(7,129,223,.28), transparent 28%), linear-gradient(135deg, #eaf4ff 0%, #f7f9fc 48%, #dceefe 100%); display: grid; min-height: 100vh; padding: 28px; place-items: center; }
.login-shell { background: rgba(255,255,255,.92); border: 1px solid rgba(255,255,255,.78); border-radius: 28px; box-shadow: 0 30px 80px rgba(28, 62, 98, .20); display: grid; grid-template-columns: minmax(320px, .95fr) minmax(360px, .78fr); max-width: 1120px; min-height: 680px; overflow: hidden; width: min(100%, 1120px); }
.login-visual { background: linear-gradient(145deg, #087fe0 0%, #0568b5 52%, #043e78 100%); color: #fff; display: flex; flex-direction: column; justify-content: space-between; min-height: 100%; overflow: hidden; padding: 34px; position: relative; }
.login-visual::before { background: rgba(255,255,255,.12); border-radius: 42px; content: ""; height: 300px; position: absolute; right: -120px; top: -90px; transform: rotate(18deg); width: 300px; }
.login-visual::after { background: rgba(255,255,255,.08); border-radius: 999px; bottom: -120px; content: ""; height: 260px; left: -80px; position: absolute; width: 260px; }
.login-visual-top, .login-visual-copy, .login-illustration { position: relative; z-index: 1; }
.login-visual-top { align-items: center; display: flex; gap: 12px; font-size: 1.05rem; font-weight: 800; }
.login-visual-top img { background: #fff; border-radius: 50%; height: 38px; padding: 4px; width: 38px; }
.login-visual-copy { max-width: 430px; }
.login-visual-copy .eyebrow { color: rgba(255,255,255,.72); }
.login-visual-copy h1 { color: #fff; font-size: clamp(2rem, 4vw, 3.2rem); font-weight: 700; line-height: 1.05; margin: 0 0 16px; }
.login-visual-copy p:last-child { color: rgba(255,255,255,.78); font-size: 1rem; line-height: 1.65; margin: 0; }
.login-illustration { height: 270px; margin-top: 32px; }
.doc-card { background: rgba(255,255,255,.94); border: 1px solid rgba(255,255,255,.6); border-radius: 18px; box-shadow: 0 24px 45px rgba(2, 33, 70, .28); display: grid; gap: 12px; padding: 22px; position: absolute; }
.doc-card span, .doc-card i { background: #dceefe; border-radius: 999px; display: block; height: 12px; }
.doc-card-main { bottom: 20px; left: 10px; width: 280px; }
.doc-card-main span:first-child { background: var(--brand); height: 34px; width: 92px; }
.doc-card-main span:nth-child(2) { width: 85%; }
.doc-card-main span:nth-child(3) { width: 64%; }
.doc-card-small { right: 8px; top: 22px; width: 190px; }
.doc-card-small i { background: #17a2ff; height: 42px; width: 42px; }
.doc-card-small span:nth-child(2) { width: 90%; }
.doc-card-small span:nth-child(3) { width: 58%; }
.login-chart { align-items: end; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22); border-radius: 18px; bottom: 0; display: flex; gap: 12px; height: 120px; padding: 18px; position: absolute; right: 68px; width: 190px; }
.login-chart span { background: rgba(255,255,255,.82); border-radius: 999px 999px 6px 6px; display: block; flex: 1; }
.login-chart span:nth-child(1) { height: 46%; }
.login-chart span:nth-child(2) { height: 74%; }
.login-chart span:nth-child(3) { height: 58%; }
.login-panel { align-content: center; background: #f8fbff; display: grid; padding: clamp(30px, 5vw, 72px); }
.login-panel .login-brand { margin-bottom: 34px; }
.login-brand { align-items: center; display: flex; gap: 12px; }
.login-brand img { border-radius: 12px; height: 52px; width: 52px; }
.login-brand strong, .login-brand span { display: block; }
.login-brand strong { color: #111923; font-size: 2rem; line-height: 1; }
.login-brand span { color: var(--muted); margin-top: 8px; }
.login-form { display: grid; gap: 16px; }
.login-form label { color: #536171; display: grid; gap: 8px; font-size: .9rem; font-weight: 800; }
.login-form input { background: #fff; border: 1px solid #e1e9f2; border-radius: 12px; min-height: 58px; padding: 14px 16px; }
.password-field { display: grid; position: relative; }
.password-field input { padding-right: 86px; }
.password-field button { background: transparent; border: 0; color: var(--brand); cursor: pointer; font-size: .78rem; font-weight: 800; height: 100%; padding: 0 16px; position: absolute; right: 0; text-transform: uppercase; top: 0; }
.login-submit { border-radius: 12px; box-shadow: 0 18px 30px rgba(7,129,223,.24); font-size: .9rem; margin-top: 10px; min-height: 56px; }
.login-footer-note { color: var(--muted); font-size: .84rem; font-weight: 700; margin: 28px 0 0; text-align: center; }

@media (max-width: 980px) {
  .app-shell, .filters, .form-grid, .compact-config, .stats-grid, .details-grid, .report-grid, .module-strip { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr; min-height: 0; }
  .login-visual { min-height: 360px; }
  .login-panel { padding: 30px; }
  .icon-rail { display: none; }
  .sidebar { border-bottom: 1px solid var(--line); border-right: 0; box-shadow: 0 4px 18px rgba(34,48,64,.09); height: auto; max-height: 100dvh; overflow: hidden; padding: 10px 14px; position: sticky; top: 0; z-index: 100; }
  .sidebar-mobile-header { align-items: center; display: flex; gap: 12px; justify-content: space-between; }
  .sidebar .brand { margin: 0; }
  .sidebar .brand small { display: block; }
  .mobile-nav-toggle { display: inline-flex; }
  .sidebar nav { display: none; gap: 4px; max-height: calc(100dvh - 76px); overflow-y: auto; overscroll-behavior: contain; padding: 12px 2px 8px; }
  .sidebar.mobile-nav-open nav { display: grid; }
  .sidebar nav .nav-section { display: block; margin: 14px 4px 5px; }
  .sidebar nav .nav-section:first-child { margin-top: 2px; }
  .sidebar nav a, .sidebar nav a.nav-category, .sidebar nav a.nav-subitem { background: var(--soft); border: 1px solid var(--line); padding: 11px 12px; white-space: normal; width: 100%; }
  .sidebar nav a.nav-subitem { padding-left: 24px; }
  .sidebar nav a:hover, .sidebar nav a.active { background: var(--brand-soft); border-color: rgba(7,129,223,.28); }
  .workspace { padding: 16px; }
  .compact-config[data-document-type-dynamic],
  .compact-config[data-document-type-dynamic].name-on-next-line { grid-template-columns: 1fr; }
  .compact-config[data-document-type-dynamic] [data-doc-field],
  .compact-config[data-document-type-dynamic].name-on-next-line [data-doc-field],
  .compact-config[data-document-type-dynamic].name-on-next-line label.check,
  .compact-config[data-document-type-dynamic].name-on-next-line .form-actions { grid-column: 1; grid-row: auto; }
}

@media (max-width: 640px) {
  .document-heading-content { gap: 14px; grid-template-columns: 1fr; }
  .document-heading-number { text-align: left; }
  .deficiency-toolbar { grid-template-columns: 1fr; }
  .deficiency-group-children { padding-left: 12px; }
  .login-page { min-height: 100dvh; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .login-shell { border-radius: 18px; width: 100%; }
  .login-visual { display: none; }
  .login-panel { padding: 28px 20px; }
  .login-brand strong { font-size: 1.55rem; }
  .workspace { padding: 12px; }
  .topbar { align-items: stretch; flex-direction: column; padding-bottom: 8px; }
  .topbar h1 { font-size: 1.3rem; line-height: 1.25; overflow-wrap: anywhere; }
  .session { align-items: center; display: grid; grid-template-columns: auto minmax(0,1fr) auto; width: 100%; }
  .session-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .session form { width: auto; }
  .action-panel, .panel-heading, .toolbar, .form-actions, .inline-actions { align-items: stretch; flex-direction: column; }
  .panel, .search-panel { margin-top: 12px; padding: 14px; }
  .button { min-height: 44px; white-space: normal; }
  .access-denied-panel { margin-top: 18px; padding: 30px 18px; }
  .access-denied-actions { align-items: stretch; flex-direction: column; width: 100%; }
  .access-denied-actions .button { width: 100%; }
  .button.small { min-height: 40px; }
  input, select, textarea { min-height: 46px; }
  .inline-actions > form, .form-actions > form { display: flex; width: 100%; }
  .inline-actions > form .button, .form-actions > form .button, .action-panel > .button, .toolbar > .button, .inline-actions > .button, .form-actions > .button { width: 100%; }
  .profile-options-row { flex-wrap: wrap; overflow-x: visible; }
  .profile-options-row .tag-check { max-width: 100%; white-space: normal; }
  .notification-item { align-items: start; grid-template-columns: 40px minmax(0, 1fr); }
  .notification-item form { grid-column: 2; }
  .notification-bell { flex: 0 0 38px; }
  .number-year-grid, .inline-option-grid, .permission-grid { grid-template-columns: 1fr; }
  .tag-check, .tag-chip { max-width: 100%; overflow-wrap: anywhere; white-space: normal; }
  .deficiency-group-header { grid-template-columns: 30px 22px minmax(0,1fr); }
  .deficiency-subgroup-items, .deficiency-n2-items { padding-left: 8px; }
  .pagination-bar, .pagination-actions { align-items: stretch; flex-direction: column; }
  .pagination-actions .button { width: 100%; }
  .read-viewer { height: 58dvh !important; padding: 6px !important; }
  .read-confirm-bar { align-items: stretch !important; flex-direction: column; }
  .read-confirm-bar .button { width: 100%; }
  .icon-picker-panel { grid-template-columns: repeat(5, 1fr) !important; left: 16px !important; max-height: 60dvh !important; right: 16px !important; width: auto !important; }
}

@media (max-width: 720px) {
  .table-wrap { overflow: visible; }
  .mobile-card-table { display: block; min-width: 0; width: 100%; }
  .mobile-card-table thead { clip: rect(0 0 0 0); clip-path: inset(50%); height: 1px; overflow: hidden; position: absolute; white-space: nowrap; width: 1px; }
  .mobile-card-table tbody, .mobile-card-table tr { display: block; width: 100%; }
  .mobile-card-table tbody { display: grid; gap: 12px; }
  .mobile-card-table tbody tr { background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 12px rgba(34,48,64,.05); overflow: hidden; }
  .mobile-card-table tbody td { align-items: start; border-bottom: 1px solid var(--line); display: grid; gap: 10px; grid-template-columns: minmax(92px, 34%) minmax(0,1fr); min-height: 44px; overflow-wrap: anywhere; padding: 11px 12px; width: 100%; }
  .mobile-card-table tbody td:last-child { border-bottom: 0; }
  .mobile-card-table tbody td::before { color: var(--muted); content: attr(data-label); font-size: .7rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
  .mobile-card-table tbody td[data-label=""] { display: block; }
  .mobile-card-table tbody td[data-label=""]::before, .mobile-card-table tbody td[colspan]::before { display: none; }
  .mobile-card-table tbody td[colspan] { display: block; }
  .mobile-card-table .inline-actions { display: grid; gap: 8px; grid-template-columns: repeat(2,minmax(0,1fr)); width: 100%; }
  .mobile-card-table .inline-actions .button, .mobile-card-table td > .button, .mobile-card-table td > form, .mobile-card-table td > form .button { width: 100%; }
  .mobile-card-table td > form { display: flex; margin: 3px 0; }
  .documents-list-table th, .documents-list-table td { width: auto !important; }
  .mobile-card-table .doc-row.editing td.cell-edit { display: grid !important; width: 100% !important; }
  .centers-table table, .compact-table table { min-width: 0; }
}
.compact-config[data-document-type-dynamic].name-on-next-line {
    grid-template-columns:
        var(--provenance-width, max-content)
        var(--issuer-width, max-content)
        auto;
}

.compact-config[data-document-type-dynamic].name-on-next-line
[data-doc-field="provenance"] {
    grid-column: 1;
    grid-row: 1;
}

.compact-config[data-document-type-dynamic].name-on-next-line
[data-doc-field="issuer"] {
    grid-column: 2;
    grid-row: 1;
}

.compact-config[data-document-type-dynamic].name-on-next-line
[data-doc-field="icon"] {
    grid-column: 3;
    grid-row: 1;
}

.compact-config[data-document-type-dynamic].name-on-next-line
[data-doc-field="name"] {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
}

.compact-config[data-document-type-dynamic].name-on-next-line
[data-doc-field="name"] input {
    width: 100%;
}

.compact-config[data-document-type-dynamic].name-on-next-line
label.check {
    grid-column: 1 / -1;
    grid-row: 3;
}

.compact-config[data-document-type-dynamic].name-on-next-line
.form-actions {
    grid-column: 1 / -1;
    grid-row: 4;
}
.compact-config[data-document-type-dynamic] {
    grid-template-columns:
        minmax(0, 1fr)
        var(--provenance-width, 120px)
        var(--issuer-width, 120px)
        auto;
}

.compact-config[data-document-type-dynamic]
[data-doc-field="name"] {
    min-width: 0;
}

.compact-config[data-document-type-dynamic]
[data-doc-field="name"] input {
    min-width: 0;
    width: 100%;
}

.compact-config[data-document-type-dynamic]
[data-doc-field="provenance"] {
    min-width: 0;
}

.compact-config[data-document-type-dynamic]
[data-doc-field="provenance"] select {
    width: 100%;
}

.compact-config[data-document-type-dynamic]
[data-doc-field="issuer"] {
    min-width: 0;
}

.compact-config[data-document-type-dynamic]
[data-doc-field="issuer"] input {
    width: 100%;
}

.compact-config[data-document-type-dynamic]
[data-doc-field="icon"] {
    min-width: max-content;
}

/* Pop-up de erro (eliminação bloqueada, etc.) */
.app-modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: flex; align-items: center; justify-content: center; z-index: 1100; padding: 16px; }
.app-modal { background: #fff; border-radius: 12px; padding: 22px 24px; width: min(460px, 92vw); box-shadow: 0 24px 60px rgba(16, 24, 40, .35); }
.app-modal h3 { margin: 0 0 8px; color: var(--ink); }
.app-modal p { margin: 0 0 16px; color: var(--muted); }

.approval-dialog { background: var(--surface); border: 0; border-radius: 10px; box-shadow: 0 28px 80px rgba(15,23,42,.3); color: var(--ink); max-height: min(88vh, 820px); max-width: calc(100vw - 32px); padding: 0; width: min(880px, calc(100vw - 32px)); }
.approval-dialog::backdrop { background: rgba(15,23,42,.58); }
.approval-dialog-form { display: flex; flex-direction: column; max-height: min(88vh, 820px); }
.approval-dialog-header, .approval-dialog-footer { background: var(--surface); padding: 18px 20px; }
.approval-dialog-header { border-bottom: 1px solid var(--line); }
.approval-dialog-header h2 { margin-bottom: 6px; }
.approval-dialog-header .hint { line-height: 1.45; }
.approval-dialog-toolbar { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.approval-dialog-body { background: var(--soft); overflow-y: auto; padding: 16px 20px; }
.approval-dialog-reason { display: grid; gap: 7px; margin-top: 14px; }
.approval-dialog-footer { align-items: center; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.approval-dialog .document-user-profile { box-shadow: none; }
.approval-dialog .document-user-profile summary { align-items: center; display: flex; gap: 12px; justify-content: space-between; }
.approval-dialog .document-user-profile summary small { color: var(--muted); font-weight: 600; }
.verification-read-note { color: var(--warn); display: block; font-size: .82rem; font-weight: 700; margin-top: 7px; }
.entity-decision-actions { margin-top: 16px; }
.button:disabled { background: #e6ebef; border-color: #d8e0e7; color: #8995a2; cursor: not-allowed; }

.document-user-tree{display:grid;gap:.75rem;max-width:100%;min-width:0;width:100%}
.document-user-profile{border:1px solid var(--line);border-radius:10px;background:#fff;max-width:100%;min-width:0;padding:.7rem .85rem;width:100%}
.document-user-profile summary{cursor:pointer;font-weight:800;color:var(--ink);margin-bottom:.65rem}
.document-user-profile:not([open]) summary{margin-bottom:0}
.document-user-profile .tag-list{padding-left:.5rem}

@media (max-width: 640px) {
  .approval-dialog-header, .approval-dialog-body, .approval-dialog-footer { padding-left: 14px; padding-right: 14px; }
  .approval-dialog-footer .button { width: 100%; }
}

/* Regras finais para garantir que configurações específicas de páginas não
   voltam a forçar grelhas largas depois dos breakpoints globais. */
@media (max-width: 980px) {
  .compact-config[data-document-type-dynamic],
  .compact-config[data-document-type-dynamic].name-on-next-line { grid-template-columns: 1fr !important; }
  .compact-config[data-document-type-dynamic] [data-doc-field],
  .compact-config[data-document-type-dynamic].name-on-next-line [data-doc-field],
  .compact-config[data-document-type-dynamic].name-on-next-line label.check,
  .compact-config[data-document-type-dynamic].name-on-next-line .form-actions { grid-column: 1 !important; grid-row: auto !important; min-width: 0 !important; }
}

@media (max-width: 640px) {
  .approval-dialog { border-radius: 0; height: 100dvh; max-height: 100dvh; max-width: 100vw; width: 100vw; }
  .approval-dialog-form { height: 100%; max-height: 100dvh; }
  .approval-dialog-body { min-height: 0; }
  .app-modal { max-height: calc(100dvh - 24px); overflow-y: auto; padding: 18px; width: calc(100vw - 24px); }
  .document-user-profile { padding: .65rem; }
  .document-user-profile .tag-list { padding-left: 0; }
  .document-user-profile .tag-check { align-items: flex-start; width: 100%; }
}
