/* Shared design system. Legacy tokens remain aliases for existing templates. */
:root {
  color-scheme: light;
  --canvas: #f7f6f2; --surface: #fff; --surface-soft: #f2f1ed;
  --ink: #202b30; --muted: #626b6c; --line: #e3e5df;
  --accent: #b63f2e; --accent-hover: #963223; --accent-soft: #faede8;
  --action: #b63f2e; --action-hover: #963223;
  --sidebar: #172326; --sidebar-text: #c3cecb;
  --success-bg: #eaf7f0; --success-ink: #246545;
  --warning-bg: #fff6e1; --warning-ink: #805813;
  --danger-bg: #fff0f1; --danger-ink: #a22432;
  --red: var(--accent); --red-hover: var(--accent-hover); --red-active: #91212b;
  --red-light: var(--danger-bg); --black: var(--ink); --white: var(--surface);
  --gray: var(--muted); --gray-light: var(--surface-soft); --border: var(--line);
  --yellow-light: var(--accent-soft); --yellow-dark: var(--accent); --yellow: #f5b85b;
  --disabled: #edf0ed; --radius: 16px;
  font-family: 'Manrope', ui-sans-serif, system-ui, -apple-system, sans-serif;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #121a1c; --surface: #1b2628; --surface-soft: #243033;
  --ink: #f0f3ed; --muted: #acb9b8; --line: #364446;
  --accent: #ffad92; --accent-hover: #ffc3ad; --accent-soft: #3a2925;
  --sidebar: #10191b; --sidebar-text: #c3cecb;
  --success-bg: #17382d; --success-ink: #a0deba;
  --warning-bg: #3a3020; --warning-ink: #edcf90;
  --danger-bg: #40272f; --danger-ink: #ffb3bc;
  --white: var(--surface); --black: var(--ink); --gray: var(--muted);
  --gray-light: var(--surface-soft); --border: var(--line); --disabled: #29323f;
}
body.bg-slate-50, html[data-theme="dark"] body { background: var(--canvas); color: var(--ink); line-height: 1.55; font-size: 14px; }
body :is(.bg-white,.card), html[data-theme="dark"] :is(.bg-white,.card) { background: var(--surface); color: var(--ink); }
body :is(.text-slate-500,.text-slate-600,.hint), html[data-theme="dark"] :is(.text-slate-500,.text-slate-600,.hint) { color: var(--muted); }
body :is(input:not([type=hidden]):not([type=checkbox]):not([type=radio]),select,textarea), html[data-theme="dark"] :is(input:not([type=hidden]):not([type=checkbox]):not([type=radio]),select,textarea) {
  min-width: 0; max-width: 100%; background: var(--surface); color: var(--ink); border: 1px solid #a5aebb; border-radius: 8px; min-height: 44px; font-size: 15px; padding: .65rem .8rem;
}
html[data-theme="dark"] :is(input:not([type=hidden]),select,textarea) { border-color: #687586; }
input[type=checkbox],input[type=radio] { accent-color: var(--accent); width: 18px; height: 18px; vertical-align: middle; }
input::placeholder,textarea::placeholder { color: var(--muted); opacity: 1; }
label { font-size: 13px; font-weight: 600; letter-spacing: .005em; }
fieldset, .grid > *, .flex > * { min-width: 0; }
h1 { font-size: clamp(1.75rem, 2.6vw, 2.25rem); font-weight: 750; letter-spacing: -.04em; }
h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -.015em; }
h3 { font-size: 1rem; font-weight: 650; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; box-shadow: 0 3px 12px #1c273303; }
.btn,.btn-secondary,.nav-link { border-radius: 8px; font-size: 13px; font-weight: 650; min-height: 44px; padding: .65rem 1rem; }
.btn { color: #fff; background: var(--action); box-shadow: 0 2px 3px #8a172a14; }
.btn:hover { background: var(--action-hover); color: #fff; }
.btn-secondary,html[data-theme="dark"] .btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: var(--surface-soft); border-color: #a5aebb; }
.nav-link:hover,.nav-link[aria-current=page] { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
a:focus-visible,button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,summary:focus-visible,[tabindex="0"]:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; box-shadow: none; }
button:disabled,.btn:disabled { color: var(--muted); background: var(--disabled); border-color: var(--line); box-shadow: none; cursor: not-allowed; }
.notice { background: var(--surface-soft); border: 1px solid var(--line); border-left: 3px solid #74859c; color: var(--ink); border-radius: 8px; font-size: 13px; }
.notice[data-state=success] { background: var(--success-bg); color: var(--success-ink); border-color: var(--success-ink); }
.error { color: var(--danger-ink); background: var(--danger-bg); border: 1px solid var(--danger-ink); border-radius: 8px; }
.critical,.text-rose-700,.text-rose-800 { color: var(--danger-ink); }
.badge,.badge[data-status] { font-size: 11px; padding: .25rem .6rem; font-weight: 650; border: 1px solid var(--line); color: var(--muted); background: var(--surface-soft); }
.badge[data-tone=success],.badge[data-status=Pronto],.badge[data-status=Entregue] { background: var(--success-bg); color: var(--success-ink); border-color: transparent; }
.badge[data-tone=warning],.badge[data-status="Em Execucao"] { background: var(--warning-bg); color: var(--warning-ink); border-color: transparent; }
.badge[data-tone=danger] { background: var(--danger-bg); color: var(--danger-ink); border-color: transparent; }
.table-wrap { position: relative; width: 100%; max-width: 100%; overflow: auto; border-radius: 10px; scrollbar-width: thin; scrollbar-color: #9aa5b4 transparent; }
table { font-size: 13px; }
body th,html[data-theme="dark"] th { background: var(--surface-soft); color: var(--muted); text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; white-space: nowrap; }
th,td { padding: .95rem 1rem; border-color: var(--line); vertical-align: middle; }
td { white-space: normal; }
tbody tr:hover { background: var(--surface-soft); }
tbody tr:last-child td { border-bottom: 0; }
td[colspan] { text-align: center; color: var(--muted); padding: 2.5rem 1rem; white-space: normal; }
caption { padding: .2rem 0 .8rem; color: var(--muted); }
.table-scroll-hint { color: var(--muted); font-size: 12px; margin: .6rem 0 0; display: flex; gap: .5rem; align-items: center; }
.table-scroll-hint::before { content: '↔'; font-size: 16px; }
summary { min-height: 44px; font-size: 14px; }
details[open] summary { margin-bottom: .7rem; color: var(--accent); }
dialog.card { border: 1px solid var(--line); max-width: min(34rem,calc(100% - 2rem)); max-height: calc(100dvh - 2rem); margin: auto; overflow: auto; box-shadow: 0 24px 80px #0004; }
dialog::backdrop { background: #121a2cb0; backdrop-filter: blur(3px); }
.workspace-sidebar { position: fixed; inset: 0 auto 0 0; width: 246px; background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; z-index: 50; }
.sidebar-brand { padding: 26px 24px 23px; }
.sidebar-brand>a { display: flex; align-items: center; gap: 11px; color: #fff; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 37px; height: 37px; border-radius: 10px; background: #bd3039; color: #fff; flex-shrink: 0; }
.brand-slash { color: #f1868e; margin-left: 2px; }
.sidebar-brand small { display: block; color: #929dab; font-size: 8px; font-weight: 600; letter-spacing: .18em; margin-top: 1px; }
.workspace-nav { overflow-y: auto; padding: 0 14px 20px; flex: 1; scrollbar-width: thin; scrollbar-color: #4a5463 transparent; }
.nav-group-label { margin: 20px 13px 8px; text-transform: uppercase; color: #96a3b4; font-size: 9px; letter-spacing: .16em; font-weight: 650; }
.nav-group-label:first-child { margin-top: 3px; }
.workspace-link { display: flex; align-items: center; gap: 11px; min-height: 42px; border-radius: 7px; padding: 9px 12px; font-size: 12px; color: #c5cdd9; margin: 2px 0; }
.workspace-link svg { width: 17px; height: 17px; stroke-width: 1.7; color: #99a6b6; }
.workspace-link:hover { color: #fff; background: #2b3340; }
.workspace-link[aria-current=page] { background: #38303a; color: #ffc7cd; font-weight: 650; }
.workspace-link[aria-current=page] svg { color: #f68b96; }
.nav-active-dot { margin-left: auto; width: 5px; height: 5px; border-radius: 50%; background: #f68b96; flex: 0 0 auto; }
.sidebar-account { display: flex; gap: 10px; align-items: center; border-top: 1px solid #343c49; padding: 16px 17px; }
.user-avatar { flex-shrink: 0; width: 33px; height: 33px; display: grid; place-items: center; border-radius: 50%; background: #394453; color: #e6ebf2; font-weight: 600; }
.sidebar-account>div { flex: 1; }
.sidebar-account strong { display: block; color: #e4e9ef; font-weight: 600; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-account small { color: #9ba7b8; font-size: 10px; }
.icon-button { display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; border-radius: 8px; color: inherit; }
.icon-button:hover { background: #74859c22; }
.workspace-topbar { min-height: 72px; margin-left: 246px; padding: 0 32px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.topbar-context,.topbar-actions { display: flex; align-items: center; gap: 17px; }
.workspace-eyebrow { font-size: 9px; letter-spacing: .13em; color: var(--muted); font-weight: 600; white-space: nowrap; }
.topbar-separator { color: var(--muted); }
.topbar-page { font-weight: 600; font-size: 12px; }
.topbar-store { display: flex; gap: 7px; align-items: center; color: var(--muted); font-size: 12px; min-height: 44px; }
.topbar-store svg { width: 15px; height: 15px; }
.workspace-topbar .theme-toggle { color: var(--muted); border: 1px solid var(--line); border-radius: 8px; min-height: 36px; padding: 7px 10px; }
.workspace-topbar .theme-toggle:hover { color: var(--ink); background: var(--surface-soft); }
.admin-shell main { margin: 0 0 0 246px; width: calc(100% - 246px); max-width: none; padding: 30px 32px 36px; }
.workspace-footer { margin-left: 246px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 1rem; padding: 16px 32px; color: var(--muted); font-size: 10px; }
.workspace-footer a { text-decoration: underline; text-underline-offset: 3px; }
.mobile-menu-control { display: none; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.page-heading .hint { margin-top: 7px; max-width: 60ch; }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 650; letter-spacing: .13em; text-transform: uppercase; margin-bottom: 8px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.stat-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 16px; margin-bottom: 25px; }
.stat-card { padding: 19px 20px; position: relative; overflow: hidden; }
.stat-label { color: var(--muted); font-size: 12px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.stat-icon { color: var(--muted); background: var(--surface-soft); display: grid; place-items: center; border-radius: 8px; width: 31px; height: 31px; }
.stat-icon svg { width: 16px; height: 16px; }
.stat-value { color: var(--ink); font-size: clamp(1.6rem,2vw,2rem); font-weight: 700; letter-spacing: -.045em; margin: 13px 0 7px; font-variant-numeric: tabular-nums; }
.stat-hint { font-size: 10px; color: var(--muted); }
.stat-card:first-child { border-top: 3px solid #bd3039; padding-top: 17px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.section-heading p { color: var(--muted); font-size: 12px; margin-top: 5px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.8fr) minmax(260px,1fr); gap: 20px; }
.dashboard-grid > * { min-width: 0; }
.quick-actions { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; margin-bottom: 25px; }
.quick-action { display: flex; align-items: center; gap: 12px; padding: 15px 17px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.quick-action>svg { color: var(--accent); width: 19px; }
.quick-action strong { font-weight: 600; font-size: 12px; }
.quick-action small { display: block; font-size: 10px; margin-top: 2px; }
.quick-action:hover { border-color: var(--accent); background: var(--accent-soft); }
.empty-state { padding: 28px 16px; text-align: center; color: var(--muted); }
.empty-state svg { margin: 0 auto 12px; width: 30px; height: 30px; color: #8b98aa; stroke-width: 1.4; }
.empty-state strong { display: block; color: var(--ink); font-size: 13px; font-weight: 600; }
.empty-state p { margin: 7px auto 0; max-width: 38ch; font-size: 12px; }
.empty-state a { margin-top: 14px; }
.section-count { font-size: 11px; background: var(--surface-soft); border: 1px solid var(--line); color: var(--muted); border-radius: 6px; padding: 3px 8px; }
.public-header { background: var(--surface); border-color: var(--line); }
.public-header .site-header-inner { min-height: 80px; }
.public-shell main { padding-top: 32px; }
.public-shell .site-footer,html[data-theme="dark"] .site-footer { background: #1c222b; color: #f5f7fa; }
.site-footer h2,.site-footer a:hover { color: #ffc0c7; }
.site-footer .footer-logo { color: #fff; }
.site-footer .hint { color: #bbc4d0; }
.theme-dock { background: #1c222b; color: #b3bfce; }
.theme-dock .theme-toggle { color: #fff; min-height: 44px; }
.public-hero { background: #202832; color: #fff; border-radius: 20px; padding: clamp(25px,5vw,64px); }
.public-hero .text-slate-300 { color: #c1ccd9; }
.public-hero .text-accent { color: #ffb3ad; }
.public-hero .hero-process { background: #293442; border-color: #485366; }
.public-hero h1 { font-size: clamp(2.2rem,4.2vw,4rem); line-height: 1.09; }
.login-layout { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); max-width: 940px; margin: 30px auto; border-radius: 20px; border: 1px solid var(--line); overflow: hidden; background: var(--surface); }
.login-story { background: #202832; color: #fff; padding: 50px 40px; display: flex; flex-direction: column; justify-content: space-between; gap: 30px; }
.login-story h2 { font-size: 2.1rem; line-height: 1.2; letter-spacing: -.045em; }
.login-story p { color: #c1ccd9; margin-top: 18px; }
.login-story .eyebrow { color: #ffb3ad; }
.login-panel { padding: 45px 40px; }
.login-panel h1 { font-size: 1.75rem; }
#fiscal-feedback { white-space: pre-line; overflow-wrap: anywhere; }
@media(min-width:1600px) { .admin-shell main { padding-left: 48px; padding-right: 48px; } }
@media(max-width:1199px) { .stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } .dashboard-grid { grid-template-columns: 1fr; } .quick-actions { gap: 8px; } .quick-action { padding: 13px; } }
@media(max-width:900px) {
  .workspace-sidebar { position: relative; width: 100%; max-height: none; }
  .workspace-nav { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .nav-group-label { grid-column: 1/-1; }
  .sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 20px; }
  .workspace-topbar,.workspace-footer { margin-left: 0; padding-left: 20px; padding-right: 20px; }
  .admin-shell main { margin-left: 0; width: 100%; padding: 25px 20px; }
  .ui-ready .mobile-menu-control { display: inline-grid; }
  .ui-ready .workspace-sidebar { position: fixed; width: min(310px,calc(100% - 40px)); height: 100dvh; transform: translateX(-100%); visibility: hidden; }
  .ui-ready .workspace-nav { display: block; }
  .workspace-link { min-height: 44px; }
  .ui-ready.nav-open .workspace-sidebar { visibility: visible; transform: translateX(0); }
  .nav-scrim { position: fixed; inset: 0; background: #11182799; z-index: 45; width: 100%; height: 100%; }
  .nav-open { overflow: hidden; }
  .workspace-topbar { min-height: 64px; position: sticky; top: 0; z-index: 30; }
  .workspace-eyebrow,.topbar-separator { display: none; }
  .topbar-context { gap: 9px; }
}
@media(max-width:639px) {
  .page-heading { align-items: stretch; flex-direction: column; gap: 16px; margin-bottom: 20px; }
  .page-actions { width: 100%; }
  .page-actions>a { flex: 1; }
  .stat-grid { gap: 10px; }
  .stat-card { padding: 15px; }
  .stat-card:first-child { padding-top: 13px; }
  .stat-value { font-size: 1.55rem; overflow-wrap: anywhere; }
  .stat-label { font-size: 11px; align-items: flex-start; }
  .stat-icon { width: 25px; height: 25px; flex-shrink: 0; }
  .quick-actions { grid-template-columns: 1fr; }
  .quick-action { padding: 14px 16px; }
  .quick-action small { font-size: 12px; }
  .dashboard-grid { gap: 16px; }
  .card { border-radius: 12px; padding: 17px; }
  .workspace-topbar { gap: 8px; padding: 8px 12px; }
  .topbar-actions { gap: 7px; }
  .topbar-store span,.workspace-topbar .theme-toggle-label { display: none; }
  .topbar-store,.workspace-topbar .theme-toggle { min-width: 44px; min-height: 44px; justify-content: center; }
  .topbar-store { border: 1px solid var(--line); border-radius: 8px; }
  .topbar-page { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 42vw; }
  .workspace-footer { flex-direction: column; font-size: 11px; padding: 17px; gap: 5px; }
  .table-wrap table { min-width: 560px; }
  .table-wrap table.table-empty { min-width: 0; }
  .table-empty thead { display: none; }
  th,td { padding: .85rem .75rem; white-space: normal; }
  body :is(input:not([type=hidden]):not([type=checkbox]):not([type=radio]),select,textarea) { font-size: 16px; }
  .public-header .site-nav { scrollbar-width: thin; gap: 4px; }
  .public-hero { border-radius: 14px; }
  .public-hero .hero-process { padding: 22px; }
  .login-layout { grid-template-columns: 1fr; margin: 0; }
  .login-story { padding: 26px; gap: 15px; }
  .login-story h2 { font-size: 1.6rem; }
  .login-story .login-story-note { display: none; }
  .login-panel { padding: 27px 22px; }
}
@media(prefers-reduced-motion:no-preference) { .workspace-link,.quick-action,.btn-secondary { transition: background-color .15s,border-color .15s; } }
@media print { .workspace-sidebar,.workspace-topbar,.workspace-footer,.nav-scrim { display: none!important; } .admin-shell main { margin: 0; width: 100%; padding: 0; } .card { box-shadow: none; } }
