:root {
  color-scheme: light;
  --bg: #f5f6f2;
  --surface: #ffffff;
  --surface-2: #eef3f0;
  --ink: #18201d;
  --muted: #66716b;
  --line: #d8dfd9;
  --green: #266955;
  --green-2: #dcebe5;
  --gold: #b47831;
  --red: #a94442;
  --blue: #346b91;
  --shadow: 0 18px 50px rgba(33, 44, 39, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 40% 25%, rgba(255, 255, 255, 0.08), transparent 34%), #17251f;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.compact-brand {
  color: var(--ink);
  margin-bottom: 8px;
}

.compact-brand p {
  color: var(--muted);
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  background: #17251f;
  color: #f8fbf7;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #f4c46c;
  color: #17251f;
  font-weight: 800;
}

.brand-logo {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  flex: 0 0 auto;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.brand p,
.source-card small,
.source-card span {
  margin: 3px 0 0;
  color: #b9c6bf;
  font-size: 0.85rem;
}

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

.nav-button,
.secondary-button {
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.18s ease;
}

.nav-button {
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  color: #d9e2dd;
  background: transparent;
}

.nav-button:hover,
.nav-button.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.source-card {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  display: grid;
  gap: 5px;
}

.logout-button {
  margin-top: 8px;
  padding: 8px 10px;
  text-align: center;
  background: rgba(255, 255, 255, 0.08);
}

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

.home-strip {
  overflow: hidden;
  margin-bottom: 22px;
  aspect-ratio: 3 / 2;
  max-height: min(72vh, 760px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b314a;
  box-shadow: var(--shadow);
}

.home-page-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.view-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h2 {
  font-size: clamp(1.5rem, 2.5vw, 2.15rem);
}

h3 {
  font-size: 1rem;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.toolbar.compact {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search,
.select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.search {
  width: min(380px, 40vw);
  padding: 0 14px;
}

.select {
  padding: 0 12px;
}

.toolbar.compact .select[type="date"] {
  width: 150px;
}

.secondary-button {
  min-height: 42px;
  padding: 0 16px;
  background: var(--green);
  color: #fff;
}

.secondary-button.subtle {
  background: #fff;
  color: var(--green);
  border-color: var(--line);
}

.row-actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.icon-button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7faf8;
  color: var(--ink);
  cursor: pointer;
}

.icon-button.danger {
  color: var(--red);
}

.sync-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 160px 160px auto;
  gap: 10px;
  align-items: center;
}

.entry-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 10px;
  align-items: center;
}

.settings-grid {
  display: grid;
  gap: 14px;
}

.settings-row {
  display: grid;
  grid-template-columns: 1.2fr repeat(3, minmax(120px, 1fr));
  gap: 10px;
  align-items: center;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  align-items: center;
}

.check-row {
  min-height: 42px;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.9rem;
}

.helper-text {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

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

.kpi-card,
.panel,
.property-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kpi-card {
  padding: 18px;
}

.kpi-card span,
.panel-header span,
.metric-label,
.property-meta,
td small {
  color: var(--muted);
  font-size: 0.82rem;
}

.kpi-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.45rem;
}

.kpi-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.35;
}

.kpi-card.negative strong {
  color: var(--red);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.8fr);
  gap: 18px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel.wide {
  grid-column: span 1;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

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

.property-card {
  padding: 15px;
  box-shadow: none;
}

.property-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.status-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.76rem;
  background: var(--green-2);
  color: var(--green);
  font-weight: 800;
}

.status-pill.loss {
  background: #f5e2df;
  color: var(--red);
}

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

.metric-value {
  display: block;
  margin-top: 3px;
  font-weight: 800;
}

.bar-list {
  display: grid;
  gap: 12px;
}

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

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

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

.bar-fill {
  min-width: 3px;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.bar-fill.gold {
  background: var(--gold);
}

.bar-fill.blue {
  background: var(--blue);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: var(--surface);
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #edf3ef;
  color: #35423b;
  font-weight: 800;
}

tr:last-child td {
  border-bottom: 0;
}

.number,
.money {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.money.negative {
  color: var(--red);
}

.report-stack,
.detail-panels {
  display: grid;
  gap: 18px;
}

.report-summary {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 18px;
}

.callout {
  padding: 18px;
  border-radius: 8px;
  background: #eaf3ef;
  border: 1px solid #cfe1d8;
}

.callout p {
  margin: 8px 0 0;
  color: #42514a;
  line-height: 1.5;
}

.raw-sheet table {
  min-width: 980px;
}

.row-number {
  width: 58px;
  color: var(--muted);
  background: #f7f8f6;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

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

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

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

  .nav-stack {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .nav-button {
    text-align: center;
  }

  .kpi-grid,
  .dashboard-grid,
  .report-summary {
    grid-template-columns: 1fr;
  }

  .property-grid {
    grid-template-columns: 1fr;
  }

  .sync-grid {
    grid-template-columns: 1fr;
  }

  .entry-grid,
  .account-grid,
  .settings-row {
    grid-template-columns: 1fr;
  }

  .search {
    width: min(100%, 420px);
  }
}

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

  .view-header {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-stack {
    grid-template-columns: 1fr 1fr;
  }

  .kpi-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 680px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .view:not(#report),
  #printReport {
    display: none !important;
  }

  .app-shell,
  .main {
    display: block;
    padding: 0;
  }

  #report {
    display: block !important;
  }

  .panel,
  .kpi-card,
  .property-card,
  .callout {
    box-shadow: none;
    break-inside: avoid;
  }
}
