:root { color-scheme:light; --blue:#1760dc; --link:#1760dc; --ink:#131722; --muted:#667085; --line:#e4e8ef; --page-bg:#f5f7fb; --surface:#fff; --surface-muted:#edf0f5; --field-border:#ccd3df; --status-bg:#e9f4ff; --status-text:#144f9e; }
html[data-theme="dark"] { color-scheme:dark; --link:#9bc5ff; --ink:#eef2fa; --muted:#b3bfd2; --line:#334159; --page-bg:#0f1420; --surface:#192130; --surface-muted:#232e40; --field-border:#485874; --status-bg:#18355a; --status-text:#a9d0ff; }
* { box-sizing:border-box; }
body { margin:0; font:15px/1.55 'Segoe UI',Arial,sans-serif; color:var(--ink); background:var(--page-bg); }
a { color:var(--link); text-decoration:none; }
a:hover { text-decoration:underline; }
.sidebar { position:fixed; inset:0 auto 0 0; width:250px; background:var(--surface); border-right:1px solid var(--line); padding:30px 22px; display:flex; flex-direction:column; }
.brand { display:flex; align-items:center; gap:9px; font-weight:750; font-size:18px; color:var(--ink); white-space:nowrap; }
.brand-icon { background:var(--blue); color:white; padding:3px 9px; border-radius:8px; }
.byline { color:var(--muted); font-size:11px; margin:10px 0 35px 41px; }
.byline strong { color:var(--ink); }
.byline b { color:var(--blue); }
.sidebar nav { display:grid; gap:10px; }
.sidebar nav a { padding:12px; color:var(--muted); border-radius:8px; }
.sidebar nav a:hover { background:var(--status-bg); color:var(--blue); }
.account { margin-top:auto; border-top:1px solid var(--line); padding-top:20px; overflow-wrap:anywhere; }
small { display:block; color:var(--muted); font-size:12px; }
main { margin-left:250px; }
.topbar { height:70px; border-bottom:1px solid var(--line); background:var(--surface); padding:0 40px; display:flex; justify-content:space-between; align-items:center; color:var(--muted); }
.content { max-width:1380px; margin:auto; padding:40px; }
h1 { font-size:30px; letter-spacing:-.8px; margin:4px 0 8px; line-height:1.25; }
h2 { font-size:19px; margin:0 0 22px; }
p { color:var(--muted); }
.eyebrow { color:var(--blue); font-size:11px; font-weight:750; letter-spacing:1.6px; }
.page-heading { display:flex; align-items:center; justify-content:space-between; gap:20px; margin-bottom:26px; }
.card { background:var(--surface); border:1px solid var(--line); border-radius:12px; padding:26px; margin-bottom:24px; box-shadow:0 2px 5px #18243a03; }
.stats { display:grid; grid-template-columns:repeat(3,1fr); gap:20px; }
.stats .card>span { color:var(--muted); }
.stats strong { display:block; font-size:28px; margin-top:12px; }
table { border-collapse:collapse; width:100%; text-align:left; }
th { color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.6px; }
td,th { border:1px solid var(--line); padding:15px 10px; }
td { font-size:14px; }
.empty { padding:42px; text-align:center; color:var(--muted); }
.table-scroll { overflow-x:auto; }
.badge { display:inline-block; padding:4px 10px; background:var(--status-bg); color:var(--blue); border-radius:20px; font-size:12px; }
.red,.expired { background:#fff0f0; color:#b52c36; }
.orange { background:#fff3e4; color:#a65d00; }
button,.button { display:inline-flex; align-items:center; justify-content:center; min-height:42px; padding:10px 18px; border:1px solid transparent; border-radius:7px; background:var(--blue); color:white; font:600 13px 'Segoe UI',Arial,sans-serif; cursor:pointer; text-decoration:none; }
button:hover,.button:hover { filter:brightness(.94); text-decoration:none; }
.secondary { background:var(--surface); color:var(--ink); border-color:var(--line); }
.danger { background:#b52c36; }
.actions { display:flex; gap:12px; align-items:center; flex-wrap:wrap; margin-top:24px; }
.form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:22px; }
.wide { grid-column:1/-1; }
label { display:block; font-size:13px; font-weight:600; margin-bottom:7px; }
input,select,textarea { display:block; width:100%; min-height:44px; padding:11px; border:1px solid var(--field-border); border-radius:6px; font:inherit; background:var(--surface); color:var(--ink); }
input:focus,select:focus,textarea:focus { outline:2px solid #1760dc40; border-color:var(--blue); }
input[type=checkbox] { width:auto; display:inline-block; min-height:0; }
textarea { height:110px; }
.errorlist { color:#b52c36; background:#fff2f2; padding:12px 20px; border-radius:6px; }
.tabs { display:flex; gap:26px; margin:25px 0; border-bottom:1px solid var(--line); overflow-x:auto; }
.tabs a { white-space:nowrap; padding:12px 0; color:var(--muted); }
.tabs a[aria-current] { color:var(--blue); border-bottom:3px solid var(--blue); }
.login { max-width:520px; margin:6vh auto; padding:40px; }
.login input { margin-top:5px; }
.login button { width:100%; margin-top:10px; }
.search { display:flex; gap:12px; margin-bottom:20px; }
dt { font-size:12px; color:var(--muted); margin-top:12px; }
dd { margin:0; overflow-wrap:anywhere; }
.identifier { font-family:monospace; }
summary { color:var(--blue); cursor:pointer; padding:12px 0; }
.lookup-review { background:var(--status-bg); padding:18px; border-radius:8px; }
.lookup-review button { margin-top:12px; }

th { background:var(--surface-muted); }
.badge { color:var(--status-text); }
.theme-button { white-space:nowrap; min-height:36px; padding:8px 12px; }
.theme-button:focus-visible { outline:2px solid #649eff; outline-offset:3px; }
html[data-theme="dark"] .red,html[data-theme="dark"] .expired,html[data-theme="dark"] .errorlist { background:#46252c; color:#ffadb5; }
html[data-theme="dark"] .orange { background:#43311c; color:#ffd098; }

.sidebar nav a[aria-current="page"] { background:var(--status-bg); color:var(--link); font-weight:600; }

.visually-hidden { position:absolute; width:1px; height:1px; padding:0; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
#loading-overlay { background:var(--surface); color:var(--ink); border:1px solid var(--line); border-radius:12px; padding:30px; text-align:center; }
#loading-overlay::backdrop { background:#0009; }
.loading-spinner { width:36px; height:36px; margin:auto; border:4px solid var(--line); border-top-color:var(--blue); border-radius:50%; animation:loading-spin .8s linear infinite; }
.loading-message { position:fixed; bottom:16px; left:16px; right:16px; z-index:100; background:var(--surface); color:var(--ink); border:1px solid var(--line); padding:18px; border-radius:8px; }
@keyframes loading-spin { to { transform:rotate(360deg); } }
@media(prefers-reduced-motion:reduce) { .loading-spinner { animation:none; } }

.provider-filters { display:flex; align-items:flex-end; gap:12px; flex-wrap:wrap; margin-bottom:22px; }
.provider-filters > div:first-child { flex:1 1 260px; }
.provider-filters > div:nth-child(2) { flex:0 1 180px; }
.provider-filters button,.provider-filters .button { min-height:46px; }
@media(max-width:650px) { .provider-filters > div { flex:1 1 100%; } }

.form-footer { justify-content:space-between; }
.save-actions { display:flex; align-items:center; justify-content:flex-end; gap:12px; flex-wrap:wrap; margin-left:auto; }

.exempt-option { display:flex; align-items:center; gap:8px; margin-top:8px; }

.search .recipient-active { width:auto; min-width:140px; }
@media(max-width:650px) { .search { flex-wrap:wrap; } }

.note-totals { display:flex; justify-content:space-between; gap:18px; margin-bottom:12px; }
.stats-link { display:block; color:var(--ink); }
.stats-link:hover { border-color:var(--link); text-decoration:none; }
.stats-link > span { color:var(--muted); }
.invoice-preview {
    margin: 1.25rem 0;
    padding: 1rem;
    border: 1px solid currentColor;
    border-radius: .5rem;
}

[hidden] { display: none !important; }

#emission-form details {
    margin: 1rem 0;
}

#emission-form details summary {
    cursor: pointer;
    margin-bottom: 1rem;
}

/* Layout compartilhado por todas as telas do produto. */
.sidebar { overflow-y:auto; }
main,.content,.card,.field,.stats > * { min-width:0; }
h1,h2,p,small,label,td,dd { overflow-wrap:anywhere; }
input,select,textarea { min-width:0; max-width:100%; }
button,.button { min-height:44px; max-width:100%; white-space:normal; text-align:center; }
input[type=checkbox] { min-width:20px; min-height:20px; flex-shrink:0; }
.table-scroll { max-width:100%; overscroll-behavior-x:contain; }
.table-scroll table { min-width:600px; }
.table-scroll:focus-visible { outline:2px solid var(--link); outline-offset:3px; }
.tabs { max-width:100%; }
.tabs a { flex-shrink:0; min-height:44px; }
.search input { flex:1 1 220px; }
.search button { flex-shrink:0; }
#loading-overlay { max-width:calc(100% - 32px); }
@media(max-width:1100px) {
    .sidebar { width:210px; padding:22px 14px; }
    .brand { font-size:15px; }
    main { margin-left:210px; }
    .content { padding:24px; }
    .stats { grid-template-columns:1fr; gap:0; }
    .form-grid { grid-template-columns:1fr; }
    .page-heading { flex-wrap:wrap; }
}
@media(max-width:900px) {
    .sidebar { position:static; width:100%; padding:16px 20px; border-right:0; border-bottom:1px solid var(--line); overflow:visible; }
    .brand { font-size:18px; white-space:normal; }
    .byline { margin:6px 0 14px 41px; }
    .sidebar nav { display:flex; flex-wrap:wrap; gap:6px; }
    .sidebar nav a { padding:10px 12px; }
    .account { display:flex; align-items:center; flex-wrap:wrap; gap:8px 16px; margin-top:12px; padding-top:12px; }
    .account form { margin-left:auto; }
    main { margin-left:0; }
    .topbar { height:auto; min-height:60px; padding:10px 20px; gap:12px; flex-wrap:wrap; }
    .theme-button { min-height:44px; }
    input,select,textarea { font-size:16px; }
}
@media(max-width:600px) {
    .sidebar { padding:14px 15px; }
    .sidebar nav a { flex:1 1 140px; }
    .content { padding:22px 15px; }
    .page-heading { align-items:flex-start; flex-direction:column; }
    h1 { font-size:25px; }
    .card { padding:18px; }
    .login { margin:24px auto; padding:22px 18px; }
    .search { flex-wrap:wrap; }
    .search input { flex-basis:100%; }
    .search .recipient-active { flex:1; }
    .form-footer { align-items:stretch; }
    .form-footer > button,.form-footer .save-actions { flex:1 1 100%; }
    .save-actions { margin-left:0; }
    .save-actions > * { flex:1 1 140px; }
    .actions > .button { flex:1 1 140px; }
    .provider-filters > div { flex:1 1 100%; }
    .tabs { gap:20px; }
    .note-totals { gap:12px; }
    .empty { padding:24px 12px; }
}
