/* ===========================================================================
   Property Manager — visual design
   A calm, private records tool. Warm paper ground, deep pine accent, serif
   headings for a considered "ledger/document" feel, monospaced tabular
   figures so money lines up like an account book. No external fonts.
   ======================================================================== */

:root {
  --paper:        #f6f4ef;
  --surface:      #ffffff;
  --surface-alt:  #fbfaf7;
  --ink:          #1c2321;
  --ink-soft:     #3c433f;
  --muted:        #727872;
  --line:         #e6e2d8;
  --line-strong:  #d8d3c6;

  --accent:       #2f5d50;
  --accent-ink:   #244a40;
  --accent-soft:  #e7efe9;

  --success-bg:#e5f0e6; --success-fg:#2c6b3f;
  --warning-bg:#f6ecd6; --warning-fg:#8a6414;
  --info-bg:   #e4ecf5; --info-fg:   #2c5787;
  --danger-bg: #f5e3df; --danger-fg: #9a3b2c;
  --muted-bg:  #ecebe5; --muted-fg:  #5f655f;

  --radius: 8px;
  --shadow: 0 1px 2px rgba(28,35,33,.04), 0 1px 3px rgba(28,35,33,.06);

  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans:  system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono:  ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- App shell ----------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  height: 64px; padding: 0 22px;
  border-bottom: 1px solid var(--line);
  font-family: var(--serif);
  font-size: 17px; font-weight: 600; letter-spacing: .01em;
}
.sidebar__mark { color: var(--accent); font-size: 18px; }
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; padding: 14px 12px; }
.navlink {
  display: block;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--ink-soft);
  font-size: 14px; font-weight: 500;
  border-left: 2px solid transparent;
  transition: background .12s, color .12s;
}
.navlink:hover { background: var(--surface-alt); text-decoration: none; color: var(--ink); }
.navlink--active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-left-color: var(--accent);
  font-weight: 600;
}
.sidebar__foot {
  margin-top: auto; padding: 16px 22px;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* --- Page header --------------------------------------------------------- */
.pageheader {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  padding: 30px 40px 18px;
  border-bottom: 1px solid var(--line);
}
.pageheader__title {
  margin: 0;
  font-family: var(--serif);
  font-size: 26px; font-weight: 600; letter-spacing: -.01em;
}
.pageheader__desc { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.pageheader__action { display: flex; gap: 8px; align-items: center; white-space: nowrap; }

.content { padding: 26px 40px 56px; }

/* --- Cards --------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card + .card, .cards-stack > .card + .card { margin-top: 18px; }
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.card__title { margin: 0; font-family: var(--serif); font-size: 16px; font-weight: 600; }
.card__body { padding: 20px; }

/* --- Stat cards ---------------------------------------------------------- */
.statgrid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  margin-bottom: 18px;
}
.stat { padding: 18px 20px; }
.stat__value { font-family: var(--mono); font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.stat__label { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.stat--accent { border-left: 3px solid var(--accent); }
.income { max-width: 420px; margin-bottom: 26px; }

/* --- Two column layout --------------------------------------------------- */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* --- Tables -------------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td {
  padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table thead th {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 600; background: var(--surface-alt);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-alt); }
.table .right { text-align: right; }
.nums { font-family: var(--mono); font-variant-numeric: tabular-nums; }

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

/* --- Line lists (dashboard) --------------------------------------------- */
.linelist { list-style: none; margin: 0; padding: 0; }
.linelist li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.linelist li:last-child { border-bottom: 0; }

/* --- Detail description list -------------------------------------------- */
.detail { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 28px; margin: 0; }
.detail dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.detail dd { margin: 2px 0 0; font-size: 14.5px; }
.notes { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.notes p { margin: 6px 0 0; color: var(--ink-soft); }

/* --- Badges -------------------------------------------------------------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.5;
}
.badge--success { background: var(--success-bg); color: var(--success-fg); }
.badge--warning { background: var(--warning-bg); color: var(--warning-fg); }
.badge--info    { background: var(--info-bg);    color: var(--info-fg); }
.badge--destructive { background: var(--danger-bg); color: var(--danger-fg); }
.badge--muted   { background: var(--muted-bg);   color: var(--muted-fg); }

/* --- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 6px; border: 1px solid transparent;
  font-family: var(--sans); font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-ink); }
.btn--outline { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn--outline:hover { background: var(--surface-alt); }
.btn--danger { background: var(--surface); border-color: var(--danger-fg); color: var(--danger-fg); }
.btn--danger:hover { background: var(--danger-bg); }
.inline { display: inline; margin: 0; }

/* --- Tabs (property detail) --------------------------------------------- */
.tabs__bar {
  display: flex; flex-wrap: wrap; gap: 2px;
  border-bottom: 1px solid var(--line); margin-bottom: 18px;
}
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 10px 14px; font-family: var(--sans); font-size: 14px; font-weight: 500;
  color: var(--muted); cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab--active { color: var(--accent-ink); border-bottom-color: var(--accent); font-weight: 600; }
.tab .count {
  display: inline-block; margin-left: 5px; padding: 0 6px; border-radius: 999px;
  background: var(--muted-bg); color: var(--muted-fg); font-size: 11px; font-weight: 600;
}
.tabpanel { display: none; }
.tabpanel--active { display: block; }

/* --- Filters (costs) ----------------------------------------------------- */
.filters { display: flex; align-items: center; gap: 6px; margin-bottom: 16px; }
.filter {
  padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line-strong);
  color: var(--ink-soft); font-size: 13px; font-weight: 500; background: var(--surface);
}
.filter:hover { background: var(--surface-alt); text-decoration: none; }
.filter--active { background: var(--accent); border-color: var(--accent); color: #fff; }
.filters__total { margin-left: auto; color: var(--muted); font-size: 13px; }

/* --- Forms --------------------------------------------------------------- */
.form { padding: 24px; max-width: 760px; }
.form__row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form__row--3 { grid-template-columns: 1fr 1fr 1fr; }
.field { display: block; margin-bottom: 16px; }
.field--narrow { max-width: 160px; }
.field__label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.req { color: var(--danger-fg); }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 6px;
  font-family: var(--sans); font-size: 14px; color: var(--ink); background: var(--surface);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { resize: vertical; }
.field__error { display: block; color: var(--danger-fg); font-size: 12.5px; margin-top: 4px; }
.form__actions {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 8px; padding-top: 18px; border-top: 1px solid var(--line);
}

/* --- Flash messages ------------------------------------------------------ */
.flash {
  margin: 18px 40px -6px; padding: 11px 16px; border-radius: 6px;
  font-size: 14px; border: 1px solid;
}
.flash--success { background: var(--success-bg); color: var(--success-fg); border-color: #c7e0cb; }
.flash--warning { background: var(--warning-bg); color: var(--warning-fg); border-color: #e7d6ac; }
.flash--error   { background: var(--danger-bg);  color: var(--danger-fg);  border-color: #e6c3ba; }

/* --- Templates ----------------------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  font-family: var(--mono); font-size: 12px; padding: 2px 8px;
  background: var(--accent-soft); color: var(--accent-ink); border-radius: 5px;
}
.template-preview {
  margin: 0; padding: 14px; background: var(--surface-alt); border: 1px solid var(--line);
  border-radius: 6px; font-family: var(--mono); font-size: 12.5px; color: var(--ink-soft);
  white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto;
}

.strong { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* --- Small buttons & row actions ---------------------------------------- */
.btn--sm { padding: 5px 10px; font-size: 12.5px; }
td .btn--sm, td .inline { vertical-align: middle; }
td .inline { margin-left: 4px; }
.panel-actions { display: flex; justify-content: flex-end; margin-bottom: 10px; }

/* --- Fieldset (tenant assignment, grouped inputs) ----------------------- */
.fieldset {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin: 4px 0 18px;
}
.fieldset legend { padding: 0 6px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.table--tight th, .table--tight td { padding: 7px 10px; }
.table--tight thead th { background: transparent; }

/* --- Checkbox line ------------------------------------------------------- */
.field--check { display: flex; flex-direction: column; }
.checkline { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; }
.checkline input { width: auto; }

/* File input a touch calmer */
.field input[type="file"] { padding: 7px; background: var(--surface-alt); }

/* --- Auth (login / setup) ------------------------------------------------ */
body.auth { background: var(--paper); }
.authwrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.authcard {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 30px 28px 22px;
}
.authbrand {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--serif); font-size: 17px; font-weight: 600; margin-bottom: 20px;
}
.authtitle { font-family: var(--serif); font-size: 22px; font-weight: 600; margin: 0 0 6px; }
.authlead { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.authform .field { margin-bottom: 14px; }
.authbtn { width: 100%; justify-content: center; margin-top: 6px; }
.authfoot { text-align: center; color: var(--muted); font-size: 12px; margin: 20px 0 0; }
.authcard .flash { margin: 0 0 16px; }
.authlead code, .authcard code {
  font-family: var(--mono); font-size: 12.5px; background: var(--accent-soft);
  color: var(--accent-ink); padding: 1px 5px; border-radius: 4px;
}

/* Sidebar user / logout */
.sidebar__user { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.sidebar__user strong { color: var(--ink-soft); }
.sidebar__logout { font-size: 13px; font-weight: 600; color: var(--accent-ink); }

/* Language switch */
.langswitch { display: inline-flex; gap: 4px; margin-top: 12px; }
.langswitch__opt {
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
  padding: 2px 8px; border-radius: 999px; color: var(--muted);
  border: 1px solid var(--line); background: transparent;
}
.langswitch__opt--active {
  color: var(--accent-ink); background: var(--accent-soft); border-color: transparent;
}
.authtop {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px;
}
.authtop .authbrand { margin-bottom: 0; }
.authtop .langswitch { margin-top: 0; }

/* --- Responsive ---------------------------------------------------------- */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar__nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar__foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 22px; }
  .sidebar__foot .sidebar__user { margin-bottom: 0; }
  .langswitch { margin-top: 0; margin-left: auto; }
  .navlink { border-left: 0; border-bottom: 2px solid transparent; }
  .navlink--active { border-left: 0; border-bottom-color: var(--accent); }
  .pageheader, .content { padding-left: 20px; padding-right: 20px; }
  .flash { margin-left: 20px; margin-right: 20px; }
  .statgrid { grid-template-columns: 1fr 1fr; }
  .cols, .form__row, .form__row--3, .detail { grid-template-columns: 1fr; }
}

/* --- Print (property detail → PDF via browser) --------------------------- */
@media print {
  .sidebar, .pageheader__action, .tabs__bar, .btn, .filters { display: none !important; }
  .tabpanel { display: block !important; page-break-inside: avoid; }
  .tabpanel::before {
    content: attr(data-panel);
    display: block; font-family: var(--serif); font-weight: 600; font-size: 15px;
    text-transform: capitalize; margin: 18px 0 8px;
  }
  body { background: #fff; font-size: 12px; }
  .content, .pageheader { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
