@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=Jost:wght@300;400;500;600&display=swap');

:root {
  --forest: #1b3a2e;
  --forest-deep: #10241c;
  --gold: #b08d4f;
  --gold-light: #cdae7a;
  --cream: #faf8f4;
  --white: #ffffff;
  --ink: #2a2f2b;
  --muted: #5c655f;
  --line: rgba(27, 58, 46, 0.14);
  --red: #a83c3c;
  --red-bg: rgba(180, 60, 60, 0.08);
  --green-bg: rgba(27, 58, 46, 0.08);
  --max: 1180px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Jost', sans-serif;
  color: var(--ink);
  background: var(--cream);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .serif {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  color: var(--forest);
  margin: 0;
}

p { margin: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; }

.boot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  color: var(--muted);
  letter-spacing: 0.05em;
}

/* ---------- Layout ---------- */

.shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: var(--forest);
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar .brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.topbar .brand img { height: 34px; width: auto; filter: brightness(0) invert(1); }
.topbar .brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.topbar .brand-text strong { font-family: 'Cormorant Garamond', serif; font-size: 1.15rem; letter-spacing: 0.06em; }
.topbar .brand-text span { font-size: 0.6rem; letter-spacing: 0.24em; text-transform: uppercase; color: var(--gold-light); }

.icon-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: var(--white);
  border-radius: 2px;
  padding: 8px 14px;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.2s ease;
  white-space: nowrap;
}
.icon-btn:hover { background: rgba(255,255,255,0.1); }

.tabbar {
  background: var(--white);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 58px;
  z-index: 40;
  overflow-x: auto;
}

.tabbar-inner {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  padding: 0 12px;
}

.tab {
  padding: 14px 18px;
  font-size: 0.86rem;
  letter-spacing: 0.03em;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  background: none;
  border-top: none; border-left: none; border-right: none;
}

.tab.active { color: var(--forest); border-bottom-color: var(--gold); font-weight: 500; }

main {
  flex: 1;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ---------- Login ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(16, 36, 28, 0.85) 0%, rgba(16, 36, 28, 0.7) 100%),
    var(--forest);
}

.login-card {
  background: var(--white);
  border-radius: 4px;
  padding: 44px 36px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 30px 70px -30px rgba(0,0,0,0.5);
}

.login-card img { height: 56px; margin: 0 auto 18px; }
.login-card h1 { font-size: 1.6rem; margin-bottom: 4px; }
.login-card p.sub { color: var(--muted); font-size: 0.88rem; margin-bottom: 26px; }

.field { display: flex; flex-direction: column; gap: 7px; text-align: left; margin-bottom: 16px; }
.field label { font-size: 0.74rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--forest); }

input, select, textarea {
  font-family: 'Jost', sans-serif;
  font-size: 0.95rem;
  padding: 11px 13px;
  border: 1px solid var(--line);
  background: var(--cream);
  color: var(--ink);
  border-radius: 2px;
  outline: none;
  width: 100%;
  transition: border-color 0.2s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
textarea { resize: vertical; min-height: 80px; font-family: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  border-radius: 2px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}
.btn-gold { background: var(--gold); color: var(--forest-deep); font-weight: 500; }
.btn-block { width: 100%; }
.btn-gold:hover { background: var(--gold-light); }
.btn-outline { border-color: var(--forest); color: var(--forest); background: none; }
.btn-outline:hover { background: var(--forest); color: var(--white); }
.btn-danger { border-color: var(--red); color: var(--red); background: none; }
.btn-danger:hover { background: var(--red); color: var(--white); }
.btn-sm { padding: 7px 14px; font-size: 0.78rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.error-msg { color: var(--red); background: var(--red-bg); padding: 10px 12px; border-radius: 2px; font-size: 0.85rem; margin-bottom: 14px; display: none; }
.error-msg.show { display: block; }

/* ---------- Cards / grid ---------- */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.page-head h2 { font-size: 1.7rem; }

.period-picker { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.period-picker select { width: auto; padding: 9px 12px; font-size: 0.85rem; }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 20px;
}

.stat-card .label { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); display: block; margin-bottom: 8px; }
.stat-card .value { font-family: 'Cormorant Garamond', serif; font-size: 1.9rem; color: var(--forest); font-weight: 600; }
.stat-card .value.negative { color: var(--red); }
.stat-card .sub { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }

.section-title {
  font-size: 1.15rem;
  margin: 30px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.property-list { display: flex; flex-direction: column; gap: 10px; }

.property-row {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  flex-wrap: wrap;
}
.property-row:hover { box-shadow: 0 12px 28px -18px rgba(27,58,46,0.3); transform: translateY(-1px); }

.property-row .name { font-family: 'Cormorant Garamond', serif; font-size: 1.25rem; color: var(--forest); }
.property-row .meta { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.property-row .metrics { display: flex; gap: 22px; flex-wrap: wrap; }
.property-row .metrics div { text-align: right; }
.property-row .metrics .v { font-family: 'Cormorant Garamond', serif; font-size: 1.15rem; color: var(--forest); font-weight: 600; }
.property-row .metrics .k { font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

.badge { display: inline-block; font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; padding: 3px 9px; border-radius: 10px; background: var(--green-bg); color: var(--forest); }
.badge.archived { background: rgba(0,0,0,0.06); color: var(--muted); }

table { width: 100%; border-collapse: collapse; background: var(--white); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
th, td { padding: 10px 12px; text-align: left; font-size: 0.86rem; border-bottom: 1px solid var(--line); }
th { background: var(--cream); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
tr:last-child td { border-bottom: none; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }
.table-wrap { overflow-x: auto; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.link-btn { background: none; border: none; color: var(--forest); cursor: pointer; font-size: 0.78rem; padding: 4px 6px; text-decoration: underline; }
.link-btn.danger { color: var(--red); }

.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-state p { margin-bottom: 16px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(16,36,28,0.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 100;
}
.modal {
  background: var(--white); border-radius: 4px; padding: 30px 28px;
  width: 100%; max-width: 520px;
}
.modal h3 { font-size: 1.4rem; margin-bottom: 20px; }
.modal .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

.form-inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.form-inline .field { margin-bottom: 0; min-width: 130px; }

.tabs-sub { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs-sub button { background: var(--white); border: 1px solid var(--line); padding: 8px 16px; border-radius: 20px; font-size: 0.82rem; cursor: pointer; color: var(--muted); }
.tabs-sub button.active { background: var(--forest); color: var(--white); border-color: var(--forest); }

.chart-wrap { background: var(--white); border: 1px solid var(--line); border-radius: 4px; padding: 20px; margin-bottom: 28px; }
.chart-wrap svg { width: 100%; height: auto; display: block; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--forest); color: var(--white); padding: 12px 20px;
  border-radius: 4px; font-size: 0.86rem; z-index: 200; opacity: 0; transition: opacity 0.25s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--red); }

.print-report { background: var(--white); border: 1px solid var(--line); padding: 40px; max-width: 700px; margin: 0 auto; }
.print-report h2 { font-size: 1.6rem; margin-bottom: 4px; }
.print-report .sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 24px; }
.print-report table { margin-top: 16px; }

@media print {
  .topbar, .tabbar, .page-head .period-picker, .no-print { display: none !important; }
  main { padding: 0; max-width: none; }
  body { background: var(--white); }
}

@media (max-width: 720px) {
  .topbar .brand-text span { display: none; }
  .modal .field-row { grid-template-columns: 1fr; }
  .property-row { flex-direction: column; align-items: flex-start; }
  .property-row .metrics { width: 100%; justify-content: space-between; gap: 10px; }
  main { padding: 18px 14px 60px; }
}
