/* ===========================================================
   LIVIA PROPERTY MANAGEMENT — Design system
   =========================================================== */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafafb;
  --border: #e7e9ee;
  --text: #171a21;
  --text-muted: #6b7280;
  --text-faint: #9aa1ac;

  --sidebar-bg: #0e1015;
  --sidebar-bg-2: #14171e;
  --sidebar-text: #9aa1b0;
  --sidebar-text-active: #ffffff;
  --sidebar-border: #21242c;

  --accent: #17624a;
  --accent-strong: #114b3a;
  --accent-light: #e7f2ee;
  --gold: #b08d57;
  --gold-light: #f7f0e4;

  --ok-bg: #e2f6ea; --ok-text: #157a45; --ok-border: #b9e7c9;
  --warn-bg: #fef3c7; --warn-text: #92400e; --warn-border: #fde5a1;
  --bad-bg: #fde8e8; --bad-text: #b91c1c; --bad-border: #f7c9c9;
  --muted-bg: #eef0f3; --muted-text: #6b7280; --muted-border: #e2e4e9;

  --chart-ok: #1f9d5c;
  --chart-bad: #e0625a;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(16, 20, 30, .04);
  --shadow: 0 1px 2px rgba(16,20,30,.04), 0 10px 28px -14px rgba(16,20,30,.16);
  --shadow-lg: 0 20px 45px -18px rgba(16,20,30,.28);

  --sidebar-w: 250px;
  --topbar-h: 68px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
button { font-family: inherit; }
::selection { background: var(--accent-light); }

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

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

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
  color: var(--sidebar-text);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 30;
}
.brand {
  padding: 26px 22px 20px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--gold), #8f6f3d);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #1a1305; font-size: 16px; flex-shrink: 0;
}
.brand-text { line-height: 1.25; }
.brand-name { color: #fff; font-size: 15.5px; font-weight: 800; letter-spacing: .03em; }
.brand-sub { color: var(--gold); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; font-weight: 600; }

.nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.nav-group-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #5b6170; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--sidebar-text);
  margin-bottom: 2px; transition: background .12s, color .12s;
  user-select: none;
}
.nav-item .ic { font-size: 16px; width: 20px; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,.05); color: #e5e7eb; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item .count { margin-left: auto; background: rgba(255,255,255,.12); padding: 1px 7px; border-radius: 20px; font-size: 11px; }
.nav-item.active .count { background: rgba(255,255,255,.25); }

.sidebar-foot { padding: 16px 20px; border-top: 1px solid var(--sidebar-border); font-size: 11.5px; color: #565c6a; }

.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 19px; }
.topbar .crumb { font-size: 12.5px; color: var(--text-faint); }
.topbar-spacer { flex: 1; }
.topbar-search { position: relative; width: 280px; max-width: 40vw; }
.topbar-search input { padding-left: 34px; }
.topbar-search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 14px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 17px; position: relative; flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn .dot { position: absolute; top: -4px; right: -4px; background: var(--bad-text); color: #fff; font-size: 10px; font-weight: 700; min-width: 17px; height: 17px; border-radius: 20px; display: flex; align-items: center; justify-content: center; padding: 0 3px; border: 2px solid var(--surface); }

.content { padding: 26px 28px 60px; max-width: 1440px; width: 100%; margin: 0 auto; }

/* ---------- Buttons ---------- */

.btn {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 16px;
  cursor: pointer; font-weight: 600; font-size: 13.5px; background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #201705; }
.btn.danger { background: var(--bad-bg); border-color: var(--bad-border); color: var(--bad-text); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 7px 11px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-icon { padding: 8px 10px; }

/* ---------- Forms ---------- */

input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px;
  font-size: 13.5px; font-family: inherit; background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
textarea { resize: vertical; min-height: 70px; }
label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 6px; color: var(--text-muted); }
.field { margin-bottom: 2px; }
.field.checkbox-field { display: flex; align-items: center; gap: 8px; }
.field.checkbox-field input { width: auto; }
.hint { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid .span-2 { grid-column: span 2; }

/* ---------- Cards / stats ---------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 18px; position: relative; overflow: hidden; }
.stat-card .stat-top { display: flex; justify-content: space-between; align-items: flex-start; }
.stat-card .stat-icon { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 16px; background: var(--accent-light); }
.stat-card .stat-label { color: var(--text-muted); font-size: 12.5px; font-weight: 600; margin-top: 12px; }
.stat-card .stat-value { font-size: 25px; font-weight: 800; margin-top: 3px; letter-spacing: -0.02em; }
.stat-card .stat-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; }
.stat-card.alert .stat-value { color: var(--bad-text); }
.stat-card.warn .stat-value { color: var(--warn-text); }

.section-title { font-size: 15px; font-weight: 800; margin: 30px 0 12px; display: flex; align-items: center; justify-content: space-between; }
.section-title .btn { margin-left: auto; }

.two-col { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; align-items: start; }

/* ---------- Badges / status ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700;
  border: 1px solid transparent; white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok-text); border-color: var(--ok-border); }
.badge.warn { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-border); }
.badge.bad { background: var(--bad-bg); color: var(--bad-text); border-color: var(--bad-border); }
.badge.muted-badge { background: var(--muted-bg); color: var(--muted-text); border-color: var(--muted-border); }
.badge.gold { background: var(--gold-light); color: #7a5c26; border-color: #ecdcb8; }

/* ---------- Toolbar / table ---------- */

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.toolbar .search-box { position: relative; flex: 1; min-width: 220px; }
.toolbar .search-box input { padding-left: 34px; }
.toolbar .search-box .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); }
.toolbar select { width: auto; min-width: 150px; }

.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 1400px; }
.table th, .table td { padding: 13px 14px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13px; white-space: nowrap; }
.table th { color: var(--text-muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; position: sticky; top: 0; background: var(--surface); }
.table tbody tr { cursor: pointer; transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.addr-cell { white-space: normal; min-width: 200px; }
.table .addr-main { font-weight: 700; }
.table .addr-sub { color: var(--text-faint); font-size: 11.5px; }
.table .num { font-variant-numeric: tabular-nums; }

.empty-state { text-align: center; padding: 70px 20px; color: var(--text-muted); }
.empty-state .emoji { font-size: 38px; margin-bottom: 10px; }
.empty-state h3 { margin-bottom: 6px; color: var(--text); }

/* ---------- Modal ---------- */

.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(10,12,16,.55); backdrop-filter: blur(2px);
  z-index: 100; align-items: flex-start; justify-content: center; padding: 40px 20px; overflow-y: auto;
}
.modal-backdrop.show { display: flex; }
.modal-box { background: var(--surface); border-radius: var(--radius-lg); max-width: 780px; width: 100%; box-shadow: var(--shadow-lg); animation: modalIn .16s ease; }
.modal-box.wide { max-width: 960px; }
.modal-box.narrow { max-width: 480px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 22px 24px; max-height: 72vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); }
.form-section-title { font-weight: 800; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-strong); margin: 22px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.form-section-title:first-child { margin-top: 0; }

/* ---------- Tabs ---------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn { padding: 11px 16px; border-radius: 10px 10px 0 0; cursor: pointer; font-weight: 700; font-size: 13px; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent-strong); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Detail page ---------- */

.detail-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.detail-head .back-btn { margin-bottom: 8px; }
.detail-title { font-size: 22px; font-weight: 800; }
.detail-sub { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.detail-actions { margin-left: auto; display: flex; gap: 8px; }

.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px 26px; }
.info-item .k { font-size: 11.5px; color: var(--text-faint); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.info-item .v { font-size: 14.5px; font-weight: 600; }

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 4px; }
.kpi { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; text-align: left; }
.kpi .k { font-size: 11px; color: var(--text-muted); font-weight: 700; }
.kpi .v { font-size: 18px; font-weight: 800; margin-top: 4px; }
.kpi.highlight { background: var(--accent-light); border-color: #cfe6da; }
.kpi.highlight .v { color: var(--accent-strong); }

/* ---------- Documents ---------- */

.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.doc-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface); }
.doc-card .doc-cat { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--accent-strong); background: var(--accent-light); display: inline-block; padding: 2px 8px; border-radius: 6px; margin-bottom: 8px; }
.doc-card .doc-name { font-weight: 700; font-size: 13.5px; margin-bottom: 3px; word-break: break-word; }
.doc-card .doc-meta { font-size: 11px; color: var(--text-faint); margin-bottom: 10px; }
.doc-card .doc-actions { display: flex; gap: 6px; }

/* ---------- Rent grid ---------- */

.rent-year-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.rent-month { border: 1px solid var(--border); border-radius: 11px; padding: 12px; cursor: pointer; transition: border-color .1s; }
.rent-month:hover { border-color: var(--accent); }
.rent-month .m-name { font-weight: 700; font-size: 13px; }
.rent-month .m-sub { font-size: 11px; color: var(--text-faint); margin-top: 4px; }
.rent-month.paid { background: var(--ok-bg); border-color: var(--ok-border); }
.rent-month.unpaid { background: var(--bad-bg); border-color: var(--bad-border); }
.rent-month.na { background: var(--muted-bg); opacity: .65; }

/* ---------- Lists (expenses, notifications) ---------- */

.list-row { display: flex; align-items: center; gap: 14px; padding: 13px 4px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.list-row .lr-icon { width: 36px; height: 36px; border-radius: 9px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.list-row .lr-main { flex: 1; min-width: 0; }
.list-row .lr-title { font-weight: 700; font-size: 13.5px; }
.list-row .lr-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.list-row .lr-right { text-align: right; flex-shrink: 0; }

/* ---------- Notification panel ---------- */

.notif-panel {
  position: fixed; top: 0; right: -420px; width: 400px; max-width: 92vw; height: 100vh; background: var(--surface);
  box-shadow: var(--shadow-lg); z-index: 110; transition: right .2s ease; display: flex; flex-direction: column;
}
.notif-panel.show { right: 0; }
.notif-panel .np-head { padding: 20px 20px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.notif-panel .np-body { flex: 1; overflow-y: auto; padding: 6px 16px; }
.notif-scrim { display: none; position: fixed; inset: 0; background: rgba(10,12,16,.35); z-index: 105; }
.notif-scrim.show { display: block; }

/* ---------- Dropzone (Ε9 import / document upload) ---------- */

.dropzone {
  border: 2px dashed var(--border); border-radius: 14px; padding: 34px 20px; text-align: center; color: var(--text-muted);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-light); }
.dropzone .dz-emoji { font-size: 30px; margin-bottom: 8px; }

/* ---------- Toast ---------- */

.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #16181d; color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg); animation: toastIn .18s ease; display: flex; align-items: center; gap: 8px; max-width: 360px; white-space: normal; line-height: 1.4; }
.toast.error { background: #7f1d1d; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Misc ---------- */

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-variant-numeric: tabular-nums; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer; }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.filter-pop { position: absolute; top: 46px; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 16px; width: 260px; z-index: 40; display: none; }
.filter-pop.show { display: block; }
.filter-wrap { position: relative; }

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .content { padding: 18px 16px 50px; }
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .rent-year-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 10px 14px; height: auto; flex-wrap: wrap; row-gap: 10px; }
  .topbar-search { order: 10; width: 100%; max-width: 100%; }
  .menu-toggle { display: flex !important; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .info-grid { grid-template-columns: 1fr; }
  .doc-grid { grid-template-columns: 1fr; }
}

.menu-toggle { display: none; }

/* ---------- Auth screen ---------- */

.auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2)); padding: 20px;
}
.auth-card {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 34px 32px; width: 100%; max-width: 380px;
}
