/* style.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green: #1D9E75;
  --green-dark: #0F6E56;
  --color-bg: #f5f4f0;
  --color-surface: #ffffff;
  --color-border: rgba(0,0,0,0.1);
  --color-border-md: rgba(0,0,0,0.18);
  --color-text: #1a1a18;
  --color-muted: #6b6b67;
  --color-hint: #9e9d99;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --font: 'Inter', system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1a1a18;
    --color-surface: #232320;
    --color-border: rgba(255,255,255,0.1);
    --color-border-md: rgba(255,255,255,0.18);
    --color-text: #f0ede8;
    --color-muted: #9e9d99;
    --color-hint: #6b6b67;
  }
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Login ─────────────────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--color-bg);
}

.login-box {
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.login-logo-icon {
  width: 40px; height: 40px;
  background: var(--green);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 20px;
}

.login-logo-text { font-size: 18px; font-weight: 500; }
.login-logo-sub  { font-size: 12px; color: var(--color-muted); }

.login-title { font-size: 15px; font-weight: 500; margin-bottom: 20px; }

.lang-bar {
  display: flex; gap: 8px; margin-bottom: 20px;
}

.flag-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border: 0.5px solid var(--color-border-md);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  color: var(--color-muted);
  transition: all 0.15s;
}

.flag-btn:hover { border-color: var(--green); color: var(--color-text); }
.flag-btn.active { border-color: var(--green); color: var(--green); background: rgba(29,158,117,0.06); font-weight: 500; }
.flag-btn .flag { font-size: 18px; line-height: 1; }

.login-error {
  background: #FCEBEB; color: #A32D2D;
  border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 13px; margin-bottom: 14px;
  display: none;
}

/* ── App Shell ─────────────────────────────────────────────────── */
#app-shell {
  display: none;
  height: 100vh;
  overflow: hidden;
}

.shell {
  display: flex;
  height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  width: 210px;
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 0.5px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 16px 16px 14px;
  border-bottom: 0.5px solid var(--color-border);
}

.sidebar-logo-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 2px;
}

.sidebar-icon {
  width: 28px; height: 28px;
  background: var(--green);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px;
}

.sidebar-logo-name { font-size: 14px; font-weight: 500; }
.sidebar-logo-sub  { font-size: 11px; color: var(--color-muted); }

.sidebar-user {
  padding: 10px 14px;
  border-bottom: 0.5px solid var(--color-border);
}

.sidebar-user-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: var(--color-muted); }

.nav-section {
  font-size: 10px;
  color: var(--color-hint);
  padding: 12px 14px 4px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--color-muted);
  border-left: 2px solid transparent;
  transition: background 0.12s, color 0.12s;
  user-select: none;
}

.nav-item:hover { background: var(--color-bg); color: var(--color-text); }
.nav-item.active { background: var(--color-bg); color: var(--color-text); font-weight: 500; border-left-color: var(--green); }
.nav-item i { font-size: 16px; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 14px;
  border-top: 0.5px solid var(--color-border);
  display: flex; flex-direction: column; gap: 10px;
}

.lang-bar-sidebar {
  display: flex; gap: 6px;
}

/* ── Main area ─────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 0.5px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
}

.topbar h1 { font-size: 15px; font-weight: 500; }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px;
}

/* ── Pages ─────────────────────────────────────────────────────── */
.page { display: none; }

/* ── Metrics grid ──────────────────────────────────────────────── */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.metric {
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.metric-label { font-size: 11px; color: var(--color-muted); margin-bottom: 5px; }
.metric-value { font-size: 22px; font-weight: 500; }
.metric-sub   { font-size: 11px; color: var(--color-hint); margin-top: 2px; }

/* ── Section headings ──────────────────────────────────────────── */
.sh { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.st { font-size: 11px; font-weight: 500; color: var(--color-hint); text-transform: uppercase; letter-spacing: .05em; }

/* ── Tables ────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
th {
  text-align: left; padding: 7px 10px;
  color: var(--color-hint); font-weight: 400; font-size: 11px;
  border-bottom: 0.5px solid var(--color-border);
}
td {
  padding: 9px 10px;
  border-bottom: 0.5px solid var(--color-border);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--color-bg); }

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.ann-title { font-size: 13px; font-weight: 500; }
.ann-meta  { font-size: 11px; color: var(--color-hint); margin-top: 3px; }
.ann-body  { font-size: 13px; color: var(--color-muted); line-height: 1.6; margin-top: 8px; }

/* ── Project cards ─────────────────────────────────────────────── */
.proj-card {
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.proj-head  { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 8px; }
.proj-title { font-size: 13px; font-weight: 500; }
.proj-desc  { font-size: 12px; color: var(--color-muted); margin-bottom: 10px; line-height: 1.5; }

.prog-bar   { height: 4px; background: var(--color-bg); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.prog-fill  { height: 100%; background: var(--green); border-radius: 2px; transition: width .3s; }
.prog-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--color-hint); margin-top: 4px; }

/* ── Directory ─────────────────────────────────────────────────── */
.dir-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--color-border);
}
.dir-row:last-child { border-bottom: none; }

.dir-info { flex: 1; min-width: 0; }
.dir-name { font-size: 13px; font-weight: 500; }
.dir-unit { font-size: 11px; color: var(--color-hint); }
.dir-contact { font-size: 12px; color: var(--color-muted); margin-top: 2px; overflow-wrap: break-word; word-break: break-all; }
.dir-badge { flex-shrink: 0; }

/* ── Avatar ────────────────────────────────────────────────────── */
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: #E6F1FB; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 500; color: #185FA5; flex-shrink: 0;
}

/* ── Badges & tags ─────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 7px; border-radius: 99px; font-size: 11px; font-weight: 500; }
.b-paid     { background: #EAF3DE; color: #3B6D11; }
.b-pending  { background: #FAEEDA; color: #854F0B; }
.b-overdue  { background: #FCEBEB; color: #A32D2D; }
.b-planning { background: #E6F1FB; color: #185FA5; }
.b-active   { background: #FAEEDA; color: #854F0B; }
.b-done     { background: #EAF3DE; color: #3B6D11; }
.b-paused   { background: #F1EFE8; color: #5F5E5A; }

.tag          { display: inline-block; padding: 2px 7px; border-radius: 99px; font-size: 11px; }
.tag-info     { background: #E6F1FB; color: #185FA5; }
.tag-warn     { background: #FAEEDA; color: #854F0B; }
.tag-success  { background: #EAF3DE; color: #3B6D11; }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; font-size: 12px;
  border: 0.5px solid var(--color-border-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font);
  transition: background 0.12s;
  white-space: nowrap;
}
.btn:hover { background: var(--color-bg); }

.btn-primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn-primary:hover { background: var(--green-dark); border-color: var(--green-dark); }

.btn-sm { padding: 3px 8px; font-size: 11px; }

.btn-logout {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--color-muted);
  background: none; border: none; cursor: pointer;
  padding: 0; font-family: var(--font);
}
.btn-logout:hover { color: var(--color-text); }

/* ── Form elements ─────────────────────────────────────────────── */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 11px; color: var(--color-muted); margin-bottom: 4px; }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="month"],
select, textarea {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  font-family: var(--font);
  border: 0.5px solid var(--color-border-md);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); }
textarea { resize: vertical; height: 72px; }

/* ── Modals ────────────────────────────────────────────────────── */
.modal-bg {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-bg.open { display: flex; }

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 22px;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  border: 0.5px solid var(--color-border);
}

.modal h2 { font-size: 15px; font-weight: 500; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

/* ── Empty state ───────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-hint);
  font-size: 13px;
}
.empty i { font-size: 28px; margin-bottom: 10px; display: block; }

/* ── Scrollbar ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-md); border-radius: 99px; }

/* ── Auth screen ──────────────────────────────────────────────────── */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--color-bg);
}

.auth-box {
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  width: 100%;
  max-width: 390px;
}

/* ── Auth tabs ────────────────────────────────────────────────────── */
.auth-tabs {
  display: flex;
  border-bottom: 0.5px solid var(--color-border);
  margin-bottom: 22px;
  gap: 0;
}

.auth-tab {
  flex: 1;
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: var(--color-muted);
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -0.5px;
}

.auth-tab:hover { color: var(--color-text); }
.auth-tab.active { color: var(--green); border-bottom-color: var(--green); font-weight: 500; }

/* ── Auth messages ────────────────────────────────────────────────── */
.auth-error {
  background: #FCEBEB;
  color: #A32D2D;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
  line-height: 1.5;
}

.auth-success {
  background: #EAF3DE;
  color: #3B6D11;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
  line-height: 1.5;
}

.auth-submit {
  width: 100%;
  justify-content: center;
  padding: 9px 16px;
  font-size: 13px;
}

/* ── Field hint ───────────────────────────────────────────────────── */
.field-hint {
  font-size: 11px;
  color: var(--color-hint);
  margin-top: 5px;
  line-height: 1.5;
  padding: 6px 8px;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
}

/* ── Profile page ─────────────────────────────────────────────────── */
.profile-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.profile-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: #E6F1FB;
  color: #185FA5;
  font-size: 18px;
  font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.profile-name { font-size: 16px; font-weight: 500; }
.profile-role { font-size: 12px; color: var(--color-muted); margin-top: 2px; }

/* ── Nav sections ─────────────────────────────────────────────────── */
.nav-section {
  font-size: 10px;
  color: var(--color-hint);
  padding: 12px 14px 4px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* ── Address / signup extras ──────────────────────────────────────── */
.field-section-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 16px 0 10px;
  padding-top: 12px;
  border-top: 0.5px solid var(--color-border);
}

.address-preview {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--color-bg);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}

.address-preview i { color: var(--green); font-size: 16px; margin-top: 1px; }

.address-row-card {
  background: var(--color-bg);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 10px;
}

.addr-row-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ── Sidebar credit ────────────────────────────────────────────────── */
.sidebar-credit {
  font-size: 10px;
  color: var(--color-hint);
  text-align: center;
  padding-top: 6px;
  border-top: 0.5px solid var(--color-border);
}
.sidebar-credit a {
  color: var(--color-hint);
  text-decoration: none;
}
.sidebar-credit a:hover { color: var(--green); text-decoration: underline; }

/* ── Help page ─────────────────────────────────────────────────────── */
.help-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.help-hero-icon {
  width: 48px; height: 48px;
  background: var(--green);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 22px; flex-shrink: 0;
}
.help-hero-title { font-size: 18px; font-weight: 500; }
.help-hero-sub { font-size: 12px; color: var(--color-muted); }

.help-contact-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.faq-item {
  padding: 10px 0;
  border-bottom: 0.5px solid var(--color-border);
}
.faq-item:last-child { border-bottom: none; }
.faq-q { font-size: 13px; font-weight: 500; }
.faq-a { font-size: 13px; color: var(--color-muted); line-height: 1.7; padding-bottom: 12px; }

/* ── Manager code badge ─────────────────────────────────────────────── */
.manager-code-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #E6F1FB;
  color: #185FA5;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
}
.manager-code-badge strong {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .05em;
}

/* ── History page ──────────────────────────────────────────────────── */
.history-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}
.history-filters select,
.history-filters input[type="month"] {
  width: auto;
  font-size: 13px;
  padding: 6px 10px;
  border: 0.5px solid var(--color-border-md);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
}

.history-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.hist-stat {
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.hist-stat-label { font-size: 11px; color: var(--color-muted); margin-bottom: 4px; }
.hist-stat-value { font-size: 20px; font-weight: 500; }
.hist-stat-sub   { font-size: 11px; color: var(--color-hint); margin-top: 2px; }

.hist-stat.green .hist-stat-value { color: #3B6D11; }
.hist-stat.red   .hist-stat-value { color: #A32D2D; }
.hist-stat.orange .hist-stat-value { color: #854F0B; }

/* Timeline view */
.hist-month-group { margin-bottom: 20px; }
.hist-month-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-hint);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 0 0 8px;
  border-bottom: 0.5px solid var(--color-border);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.hist-month-total {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text);
}

.hist-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 0.5px solid var(--color-border);
}
.hist-row:last-child { border-bottom: none; }

.hist-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.hist-dot.paid    { background: #3B6D11; }
.hist-dot.pending { background: #854F0B; }
.hist-dot.overdue { background: #A32D2D; }

.hist-info { flex: 1; min-width: 0; }
.hist-apt  { font-size: 13px; font-weight: 500; }
.hist-desc { font-size: 12px; color: var(--color-muted); }
.hist-date { font-size: 11px; color: var(--color-hint); margin-top: 1px; }

.hist-amount {
  font-size: 13px;
  font-weight: 500;
  text-align: right;
  flex-shrink: 0;
}
.hist-amount.paid    { color: #3B6D11; }
.hist-amount.pending { color: #854F0B; }
.hist-amount.overdue { color: #A32D2D; }

/* ── History page ────────────────────────────────────────────────── */
.history-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.history-filters select,
.history-filters input[type="month"] {
  flex: 1;
  min-width: 140px;
  font-size: 13px;
  padding: 7px 10px;
  border: 0.5px solid var(--color-border-md);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
}

.history-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.hist-stat {
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  text-align: center;
}
.hist-stat-label { font-size: 11px; color: var(--color-muted); margin-bottom: 4px; }
.hist-stat-value { font-size: 20px; font-weight: 500; }
.hist-stat-count { font-size: 11px; color: var(--color-hint); margin-top: 2px; }

.hist-month-group { margin-bottom: 20px; }
.hist-month-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 8px;
  padding-left: 2px;
}

/* ── Admin entrance card ─────────────────────────────────────────── */
.admin-entrance-card { padding: 14px 16px; }
.aec-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.aec-name { font-size: 14px; font-weight: 500; }
.aec-addr { font-size: 12px; color: var(--color-muted); margin-top: 2px; }
.aec-mgr  { font-size: 11px; color: var(--color-hint); margin-top: 4px; }
.aec-stats {
  display: flex; gap: 16px; flex-shrink: 0;
  text-align: right;
}
.aec-stat { font-size: 13px; }
.aec-stat span { font-weight: 500; display: block; font-size: 16px; }
.aec-stat small { font-size: 11px; color: var(--color-hint); }

/* ── Manager entrance card ───────────────────────────────────────── */
.manager-entrance-card { padding: 14px 16px; }
.mec-head {
  display: flex; justify-content: space-between;
  align-items: flex-start; margin-bottom: 12px;
}
.mec-name { font-size: 14px; font-weight: 500; }
.mec-addr { font-size: 12px; color: var(--color-muted); margin-top: 2px; }
.mec-stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; text-align: center;
  background: var(--color-bg);
  border-radius: var(--radius-md);
  padding: 10px;
}
.mec-stat {}
.mec-val { font-size: 18px; font-weight: 500; }
.mec-lbl { font-size: 11px; color: var(--color-hint); margin-top: 2px; }

/* ── Household cards ─────────────────────────────────────────────── */
.household-card { padding: 14px 16px; margin-bottom: 10px; }
.hh-head { display: flex; justify-content: space-between; align-items: flex-start; }
.hh-apt  { font-size: 15px; font-weight: 500; }
.hh-floor { font-size: 12px; font-weight: 400; color: var(--color-muted); }
.hh-entrance { font-size: 12px; color: var(--color-muted); margin-top: 2px; }
.hh-owner, .hh-resident { font-size: 12px; color: var(--color-hint); margin-top: 2px; }
.hh-right { text-align: right; }
.hh-fee { font-size: 18px; font-weight: 500; }
.hh-fee span { font-size: 11px; color: var(--color-hint); }
.hh-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; }
.hh-members { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.hh-names { font-size: 12px; color: var(--color-muted); margin-top: 4px; }

.member-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 99px; font-size: 12px; font-weight: 500;
}
.member-chip.adult   { background: #E6F1FB; color: #185FA5; }
.member-chip.child   { background: #EAF3DE; color: #3B6D11; }
.member-chip.pet     { background: #FAEEDA; color: #854F0B; }

/* ── Members modal ────────────────────────────────────────────────── */
.member-row {
  display: flex; gap: 8px; align-items: center; margin-bottom: 6px;
}
.member-row input { flex: 1; }

/* ── Fee types list ───────────────────────────────────────────────── */
.feetype-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-bottom: 0.5px solid var(--color-border);
}
.feetype-row:last-child { border-bottom: none; }
.feetype-info { flex: 1; min-width: 0; }
.feetype-name { font-size: 13px; font-weight: 500; }
.feetype-meta { display: flex; gap: 6px; margin-top: 4px; }
.feetype-amount { font-size: 16px; font-weight: 500; flex-shrink: 0; }
.feetype-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Fee household multi-select checklist ───────────────────────────── */
.fee-household-list {
  max-height: 180px; overflow-y: auto; margin-top: 6px;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
}
.fee-household-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-bottom: 0.5px solid var(--color-border);
  cursor: pointer; font-size: 13px;
}
.fee-household-row:last-child { border-bottom: none; }
.fee-household-row input { width: auto; margin: 0; flex-shrink: 0; }
.fee-household-row .fhr-entrance { color: var(--color-hint); font-size: 12px; }
.fee-household-row.fhr-hidden { display: none; }

/* ── Recurring fees list ──────────────────────────────────────────── */
.recurfee-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-bottom: 0.5px solid var(--color-border);
}
.recurfee-row:last-child { border-bottom: none; }
.recurfee-info { flex: 1; min-width: 0; }
.recurfee-name { font-size: 13px; font-weight: 500; }
.recurfee-meta { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; align-items: center; }
.recurfee-amount { font-size: 16px; font-weight: 500; flex-shrink: 0; }
.recurfee-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Fee groups ──────────────────────────────────────────────────── */
.fee-group-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; cursor: pointer; user-select: none;
  transition: background 0.12s;
}
.fee-group-head:hover { background: var(--color-bg); }

.fee-group-apt {
  display: flex; align-items: center; gap: 8px;
}
.fee-chevron {
  font-size: 14px; color: var(--color-hint);
  transition: transform 0.2s; flex-shrink: 0;
}
.fga-apt      { font-size: 14px; font-weight: 500; }
.fga-entrance { font-size: 12px; color: var(--color-muted); }

.fee-group-meta {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.fga-month  { font-size: 12px; color: var(--color-hint); }
.fga-total  { font-size: 15px; font-weight: 500; }

.fee-group-details {
  border-top: 0.5px solid var(--color-border);
  background: var(--color-bg);
}
.fee-group-details table th,
.fee-group-details table td { background: transparent; }

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile first (≤ 768px)
══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── Auth screen ──────────────────────────────────────────────── */
  #auth-screen { padding: 16px; align-items: flex-start; padding-top: 32px; }
  .auth-box { padding: 24px 18px; }

  /* ── App shell: sidebar becomes bottom nav ────────────────────── */
  .shell { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 0.5px solid var(--color-border);
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 50;
    background: var(--color-surface);
    border-top: 0.5px solid var(--color-border);
  }

  /* Hide logo, user info, section labels, footer in mobile nav */
  .sidebar-logo,
  .sidebar-user,
  .nav-section,
  .sidebar-footer { display: none !important; }

  .nav-item {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    gap: 3px;
    font-size: 10px;
    border-left: none;
    border-top: 2px solid transparent;
    white-space: nowrap;
    min-width: 60px;
    flex-shrink: 0;
  }
  .nav-item.active {
    border-left: none;
    border-top-color: var(--green);
    color: var(--green);
    background: none;
  }
  .nav-item i { font-size: 20px; }

  /* ── Main area ────────────────────────────────────────────────── */
  .main { overflow: hidden; }
  .content {
    padding: 14px 14px 80px; /* bottom padding for fixed nav */
    overflow-y: auto;
    height: calc(100vh - 52px); /* topbar height */
    -webkit-overflow-scrolling: touch;
  }

  /* ── Topbar ───────────────────────────────────────────────────── */
  .topbar {
    padding: 10px 14px;
    gap: 8px;
  }
  .topbar h1 { font-size: 14px; }
  #topbar-action { display: flex; gap: 6px; flex-wrap: wrap; }
  #topbar-action .btn { font-size: 11px; padding: 5px 8px; }

  /* ── Metrics grid: 2 columns on mobile ───────────────────────── */
  .metrics { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .metric-value { font-size: 18px; }

  /* ── Tables: scroll horizontally ─────────────────────────────── */
  .content table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* Allow text to wrap in description/name columns, keep amounts/dates on one line */
  th { white-space: nowrap; }
  td { white-space: normal; word-break: break-word; }
  td:nth-child(3), td:nth-child(4), td:nth-child(5), td:nth-child(6) { white-space: nowrap; }

  /* ── Cards ────────────────────────────────────────────────────── */
  .card { padding: 12px; }

  /* ── Fee groups ───────────────────────────────────────────────── */
  .fee-group-head { flex-wrap: wrap; gap: 6px; }
  .fee-group-meta { flex-wrap: wrap; gap: 6px; }
  .fga-total { font-size: 14px; }

  /* ── History stats: 2×2 grid ──────────────────────────────────── */
  .history-stats { grid-template-columns: repeat(2, 1fr); }

  /* ── Project cards ────────────────────────────────────────────── */
  .proj-head { flex-direction: column; gap: 6px; }

  /* ── Directory rows ───────────────────────────────────────────── */
  .dir-contact { white-space: normal; }

  /* ── Household cards ──────────────────────────────────────────── */
  .hh-head { flex-wrap: wrap; gap: 8px; }
  .hh-right { text-align: left; width: 100%; display: flex; align-items: center; justify-content: space-between; }

  /* ── Manager entrance cards ───────────────────────────────────── */
  .mec-stats { grid-template-columns: repeat(2, 1fr); }
  .mec-head { flex-wrap: wrap; gap: 8px; }

  /* ── Admin entrance cards ─────────────────────────────────────── */
  .aec-head { flex-direction: column; gap: 8px; }
  .aec-stats { flex-direction: row; flex-wrap: wrap; justify-content: flex-start; text-align: left; gap: 12px; }

  /* ── Modals: full screen on mobile ───────────────────────────── */
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100%;
    width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px 16px;
  }

  /* ── Help page ────────────────────────────────────────────────── */
  .help-hero { flex-direction: column; text-align: center; }
  .help-contact-row { flex-direction: column; align-items: center; text-align: center; }

  /* ── Fee types list ───────────────────────────────────────────── */
  .feetype-row { flex-wrap: wrap; gap: 8px; }
  .feetype-actions { width: 100%; justify-content: flex-end; }

  /* ── History filters ──────────────────────────────────────────── */
  .history-filters { flex-direction: column; }
  .history-filters select,
  .history-filters input[type="month"] { width: 100%; }

  /* ── Auth tabs ────────────────────────────────────────────────── */
  .auth-tabs { margin-bottom: 16px; }

  /* ── Lang bar ─────────────────────────────────────────────────── */
  .lang-bar { justify-content: center; }
}

/* ── Small phones (≤ 380px) ──────────────────────────────────────── */
@media (max-width: 380px) {
  .nav-item { min-width: 52px; padding: 8px 6px; font-size: 9px; }
  .nav-item i { font-size: 18px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .auth-box { padding: 20px 14px; }
}

/* ── Tablet (769px – 1024px): compact sidebar ────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar { width: 160px; }
  .nav-item { font-size: 12px; padding: 7px 12px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .mec-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ── Mobile header ───────────────────────────────────────────────── */
.mobile-header {
  display: none; /* shown via JS on mobile */
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--color-surface);
  border-bottom: 0.5px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 40;
}
.mobile-logo {
  display: flex; align-items: center; gap: 8px;
}
@media (max-width: 768px) {
  .mobile-header { display: flex !important; }
  /* Скрий само заглавието на topbar, остави action бутоните */
  .topbar h1 { display: none; }
  .topbar {
    padding: 8px 12px;
    min-height: 44px;
    justify-content: flex-end;
    border-bottom: 0.5px solid var(--color-border);
    background: var(--color-surface);
  }
  #topbar-action { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; width: 100%; }
  #topbar-action .btn { font-size: 11px; padding: 5px 9px; }
  #app-shell { height: 100dvh; height: 100vh; }
  .shell { height: 100%; }
  .main { height: 100%; overflow: hidden; display: flex; flex-direction: column; }
  .content { flex: 1; }

  /* Tables — prevent overflow, allow horizontal scroll */
  .content > div { max-width: 100%; overflow-x: visible; }
  table { font-size: 12px; }
  table th, table td { padding: 7px 8px; }

  /* Fee group details table */
  .fee-group-details { overflow-x: auto; }
  .fee-group-meta { gap: 6px; }
  .fee-group-meta .btn { font-size: 11px; padding: 4px 8px; }

  /* History page */
  #history-list .card { overflow-x: auto; }

  /* Hide less important columns on mobile */
  .hide-mobile { display: none !important; }
}

/* ── History item cards ──────────────────────────────────────────── */
.hist-item-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px;
}
.hist-apt { font-size: 14px; font-weight: 500; }
.hist-entrance {
  font-size: 11px; color: var(--color-hint);
  margin-left: 8px; background: var(--color-bg);
  padding: 1px 6px; border-radius: 99px;
}
.hist-amount { font-size: 15px; font-weight: 500; }
.hist-item-desc { font-size: 12px; color: var(--color-muted); margin-bottom: 4px; }
.hist-item-meta {
  display: flex; gap: 12px; flex-wrap: wrap;
  font-size: 11px; color: var(--color-hint);
}

/* ── Compact selects in filters/modals ──────────────────────────── */
select { max-height: 200px; }

/* History filters — more compact on mobile */
@media (max-width: 768px) {
  .history-filters { gap: 6px; }
  .history-filters select,
  .history-filters input[type="month"] {
    font-size: 13px; padding: 6px 8px;
  }
  .hist-stats { grid-template-columns: repeat(2,1fr); gap: 6px; }
  .hist-stat { padding: 8px 10px; }
  .hist-stat-value { font-size: 16px; }
}

/* ── Dashboard apt rows ──────────────────────────────────────────── */
.dash-apt-row {
  border-bottom: 0.5px solid var(--color-border);
}
.dash-apt-row:last-child { border-bottom: none; }

.dash-apt-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; cursor: pointer; user-select: none;
  transition: background 0.1s;
}
.dash-apt-head:hover { background: var(--color-bg); border-radius: var(--radius-sm); padding-left: 4px; padding-right: 4px; }

.dash-apt-details { background: var(--color-bg); border-radius: var(--radius-sm); margin: 4px 0; }

/* ── FAQ tabs — grid, 2 rows ──────────────────────────────────────── */
.faq-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: 100%;
  border-bottom: 0.5px solid var(--color-border);
}
.faq-tab-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px;
  font-size: 10px; font-family: var(--font);
  color: var(--color-hint);
  background: none; border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  text-align: center; word-break: break-word;
}
.faq-tab-btn i { font-size: 16px; flex-shrink: 0; }
.faq-tab-btn:hover { color: var(--color-text); }
.faq-tab-btn.active { color: var(--green); border-bottom-color: var(--green); font-weight: 500; }

/* ── FAQ items (accordion) ────────────────────────────────────────── */
.faq-item {
  border-bottom: 0.5px solid var(--color-border);
  padding: 0;
}
.faq-item:last-child { border-bottom: none; }

.faq-q-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; cursor: pointer; gap: 8px;
}
.faq-q-row:hover .faq-q { color: var(--green); }
.faq-q { font-size: 13px; font-weight: 500; line-height: 1.4; }
.faq-chevron {
  font-size: 14px; color: var(--color-hint);
  flex-shrink: 0; transition: transform 0.2s;
}
.faq-a {
  font-size: 13px; color: var(--color-muted);
  line-height: 1.7; padding-bottom: 12px;
}

@media (max-width: 768px) {
  .faq-tab-btn { padding: 8px 10px; font-size: 10px; }
  .faq-tab-btn i { font-size: 16px; }
}

/* ── FAQ tabs scroll indicator ───────────────────────────────────── */
.faq-tabs-wrap {
  position: relative;
}
.faq-tabs-wrap::after {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 32px;
  background: linear-gradient(to right, transparent, var(--color-surface));
  pointer-events: none;
}

/* ── Help page compact on mobile ─────────────────────────────────── */
@media (max-width: 768px) {
  .help-hero { flex-direction: row !important; text-align: left !important; }
  .help-contact-row { flex-direction: row !important; align-items: center !important; text-align: left !important; }
}

/* ── Global text wrapping fix ────────────────────────────────────── */
/* Only text containers wrap — not scrollable containers */
.card, .proj-card, .hist-item, .household-card,
.ann-body, .ann-title, .ann-meta,
.faq-a, .faq-q,
.proj-title, .proj-desc,
.hist-item-desc, .hist-item-meta,
.mec-name, .mec-addr,
.aec-name, .aec-addr,
.hh-apt, .hh-entrance, .hh-owner, .hh-resident,
.feetype-name,
.dir-name, .dir-unit {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Prevent any element from pushing past viewport */
.content, .page, .modal {
  max-width: 100%;
  box-sizing: border-box;
}

/* Fix other scrollable containers (not faq-tabs — that's a grid now) */
.sidebar,
.content,
.history-filters,
.fee-group-details {
  overflow-x: auto;
}

/* Contact card buttons — force full row, no overflow */
.help-contact-buttons {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 10px;
  width: 100%;
}
