:root {
  color-scheme: light;
  font-family: "Inter", Arial, sans-serif;
  color: #191716;
  background: #fbfaf7;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --wine: #74102f;
  --wine-dark: #52091f;
  --wine-soft: #f6e9ec;
  --wine-faint: #fbf4f5;
  --ink: #191716;
  --muted: #706b68;
  --line: #ddd8d2;
  --line-dark: #c9c2bc;
  --paper: #fffefa;
  --ivory: #fbfaf7;
  --stone: #f4f1ed;
  --success: #2d684f;
  --danger: #9a2f3d;
  --serif: "DM Serif Display", Georgia, serif;
  --topbar: 112px;
  --sidebar: 238px;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--ivory); }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--ivory); -webkit-font-smoothing: antialiased; }
html[data-app-mode="standalone"], html[data-app-mode="standalone"] body { height: 100%; overscroll-behavior-y: none; background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:not(:disabled), select:not(:disabled) { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(116, 16, 47, 0.22); outline-offset: 2px; }
::selection { color: #fff; background: var(--wine); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.wordmark { display: inline-flex; flex-direction: column; align-items: flex-start; width: max-content; color: var(--wine); }
.wordmark__name { font-family: var(--serif); font-size: 48px; line-height: .92; letter-spacing: .035em; }
.wordmark__rule { width: 100%; height: 1px; margin: 10px 0 7px; background: currentColor; opacity: .58; }
.wordmark__descriptor { align-self: center; font-size: 11px; font-weight: 600; line-height: 1; letter-spacing: .48em; text-transform: uppercase; transform: translateX(.24em); }
.wordmark--light { color: #fff9f2; }
.wordmark--compact .wordmark__name { font-size: 38px; }
.wordmark--compact .wordmark__rule { margin: 7px 0 5px; }
.wordmark--compact .wordmark__descriptor { font-size: 9px; }
.eyebrow { display: inline-block; color: var(--wine); font-size: 12px; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; }

.primary-button, .secondary-button, .text-button, .text-link, .inline-action, .icon-text-button, .icon-button, .input-icon-button { border: 0; background: none; }
.primary-button { display: inline-flex; min-height: 52px; align-items: center; justify-content: center; gap: 10px; padding: 0 24px; border: 1px solid var(--wine); border-radius: 3px; color: #fff; background: var(--wine); font-size: 15px; font-weight: 600; transition: background 160ms ease, border-color 160ms ease, transform 160ms ease; }
.primary-button:hover:not(:disabled) { border-color: var(--wine-dark); background: var(--wine-dark); transform: translateY(-1px); }
.primary-button:disabled { opacity: .48; cursor: not-allowed; }
.secondary-button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; border: 1px solid var(--line-dark); border-radius: 3px; color: var(--ink); background: var(--paper); font-size: 14px; font-weight: 600; }
.secondary-button:hover { border-color: var(--wine); color: var(--wine); }
.secondary-button:disabled { border-color: var(--line); color: var(--muted); background: var(--stone); cursor: default; opacity: .78; }
.secondary-button--danger:hover { border-color: var(--danger); color: var(--danger); }
.text-button, .text-link { padding: 0; color: var(--wine); font-size: 14px; font-weight: 500; text-decoration: underline; text-underline-offset: 4px; }
.icon-button, .input-icon-button { display: inline-flex; width: 42px; height: 42px; align-items: center; justify-content: center; border-radius: 50%; }
.icon-button:hover, .input-icon-button:hover { color: var(--wine); background: var(--wine-faint); }

.login-page { display: grid; min-height: 100vh; grid-template-columns: minmax(380px, .88fr) minmax(560px, 1.12fr); background: var(--paper); }
.login-brand { position: relative; display: flex; min-height: 100vh; align-items: center; justify-content: center; overflow: hidden; color: #fff; background: var(--wine); }
.login-brand::after { position: absolute; right: -20%; bottom: -24%; width: 80%; height: 43%; border: 1px solid rgba(255,255,255,.2); border-radius: 50%; content: ""; }
.login-brand__content { position: relative; z-index: 1; display: flex; width: min(410px,72%); min-height: 450px; flex-direction: column; justify-content: space-between; }
.login-brand__institution { padding-top: 26px; border-top: 1px solid rgba(255,255,255,.44); }
.login-brand__institution p { margin: 0 0 8px; font-size: 17px; line-height: 1.4; }
.login-brand__institution p:last-child { font-size: 13px; font-weight: 600; letter-spacing: .19em; }
.login-form-area { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 56px; background: var(--paper); }
.login-form { display: grid; width: min(440px,100%); gap: 22px; }
.login-form__heading { margin-bottom: 12px; }
.login-form__heading h1 { margin: 14px 0 12px; font-family: var(--serif); font-size: clamp(39px,3.3vw,55px); font-weight: 400; line-height: 1.06; letter-spacing: -.015em; }
.login-form__heading p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.6; }

.field { display: grid; gap: 9px; }
.field > span:first-child, .field legend { color: #312e2c; font-size: 13px; font-style: normal; font-weight: 600; }
.field em { margin-left: 4px; color: var(--muted); font-size: 12px; font-style: normal; font-weight: 400; }
.field > input, .field > textarea, .modal-form .field > input { width: 100%; min-height: 50px; padding: 0 14px; border: 1px solid var(--line-dark); border-radius: 3px; color: var(--ink); background: var(--paper); }
.field > textarea { min-height: 92px; padding-top: 13px; resize: vertical; }
.field > input:focus, .field > textarea:focus, .input-shell:focus-within, .select-shell--field:focus-within { border-color: var(--wine); }
.input-shell { display: grid; min-height: 54px; align-items: center; grid-template-columns: 1fr auto; gap: 8px; padding: 0 8px 0 15px; border: 1px solid var(--line-dark); border-radius: 3px; color: var(--muted); background: #fff; }
.input-shell input { width: 100%; height: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; }
.input-shell input::placeholder, .field input::placeholder, .field textarea::placeholder, .search-field input::placeholder { color: #aaa39e; }
.input-icon-button { width: 38px; height: 38px; }
.login-submit { width: 100%; margin-top: 6px; }
.login-forgot { justify-self: center; }
.secure-note { display: inline-flex; align-items: center; justify-content: center; gap: 7px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.form-message { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 3px; font-size: 13px; line-height: 1.45; }
.form-message svg { flex: 0 0 auto; }
.form-message--error { color: #7e1f2f; background: #fae9ec; }
.form-message--success { color: var(--success); background: #eaf4ef; }

.app-shell { display: grid; min-height: 100vh; grid-template-columns: var(--sidebar) minmax(0,1fr); grid-template-rows: var(--topbar) minmax(calc(100vh - var(--topbar)),auto); background: var(--ivory); }
.topbar { position: sticky; z-index: 30; top: 0; display: grid; min-width: 0; grid-column: 1/-1; grid-row: 1; grid-template-columns: var(--sidebar) minmax(0,1fr) auto; align-items: center; border-bottom: 1px solid var(--line); background: rgba(255,254,250,.97); }
.topbar__brand { display: flex; height: 100%; align-items: center; padding-left: 52px; }
.topbar__context { display: flex; min-width: 0; align-items: center; gap: 22px; padding-left: 56px; font-size: 14px; }
.topbar__context i { width: 1px; height: 24px; background: var(--line-dark); }
.topbar__context strong { color: var(--wine); font-weight: 500; }
.topbar__actions { position: relative; display: flex; align-items: center; gap: 8px; padding-right: 24px; }
.topbar-install-button { display: inline-flex; min-height: 42px; align-items: center; gap: 8px; padding: 0 12px; border: 0; border-radius: 3px; color: var(--wine); background: transparent; font-size: 12px; font-weight: 600; }
.topbar-install-button:hover { background: var(--wine-faint); }
.profile-button { display: flex; max-width: 260px; align-items: center; gap: 10px; margin-right: 0; padding: 9px 10px; border: 0; border-radius: 3px; background: transparent; text-align: left; }
.profile-button:hover { background: var(--wine-faint); }
.profile-button > span:nth-child(2) { display: grid; gap: 2px; }
.profile-button strong, .profile-button small { overflow: hidden; max-width: 155px; text-overflow: ellipsis; white-space: nowrap; }
.profile-button strong { font-size: 13px; }
.profile-button small { color: var(--muted); font-size: 11px; }
.avatar { display: inline-flex; width: 38px; height: 38px; flex: 0 0 auto; align-items: center; justify-content: center; border: 0; border-radius: 50%; color: #fff; background: var(--wine); font-size: 12px; font-weight: 600; letter-spacing: .03em; }
.profile-menu { position: absolute; z-index: 50; top: 85px; right: 34px; width: 268px; padding: 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); box-shadow: 0 18px 42px rgba(44,30,27,.14); }
.profile-menu > div { display: grid; gap: 5px; padding: 12px; border-bottom: 1px solid var(--line); }
.profile-menu strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; }
.profile-menu span { color: var(--muted); font-size: 12px; }
.profile-menu button { display: flex; width: 100%; align-items: center; gap: 9px; margin-top: 5px; padding: 11px 12px; border: 0; background: transparent; font-size: 13px; text-align: left; }
.profile-menu button:hover { color: var(--wine); background: var(--wine-faint); }

.sidebar { position: sticky; top: var(--topbar); display: flex; height: calc(100vh - var(--topbar)); flex-direction: column; justify-content: space-between; grid-column: 1; grid-row: 2; padding: 58px 22px 30px 0; border-right: 1px solid var(--line); background: var(--ivory); }
.sidebar nav { display: grid; gap: 11px; }
.sidebar nav button { position: relative; min-height: 50px; padding: 0 15px 0 52px; border: 0; color: #33302e; background: transparent; font-size: 14px; text-align: left; }
.sidebar nav button:hover { color: var(--wine); }
.sidebar nav button.is-active { color: var(--wine); font-weight: 600; }
.sidebar nav button.is-active::before { position: absolute; top: 8px; bottom: 8px; left: 22px; width: 4px; background: var(--wine); content: ""; }
.sidebar__footer { display: flex; align-items: flex-start; gap: 10px; padding-left: 48px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.sidebar__footer strong { color: var(--ink); font-weight: 500; }
.mobile-header, .mobile-nav { display: none; }
.app-content { min-width: 0; grid-column: 2; grid-row: 2; padding: 72px clamp(42px,5.1vw,84px) 88px; background: var(--paper); }
.screen-enter { width: min(1160px,100%); margin: 0 auto; animation: screen-in 240ms ease both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.overview-screen { width: min(1100px,100%); }
.overview-hero { display: flex; align-items: center; justify-content: space-between; gap: 40px; padding: 18px 0 55px; }
.overview-hero h1 { margin: 0; font-family: var(--serif); font-size: clamp(52px,5.25vw,82px); font-weight: 400; line-height: .98; letter-spacing: -.018em; }
.overview-hero h1 span { color: var(--wine); }
.overview-hero .primary-button { min-width: 284px; min-height: 58px; }
.overview-facts { display: grid; grid-template-columns: 1.08fr .92fr; border-top: 1px solid var(--line-dark); border-bottom: 1px solid var(--line); }
.composition-block, .critical-block { min-height: 210px; padding: 30px 0 32px; }
.composition-block { padding-right: 48px; border-right: 1px solid var(--line-dark); }
.critical-block { padding-left: 48px; }
.composition-block h2, .critical-block h2, .recent-section h2, .history-section h2, .report-breakdown h2, .settings-group h2 { margin: 0; font-size: 18px; font-weight: 600; }
.composition-numbers { display: flex; align-items: center; gap: 26px; margin-top: 31px; }
.composition-numbers > div { display: flex; align-items: baseline; gap: 10px; }
.composition-numbers strong { color: var(--wine); font-family: var(--serif); font-size: 54px; font-weight: 400; line-height: 1; }
.composition-numbers span:not(.vertical-rule) { color: #3f3b39; font-size: 13px; }
.vertical-rule { width: 1px; height: 48px; background: var(--line-dark); }
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.section-title-row > span { color: var(--muted); font-size: 12px; }
.critical-block .section-title-row { padding-bottom: 15px; border-bottom: 2px solid var(--wine); }
.critical-list { display: grid; margin: 14px 0; }
.critical-row { display: grid; min-height: 38px; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 20px; font-size: 13px; }
.critical-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.critical-row strong { color: var(--wine); font-weight: 600; }
.recent-section { padding-top: 42px; }
.recent-section > .section-title-row { margin-bottom: 14px; }
.install-nudge { display: none; }

.movement-list { border-top: 1px solid var(--line-dark); }
.movement-row { display: grid; width: 100%; min-height: 82px; grid-template-columns: 132px minmax(0,1fr) minmax(150px,.3fr) 24px; align-items: center; gap: 20px; padding: 13px 3px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.movement-row:disabled { color: inherit; cursor: default; }
.movement-row:not(:disabled):hover { background: var(--wine-faint); }
.movement-row time { display: grid; gap: 4px; color: var(--wine); font-size: 12px; }
.movement-row time strong { font-size: 13px; font-weight: 600; }
.movement-row__description { display: flex; min-width: 0; flex-wrap: wrap; gap: 6px; font-size: 13px; line-height: 1.5; }
.movement-row__description strong { font-weight: 600; }
.movement-row__person { display: grid; gap: 4px; }
.movement-row__person span { color: var(--muted); font-size: 11px; }
.movement-row__person strong { font-size: 13px; font-weight: 500; }
.movement-row__caret { color: var(--muted); }
.movement-list--compact .movement-row { grid-template-columns: 132px minmax(0,1fr) minmax(150px,.3fr); }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 40px; padding-bottom: 34px; border-bottom: 1px solid var(--line-dark); }
.page-heading h1 { margin: 9px 0 8px; font-family: var(--serif); font-size: clamp(44px,4.2vw,62px); font-weight: 400; line-height: 1; }
.page-heading p { max-width: 640px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 28px 0 30px; }
.search-field { display: flex; width: min(390px,100%); min-height: 48px; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--line-dark); color: var(--muted); }
.search-field:focus-within { border-color: var(--wine); color: var(--wine); }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 14px; }
.segmented-control { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 4px; }
.segmented-control button { min-height: 37px; padding: 0 14px; border: 0; border-radius: 2px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 500; }
.segmented-control button.is-active { color: #fff; background: var(--wine); }
.select-shell { display: inline-flex; min-height: 44px; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--line-dark); border-radius: 3px; color: var(--muted); background: var(--paper); }
.select-shell select { min-width: 110px; border: 0; outline: 0; color: var(--ink); background: transparent; appearance: none; }
.select-shell--field { display: grid; width: 100%; min-height: 50px; grid-template-columns: minmax(0,1fr) auto; padding: 0 13px; }
.select-shell--field select { width: 100%; }
.select-shell--plain { min-height: 39px; justify-self: start; padding-left: 11px; }

.product-matrices { display: grid; gap: 30px; }
.product-matrix { border-top: 3px solid var(--wine); background: var(--paper); }
.product-matrix > header { display: flex; min-height: 94px; align-items: center; justify-content: space-between; gap: 25px; padding: 15px 4px; border-bottom: 1px solid var(--line-dark); }
.product-matrix > header > div:first-child { display: grid; gap: 7px; }
.product-matrix > header span { color: var(--muted); font-size: 11px; font-weight: 500; letter-spacing: .07em; text-transform: uppercase; }
.product-matrix h2 { margin: 0; font-size: 22px; font-weight: 600; }
.matrix-total { display: flex; align-items: baseline; gap: 7px; }
.matrix-total strong { color: var(--wine); font-family: var(--serif); font-size: 38px; font-weight: 400; }
.stock-table-wrap { width: 100%; overflow-x: auto; }
.stock-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-variant-numeric: tabular-nums; }
.stock-table th, .stock-table td { height: 57px; padding: 8px 18px; border-bottom: 1px solid var(--line); text-align: center; }
.stock-table thead th { height: 49px; color: var(--muted); font-size: 12px; font-weight: 500; }
.stock-table th:first-child { width: 26%; text-align: left; }
.stock-table tbody th { font-size: 14px; font-weight: 600; }
.stock-table tbody td { position: relative; font-family: var(--serif); font-size: 25px; }
.stock-cell--critical { color: var(--wine); background: var(--wine-faint); }
.stock-cell--critical::after { position: absolute; top: 50%; right: 18%; width: 4px; height: 4px; border-radius: 50%; background: var(--wine); content: ""; transform: translateY(-50%); }
.single-stock-row { display: grid; min-height: 92px; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 30px; padding: 0 5px; border-bottom: 1px solid var(--line); }
.single-stock-row strong { color: var(--wine); font-family: var(--serif); font-size: 42px; font-weight: 400; }
.critical-caption, .muted-caption { font-size: 12px; }
.critical-caption { color: var(--wine); }
.muted-caption { color: var(--muted); }
.inline-action { display: flex; align-items: center; gap: 8px; margin: 28px 0 0 auto; padding: 8px 0; color: var(--wine); font-size: 13px; font-weight: 500; }
.toolbar--movements { justify-content: flex-start; }
.toolbar--movements .search-field { margin-right: auto; }
.history-section { padding-top: 8px; }
.history-section > .section-title-row { margin-bottom: 14px; }

.entity-list { margin-top: 36px; border-top: 2px solid var(--wine); }
.entity-list__header, .entity-row { display: grid; align-items: center; gap: 20px; }
.entity-list__header { min-height: 50px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.entity-row { min-height: 86px; padding: 13px 0; border-top: 1px solid var(--line); font-size: 13px; }
.entity-row > div:first-child:not(.user-identity) { display: grid; gap: 6px; }
.entity-row > div:first-child span, .user-identity > div span { color: var(--muted); font-size: 11px; }
.entity-row code { color: var(--muted); font-family: "Inter",sans-serif; font-size: 11px; letter-spacing: .04em; }
.product-list-grid { grid-template-columns: minmax(250px,1.3fr) minmax(110px,.55fr) minmax(130px,.65fr) 90px minmax(150px,auto); }
.user-list-grid { grid-template-columns: minmax(260px,1.2fr) minmax(140px,.55fr) minmax(130px,.5fr) minmax(100px,.35fr); }
.entity-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.icon-text-button { display: inline-flex; min-height: 40px; align-items: center; gap: 7px; padding: 0 10px; color: var(--muted); font-size: 12px; }
.icon-text-button:hover { color: var(--wine); }
.tabular-number { font-variant-numeric: tabular-nums; }
.user-identity { display: flex; min-width: 0; align-items: center; gap: 12px; }
.user-identity > div { display: grid; min-width: 0; gap: 5px; }
.user-identity strong, .user-identity span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-text { display: inline-flex; align-items: center; gap: 7px; color: var(--success); font-size: 12px; }
.status-text i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.permission-note, .audit-note { display: flex; align-items: flex-start; gap: 14px; margin-top: 30px; padding: 18px 20px; color: #4a403b; background: var(--wine-faint); }
.permission-note svg, .audit-note svg { flex: 0 0 auto; color: var(--wine); }
.permission-note div { display: grid; gap: 7px; }
.permission-note p { max-width: 760px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.report-hero { display: grid; grid-template-columns: .8fr .8fr 1.4fr; margin-top: 34px; border-top: 2px solid var(--wine); border-bottom: 1px solid var(--line-dark); }
.report-hero > div { display: flex; min-height: 180px; flex-direction: column; justify-content: center; padding: 24px 35px; border-right: 1px solid var(--line); }
.report-hero > div:first-child { padding-left: 3px; }
.report-hero > div:last-child { border-right: 0; }
.report-hero span { color: var(--muted); font-size: 12px; }
.report-hero strong { margin: 9px 0 1px; color: var(--wine); font-family: var(--serif); font-size: 52px; font-weight: 400; line-height: 1; }
.report-hero .report-name { max-width: 300px; font-family: "Inter",sans-serif; font-size: 22px; font-weight: 600; line-height: 1.15; }
.report-hero p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.report-breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 65px; margin-top: 45px; }
.report-breakdown h2 { margin-bottom: 26px; }
.report-lines { display: grid; gap: 20px; }
.report-lines > div { display: grid; grid-template-columns: 90px minmax(0,1fr) 26px; align-items: center; gap: 14px; font-size: 12px; }
.line-fill { height: 3px; background: var(--line); }
.line-fill i { display: block; height: 100%; background: var(--wine); }
.report-lines strong { text-align: right; }
.critical-list--report { margin-top: -7px; }
.critical-list--report .critical-row { min-height: 43px; border-bottom: 1px solid var(--line); }

.settings-screen { max-width: 950px; }
.settings-group { margin-top: 36px; border-top: 2px solid var(--wine); }
.settings-group__title { display: flex; align-items: flex-start; gap: 13px; padding: 24px 0 18px; border-bottom: 1px solid var(--line); }
.settings-group__title svg { color: var(--wine); }
.settings-group__title div { display: grid; gap: 5px; }
.settings-group__title p { margin: 0; color: var(--muted); font-size: 12px; }
.toggle-row, .settings-action-row { display: flex; min-height: 78px; align-items: center; justify-content: space-between; gap: 30px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.toggle-row > div, .settings-action-row > div { display: grid; gap: 6px; }
.toggle-row strong, .settings-action-row strong { font-size: 13px; }
.toggle-row > div span, .settings-action-row > div span { color: var(--muted); font-size: 12px; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-visual { position: relative; width: 44px; height: 24px; flex: 0 0 auto; border-radius: 20px; background: var(--line-dark); transition: background 150ms ease; }
.toggle-visual i { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 150ms ease; }
.toggle-row input:checked + .toggle-visual { background: var(--wine); }
.toggle-row input:checked + .toggle-visual i { transform: translateX(20px); }
.toggle-row input:focus-visible + .toggle-visual { outline: 3px solid rgba(116,16,47,.22); outline-offset: 3px; }

.install-guide { display: grid; gap: 24px; }
.install-guide__identity { display: flex; align-items: center; gap: 15px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.install-guide__identity img { width: 62px; height: 62px; border-radius: 14px; box-shadow: 0 8px 22px rgba(82,9,31,.14); }
.install-guide__identity div { display: grid; gap: 5px; }
.install-guide__identity strong { font-family: var(--serif); color: var(--wine); font-size: 23px; font-weight: 400; }
.install-guide__identity span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.install-steps { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.install-steps li { display: grid; grid-template-columns: 42px minmax(0,1fr); gap: 13px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.install-steps li > span { display: flex; width: 38px; height: 38px; align-items: center; justify-content: center; border-radius: 50%; color: var(--wine); background: var(--wine-faint); }
.install-steps li > div { display: grid; gap: 5px; }
.install-steps strong { font-size: 13px; line-height: 1.4; }
.install-steps p, .install-guide__note { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.install-guide__note { padding-left: 55px; }

.empty-state { display: flex; min-height: 190px; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); text-align: center; }
.empty-state svg { color: var(--wine); }
.empty-state strong { color: var(--ink); }
.empty-state span { font-size: 13px; }

.modal-backdrop, .drawer-backdrop, .more-backdrop { position: fixed; z-index: 100; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(29,18,17,.46); backdrop-filter: blur(3px); animation: fade-in 160ms ease both; }
@keyframes fade-in { from { opacity: 0; } }
.modal { width: min(560px,100%); max-height: min(780px,calc(100vh - 48px)); overflow: auto; border-radius: 4px; background: var(--paper); box-shadow: 0 24px 70px rgba(44,24,22,.24); animation: modal-in 200ms ease both; }
.modal--wide { width: min(740px,100%); }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.99); } }
.modal__header, .drawer-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding: 30px 34px 24px; border-bottom: 1px solid var(--line); }
.modal__header > div, .drawer-header > div { display: grid; gap: 7px; }
.modal__header h2, .drawer-header h2 { margin: 0; font-family: var(--serif); font-size: 34px; font-weight: 400; line-height: 1.08; }
.modal__header p, .drawer-header p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.modal__body { padding: 28px 34px 32px; }
.modal__footer { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 18px 34px; border-top: 1px solid var(--line); background: var(--stone); }
.modal__footer .primary-button { min-height: 44px; }
.modal-form { display: grid; gap: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field--small { max-width: 240px; }
.details-list { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line-dark); }
.details-list > div { display: grid; min-height: 74px; align-content: center; gap: 7px; padding: 12px 16px 12px 0; border-bottom: 1px solid var(--line); }
.details-list > div:nth-child(even) { padding-left: 18px; border-left: 1px solid var(--line); }
.details-list .details-list__wide { grid-column: 1/-1; padding-left: 0; border-left: 0; }
.details-list span { color: var(--muted); font-size: 11px; }
.details-list strong { font-size: 13px; font-weight: 500; line-height: 1.45; }
.audit-note { margin-top: 22px; font-size: 12px; line-height: 1.5; }

.drawer-backdrop { justify-content: flex-end; padding: 0; }
.movement-drawer { width: min(610px,100%); height: 100%; overflow-y: auto; background: var(--paper); box-shadow: -20px 0 65px rgba(44,24,22,.21); animation: drawer-in 240ms ease both; }
@keyframes drawer-in { from { transform: translateX(22px); opacity: 0; } }
.drawer-header { position: sticky; z-index: 4; top: 0; padding: 28px 34px 23px; background: rgba(255,254,250,.98); }
.movement-form { display: grid; gap: 24px; padding: 26px 34px 36px; }
.movement-type-field, .choice-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.movement-type-field legend, .choice-field legend { margin-bottom: 10px; color: #312e2c; font-size: 13px; font-weight: 600; }
.movement-type-field > div, .choice-field > div { display: flex; flex-wrap: wrap; gap: 8px; }
.movement-type-field button, .choice-field button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 7px; padding: 0 14px; border: 1px solid var(--line-dark); border-radius: 3px; background: var(--paper); font-size: 12px; font-weight: 500; }
.movement-type-field button.is-active, .choice-field button.is-active { border-color: var(--wine); color: #fff; background: var(--wine); }
.form-grid--quantity { grid-template-columns: .7fr 1.3fr; }
.quantity-control { display: grid; min-height: 50px; grid-template-columns: 45px minmax(40px,1fr) 45px; border: 1px solid var(--line-dark); border-radius: 3px; overflow: hidden; }
.quantity-control button { display: flex; align-items: center; justify-content: center; border: 0; background: var(--stone); }
.quantity-control button:hover { color: var(--wine); background: var(--wine-faint); }
.quantity-control input { width: 100%; border: 0; outline: 0; text-align: center; appearance: textfield; }
.quantity-control input::-webkit-inner-spin-button { appearance: none; }
.movement-summary { display: flex; min-height: 88px; align-items: center; justify-content: center; gap: 38px; padding: 15px; color: var(--wine); background: var(--wine-faint); }
.movement-summary > div { display: grid; gap: 4px; text-align: center; }
.movement-summary span { color: var(--muted); font-size: 11px; }
.movement-summary strong { font-family: var(--serif); font-size: 32px; font-weight: 400; }
.movement-summary--error { color: var(--danger); background: #fae9ec; }
.drawer-submit { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 8px; }
.drawer-submit > div { display: grid; gap: 5px; }
.drawer-submit > div span { color: var(--muted); font-size: 11px; }
.drawer-submit > div strong { font-size: 13px; }
.minimum-grid { display: grid; grid-template-columns: repeat(3,1fr); border-top: 1px solid var(--line-dark); }
.minimum-grid label { display: grid; min-height: 70px; grid-template-columns: minmax(0,1fr) 58px; align-items: center; gap: 10px; padding: 10px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 12px; }
.minimum-grid label:nth-child(3n) { border-right: 0; }
.minimum-grid input { width: 58px; height: 38px; border: 1px solid var(--line-dark); border-radius: 3px; text-align: center; }
.toast { position: fixed; z-index: 200; right: 30px; bottom: 28px; display: flex; max-width: 420px; min-height: 52px; align-items: center; gap: 10px; padding: 12px 17px; border: 1px solid #c8dbd0; border-radius: 4px; color: var(--success); background: #f4fbf7; box-shadow: 0 13px 35px rgba(37,60,48,.14); font-size: 13px; animation: toast-in 240ms ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
.more-backdrop { display: none; }

@media (max-width: 1120px) {
  :root { --sidebar: 205px; }
  .topbar__brand { padding-left: 35px; }
  .topbar__context { padding-left: 40px; }
  .topbar__actions { padding-right: 14px; }
  .topbar-install-button span { display: none; }
  .topbar-install-button { width: 42px; justify-content: center; padding: 0; }
  .sidebar nav button { padding-left: 42px; }
  .sidebar nav button.is-active::before { left: 16px; }
  .sidebar__footer { padding-left: 36px; }
  .app-content { padding-inline: 42px; }
  .overview-facts { grid-template-columns: 1fr; }
  .composition-block { border-right: 0; }
  .critical-block { padding-left: 0; border-top: 1px solid var(--line); }
  .product-list-grid { grid-template-columns: minmax(220px,1fr) 110px 90px minmax(140px,auto); }
  .product-list-grid > :nth-child(3) { display: none; }
}

@media (max-width: 820px) {
  :root { --topbar: 72px; }
  .login-page { display: block; min-height: 100dvh; background: var(--paper); }
  .login-brand { display: flex; min-height: 350px; padding: 38px 28px; }
  .login-brand::after { display: none; }
  .login-brand__content { width: 100%; min-height: 224px; align-items: center; justify-content: center; gap: 42px; }
  .login-brand .wordmark__name { font-size: 48px; }
  .login-brand__institution { align-self: center; padding-top: 0; border-top: 0; text-align: center; }
  .login-brand__institution p { margin-bottom: 4px; font-size: 13px; }
  .login-brand__institution p:last-child { font-size: 10px; }
  .login-form-area { display: block; min-height: 0; padding: 28px 26px 32px; }
  .login-form { margin: 0 auto; gap: 16px; }
  .login-form__heading { margin-bottom: 2px; }
  .login-form__heading .eyebrow, .login-form__heading p { display: none; }
  .login-form__heading h1 { margin: 0; color: var(--wine); font-size: 32px; line-height: 1.08; }

  .app-shell { display: block; min-height: 100dvh; padding: 72px 0 88px; background: var(--paper); }
  .topbar, .sidebar { display: none; }
  .mobile-header { position: fixed; z-index: 40; top: 0; right: 0; left: 0; display: flex; height: 72px; align-items: center; justify-content: space-between; padding: 0 20px; border-bottom: 1px solid var(--line); background: rgba(255,254,250,.97); backdrop-filter: blur(14px); }
  .mobile-header .wordmark--compact .wordmark__name { font-size: 24px; }
  .mobile-header .wordmark__rule { width: 100%; margin: 4px 0 3px; }
  .mobile-header .wordmark__descriptor { font-size: 6px; }
  .mobile-header .avatar { width: 36px; height: 36px; }
  .app-content { display: block; padding: 26px 20px 40px; }
  .mobile-nav { position: fixed; z-index: 45; right: 0; bottom: 0; left: 0; display: grid; height: 78px; grid-template-columns: 1fr 1fr 1.18fr 1fr; align-items: end; padding: 8px max(10px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left)); border-top: 1px solid var(--line); background: rgba(255,254,250,.98); box-shadow: 0 -8px 25px rgba(39,27,24,.05); backdrop-filter: blur(14px); }
  .mobile-nav--readonly { grid-template-columns: repeat(3,1fr); }
  .mobile-nav > button { display: flex; min-width: 0; min-height: 56px; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 0; color: var(--muted); background: transparent; font-size: 10px; }
  .mobile-nav > button.is-active { color: var(--wine); }
  .mobile-move-button { position: relative; }
  .mobile-move-button > span { display: flex; width: 50px; height: 50px; align-items: center; justify-content: center; margin-top: -24px; border-radius: 50%; color: #fff; background: var(--wine); box-shadow: 0 8px 20px rgba(116,16,47,.24); }
  .mobile-move-button small { color: var(--wine); font-size: 10px; font-weight: 600; }

  .overview-hero { display: grid; gap: 24px; padding: 11px 0 31px; }
  .overview-hero h1 { font-size: clamp(47px,14vw,64px); line-height: .99; }
  .overview-hero .primary-button { width: 100%; min-width: 0; min-height: 54px; }
  .install-nudge { display: grid; grid-template-columns: 48px minmax(0,1fr) 36px; align-items: center; gap: 5px 12px; margin: -8px 0 25px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .install-nudge img { width: 48px; height: 48px; grid-row: 1/3; border-radius: 11px; box-shadow: 0 7px 18px rgba(82,9,31,.13); }
  .install-nudge > div { display: grid; gap: 4px; }
  .install-nudge strong { font-size: 13px; line-height: 1.35; }
  .install-nudge span { color: var(--muted); font-size: 11px; line-height: 1.4; }
  .install-nudge__action { display: inline-flex; min-height: 35px; grid-column: 2/4; grid-row: 2; align-items: center; justify-self: start; gap: 7px; padding: 0; border: 0; color: var(--wine); background: transparent; font-size: 12px; font-weight: 600; text-decoration: underline; text-underline-offset: 4px; }
  .install-nudge__close { width: 36px; height: 36px; grid-column: 3; grid-row: 1; }
  .overview-facts { border-top: 1px solid var(--line-dark); }
  .composition-block, .critical-block { min-height: 0; padding: 24px 0 26px; }
  .composition-block { padding-right: 0; }
  .composition-numbers { gap: 18px; margin-top: 22px; }
  .composition-numbers strong { font-size: 44px; }
  .composition-numbers span:not(.vertical-rule) { max-width: 72px; font-size: 11px; line-height: 1.3; }
  .vertical-rule { height: 40px; }
  .critical-block { padding-left: 0; }
  .recent-section { padding-top: 28px; }
  .recent-section .section-title-row .text-link { display: none; }

  .movement-row, .movement-list--compact .movement-row { position: relative; min-height: 91px; grid-template-columns: minmax(0,1fr) auto; gap: 7px 16px; padding: 15px 2px; }
  .movement-row time { grid-column: 2; grid-row: 1; justify-items: end; }
  .movement-row time strong { font-size: 11px; }
  .movement-row time span { font-size: 10px; }
  .movement-row__description { grid-column: 1; grid-row: 1; padding-right: 4px; font-size: 12px; }
  .movement-row__person { grid-column: 1/-1; grid-row: 2; display: flex; gap: 5px; }
  .movement-row__person span { font-size: 10px; }
  .movement-row__person strong { color: var(--muted); font-size: 10px; font-weight: 400; }
  .movement-row__caret { display: none; }

  .page-heading { display: grid; gap: 22px; padding-bottom: 26px; }
  .page-heading h1 { font-size: 45px; }
  .page-heading p { font-size: 13px; }
  .page-heading .primary-button { width: 100%; }
  .toolbar { display: grid; justify-content: stretch; gap: 13px; margin: 20px 0 24px; }
  .search-field { width: 100%; }
  .segmented-control { width: 100%; overflow-x: auto; }
  .segmented-control button { flex: 1; }
  .toolbar--movements { grid-template-columns: 1fr auto; }
  .toolbar--movements .search-field { grid-column: 1/-1; }
  .toolbar--movements .secondary-button { min-width: 0; padding-inline: 12px; }

  .product-matrices { gap: 26px; }
  .product-matrix > header { min-height: 81px; }
  .product-matrix h2 { font-size: 18px; line-height: 1.25; }
  .matrix-total strong { font-size: 32px; }
  .stock-table { min-width: 430px; }
  .stock-table th, .stock-table td { height: 53px; padding-inline: 12px; }
  .stock-table th:first-child { position: sticky; z-index: 1; left: 0; width: 100px; background: var(--paper); }
  .stock-cell--critical::after { right: 8%; }
  .single-stock-row { min-height: 82px; gap: 15px; }
  .single-stock-row strong { font-size: 36px; }
  .inline-action { margin-left: 0; justify-content: flex-end; text-align: right; }

  .entity-list { margin-top: 26px; }
  .entity-list__header { display: none; }
  .entity-row { display: grid; min-height: 0; padding: 18px 0; }
  .product-list-grid { grid-template-columns: minmax(0,1fr) auto; gap: 10px 16px; }
  .product-list-grid > :first-child { grid-column: 1/-1; }
  .product-list-grid > :nth-child(2) { grid-column: 1; }
  .product-list-grid > :nth-child(3) { display: none; }
  .product-list-grid > :nth-child(4) { grid-column: 2; grid-row: 2; }
  .product-list-grid > :nth-child(5) { grid-column: 1/-1; justify-content: flex-start; }
  .user-list-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
  .user-list-grid > :first-child { grid-column: 1/-1; }
  .user-list-grid > :nth-child(4) { justify-self: end; }
  .permission-note { padding: 16px; }

  .report-hero { grid-template-columns: 1fr 1fr; }
  .report-hero > div { min-height: 135px; padding: 18px; }
  .report-hero > div:first-child { padding-left: 0; }
  .report-hero > div:nth-child(2) { border-right: 0; }
  .report-hero > div:last-child { grid-column: 1/-1; min-height: 118px; padding-left: 0; border-top: 1px solid var(--line); }
  .report-hero strong { font-size: 44px; }
  .report-breakdown { grid-template-columns: 1fr; gap: 40px; margin-top: 35px; }
  .settings-action-row, .toggle-row { gap: 18px; }
  .settings-action-row { align-items: flex-start; flex-direction: column; }

  .drawer-backdrop { align-items: flex-end; }
  .movement-drawer { width: 100%; height: min(93dvh,900px); border-radius: 12px 12px 0 0; }
  .drawer-header { padding: 22px 20px 18px; }
  .drawer-header h2 { font-size: 29px; }
  .movement-form { gap: 21px; padding: 22px 20px 110px; }
  .movement-type-field > div { display: grid; grid-template-columns: repeat(3,1fr); }
  .movement-type-field button { padding-inline: 7px; }
  .form-grid, .form-grid--quantity { grid-template-columns: 1fr; }
  .drawer-submit { position: fixed; z-index: 5; right: 0; bottom: 0; left: 0; padding: 13px 20px max(13px,env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255,254,250,.98); }
  .drawer-submit > div { display: none; }
  .drawer-submit .primary-button { width: 100%; }
  .movement-summary { gap: 27px; }

  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { width: 100%; max-height: 91dvh; border-radius: 12px 12px 0 0; }
  .modal--wide { width: 100%; }
  .modal__header { padding: 23px 20px 18px; }
  .modal__header h2 { font-size: 30px; }
  .modal__body { padding: 22px 20px 26px; }
  .modal__footer { position: sticky; bottom: 0; padding: 13px 20px max(13px,env(safe-area-inset-bottom)); }
  .details-list { grid-template-columns: 1fr; }
  .details-list > div, .details-list > div:nth-child(even) { padding-left: 0; border-left: 0; }
  .minimum-grid { grid-template-columns: 1fr 1fr; }
  .minimum-grid label:nth-child(3n) { border-right: 1px solid var(--line); }
  .minimum-grid label:nth-child(2n) { border-right: 0; }

  .more-backdrop { z-index: 90; display: flex; align-items: flex-end; padding: 0; }
  .more-sheet { width: 100%; max-height: 88dvh; overflow-y: auto; padding: 0 20px max(22px,env(safe-area-inset-bottom)); border-radius: 14px 14px 0 0; background: var(--paper); animation: sheet-in 220ms ease both; }
  @keyframes sheet-in { from { transform: translateY(20px); opacity: 0; } }
  .more-sheet > header { display: flex; align-items: center; justify-content: space-between; padding: 22px 0 16px; border-bottom: 1px solid var(--line); }
  .more-sheet nav { display: grid; padding: 10px 0; }
  .more-sheet nav button { display: grid; min-height: 58px; grid-template-columns: 30px minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 0 4px; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); background: transparent; text-align: left; }
  .more-sheet nav button.is-active { color: var(--wine); font-weight: 600; }
  .more-install-button { display: grid; width: 100%; min-height: 54px; grid-template-columns: 30px minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 0 4px; border: 0; border-bottom: 1px solid var(--line); color: var(--wine); background: transparent; font-size: 13px; font-weight: 600; text-align: left; }
  .logout-button { display: flex; min-height: 50px; align-items: center; gap: 9px; margin-top: 8px; padding: 0 4px; border: 0; color: var(--wine); background: transparent; }
  .toast { right: 16px; bottom: 94px; left: 16px; max-width: none; }

  html[data-app-mode="standalone"] .app-shell { min-height: 100dvh; padding-top: calc(72px + env(safe-area-inset-top)); padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  html[data-app-mode="standalone"] .mobile-header { height: calc(72px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
  html[data-app-mode="standalone"] .mobile-nav { height: calc(78px + env(safe-area-inset-bottom)); }
  html[data-app-mode="standalone"] .login-brand { padding-top: calc(38px + env(safe-area-inset-top)); }
}

@media (max-width: 430px) {
  .app-content { padding-inline: 17px; }
  .composition-numbers { gap: 12px; }
  .composition-numbers strong { font-size: 40px; }
  .composition-numbers span:not(.vertical-rule) { max-width: 63px; }
  .vertical-rule { margin-inline: 2px; }
  .page-heading h1 { font-size: 42px; }
  .minimum-grid { grid-template-columns: 1fr; }
  .minimum-grid label, .minimum-grid label:nth-child(3n) { border-right: 0; }
  .modal__footer { display: grid; grid-template-columns: .8fr 1.2fr; }
  .modal__footer .secondary-button, .modal__footer .primary-button { width: 100%; padding-inline: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Produção Supabase */
.boot-screen { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 18px; padding: 32px; background: var(--paper); text-align: center; }
.boot-screen p { margin: 0; color: var(--muted); font-size: 13px; }
.boot-spinner { width: 28px; height: 28px; border: 2px solid var(--line-dark); border-top-color: var(--wine); border-radius: 50%; animation: dapev-spin .8s linear infinite; }
@keyframes dapev-spin { to { transform: rotate(360deg); } }
.user-status-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.user-status-actions .icon-button { width: 32px; height: 32px; }
.production-badge { display: inline-flex; align-items: center; gap: 7px; color: var(--success); font-size: 12px; font-weight: 600; }
.credential-card { display: grid; gap: 14px; padding: 18px; border: 1px solid var(--line-dark); border-radius: 4px; background: var(--stone); }
.credential-card > span { color: var(--muted); font-size: 12px; }
.credential-card > strong { overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 20px; letter-spacing: .04em; }
.credential-card .secondary-button { justify-self: start; }
.credential-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.password-change-backdrop { z-index: 180; }
.password-change-backdrop .modal { width: min(520px, 100%); }
.password-change-backdrop .modal-form .primary-button { justify-self: stretch; justify-content: center; width: 100%; }

@media (max-width: 720px) {
  .user-status-actions { justify-self: stretch !important; }
  .credential-card > strong { font-size: 17px; }
}
