/* Styles scoped to the private members area (login + dashboard).
   Inherits the brand tokens from main.css and only declares aliases
   for the few legacy variables this file used (--card, --shadow,
   --radius) so the rest of the rules below render with the public
   site's palette + spacing. */

.page-private {
  /* Aliases mapped to canonical brand tokens */
  --card: #ffffff;
  --shadow: 0 8px 22px rgba(29, 63, 60, 0.06);
  --radius: var(--radius-md);

  background: linear-gradient(180deg, var(--paper) 0%, var(--cream) 100%);
  min-height: 100vh;
  padding-top: var(--header-height);
  font-family: var(--font-sans);
}

.page-private header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: rgba(250, 247, 240, 0.92);
  backdrop-filter: saturate(160%) blur(8px);
  -webkit-backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--line);
  z-index: 50;
}

.page-private .nav-actions {
  flex-wrap: wrap;
}

/* ----- User badge in dashboard header ----- */

.user-badge {
  display: flex;
  flex-direction: column;
  text-align: right;
  gap: 2px;
  padding-right: 8px;
}

.user-badge__name {
  font-weight: 600;
  color: var(--brand);
  font-size: 0.95rem;
}

.user-badge__email {
  font-size: 0.78rem;
  color: var(--muted);
}

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

.login-section {
  min-height: calc(100vh - var(--header-height) - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

.login-card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  box-shadow: var(--shadow);
}

.login-card .small {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brand-2);
  font-weight: 600;
  font-size: 0.72rem;
  margin: 0 0 8px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 1.65rem;
  color: var(--brand);
}

.login-card .lead {
  color: var(--muted);
  margin: 0 0 28px;
  font-size: 0.95rem;
}

.btn-google {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

.btn-google:hover {
  border-color: var(--brand-2);
  box-shadow: 0 4px 14px rgba(14, 61, 54, 0.08);
}

.btn-google:active {
  transform: translateY(1px);
}

.btn-google:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-google__icon {
  width: 18px;
  height: 18px;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1 1 auto;
  height: 1px;
  background: var(--border);
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.login-card label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--brand);
  margin-top: 12px;
}

.login-card input {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-card input:focus {
  outline: none;
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(24, 160, 146, 0.15);
}

.login-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.login-actions .btn.primary {
  flex: 1 1 auto;
}

.text-link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--brand-2);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.text-link:hover {
  color: var(--brand);
}

.text-link:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.login-error {
  color: var(--err);
  background: rgba(196, 71, 61, 0.08);
  border: 1px solid rgba(196, 71, 61, 0.25);
  padding: 10px 12px;
  border-radius: 10px;
  margin-top: 16px;
  font-size: 0.9rem;
}

.login-status {
  color: var(--ok);
  background: rgba(27, 127, 85, 0.08);
  border: 1px solid rgba(27, 127, 85, 0.25);
  padding: 10px 12px;
  border-radius: 10px;
  margin-top: 16px;
  font-size: 0.9rem;
}

.login-help {
  margin-top: 24px;
  color: var(--muted);
  text-align: center;
}

/* ----- Dashboard layout ----- */

.dashboard {
  padding: 32px 0 80px;
}

.dashboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.dashboard-header__title {
  flex: 1 1 320px;
  min-width: 0;
}

.dashboard-header__action {
  flex-shrink: 0;
  align-self: flex-start;
}

.dashboard-header .small {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brand-2);
  font-weight: 600;
  font-size: 0.72rem;
  margin: 0 0 6px;
}

.dashboard-header h1 {
  margin: 0 0 8px;
  font-size: 1.9rem;
  color: var(--brand);
}

.dashboard-header .lead {
  color: var(--muted);
  margin: 0;
}

.dashboard-empty {
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 32px;
  text-align: center;
  color: var(--muted);
}

.dashboard-empty h2 {
  color: var(--brand);
  margin: 0 0 8px;
}

/* ----- Tabs layout (left rail + content) ----- */

.tabs-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.tabs-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 96px;
  align-self: start;
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.tab-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.tab-link:hover {
  background: rgba(145, 204, 169, 0.10);
  color: var(--brand);
}
.tab-link.is-active {
  background: rgba(145, 204, 169, 0.18);
  border-color: rgba(145, 204, 169, 0.50);
  color: var(--brand);
  font-weight: 600;
}
.tab-link svg {
  flex-shrink: 0;
}

.tabs-content {
  min-width: 0;
}
.tab-pane[hidden] {
  display: none;
}

@media (max-width: 900px) {
  .tabs-layout {
    grid-template-columns: 1fr;
  }
  .tabs-nav {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    padding: 6px;
  }
  .tab-link {
    white-space: nowrap;
  }
}

/* ----- Two-column layout: charts + sidebar KPIs ----- */

.dashboard-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 24px;
  margin-bottom: 28px;
  align-items: start;
}

.dashboard-charts {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.chart-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.dashboard-sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: 96px;
  align-self: start;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  padding-right: 4px;
}

.dashboard-sidebar::-webkit-scrollbar { width: 6px; }
.dashboard-sidebar::-webkit-scrollbar-thumb {
  background: rgba(39, 82, 78, 0.18);
  border-radius: 3px;
}

.sidebar-section {
  margin: 14px 0 4px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.sidebar-section:first-of-type { margin-top: 0; }

/* Compact KPI variant for the sidebar */
.kpi--compact {
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: none;
  gap: 2px;
}
.kpi--compact .kpi__label {
  font-size: 0.66rem;
  letter-spacing: 0.08em;
}
.kpi--compact .kpi__value {
  font-size: 1.05rem;
  margin: 2px 0 0;
}
.kpi--compact .kpi__delta {
  margin: 2px 0 0;
  font-size: 0.7rem;
  line-height: 1.3;
}

@media (max-width: 1100px) {
  .dashboard-main {
    grid-template-columns: 1fr;
  }
  .dashboard-sidebar {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 720px) {
  .chart-pair {
    grid-template-columns: 1fr;
  }
}

/* ----- Insights row ----- */

.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.insight {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand-2);
  border-radius: 12px;
  padding: 16px 18px;
}

.insight--alert {
  border-left-color: var(--err);
  background: linear-gradient(180deg, rgba(196, 71, 61, 0.04) 0%, var(--card) 100%);
}

.insight__label {
  margin: 0 0 6px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
}

.insight__value {
  margin: 0 0 4px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.2;
}

.insight__hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

/* ----- KPI grid ----- */

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

.kpi-grid--secondary {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 28px;
}

.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 6px 18px rgba(14, 61, 54, 0.05);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi--primary {
  border-color: var(--brand-2);
  background: linear-gradient(180deg, rgba(145, 204, 169, 0.08) 0%, var(--card) 100%);
}

.kpi__delta {
  margin: 4px 0 0;
  font-size: 0.74rem;
  color: var(--muted);
}

.kpi--secondary {
  background: rgba(255, 255, 255, 0.6);
}

.kpi__label {
  margin: 0 0 6px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

.kpi__value {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--brand);
}

.kpi__value--income {
  color: var(--ok);
}

.kpi__value--expense {
  color: var(--err);
}

/* ----- Chart grid ----- */

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.chart-grid--wide {
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
}

.chart-card--wide {
  grid-column: span 1;
}

.chart-card__head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}

.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 22px 18px;
  box-shadow: 0 8px 22px rgba(14, 61, 54, 0.06);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chart-card h2 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--brand);
}

.chart-card__hint {
  margin: 0 0 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.chart-card__hint code {
  background: rgba(14, 61, 54, 0.06);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.78rem;
}

.chart-card__canvas {
  position: relative;
  height: 280px;
}

.chart-card__canvas--small {
  height: 240px;
}

/* ----- Tables ----- */

.table-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 8px 22px rgba(14, 61, 54, 0.06);
  margin-bottom: 24px;
}

.table-card__header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

.table-card__header h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--brand);
}

.table-card__header .small {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.table-wrapper {
  overflow-x: auto;
}

.table-wrapper--scroll {
  max-height: 480px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.table-wrapper--scroll thead {
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
  box-shadow: 0 1px 0 var(--border);
}

.section-eyebrow {
  margin: 24px 0 8px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.section-eyebrow:first-of-type { margin-top: 0; }

.table-wrapper table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 720px;
}

.table-wrapper th,
.table-wrapper td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.table-wrapper th {
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
}

.table-wrapper tbody tr:hover {
  background: rgba(24, 160, 146, 0.04);
}

.amount {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
  text-align: right;
}

.table-wrapper tr.totals {
  background: var(--mint-soft);
  border-top: 2px solid var(--brand);
}

.table-wrapper tr.totals td {
  border-bottom: none;
  padding-top: 14px;
  padding-bottom: 14px;
}

.amount--income {
  color: var(--ok);
}

.amount--expense {
  color: var(--err);
}

.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(14, 61, 54, 0.08);
  color: var(--brand);
}

.tag--caixabank {
  background: rgba(24, 160, 146, 0.12);
  color: var(--brand-2);
}

.tag--adaral {
  background: rgba(242, 201, 76, 0.18);
  color: #8a6d12;
}

.tag--status.tag--paid {
  background: rgba(27, 127, 85, 0.12);
  color: var(--ok);
}

.tag--status.tag--overdue {
  background: rgba(196, 71, 61, 0.12);
  color: var(--err);
}

.tag--status.tag--sent,
.tag--status.tag--draft {
  background: rgba(14, 61, 54, 0.08);
  color: var(--brand);
}

.table-empty {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

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

@media (max-width: 720px) {
  .login-card {
    padding: 32px 24px;
  }

  .dashboard-header h1 {
    font-size: 1.55rem;
  }

  .user-badge {
    text-align: left;
    padding: 0;
  }

  .chart-card__canvas {
    height: 240px;
  }
}
