/* ── Reset & base ────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: #111827;
  background: #f9fafb;
}

/* ── Page layout ─────────────────────────────────────────────────────── */

.page-wrapper {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Top nav */
.app-nav {
  background: #1e293b;
  color: #e2e8f0;
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 52px;
  gap: 24px;
}

.app-nav a { color: #cbd5e1; text-decoration: none; font-size: 0.875rem; }
.app-nav a:hover { color: #fff; }
.app-nav .app-name { font-weight: 700; font-size: 1rem; color: #fff; letter-spacing: -0.01em; }

.page-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ── Typography ──────────────────────────────────────────────────────── */

h1 { font-size: 1.6rem; font-weight: 700; margin: 0 0 16px; color: #0f172a; }
h2 { font-size: 1.2rem; font-weight: 600; margin: 24px 0 12px; color: #1e293b; }
h3 { font-size: 1rem;   font-weight: 600; margin: 20px 0 8px;  color: #1e293b; }

p { margin: 0 0 12px; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

.draft-meta {
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 16px;
}

/* ── Breadcrumb ──────────────────────────────────────────────────────── */

nav.breadcrumb, nav[class=""] {
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 16px;
}

nav.breadcrumb a, nav[class=""] a { color: #4b5563; }

/* ── Flash messages ──────────────────────────────────────────────────── */

#notice, #alert {
  padding: 10px 16px;
  border-radius: 5px;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

#notice { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
#alert  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* ── Forms ───────────────────────────────────────────────────────────── */

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  font-size: 0.9375rem;
  font-family: inherit;
  color: #111827;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

input[type="submit"],
button[type="submit"],
.btn {
  display: inline-block;
  padding: 9px 18px;
  border: none;
  border-radius: 5px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  background: #1d4ed8;
  color: #fff;
  font-family: inherit;
  transition: background 0.15s;
}

input[type="submit"]:hover,
button[type="submit"]:hover,
.btn:hover { background: #1e40af; }

input[type="submit"]:disabled,
button:disabled { opacity: 0.6; cursor: not-allowed; }

form > div { margin-bottom: 14px; }

/* Devise / simple form wrappers */
.field        { margin-bottom: 14px; }
.actions      { margin-top: 20px; }
.error_notification { color: #dc2626; margin-bottom: 12px; font-size: 0.9rem; }
#error_explanation {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 5px;
  padding: 12px 16px;
  margin-bottom: 16px;
  color: #991b1b;
  font-size: 0.875rem;
}
#error_explanation ul { margin: 6px 0 0 16px; padding: 0; }

/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn-secondary {
  background: #fff;
  color: #374151;
  border: 1px solid #d1d5db;
}
.btn-secondary:hover { background: #f9fafb; }

.btn-destructive {
  background: #fff;
  color: #dc2626;
  border: 1px solid #dc2626;
}
.btn-destructive:hover { background: #fef2f2; }

/* Inline button_to forms don't add extra space */
form.button_to { display: inline; }
form.button_to button {
  background: none;
  border: none;
  padding: 0;
  color: #dc2626;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
}

/* ── Tables ──────────────────────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}

thead th {
  text-align: left;
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  font-weight: 600;
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* ── Badges ──────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 4px;
  padding: 2px 7px;
  background: #e5e7eb;
  color: #374151;
}

.badge--capex        { background: #dbeafe; color: #1d4ed8; }
.badge--refinance    { background: #ede9fe; color: #6d28d9; }
.badge--acquisition  { background: #d1fae5; color: #065f46; }
.badge--disposition  { background: #fef3c7; color: #92400e; }
.badge--other        { background: #f3f4f6; color: #4b5563; }

/* ── Auth pages (Devise) ─────────────────────────────────────────────── */

.auth-container {
  max-width: 400px;
  margin: 80px auto;
  padding: 32px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.auth-container h2 { margin-top: 0; }
.auth-container .actions input { width: 100%; }

/* Devise wraps forms in a div with no class — target specifically */
body > div > h2 { /* Devise sign-in heading fallback */ }

/* ── Sections / cards ────────────────────────────────────────────────── */

section { margin-bottom: 40px; }

.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 20px;
}

/* ── Property tab navigation ─────────────────────────────────── */

.property-tabs {
  display: flex;
  border-bottom: 2px solid #e5e7eb;
  margin-bottom: 28px;
  gap: 0;
}

.property-tab {
  display: inline-block;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #6b7280;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s;
}

.property-tab:hover { color: #374151; text-decoration: none; }
.property-tab.active { color: #1d4ed8; border-bottom-color: #1d4ed8; }

/* Snapshot date tabs on rent roll (reuse same style) */
.snapshot-tabs {
  display: flex;
  border-bottom: 2px solid #e5e7eb;
  margin-bottom: 20px;
  gap: 0;
  flex-wrap: wrap;
}

.snapshot-tab {
  display: inline-block;
  padding: 8px 14px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #6b7280;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.snapshot-tab:hover { color: #374151; text-decoration: none; }
.snapshot-tab.active { color: #1d4ed8; border-bottom-color: #1d4ed8; }

/* ── Month End Report ────────────────────────────────────────── */

.mer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 28px;
}

.mer-panel { min-width: 0; }

.mer-full { margin-bottom: 28px; }

.mer-section-title {
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #374151;
  margin: 0 0 10px;
}

.mer-col-label {
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #9ca3af;
  margin-left: 6px;
}

.mer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}

.mer-table thead th {
  padding: 8px 12px;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
}

.mer-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #111827;
}

.mer-table tbody tr:last-child td { border-bottom: none; }

.mer-label-col { width: 55%; }
.mer-num-col   { text-align: right; font-variant-numeric: tabular-nums; }

.mer-subtotal td {
  font-weight: 600;
  background: #f9fafb;
  border-top: 1px solid #d1d5db;
  border-bottom: 1px solid #d1d5db;
}

.mer-gap td {
  padding: 4px 0;
  border-bottom: none;
  background: transparent;
}

.mer-empty { color: #d1d5db; }

.inline-rate-form {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin: 0;
}

.inline-rate-input {
  width: 5rem;
  padding: 2px 5px;
  font-size: 0.85rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  text-align: right;
}

.inline-rate-input:focus {
  outline: none;
  border-color: #3b82f6;
}

.inline-rate-pct {
  font-size: 0.85rem;
  color: #6b7280;
}

.inline-rate-save {
  background: none;
  border: none;
  cursor: pointer;
  color: #059669;
  font-size: 0.9rem;
  padding: 2px 4px;
  border-radius: 4px;
}

.inline-rate-save:hover { background: #f0fdf4; }

/* ── Portfolio summary strip ─────────────────────────────────── */

.portfolio-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 20px 0 28px;
}

.portfolio-stat {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.portfolio-stat__label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
}

.portfolio-stat__value {
  font-size: 1.35rem;
  font-weight: 700;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.portfolio-stat__value--positive { color: #059669; }
.portfolio-stat__value--negative { color: #dc2626; }
.portfolio-stat__value--muted    { color: #9ca3af; font-weight: 500; font-size: 1.1rem; }

.portfolio-noi-chart-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 20px 24px;
  margin: 24px 0;
}

.portfolio-noi-chart-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.portfolio-noi-chart-card__title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.portfolio-noi-chart-select {
  font-size: 0.8rem;
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: #374151;
  background: #f9fafb;
  cursor: pointer;
}
