﻿:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --text: #1d252d;
  --muted: #607080;
  --line: #d9e0e7;
  --red: #d94848;
  --blue: #276ef1;
  --green: #20805f;
  --yellow: #b57900;
  --ink-red: #7b1f1f;
  --radius: 8px;
  --shadow: 0 18px 45px rgba(23, 35, 48, 0.12);
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

.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;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 36px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.7rem, 3vw, 2.4rem);
}

h2 {
  font-size: 1.05rem;
}

.header-actions,
.dialog-actions,
.records-toolbar,
.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button,
.view-button,
.segment {
  min-height: 40px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 700;
}

.primary-button {
  background: var(--red);
  color: #ffffff;
}

.secondary-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--text);
}

.ghost-button {
  background: transparent;
  color: var(--red);
}

.danger-button {
  background: #fff2f2;
  color: var(--ink-red);
  border-color: #f2c6c6;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  padding: 0;
  background: #ffffff;
  border-color: var(--line);
  color: var(--text);
  font-size: 1.25rem;
}
.sync-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.sync-badge[data-tone="ok"] {
  background: #e2f6ee;
  border-color: #b6e2d0;
  color: #155f47;
}

.sync-badge[data-tone="warn"] {
  background: #fff4d8;
  border-color: #ebce8b;
  color: #7a5000;
}

.app-shell {
  width: min(1420px, calc(100% - 40px));
  margin: 26px auto 44px;
}

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

.metric {
  display: grid;
  gap: 10px;
  min-height: 110px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}

.metric span {
  color: var(--muted);
  font-weight: 700;
}

.metric strong {
  font-size: 2rem;
  line-height: 1;
}

.metric-red {
  border-top: 4px solid var(--red);
}

.metric-blue {
  border-top: 4px solid var(--blue);
}

.metric-yellow {
  border-top: 4px solid var(--yellow);
}

.metric-green {
  border-top: 4px solid var(--green);
}

.workbench {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.filters-panel,
.records-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.filters-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
  position: sticky;
  top: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(39, 110, 241, 0.14);
}

.quick-views {
  display: grid;
  gap: 8px;
}

.view-button {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
}

.view-button.active {
  background: #ffe9e9;
  color: var(--ink-red);
}

.records-panel {
  overflow: hidden;
}

.records-toolbar {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.records-toolbar p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

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

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

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #fafbfc;
}

td {
  font-size: 0.92rem;
}

tr:hover td {
  background: #fbfcfd;
}

.supplier-cell {
  display: grid;
  gap: 3px;
}

.supplier-cell small {
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.pill.compras {
  background: #ffe9e9;
  color: var(--ink-red);
}

.pill.contabil {
  background: #e8f0ff;
  color: #1646a0;
}

.pill.divergencia {
  background: #fff4d8;
  color: #7a5000;
}

.pill.ok {
  background: #e2f6ee;
  color: #155f47;
}

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

dialog {
  width: min(860px, calc(100% - 28px));
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(10, 18, 28, 0.42);
}

#recordForm {
  padding: 22px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

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

.segment {
  background: transparent;
  color: var(--muted);
}

.segment.active {
  background: #ffffff;
  color: var(--red);
  box-shadow: 0 1px 4px rgba(23, 35, 48, 0.12);
}
.field-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 16px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.field-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot-contabil {
  background: var(--blue);
}

.dot-compras {
  background: var(--red);
}

.dot-shared {
  background: #79828c;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.label-row small {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  white-space: nowrap;
}

.field-owner-contabil .label-row small {
  background: #e8f0ff;
  color: #1646a0;
}

.field-owner-compras .label-row small {
  background: #ffe9e9;
  color: var(--ink-red);
}

.field-owner-shared .label-row small {
  background: #edf0f3;
  color: #43505c;
}

.field-owner-contabil input,
.field-owner-contabil select,
.field-owner-contabil textarea {
  border-left: 4px solid var(--blue);
}

.field-owner-compras input,
.field-owner-compras select,
.field-owner-compras textarea {
  border-left: 4px solid var(--red);
}

.field-owner-shared input,
.field-owner-shared select,
.field-owner-shared textarea {
  border-left: 4px solid #79828c;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

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

.dialog-actions {
  margin-top: 20px;
}

.dialog-actions > div {
  display: flex;
  gap: 10px;
}

.empty-state {
  padding: 34px 18px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 920px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 24px 20px;
  }

  .summary-grid,
  .workbench,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .filters-panel {
    position: static;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}
