/* ============================================================
   RentTrack — Luxury property-management theme
   ============================================================ */

:root {
  --bg:        #0F1623;
  --bg-2:      #131C2C;
  --panel:     #161E2E;
  --panel-2:   #1B2538;
  --line:      #25304a;
  --line-soft: #1f2a40;
  --text:      #E8EAF0;
  --text-dim:  #AEB6C8;
  --muted:     #7A839A;
  --gold:      #C9A84C;
  --gold-soft: #e0c878;
  --green:     #2ECC71;
  --red:       #E74C3C;
  --orange:    #E59A3C;
  --radius:    14px;
  --radius-sm: 10px;
  --shadow:    0 18px 40px -18px rgba(0,0,0,.7);
  --sidebar-w: 248px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'DM Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(201,168,76,.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(46,204,113,.06), transparent 55%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}
h1, h2, h3 { font-family: 'Playfair Display', Georgia, serif; font-weight: 600; margin: 0; letter-spacing: .2px; }
a { color: inherit; text-decoration: none; }
code { background: var(--panel-2); padding: 2px 6px; border-radius: 6px; color: var(--gold-soft); font-size: .85em; }

/* ---------- Brand ---------- */
.brand-mark { font-family: 'Playfair Display', serif; font-weight: 700; font-size: 22px; color: #fff; letter-spacing: .5px; }
.brand-mark span { color: var(--gold); }
.brand-mark.big { font-size: 34px; }
.brand-by { display: block; margin-top: 4px; color: var(--muted); font-size: 10.5px; letter-spacing: .3px; }
.auth-by { margin: 4px 0 0; color: var(--gold-soft); font-size: 11.5px; letter-spacing: .3px; }

/* ============================================================
   AUTH (login / change password)
   ============================================================ */
.auth-body {
  display: grid; place-items: center; min-height: 100vh; padding: 24px;
}
.auth-wrap { width: 100%; max-width: 420px; }
.auth-card {
  background: linear-gradient(160deg, rgba(27,37,56,.85), rgba(15,22,35,.9));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 40px 34px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-tag { color: var(--muted); margin: 8px 0 0; font-size: 13px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }

/* Password show/hide toggle */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 44px; width: 100%; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--muted);
  padding: 6px; display: inline-flex; border-radius: 6px;
}
.pw-toggle svg { width: 19px; height: 19px; }
.pw-toggle:hover { color: var(--text); }
.pw-toggle.on { color: var(--gold); }
.auth-hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }

/* ============================================================
   LAYOUT
   ============================================================ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: linear-gradient(180deg, #131C2C, #0d131f);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 40;
}
.brand { padding: 24px 22px; border-bottom: 1px solid var(--line-soft); }
.nav { padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-weight: 500; font-size: 14.5px;
  border-left: 3px solid transparent; transition: all .18s ease;
}
.nav-item:hover { background: var(--panel-2); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(201,168,76,.16), rgba(201,168,76,.02));
  color: #fff; border-left-color: var(--gold);
}
.nav-ico { width: 20px; height: 20px; display: inline-flex; }
.nav-ico svg { width: 20px; height: 20px; }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--line-soft); }
.nav-logout:hover { color: var(--red); }
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 35;
}
.sidebar-backdrop.show { display: block; }

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

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 26px; border-bottom: 1px solid var(--line);
  background: rgba(15,22,35,.7); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 30;
}
.page-title { font-size: 22px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.topbar-month { color: var(--muted); font-size: 13px; }
.bell { position: relative; background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 6px; }
.bell svg { width: 20px; height: 20px; }
.bell-dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; background: var(--red); border-radius: 50%; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #8c7430);
  color: #1a1305; font-weight: 700; display: grid; place-items: center;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-weight: 600; font-size: 14px; }
.user-role { color: var(--muted); font-size: 11px; }

.hamburger { display: none; flex-direction: column; gap: 4px; background: none; border: none; cursor: pointer; padding: 6px; }
.hamburger span { width: 22px; height: 2px; background: var(--text); border-radius: 2px; }

/* ---------- Content ---------- */
.content { padding: 26px; }

/* ---------- Page fade-in ---------- */
.page-section { animation: fadeUp .5s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 18px; margin-bottom: 24px;
}
.stat-card {
  position: relative; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px;
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: var(--shadow);
}
.stat-card::after {
  content: ''; position: absolute; right: -30px; top: -30px;
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, rgba(201,168,76,.18), transparent 70%);
}
.stat-label { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .6px; }
.stat-value { font-family: 'Playfair Display', serif; font-size: 32px; font-weight: 700; color: #fff; }
.stat-sub { color: var(--text-dim); font-size: 12.5px; }
.grad-1::after { background: radial-gradient(circle, rgba(201,168,76,.20), transparent 70%); }
.grad-2::after { background: radial-gradient(circle, rgba(46,204,113,.16), transparent 70%); }
.grad-3::after { background: radial-gradient(circle, rgba(88,166,255,.16), transparent 70%); }
.grad-4::after { background: radial-gradient(circle, rgba(231,76,60,.16), transparent 70%); }
.grad-5::after { background: radial-gradient(circle, rgba(229,154,60,.16), transparent 70%); }
.grad-6::after { background: radial-gradient(circle, rgba(155,89,182,.16), transparent 70%); }

/* ============================================================
   PANELS
   ============================================================ */
.panel-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.panel, .card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel { padding: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.panel-head h2, .panel-head h3 { font-size: 18px; }
.link-gold { color: var(--gold); font-size: 13px; font-weight: 600; }
.empty { color: var(--muted); text-align: center; padding: 28px 10px; }

/* ============================================================
   TABLES
   ============================================================ */
/* Cards scroll horizontally when a table is wider than the viewport,
   so the right-most columns (Actions / Visa) are never clipped. */
.card { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
.card.pad { padding: 24px; overflow: visible; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead th {
  text-align: left; padding: 14px 16px; color: var(--muted);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px;
  border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none;
}
.table tbody td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:nth-child(even) { background: rgba(255,255,255,.015); }
.table tbody tr:hover { background: rgba(201,168,76,.05); }
.table tbody tr:last-child td { border-bottom: none; }
.table.compact thead th, .table.compact tbody td { padding: 10px 12px; }
.table .right { text-align: right; }
.table .nowrap { white-space: nowrap; }
.table .center { text-align: center; }
.table .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.summary-row td { background: var(--panel-2); font-weight: 600; border-top: 1px solid var(--line); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
th[data-dir]::after { content: ' ▲'; color: var(--gold); font-size: 10px; }
th[data-dir="desc"]::after { content: ' ▼'; }

.actions { white-space: nowrap; }

/* Inline amount editor (Utilities → By Premises) */
.amt-cell { display: flex; align-items: center; gap: 8px; }
.amt-cell .amt-input { width: 130px; min-width: 0; }
.filter-form { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.filter-form label { display: flex; align-items: center; gap: 8px; color: var(--text-dim); font-size: 13px; }

/* Visa section divider inside the staff form */
.visa-sep {
  display: block; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line);
  color: var(--gold-soft); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .5px;
}
/* Manage-utilities checklist */
.util-checklist { display: flex; flex-direction: column; gap: 2px; margin: 14px 0; }

/* High utility bill warning */
.cell-high { background: rgba(231, 76, 60, .12); }
.cell-high .amt-input { border-color: var(--red); }
.warn-flag { color: var(--red); font-size: 14px; cursor: help; }

/* Warn-limit source tag */
.src-tag {
  display: inline-block; margin-left: 5px; padding: 1px 7px; border-radius: 999px;
  font-size: 10px; text-transform: uppercase; letter-spacing: .4px; vertical-align: middle;
}
.src-unit    { background: rgba(201,168,76,.16); color: var(--gold-soft); }
.src-global  { background: rgba(88,166,255,.16); color: #8fc0ff; }
.src-default { background: rgba(122,131,154,.16); color: var(--muted); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-block; padding: 4px 11px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .3px; line-height: 1.4;
}
.badge-success { background: rgba(46,204,113,.15); color: var(--green); border: 1px solid rgba(46,204,113,.35); }
.badge-danger  { background: rgba(231,76,60,.15);  color: var(--red);   border: 1px solid rgba(231,76,60,.35); }
.badge-warning { background: rgba(229,154,60,.15); color: var(--orange);border: 1px solid rgba(229,154,60,.35); }
.badge-muted   { background: rgba(122,131,154,.15);color: var(--muted); border: 1px solid rgba(122,131,154,.3); }
.badge-gold    { background: rgba(201,168,76,.16); color: var(--gold-soft); border: 1px solid rgba(201,168,76,.4); }

.env { font-size: 15px; }
.env.sent { color: var(--green); }
.env.muted { color: var(--muted); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .16s ease; white-space: nowrap;
}
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-gold { background: linear-gradient(135deg, var(--gold), #b3922f); color: #1a1305; }
.btn-gold:hover { filter: brightness(1.08); box-shadow: 0 8px 20px -8px rgba(201,168,76,.6); }
.btn-ghost { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--line); }
.btn-danger { background: linear-gradient(135deg, #e74c3c, #b83227); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.icon-btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text-dim);
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 14px;
  margin-left: 4px; transition: all .15s ease;
}
.icon-btn:hover { color: #fff; border-color: var(--gold); }
.icon-btn.danger:hover { color: var(--red); border-color: var(--red); }

/* ============================================================
   TOOLBAR / SEARCH / FORMS
   ============================================================ */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 13px; }
.search-box { position: relative; flex: 1; max-width: 360px; }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); }
.search-box input { padding-left: 38px; }

input, select, textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text); padding: 11px 13px;
  font-family: inherit; font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,168,76,.15);
}
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }
input[type="month"], input[type="date"], input[type="number"] { width: auto; min-width: 160px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }
.field span { font-weight: 500; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-dim); }
.checkbox input { width: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.narrow { grid-template-columns: 1fr; max-width: 420px; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 12px; justify-content: flex-end; margin-top: 6px; }
.radio-row { display: flex; gap: 18px; align-items: center; }
.radio-row label { display: flex; gap: 7px; align-items: center; color: var(--text-dim); }
.radio-row input { width: auto; }

.month-picker label { display: flex; align-items: center; gap: 10px; color: var(--text-dim); font-size: 13px; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 18px; }
.alert-danger { background: rgba(231,76,60,.12); border: 1px solid rgba(231,76,60,.35); color: #f6a89f; }
.alert-success { background: rgba(46,204,113,.12); border: 1px solid rgba(46,204,113,.35); color: #9be7bd; }

/* ============================================================
   TABS
   ============================================================ */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tab {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  padding: 12px 18px; font-family: inherit; font-size: 14px; font-weight: 600;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .15s;
}
.tab:hover { color: #fff; }
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.tab-panel { display: none; animation: fadeUp .35s ease both; }
.tab-panel.active { display: block; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(8,12,20,.6); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 24px;
  opacity: 0; transition: opacity .2s ease;
}
/* The [hidden] attribute must win over display:grid, otherwise this
   transparent overlay stays on top and swallows every click. */
.modal-overlay[hidden] { display: none; }
.modal-overlay.open { opacity: 1; }
.modal-panel {
  width: 100%; max-width: 560px; max-height: 90vh; overflow: auto;
  background: linear-gradient(160deg, rgba(27,37,56,.95), rgba(18,26,40,.97));
  border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow); transform: translateY(16px) scale(.98);
  transition: transform .22s ease;
}
.modal-overlay.open .modal-panel { transform: none; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 20px; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 26px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: #fff; }
.modal-body { padding: 24px; }
.modal-body .form-grid { margin-bottom: 4px; }
.confirm-msg { font-size: 15px; color: var(--text-dim); margin-top: 0; }

/* ============================================================
   TOASTS
   ============================================================ */
.toast-host { position: fixed; right: 24px; bottom: 24px; z-index: 120; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 13px 18px; border-radius: var(--radius-sm); box-shadow: var(--shadow);
  min-width: 240px; max-width: 360px; font-size: 14px;
  opacity: 0; transform: translateX(20px); transition: all .3s ease;
  border-left: 4px solid var(--gold);
}
.toast.show { opacity: 1; transform: none; }
.toast-success { border-left-color: var(--green); }
.toast-error { border-left-color: var(--red); }
.toast-info { border-left-color: var(--gold); }

/* ============================================================
   REPORTS / CHARTS
   ============================================================ */
.report-area { padding: 8px; min-height: 80px; }
.report-area table { margin-top: 4px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.chart-card { padding: 20px; }
.chart-card h3 { font-size: 16px; margin-bottom: 14px; }
.chart-card canvas { max-height: 320px; }
.report-group-title { font-family: 'Playfair Display', serif; font-size: 17px; color: var(--gold-soft); margin: 22px 0 10px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 980px) {
  .panel-row, .chart-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-100%);
    transition: transform .25s ease; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .hamburger { display: flex; }
  .topbar-month, .user-meta { display: none; }
  .content { padding: 18px 14px; }
  .table { font-size: 13px; }
  .table thead th, .table tbody td { padding: 10px 10px; }
}

/* table horizontal scroll on small screens */
.card { -webkit-overflow-scrolling: touch; }
@media (max-width: 620px) {
  .card { overflow-x: auto; }
  .table { min-width: 560px; }
}
