:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-soft: #fbfcfe;
  --text: #172337;
  --muted: #6c7b8e;
  --line: #dfe6ee;
  --line-strong: #ccd7e2;
  --navy: #102b43;
  --navy-2: #173b5d;
  --navy-3: #245b88;
  --blue: #2779db;
  --green: #24945a;
  --orange: #ef7a22;
  --amber: #c98016;
  --red: #e44444;
  --shadow: 0 8px 26px rgba(25, 47, 78, .07);
  --shadow-soft: 0 2px 10px rgba(25, 47, 78, .06);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: #176da7; text-decoration: none; }
a:hover { text-decoration: none; color: #0f5688; }
button, input, select, textarea { font: inherit; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Shell */
.app-shell { display: grid; grid-template-columns: 196px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #102b43 0%, #0f2940 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  border-right: 1px solid rgba(255,255,255,.05);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 15px 12px;
  min-height: 64px;
  color: #fff;
}
.brand:hover { color: #fff; }
.brand-house {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: #fff;
}
.brand-house svg { width: 34px; height: 34px; stroke-width: 1.4; }
.brand-copy strong, .brand-copy small { display: block; }
.brand-copy strong { font-size: 15px; letter-spacing: .01em; }
.brand-copy small { margin-top: 2px; color: #b8c9d8; font-size: 9px; text-transform: lowercase; }

.nav { padding: 7px 10px 10px; overflow: auto; scrollbar-width: thin; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  color: #d8e6f1;
  padding: 8px 10px;
  border-radius: 6px;
  margin: 2px 0;
  font-size: 12px;
  font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-link.active { color: #fff; background: linear-gradient(90deg, #23547e, #234e75); box-shadow: inset 3px 0 0 #5ca6ff; }
.nav-icon { width: 16px; height: 16px; flex: 0 0 auto; stroke-width: 1.7; }

.sidebar-period { margin: auto 10px 9px; padding: 10px 11px; border: 1px solid rgba(255,255,255,.14); border-radius: 8px; background: rgba(255,255,255,.035); }
.sidebar-period > span { display: block; font-size: 9px; color: #9fb5c7; margin-bottom: 5px; }
.sidebar-period select { width: 100%; background: transparent; border: 0; color: #fff; font-size: 11px; padding: 2px 0; outline: none; }
.sidebar-period option { color: #172337; background: #fff; }
.sidebar-footer { padding: 10px 12px; border-top: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-user { min-width: 0; display: flex; align-items: center; gap: 7px; }
.sidebar-user span:last-child { min-width: 0; }
.sidebar-user strong, .sidebar-user small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user strong { font-size: 10px; }
.sidebar-user small { color: #9fb5c7; font-size: 9px; margin-top: 1px; }
.link-button { border: 0; background: transparent; color: #dce9f3; cursor: pointer; padding: 3px; font-size: 10px; }
.link-button:hover { color: #fff; }

.main { min-width: 0; }
.topbar {
  height: 58px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.menu-button { display: none; border: 0; background: none; font-size: 23px; color: var(--navy); cursor: pointer; }
.topbar-title { font-size: 16px; font-weight: 700; color: #111a29; }
.topbar-spacer { flex: 1; }
.period-picker {
  height: 34px;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 7px 0 9px;
  background: #fff;
}
.period-picker svg { width: 15px; height: 15px; color: #51667a; }
.period-picker select { border: 0; background: transparent; outline: none; color: #26384a; min-width: 125px; font-size: 11px; cursor: pointer; }
.top-icon { width: 34px; height: 34px; display: grid; place-items: center; position: relative; color: #32485c; border-radius: 7px; }
.top-icon:hover { background: #f2f5f8; color: #173b5d; }
.top-icon svg { width: 18px; height: 18px; }
.notification-dot { position: absolute; right: 2px; top: 1px; min-width: 15px; height: 15px; border-radius: 10px; padding: 0 4px; display: grid; place-items: center; background: #ef3f45; color: #fff; border: 2px solid #fff; font-size: 8px; font-weight: 700; line-height: 1; }
.profile-chip { display: flex; align-items: center; gap: 8px; min-width: 125px; }
.profile-chip strong, .profile-chip small { display: block; }
.profile-chip strong { font-size: 10px; color: #27384a; }
.profile-chip small { font-size: 9px; color: var(--muted); margin-top: 1px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #e3e8ed; color: #68798b; font-size: 12px; font-weight: 700; border: 1px solid #d6dee6; }
.avatar-sm { width: 24px; height: 24px; font-size: 9px; }
.content { padding: 12px 16px 24px; max-width: 1780px; margin: 0 auto; }

/* General page UI */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin: 8px 0 16px; }
.page-header h1 { margin: 0 0 4px; font-size: 22px; line-height: 1.2; color: #111a29; }
.muted { color: var(--muted); margin: 0; font-size: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.button { display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 6px; padding: 8px 13px; min-height: 34px; font-weight: 600; font-size: 11px; cursor: pointer; text-decoration: none; transition: transform .12s ease, box-shadow .12s ease, background .12s ease; }
.button:hover { text-decoration: none; transform: translateY(-1px); }
.button.primary { background: #1769aa; color: #fff; box-shadow: 0 3px 8px rgba(23,105,170,.18); }
.button.primary:hover { background: #12598f; color: #fff; }
.button.secondary { background: #fff; border-color: var(--line-strong); color: #24384c; }
.button.secondary:hover { background: #f8fafc; color: #172337; }
.button.danger { background: var(--red); color: #fff; }
.button.full { width: 100%; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-soft); padding: 16px; margin-bottom: 14px; }
.panel h2 { font-size: 14px; margin: 0 0 12px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.panel-header h2 { margin: 0; font-size: 13px; }
.panel-header > a { font-size: 11px; }
.compact-panel { padding: 13px 14px; margin: 0; }

.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stats-grid.four { grid-template-columns: repeat(4, minmax(0,1fr)); }
.stat-card { background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--navy-3); border-radius: 8px; padding: 14px; box-shadow: var(--shadow-soft); }
.stat-card span, .stat-card small { display: block; color: var(--muted); }
.stat-card strong { display: block; font-size: 22px; margin: 6px 0; color: #111a29; }
.stat-card.success { border-left-color: var(--green); }
.stat-card.warning { border-left-color: var(--amber); }
.stat-card.danger { border-left-color: var(--red); }
.dashboard-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.dashboard-grid > .panel { margin: 0; }

.table-wrap { overflow: auto; }
.panel.table-wrap { padding: 0; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th, td { text-align: left; padding: 9px 11px; border-bottom: 1px solid #e7edf2; vertical-align: middle; }
th { font-size: 9px; text-transform: uppercase; letter-spacing: .02em; color: #657588; background: #f9fbfc; font-weight: 700; }
tr:last-child td { border-bottom: 0; }
.list { display: flex; flex-direction: column; }
.list-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid #e9eef3; }
.list-row:last-child { border-bottom: 0; }
.list-row strong, .list-row small { display: block; }
.list-row strong { font-size: 11px; }
.list-row small { color: var(--muted); margin-top: 3px; font-size: 9px; }
.tight-list .list-row { padding: 8px 0; }
.badge { display: inline-flex; padding: 3px 7px; border-radius: 999px; background: #edf2f6; color: #435767; font-size: 9px; white-space: nowrap; }
.badge.ok, .badge.active { background: #e5f5eb; color: #227044; }
.badge.warning, .badge.near-full, .badge.high { background: #fff0d4; color: #945d00; }
.badge.danger, .badge.expired, .badge.emergency, .badge.blacklist { background: #fde5e5; color: #a22929; }
.empty { text-align: center; color: var(--muted); padding: 20px; }
.compact-empty { padding: 18px 8px; font-size: 10px; }

.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 11px; }
.filters input, .filters select, .inline-form input { min-width: 160px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 11px; }

.room-grid { column-width: 260px; column-gap: 8px; }
.room-card { display: inline-block; width: 100%; margin: 0 0 8px; vertical-align: top; break-inside: avoid; background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--green); border-radius: 7px; box-shadow: var(--shadow-soft); overflow: hidden; }
.room-card.near-full { border-top-color: var(--amber); }
.room-card.full, .room-card.over { border-top-color: var(--red); }
.room-card > header { display: flex; justify-content: space-between; align-items: flex-start; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.room-card > header strong { font-size: 17px; }
.room-card > header small { display: block; color: var(--muted); margin-top: 1px; font-size: 8px; }
.room-card > footer { display: flex; justify-content: space-between; padding: 6px 10px; background: #f8fafb; font-size: 9px; }
.room-residents { min-height: 0; padding: 2px 10px; }
.resident-chip { display: flex; justify-content: space-between; gap: 5px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.resident-chip:last-child { border-bottom: 0; }
.resident-chip a { font-weight: 600; font-size: 10px; }
.resident-chip small { display: block; color: var(--muted); margin-top: 1px; font-size: 8px; }
.chip-actions { display: flex; gap: 3px; }
.chip-actions a { display: grid; place-items: center; width: 21px; height: 21px; border-radius: 4px; background: #eef3f6; }
.room-empty { padding: 12px 0; }
.danger-text { color: var(--red); }

.form-panel { max-width: 1000px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 10px; font-weight: 600; color: #3a4d60; }
.field input, .field select, .field textarea, .filters input, .filters select, .inline-form input { width: 100%; border: 1px solid #cdd8e2; border-radius: 6px; padding: 8px 9px; background: #fff; color: var(--text); font-size: 11px; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus, .filters input:focus, .filters select:focus { border-color: #70a5d0; box-shadow: 0 0 0 2px rgba(58,130,185,.09); }
.field textarea { min-height: 96px; resize: vertical; }
.field-checkbox { flex-direction: row; align-items: center; }
.field-checkbox input { width: auto; }
.required, .field-error, .form-errors { color: var(--red); }
.field small { color: var(--muted); font-size: 9px; }
.form-actions { display: flex; gap: 8px; margin-top: 18px; }
.messages { margin-bottom: 12px; }
.message { padding: 9px 12px; border-radius: 6px; background: #e8f3fb; border: 1px solid #b9d8ed; font-size: 11px; }
.message.success { background: #e6f5eb; border-color: #b8dfc5; }
.message.error { background: #fbe7e7; border-color: #e9baba; }
.message.warning { background: #fff1d8; border-color: #ead19d; }
.detail-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.details { display: grid; grid-template-columns: 145px 1fr; gap: 8px; margin: 0; }
.details dt { color: var(--muted); font-size: 10px; }
.details dd { margin: 0; font-weight: 500; font-size: 11px; }

/* Dashboard matching the approved reference */
.dashboard-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 16px; align-items: start; }
.dashboard-main { min-width: 0; }
.dashboard-stats { display: grid; grid-template-columns: repeat(4, minmax(155px, 1fr)); gap: 11px; }
.metric-card {
  min-height: 102px;
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.dashboard-stats > a.metric-card { color:inherit; text-decoration:none; }
.dashboard-stats > a.metric-card:hover { box-shadow:0 5px 16px rgba(22,55,78,.12); transform:translateY(-1px); }
.dashboard-stats > a.metric-card { color:inherit; text-decoration:none; }
.dashboard-stats > a.metric-card:hover { box-shadow:0 5px 16px rgba(22,55,78,.12); transform:translateY(-1px); }
.metric-card > div { position: relative; z-index: 1; min-width: 0; }
.metric-card span { display: block; font-size: 10px; font-weight: 600; color: #4b6175; margin-bottom: 5px; white-space: normal; }
.metric-card strong { display: block; font-size: 25px; line-height: 1.05; color: #111820; font-weight: 700; letter-spacing: -.02em; }
.metric-card small { display: block; margin-top: 5px; font-size: 9px; line-height: 1.35; color: #697c8f; }
.metric-icon { width: 28px; height: 28px; align-self: flex-end; margin: 0 0 2px 8px; flex: 0 0 auto; }
.metric-icon-out { transform: rotate(180deg); }
.metric-blue { background: linear-gradient(135deg,#fff 0%,#f5f9ff 100%); border-color: #cfe0f4; }
.metric-blue span, .metric-blue .metric-icon { color: #2d70dc; }
.metric-green { background: linear-gradient(135deg,#fff 0%,#f0faf3 100%); border-color: #cde7d5; }
.metric-green span, .metric-green .metric-icon { color: #27834f; }
.metric-orange { background: linear-gradient(135deg,#fff 0%,#fff6ef 100%); border-color: #f1d8c3; }
.metric-orange span, .metric-orange .metric-icon { color: #e46d1b; }
.metric-red { background: linear-gradient(135deg,#fff 0%,#fff2f2 100%); border-color: #efcfcf; }
.metric-red span, .metric-red .metric-icon { color: #e13c40; }
.metric-amber { background: linear-gradient(135deg,#fff 0%,#fff8ed 100%); border-color: #f1dfc5; }
.metric-amber span, .metric-amber .metric-icon { color: #bd7114; }
.metric-mint { background: linear-gradient(135deg,#fff 0%,#f1faf6 100%); border-color: #d3e7dd; }
.metric-mint span, .metric-mint .metric-icon { color: #2a8a58; }
.metric-neutral { background: linear-gradient(135deg,#fff 0%,#f7f9fb 100%); }
.metric-neutral span, .metric-neutral .metric-icon { color: #5a6f82; }

.dashboard-panels { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(260px, .95fr); gap: 11px; margin-top: 12px; }
.lower-panels { grid-template-columns: repeat(2, minmax(0,1fr)); }
.dashboard-table-wrap { margin: 0 -2px; }
.dashboard-table { font-size: 9px; }
.dashboard-table th { font-size: 8px; padding: 8px 7px; background: #fff; color: #738496; }
.dashboard-table td { padding: 8px 7px; white-space: nowrap; }
.dashboard-table td:nth-child(3), .dashboard-table td:nth-child(5) { white-space: normal; }
.dashboard-table a { color: #26384c; font-weight: 500; }
.event-type { font-size: 8px; font-weight: 600; }
.event-type.in { color: #24854c; }
.event-type.out { color: #d74141; }
.panel-more { display: inline-flex; align-items: center; gap: 5px; margin-top: 8px; font-size: 9px; color: #2779db; font-weight: 600; }
.panel-more svg { width: 11px; height: 11px; }
.problem-list { min-height: 138px; }
.problem-row { display: flex; align-items: center; gap: 7px; min-height: 27px; padding: 4px 2px; font-size: 9px; color: #4b5d70; }
.problem-row:hover { color: #1d3853; }
.problem-row strong { font-weight: 700; }
.problem-dot { width: 14px; height: 14px; display: grid; place-items: center; border-radius: 4px; border: 1px solid currentColor; font-size: 8px; font-weight: 800; flex: 0 0 auto; }
.problem-row.danger { color: #df3d3d; }
.problem-row.warning { color: #e06c16; }
.problem-row.info { color: #357ad4; }

.dashboard-aside { display: flex; flex-direction: column; gap: 12px; }
.info-card { background: #fff; border: 1px solid #bfd1e3; border-radius: 9px; box-shadow: var(--shadow-soft); padding: 16px; }
.info-card h2 { margin: 0 0 11px; font-size: 13px; color: #17304c; }
.info-card p { margin: 0; font-size: 10px; line-height: 1.6; color: #53687c; }
.month-flow { display: grid; grid-template-columns: 1fr auto 1.35fr auto 1fr; gap: 5px; align-items: center; margin: 15px 0 13px; }
.month-flow form { margin: 0; }
.month-pill { width: 100%; min-height: 30px; border-radius: 7px; display: grid; place-items: center; padding: 5px 7px; border: 1px solid #dce4eb; font-size: 8px; font-weight: 600; text-align: center; }
button.month-pill { cursor: pointer; }
.secondary-pill { background: #f4f6f8; color: #4b5f72; }
.secondary-pill:hover { background: #edf1f4; }
.current-pill { background: #e8f7ee; color: #2d7b4e; border-color: #bee0c9; }
.month-arrow { color: #708396; font-size: 13px; }
.info-divider { height: 1px; background: #dbe4ec; margin: 14px 0; }
.check-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; }
.check-list li { position: relative; padding-left: 19px; color: #53687c; font-size: 9px; line-height: 1.45; }
.check-list li::before { content: "✓"; position: absolute; left: 0; top: 0; width: 13px; height: 13px; display: grid; place-items: center; border-radius: 50%; border: 1px solid #56a974; color: #2d8c53; font-size: 8px; font-weight: 700; }
.quick-card { padding-bottom: 9px; }
.quick-action { display: grid; grid-template-columns: 32px 1fr 14px; align-items: center; gap: 8px; color: #24384b; padding: 9px 0; border-top: 1px solid #edf1f4; }
.quick-action:first-of-type { border-top: 0; }
.quick-action:hover { color: #173b5d; }
.quick-action strong, .quick-action small { display: block; }
.quick-action strong { font-size: 10px; }
.quick-action small { font-size: 8px; color: #778798; margin-top: 2px; }
.quick-icon { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 7px; }
.quick-icon svg { width: 16px; height: 16px; }
.quick-icon.green { background: #e9f6ee; color: #27834f; }
.quick-icon.blue { background: #edf4fd; color: #2e72cf; }
.quick-icon.amber { background: #fff3de; color: #b26b11; }
.quick-icon.slate { background: #eef2f5; color: #50697d; }
.quick-arrow { width: 12px; height: 12px; color: #8ca0b2; }

/* Login and error pages */
.login-page { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg,#0f2a3e,#24597d); }
.login-card { width: min(420px,calc(100% - 32px)); background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 30px 70px rgba(0,0,0,.25); }
.login-card h1 { margin: 18px 0 5px; }
.login-brand { padding: 0; color: var(--text); }
.login-brand .brand-house { background: var(--navy); border-radius: 8px; }
.login-card .field { margin: 14px 0; }
.error-page { min-height: 65vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.error-page > strong { font-size: 84px; color: #d7e1e8; }
.inline-form { display: flex; gap: 7px; }
.nowrap { white-space: nowrap; }

@media (max-width: 1450px) {
  .dashboard-layout { grid-template-columns: minmax(0,1fr) 280px; }
  .dashboard-stats { grid-template-columns: repeat(4,minmax(145px,1fr)); }
  .metric-card { padding: 12px; }
  .metric-card strong { font-size: 22px; }
}
@media (max-width: 1200px) {
  .app-shell { grid-template-columns: 184px minmax(0,1fr); }
  .dashboard-layout { grid-template-columns: 1fr; }
  .dashboard-aside { display: grid; grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: repeat(3,1fr); }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -210px; width: 196px; transition: left .2s; box-shadow: 16px 0 35px rgba(10,30,48,.2); }
  .sidebar.open { left: 0; }
  .menu-button { display: block; }
  .content { padding: 12px; }
  .profile-chip > span:last-child { display: none; }
  .profile-chip { min-width: auto; }
  .dashboard-stats { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dashboard-panels, .lower-panels, .dashboard-aside, .dashboard-grid, .detail-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .topbar { padding: 0 10px; gap: 7px; }
  .topbar-title { font-size: 14px; }
  .period-picker svg { display: none; }
  .period-picker select { min-width: 105px; max-width: 115px; }
  .dashboard-stats, .stats-grid, .stats-grid.four { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .room-grid { column-count: 1; }
  .metric-card { min-height: 92px; }
}

/* Document intake / local OCR */
.scan-security-note { display:flex; gap:10px; align-items:flex-start; margin:0 0 14px; padding:11px 13px; border:1px solid #cfe1ef; border-radius:8px; background:#f5faff; font-size:11px; color:#38546b; }
.scan-security-note strong { white-space:nowrap; color:#174d78; }
.scan-upload-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
.scan-upload-card { position:relative; min-height:220px; padding:20px; }
.scan-upload-card h2 { font-size:16px; margin:2px 0 8px; }
.scan-upload-card p { color:var(--muted); font-size:11px; line-height:1.55; min-height:52px; }
.scan-upload-card input[type="file"] { padding:13px; border:1px dashed #9db5c8; background:#f8fbfd; }
.scan-step { width:27px; height:27px; border-radius:50%; display:grid; place-items:center; background:#173b5d; color:#fff; font-size:11px; font-weight:700; margin-bottom:10px; }
.scan-howto { margin-top:14px; }
.scan-tips { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; }
.scan-tips span { padding:9px 10px; border-radius:6px; background:#f7f9fb; border:1px solid var(--line); color:#4d6173; font-size:10px; }
.intake-layout { display:grid; grid-template-columns:330px minmax(0,1fr); gap:14px; align-items:start; }
.intake-documents { position:sticky; top:72px; min-width:0; }
.scan-preview-card { overflow:hidden; }
.scan-preview-image { display:block; width:100%; max-height:460px; object-fit:contain; border:1px solid var(--line); border-radius:6px; background:#eef2f5; }
.scan-error { margin:10px 0 0; color:var(--red); font-size:10px; line-height:1.4; }
.ocr-field { background:#fff9e9; border:1px solid #f0ddb0; border-radius:7px; padding:8px; }
.ocr-field label::after { content:" OCR"; margin-left:5px; color:#946414; font-size:8px; font-weight:700; }
.scan-confirm-bar { position:sticky; bottom:10px; z-index:15; display:flex; align-items:center; justify-content:space-between; gap:14px; background:#102b43; color:#fff; border-radius:8px; padding:12px 14px; box-shadow:0 8px 28px rgba(15,43,67,.24); }
.scan-confirm-bar strong, .scan-confirm-bar small { display:block; }
.scan-confirm-bar strong { font-size:11px; }
.scan-confirm-bar small { margin-top:3px; color:#bdd0df; font-size:9px; }
.duplicate-warning a { font-weight:700; }
.document-card { padding:10px 0; border-bottom:1px solid var(--line); }
.document-card:last-child { border-bottom:0; }
.document-actions { margin-top:10px; }

@media (max-width: 1050px) {
  .intake-layout { grid-template-columns:1fr; }
  .intake-documents { position:static; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
  .scan-preview-image { max-height:300px; }
}
@media (max-width: 720px) {
  .scan-upload-grid, .scan-tips, .intake-documents { grid-template-columns:1fr; }
  .scan-confirm-bar { position:static; flex-direction:column; align-items:stretch; }
}
.scanner-agent-status { margin:0 0 12px; padding:9px 11px; border:1px solid var(--line); border-radius:6px; background:#fff; color:var(--muted); font-size:10px; }
.scanner-agent-status[data-state="ok"] { background:#edf8f1; border-color:#c8e5d3; color:#276943; }
.scanner-agent-status[data-state="warning"] { background:#fff7e8; border-color:#efd9ac; color:#835915; }
.scanner-agent-status[data-state="error"] { background:#fdecec; border-color:#efc1c1; color:#9e3232; }
.scanner-agent-status[data-state="working"] { background:#eef6fd; border-color:#c8dfef; color:#315f82; }
.scanner-button { margin-top:10px; }
.scanner-button:disabled { opacity:.55; cursor:not-allowed; transform:none; }

/* Single-PDF document intake */
.scan-packet-card { max-width: 980px; }
.scan-packet-rules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.scan-packet-rules span { display: block; padding: 12px 14px; border: 1px solid #dbe5ef; border-radius: 10px; background: #f8fbfd; line-height: 1.45; }
.packet-page-list { display: grid; gap: 7px; }
.packet-page-row { display: grid; grid-template-columns: 64px 1fr; gap: 8px; align-items: center; text-decoration: none; padding: 9px 10px; border: 1px solid #e3eaf1; border-radius: 8px; background: #fff; color: inherit; }
.packet-page-row:hover { background: #f4f8fb; border-color: #cbd8e5; }
.packet-page-row span { color: #718096; font-size: 12px; }
.packet-page-row strong { font-size: 13px; font-weight: 600; }
@media (max-width: 760px) {
  .scan-packet-rules { grid-template-columns: 1fr; }
  .packet-page-row { grid-template-columns: 56px 1fr; }
}

/* Separate-document OCR intake */
.scanner-status-line { display:flex; align-items:center; gap:8px; margin:0 0 14px; padding:10px 12px; border:1px solid var(--line); border-radius:8px; background:#fff; font-size:11px; }
.scanner-dot { width:8px; height:8px; border-radius:50%; background:#9aa9b5; }
.scanner-status-line:has([data-state="ok"]) .scanner-dot { background:#2e9b68; }
.scanner-status-line:has([data-state="warning"]) .scanner-dot { background:#d59a27; }
.scanner-status-line:has([data-state="offline"]), .scanner-status-line:has([data-state="error"]) { border-color:#f0c8c4; background:#fff8f7; }
.separate-doc-grid { align-items:stretch; }
.separate-doc-grid .scan-upload-card { min-height:310px; display:flex; flex-direction:column; }
.separate-doc-grid .scan-upload-card .form-field { margin-top:auto; }
.important-scan-card { border-top:3px solid #1d6fa5; }
.migration-priority-card { border-top-color:#2e9b68; background:linear-gradient(180deg,#fbfffd 0,#fff 40%); }
.scan-button { margin-top:8px; width:100%; }
.recognition-result { margin-top:10px; padding:9px 10px; border-radius:7px; background:#f5f7f9; color:#5d6b78; font-size:10px; line-height:1.45; min-height:36px; }
.recognition-result[data-state="working"] { background:#f3f8fc; color:#245779; }
.recognition-result[data-state="ok"] { background:#eef9f3; color:#216f4d; border:1px solid #cdebdc; }
.recognition-result[data-state="error"] { background:#fff2f1; color:#a43731; border:1px solid #f0cfcc; }
.ocr-result-fields { margin:7px 0 0; display:grid; gap:3px; }
.ocr-result-fields div { display:grid; grid-template-columns:minmax(110px,.8fr) 1.2fr; gap:7px; }
.ocr-result-fields strong { font-weight:600; }
.scan-quality-note { margin:12px 0 0; }
.scan-quality { margin:0 0 8px; color:var(--muted); font-size:10px; }
.ocr-mini-fields { display:grid; grid-template-columns:minmax(90px,.9fr) 1.1fr; gap:4px 8px; margin:10px 0 0; padding-top:9px; border-top:1px solid var(--line); font-size:9px; }
.ocr-mini-fields dt { color:var(--muted); }
.ocr-mini-fields dd { margin:0; overflow-wrap:anywhere; }
.fio-source-message { margin-bottom:14px; }
.migration-fio-panel { border-top:3px solid #2e9b68; }
@media (max-width:900px) { .separate-doc-grid .scan-upload-card { min-height:0; } }
.secondary-side-scan { margin-top:10px; border-top:1px solid var(--line); padding-top:9px; }
.secondary-side-scan summary { cursor:pointer; color:#365c78; font-size:10px; font-weight:600; }
.secondary-side-scan label { display:block; margin:9px 0 5px; color:var(--muted); font-size:9px; }
.secondary-side-scan input[type="file"] { width:100%; padding:9px; border:1px dashed #b7c7d4; background:#fbfcfd; }
.row-done td { background:#e9f8ef; color:#277447; }
.task-reminder[hidden] { display:none; }
.task-reminder { position:fixed; inset:0; z-index:1000; display:grid; place-items:center; padding:20px; background:rgba(8,25,40,.62); }
.task-reminder-card { width:min(620px,100%); padding:30px; border-radius:14px; background:#fff; box-shadow:0 24px 80px rgba(0,0,0,.32); text-align:center; }
.task-reminder-icon { width:64px; height:64px; margin:0 auto 14px; display:grid; place-items:center; border-radius:50%; background:#fff0d7; color:#bd6900; font-size:38px; font-weight:800; }
.task-reminder-card h2 { margin:0 0 8px; font-size:25px; }
.task-reminder-card p { color:var(--muted); }
.task-reminder-list { display:grid; gap:8px; margin:18px 0; text-align:left; }
.task-reminder-list a { display:block; padding:12px 14px; border:1px solid #efd9ac; border-radius:8px; background:#fff8e9; color:#744b0a; font-weight:700; }
.task-reminder-card .button { min-width:130px; font-size:16px; }
.task-reminder-card small { display:block; margin-top:12px; color:var(--muted); }
