:root {
  color-scheme: light;
  --bg: #0b0b0a;
  --surface: #ffffff;
  --surface-soft: #f3f0e8;
  --ink: #191816;
  --muted: #716b5f;
  --line: #ded3bd;
  --accent: #c9a45a;
  --accent-strong: #9f7535;
  --accent-light: #f1df9d;
  --income: #b8944f;
  --expense: #b24747;
  --warning: #c9882f;
  --blue: #141414;
  --shadow: 0 22px 58px rgba(0, 0, 0, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(201, 164, 90, 0.2), transparent 28rem),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.4;
}

.login-screen {
  align-items: center;
  background:
    radial-gradient(circle at top, rgba(201, 164, 90, 0.18), transparent 26rem),
    #050505;
  display: none;
  inset: 0;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  position: fixed;
  z-index: 10;
}

.login-required .login-screen {
  display: flex;
}

.login-required .app-shell {
  display: none;
}

.login-card {
  background: #ffffff;
  border: 1px solid rgba(201, 164, 90, 0.45);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  max-width: 420px;
  padding: 24px;
  width: 100%;
}

.login-card h1 {
  color: var(--ink);
  font-size: 2rem;
}

.login-card p {
  color: var(--muted);
  margin-bottom: 0;
}

.login-card label {
  color: var(--muted);
  display: grid;
  font-size: 0.9rem;
  font-weight: 800;
  gap: 6px;
}

.login-logo {
  background: #000;
  border-radius: 8px;
  height: 82px;
  object-fit: cover;
  padding: 5px;
  width: 82px;
}

.login-error {
  color: #b24747 !important;
  font-weight: 800;
  min-height: 20px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #000000;
  border-right: 1px solid rgba(201, 164, 90, 0.35);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
}

.brand-logo {
  background: #000000;
  border: 1px solid rgba(201, 164, 90, 0.45);
  border-radius: 8px;
  height: 68px;
  object-fit: cover;
  object-position: center;
  padding: 4px;
  width: 68px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.sidebar-summary span,
.sidebar-summary small {
  color: #cdbb91;
}

.brand strong {
  color: #ffffff;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  background: transparent;
  border-radius: 8px;
  color: #e8e1d1;
  padding: 12px 14px;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: linear-gradient(135deg, rgba(201, 164, 90, 0.26), rgba(255, 255, 255, 0.08));
  box-shadow: inset 3px 0 0 var(--accent);
  color: #ffffff;
}

.sidebar-summary {
  background: linear-gradient(145deg, #141414, #050505);
  border: 1px solid rgba(201, 164, 90, 0.45);
  border-radius: 8px;
  margin-top: auto;
  padding: 16px;
}

.sidebar-summary strong {
  color: var(--accent-light);
  display: block;
  font-size: 1.6rem;
  margin: 6px 0;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  color: #ffffff;
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1.05;
  margin-bottom: 0;
}

h2 {
  font-size: 1.05rem;
  margin-bottom: 0;
}

.topbar-actions,
.filter-row,
.button-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.month-picker {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  padding: 8px 10px;
}

.month-picker span {
  color: var(--muted);
  font-size: 0.86rem;
}

input,
select,
textarea {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 11px;
  width: 100%;
}

textarea {
  resize: vertical;
}

.primary-button {
  background: linear-gradient(135deg, #f1df9d, #c49b4e 50%, #8a5f2a);
  border-radius: 8px;
  color: #111111;
  font-weight: 800;
  min-height: 42px;
  padding: 10px 15px;
}

.primary-button:hover {
  background: linear-gradient(135deg, #ffeeb5, #cca455 50%, #9b6d31);
}

.ghost-button {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-weight: 800;
  min-height: 42px;
  padding: 10px 14px;
}

.icon-toggle {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: inline-grid;
  height: 42px;
  justify-content: center;
  width: 46px;
}

.icon-toggle svg {
  fill: none;
  height: 22px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 22px;
}

.sensitive-hidden .icon-toggle {
  background: #111111;
  color: #f1df9d;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid rgba(201, 164, 90, 0.28);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  min-height: 118px;
  padding: 18px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 0.88rem;
}

.metric strong {
  display: block;
  font-size: clamp(1.4rem, 2vw, 2.1rem);
  margin-top: 12px;
}

.metric.income {
  border-top: 5px solid var(--accent);
}

.metric.expense {
  border-top: 5px solid var(--expense);
}

.metric.warning {
  border-top: 5px solid var(--warning);
}

.metric strong {
  color: #111111;
}

.dashboard-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.45fr) minmax(330px, 0.55fr);
  margin-bottom: 18px;
}

.dashboard-layout.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  padding: 18px;
}

.section-heading {
  align-items: start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-heading p {
  color: var(--muted);
  margin: 4px 0 0;
}

.chart-panel canvas {
  display: block;
  height: 320px;
  width: 100%;
}

.category-bars,
.stack-list,
.card-list {
  display: grid;
  gap: 12px;
}

.category-row {
  display: grid;
  gap: 6px;
}

.category-row header,
.list-item,
.account-card header,
.budget-card header,
.goal-card header {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.bar-track {
  background: var(--surface-soft);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.bar-fill {
  background: linear-gradient(90deg, #8a5f2a, #f1df9d);
  border-radius: inherit;
  height: 100%;
}

.list-item,
.account-card,
.budget-card,
.goal-card {
  background: #fafbf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
}

.muted,
.empty-state {
  color: var(--muted);
}

.amount.income {
  color: var(--income);
}

.amount.expense {
  color: var(--expense);
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 900px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.align-right {
  text-align: right;
}

.status {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 5px 9px;
}

.status.paid {
  background: #bbebc9;
  color: #075c2b;
}

.status.pending {
  background: #ffd08a;
  color: #8a3f00;
}

.status.partial {
  background: #cbdcff;
  color: #143d86;
}

.status.overdue {
  background: #ffc9c9;
  color: #8f1111;
}

.status.carried {
  background: #ece7db;
  color: #6f6656;
}

.status.priority-high {
  background: #ffc9c9;
  color: #8f1111;
}

.status.priority-medium {
  background: #ffd08a;
  color: #8a3f00;
}

.status.priority-low {
  background: #cbdcff;
  color: #143d86;
}

.status.priority-blocked {
  background: #ece7db;
  color: #6f6656;
}

.status.stock-ok {
  background: #bbebc9;
  color: #075c2b;
}

.status.stock-low {
  background: #ffc9c9;
  color: #8f1111;
}

.status.consequence-protected {
  background: #b91c1c;
  color: #fff7f7;
}

.status.consequence-negotiate {
  background: #d97706;
  color: #fff9ed;
}

.status.consequence-postpone {
  background: #315fbd;
  color: #eef4ff;
}

.status.consequence-cut {
  background: #525252;
  color: #f5f5f5;
}

.status.consequence-auto {
  background: #e7e0d1;
  color: #5f5748;
}

.priority-group {
  background: #fafbf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.priority-group.protected {
  box-shadow: inset 5px 0 0 #b91c1c;
}

.priority-group.negotiate {
  box-shadow: inset 5px 0 0 #d97706;
}

.priority-group.postpone {
  box-shadow: inset 5px 0 0 #315fbd;
}

.priority-group.cut {
  box-shadow: inset 5px 0 0 #525252;
}

.priority-group header,
.priority-items div {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.priority-group p {
  margin: 3px 0 0;
}

.priority-items {
  display: grid;
  gap: 8px;
}

.priority-items div {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.priority-items span {
  color: var(--muted);
  font-size: 0.9rem;
}

.smart-row.high {
  box-shadow: inset 4px 0 0 #c81f1f;
}

.smart-row.medium {
  box-shadow: inset 4px 0 0 #d97706;
}

.smart-row.low {
  box-shadow: inset 4px 0 0 #2f80c9;
}

.smart-row.blocked {
  opacity: 0.72;
}

.inventory-row.low {
  background: #fff0f0;
  box-shadow: inset 4px 0 0 #d72424;
}

.inventory-row.ok {
  box-shadow: inset 4px 0 0 #15964a;
}

.lookup-result {
  margin-top: 12px;
}

.purchase-request-item {
  align-items: center;
}

.request-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.request-actions label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.compact-input {
  margin-top: 4px;
  max-width: 132px;
  min-height: 36px;
  padding: 8px 10px;
}

.text-button {
  min-width: 82px;
  width: auto;
}

.seller-mode .topbar-actions,
.seller-mode .sidebar-summary,
.seller-mode #inventory .metric-grid,
.seller-mode .inventory-management-panel,
.seller-mode .inventory-product-admin,
.seller-mode .inventory-movement-admin {
  display: none;
}

.seller-mode .sidebar {
  height: auto;
  position: static;
}

.seller-mode .app-shell {
  grid-template-columns: 220px minmax(0, 1fr);
}

.seller-mode .inventory-count-panel .section-heading h2::after {
  content: " / balanco";
}

.recurrence-pill {
  background: #f4eddc;
  border-radius: 999px;
  color: #7a561e;
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 800;
  margin-top: 5px;
  padding: 4px 8px;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.transaction-row,
.commitment-item {
  border-left: 5px solid transparent;
}

.transaction-row.pending,
.commitment-item.pending {
  background: #fff0d6;
  border-left-color: #e07200;
}

.transaction-row.overdue,
.commitment-item.overdue {
  background: #ffeaea;
  border-left-color: #d72424;
}

.transaction-row.partial,
.commitment-item.partial {
  background: #edf4ff;
  border-left-color: #245fc3;
}

.transaction-row.paid,
.commitment-item.paid {
  background: #e6faeb;
  border-left-color: #15964a;
}

.icon-button,
.row-actions button {
  align-items: center;
  background: #f4eddc;
  border-radius: 8px;
  color: var(--ink);
  display: inline-grid;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.row-actions button[data-action="edit"] {
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0 10px;
  width: auto;
}

.two-column {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid label {
  color: var(--muted);
  display: grid;
  font-size: 0.88rem;
  font-weight: 700;
  gap: 6px;
}

.schedule-fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 10px;
}

.schedule-fieldset legend {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  padding: 0 6px;
}

.schedule-options {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, 1fr);
}

.schedule-options label {
  align-items: center;
  background: var(--surface-soft);
  border-radius: 8px;
  color: var(--ink);
  display: flex;
  justify-content: center;
  min-height: 40px;
  padding: 8px;
  text-align: center;
}

.schedule-options label:has(input:checked) {
  background: #111111;
  color: #f1df9d;
}

.is-hidden {
  display: none !important;
}

.full-width {
  grid-column: 1 / -1;
}

.progress-line {
  background: var(--surface-soft);
  border-radius: 999px;
  height: 10px;
  margin-top: 12px;
  overflow: hidden;
}

.progress-line span {
  background: linear-gradient(90deg, #8a5f2a, #f1df9d);
  display: block;
  height: 100%;
}

.calendar-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekday {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0 4px 4px;
  text-align: center;
  text-transform: uppercase;
}

.calendar-cell,
.calendar-day-row {
  background: #fafbf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 6px;
  min-height: 104px;
  padding: 10px;
  text-align: left;
}

.calendar-cell span {
  color: var(--muted);
  font-weight: 800;
}

.calendar-cell strong,
.calendar-day-row strong {
  color: var(--expense);
  font-size: 0.9rem;
  min-height: 20px;
}

.calendar-cell small,
.calendar-day-row small {
  color: var(--muted);
}

.calendar-cell em {
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
}

.calendar-cell .calendar-protected {
  color: #b91c1c;
  font-weight: 800;
}

.calendar-cell.is-muted {
  background: transparent;
  border-color: transparent;
  min-height: 104px;
}

.calendar-cell.is-selected,
.calendar-day-row.is-selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(201, 164, 90, 0.35);
}

.calendar-grid-list {
  grid-template-columns: 1fr;
}

.calendar-day-row {
  align-items: center;
  grid-template-columns: 1fr auto auto;
  min-height: 66px;
}

.reconciliation-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 12px;
}

.reconciliation-grid span {
  background: var(--surface-soft);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  gap: 4px;
  padding: 10px;
}

.reconciliation-grid strong {
  color: var(--ink);
}

.danger-zone {
  border-color: #edc8c8;
}

.danger-button {
  background: #b74343;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  min-height: 42px;
  padding: 10px 14px;
}

.file-button,
.button-row button {
  background: #f4eddc;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 800;
  padding: 10px 14px;
}

.file-button input {
  display: none;
}

dialog {
  border: 0;
  border-radius: 8px;
  max-width: 760px;
  padding: 0;
  width: calc(100% - 32px);
}

dialog::backdrop {
  background: rgba(13, 25, 22, 0.55);
}

.modal-card {
  padding: 22px;
}

.modal-header,
.modal-actions {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 18px;
}

.segmented {
  background: var(--surface-soft);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 16px;
  padding: 6px;
}

.segmented label {
  align-items: center;
  border-radius: 8px;
  display: flex;
  font-weight: 800;
  gap: 8px;
  justify-content: center;
  min-height: 40px;
}

.segmented label:has(input:checked) {
  background: #ffffff;
  box-shadow: 0 1px 8px rgba(23, 33, 31, 0.1);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    position: static;
  }

  .nav-list {
    grid-template-columns: repeat(3, 1fr);
  }

  .metric-grid,
  .dashboard-layout,
  .dashboard-layout.compact,
  .two-column {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .main,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .filter-row {
    align-items: stretch;
    flex-direction: column;
  }

  .schedule-options {
    grid-template-columns: 1fr;
  }

  .calendar-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calendar-weekday,
  .calendar-cell.is-muted {
    display: none;
  }

  .calendar-day-row {
    grid-template-columns: 1fr;
  }

  .nav-list {
    grid-template-columns: repeat(2, 1fr);
  }
}
