:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --ink: #1f252b;
  --muted: #68727d;
  --line: #dfe4e8;
  --coffee: #6d3628;
  --coffee-dark: #52251b;
  --coffee-soft: #f3e9e5;
  --green: #217a4b;
  --green-soft: #e6f4ec;
  --amber: #9a6208;
  --amber-soft: #fff2d7;
  --red: #b02a37;
  --red-soft: #fde9eb;
  --shadow: 0 6px 24px rgba(24, 34, 43, 0.06);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: inherit; }
button, input, select { font: inherit; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 242px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: #20272c; color: #edf0f2; padding: 22px 14px; z-index: 20; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; min-width: 0; }
.brand-mark { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 11px; background: var(--coffee); color: white; font: 700 21px Georgia, serif; flex: 0 0 auto; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.05rem; letter-spacing: .01em; }
.brand small { font-size: .75rem; color: #aeb7bd; margin-top: 2px; }
.sidebar nav { margin-top: 30px; display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a { display: flex; align-items: center; gap: 11px; min-height: 44px; padding: 0 12px; border-radius: 9px; color: #d7dde1; text-decoration: none; font-size: .925rem; }
.sidebar nav a:hover { background: #2a3339; }
.sidebar nav a.active { color: white; background: var(--coffee); }
.nav-icon { width: 20px; text-align: center; color: #aab4ba; font-weight: 700; }
.active .nav-icon { color: white; }
.nav-heading { margin: 19px 12px 6px; color: #7f8a92; font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; }
.nav-badge { margin-left: auto; min-width: 24px; padding: 2px 6px; text-align: center; border-radius: 20px; background: var(--amber-soft); color: var(--amber); font-size: .72rem; font-weight: 700; }
.logout-form { margin-top: auto; padding: 8px 12px; }
.link-button { border: 0; background: none; padding: 5px 0; color: #aeb7bd; cursor: pointer; }
.link-button:hover { color: white; }
.main { min-width: 0; }
.topbar { min-height: 92px; padding: 20px 30px; display: flex; align-items: center; gap: 16px; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.88); backdrop-filter: blur(8px); }
.topbar h1 { margin: 0; font-size: 1.45rem; letter-spacing: -.02em; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: .875rem; }
.topbar-status { color: var(--muted); font-size: .82rem; display: flex; align-items: center; gap: 7px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #29a867; box-shadow: 0 0 0 4px rgba(41,168,103,.13); }
.mobile-menu { display: none; border: 0; background: none; font-size: 1.4rem; }
.content { padding: 26px 30px 48px; }
.messages { padding: 18px 30px 0; }
.message { padding: 12px 15px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.message + .message { margin-top: 8px; }
.message.success { color: var(--green); background: var(--green-soft); border-color: #bee0cd; }
.message.error { color: var(--red); background: var(--red-soft); border-color: #f0c3c9; }
.message.warning { color: var(--amber); background: var(--amber-soft); border-color: #ead19f; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.search-form { display: flex; gap: 8px; flex: 1; max-width: 630px; }
.search-form input { flex: 1; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
input, select { min-height: 42px; border: 1px solid #cfd6dc; border-radius: 8px; background: white; padding: 8px 11px; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: var(--coffee); box-shadow: 0 0 0 3px rgba(109,54,40,.11); }
.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid #cbd2d8; border-radius: 8px; padding: 8px 14px; background: white; color: var(--ink); text-decoration: none; cursor: pointer; font-weight: 600; font-size: .875rem; white-space: nowrap; }
.button:hover { border-color: #aab3ba; background: var(--surface-2); }
.button.primary { color: white; background: var(--coffee); border-color: var(--coffee); }
.button.primary:hover { background: var(--coffee-dark); }
.button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.button.full { width: 100%; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.tabs a { padding: 9px 13px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: .875rem; font-weight: 600; }
.tabs a:hover { background: white; }
.tabs a.active { background: var(--coffee-soft); color: var(--coffee-dark); }
.tabs a span { margin-left: 5px; opacity: .7; }
.table-card { overflow-x: auto; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th { color: #59646e; background: var(--surface-2); font-size: .76rem; text-transform: uppercase; letter-spacing: .035em; text-align: left; }
th, td { padding: 12px 13px; border-bottom: 1px solid #e8ecef; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfc; }
td small { display: block; margin-top: 3px; color: var(--muted); font-size: .75rem; }
.number { text-align: right; white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; white-space: nowrap; }
.actions { text-align: right; }
.actions a { color: var(--coffee); font-weight: 600; text-decoration: none; }
.empty { padding: 44px; text-align: center; color: var(--muted); }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 20px; background: #edf0f2; color: #5c6870; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.badge.success, .fiscal-fiscalized { color: var(--green); background: var(--green-soft); }
.badge.muted, .fiscal-not_required { color: #647079; background: #edf0f2; }
.badge.warning, .fiscal-pending { color: var(--amber); background: var(--amber-soft); }
.badge.error, .fiscal-error { color: var(--red); background: var(--red-soft); }
.pagination { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: 20px; color: var(--muted); font-size: .875rem; }
.pagination a { color: var(--coffee); text-decoration: none; font-weight: 600; }
.panel { border: 1px solid var(--line); border-radius: 11px; background: white; box-shadow: var(--shadow); }
.form-panel { max-width: 860px; padding: 25px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.form-grid label, .form-stack label, .filter-panel label { display: flex; flex-direction: column; gap: 7px; color: #505b64; font-size: .82rem; font-weight: 600; }
.form-grid label.wide { grid-column: 1/-1; }
.form-grid small, .form-stack small { color: var(--muted); font-weight: 400; }
.required, .field-error { color: var(--red); }
.field-error { display: block; font-size: .78rem; font-weight: 500; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }
.form-actions.centered { justify-content: center; }
.form-note { margin: 20px 0 0; color: var(--muted); font-size: .84rem; }
.narrow-panel { max-width: 720px; padding: 25px; }
.form-stack { display: flex; flex-direction: column; gap: 18px; }
.upload-form input[type=file] { padding: 8px; }
.info-box { padding: 13px 15px; border-radius: 9px; background: #f3f6f8; color: #4c5861; font-size: .84rem; }
.info-box p { margin: 5px 0 0; }
.stepper { display: flex; gap: 8px; margin-bottom: 22px; }
.stepper span { padding: 7px 11px; border-radius: 20px; background: #eef1f3; color: var(--muted); font-size: .78rem; font-weight: 700; }
.stepper span.active { background: var(--coffee-soft); color: var(--coffee); }
.success-mark { width: 58px; height: 58px; display: grid; place-items: center; margin: 8px auto 18px; border-radius: 50%; color: white; background: var(--green); font-size: 1.8rem; font-weight: 700; }
.summary-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.summary-grid div { padding: 14px; border-radius: 9px; background: var(--surface-2); text-align: center; }
.summary-grid strong, .summary-grid span { display: block; }
.summary-grid strong { font-size: 1.25rem; }
.summary-grid span { margin-top: 3px; color: var(--muted); font-size: .75rem; }
.center-note { margin: 20px auto 0; max-width: 560px; text-align: center; color: var(--muted); font-size: .84rem; }
.error-list ul { margin: 8px 0 0; padding-left: 20px; max-height: 260px; overflow: auto; }
.import-table-wrap { max-height: calc(100vh - 265px); overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: white; }
.import-table { min-width: max-content; }
.import-table thead { position: sticky; top: 0; z-index: 3; }
.import-table th { padding: 8px; }
.import-table th select { min-width: 155px; min-height: 36px; font-size: .8rem; }
.import-table td { max-width: 310px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.import-table .remove-col { position: sticky; left: 0; z-index: 2; width: 74px; text-align: center; background: white; }
.import-table thead .remove-col { z-index: 4; background: var(--surface-2); }
.remove-check input { position: absolute; opacity: 0; }
.remove-check span { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: var(--red); background: var(--red-soft); cursor: pointer; font-size: 1.2rem; }
.import-table tr.excluded td { opacity: .35; text-decoration: line-through; background: #f7f8f9; }
.import-table tr.excluded .remove-col { opacity: 1; text-decoration: none; }
.filter-panel { display: flex; align-items: flex-end; gap: 10px; padding: 14px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.filter-panel label:first-child { flex: 1; }
.filter-panel label.grow { flex: 1; }
.receipt-layout { display: grid; grid-template-columns: minmax(0,1fr) 310px; gap: 18px; align-items: start; }
.receipt-summary { padding: 18px; position: sticky; top: 18px; }
.summary-line { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: .85rem; }
.summary-line.total { margin-top: 5px; padding-top: 13px; border-top: 1px solid var(--line); font-size: 1rem; }
.summary-line.net { color: var(--coffee); font-size: .95rem; }
.receipt-summary hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }
.receipt-actions { display: grid; gap: 8px; margin-top: 16px; }
.inline-error { margin-top: 10px; padding: 9px; border-radius: 7px; color: var(--red); background: var(--red-soft); font-size: .78rem; }
.section-panel { margin-top: 18px; padding: 18px; }
.section-panel h2 { margin: 0 0 12px; font-size: 1rem; }
.history-list { display: grid; }
.history-list a { display: flex; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); text-decoration: none; }
.history-list small { display: block; color: var(--muted); margin-top: 3px; }
.metric-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.metric { padding: 17px; border: 1px solid var(--line); border-radius: 10px; background: white; box-shadow: var(--shadow); }
.metric span { display: block; color: var(--muted); font-size: .78rem; }
.metric strong { display: block; margin-top: 6px; font-size: 1.2rem; }
.report-actions { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.status-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.status-card { padding: 20px; }
.status-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.status-card h2 { margin: 0; font-size: 1rem; }
.status-card dl { margin: 16px 0; }
.status-card dl div { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px solid #edf0f2; font-size: .84rem; }
.status-card dt, .muted-text { color: var(--muted); }
.status-card dd { margin: 0; font-weight: 600; text-align: right; }
.muted-text { font-size: .84rem; line-height: 1.5; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #22292e; }
.login-card { width: min(430px,100%); padding: 30px; border-radius: 14px; background: white; box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.login-brand { color: var(--ink); margin-bottom: 30px; }
.login-brand small { color: var(--muted); }
.login-card h1 { margin: 0 0 20px; font-size: 1.25rem; }

@media (max-width: 1050px) {
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-actions { justify-content: flex-start; }
  .search-form { max-width: none; }
  .receipt-layout { grid-template-columns: 1fr; }
  .receipt-summary { position: static; }
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .filter-panel { flex-wrap: wrap; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: -260px; width: 242px; transition: left .2s ease; box-shadow: 10px 0 30px rgba(0,0,0,.2); }
  .menu-open .sidebar { left: 0; }
  .mobile-menu { display: block; }
  .topbar { padding: 16px; justify-content: flex-start; }
  .topbar-status { margin-left: auto; font-size: 0; }
  .content { padding: 18px 14px 40px; }
  .messages { padding: 12px 14px 0; }
  .form-grid, .status-grid { grid-template-columns: 1fr; }
  .form-grid label.wide { grid-column: auto; }
  .toolbar-actions .button { flex: 1; }
  .search-form { flex-wrap: wrap; }
  .search-form input { flex-basis: 100%; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .filter-panel label, .filter-panel label:first-child, .filter-panel label.grow { flex: 1 1 190px; }
}
@media (max-width: 440px) {
  .metric-grid { grid-template-columns: 1fr; }
  .toolbar-actions { display: grid; grid-template-columns: 1fr 1fr; }
}
