:root {
  --primary: #1a3a5c;
  --primary-light: #2563a8;
  --accent: #f59e0b;
  --accent-light: #fbbf24;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f0f4f8;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--primary);
  color: white;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo h1 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--accent);
}

.sidebar-logo p {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.4);
  padding: 12px 20px 6px;
  text-transform: uppercase;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.nav-link:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.nav-link.active {
  background: rgba(255,255,255,0.12);
  color: white;
  border-left-color: var(--accent);
}

.nav-link .icon { font-size: 16px; width: 20px; text-align: center; }

/* Main content */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}

.top-bar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-bar h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge-update {
  background: #e0f2fe;
  color: #0369a1;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.page-body {
  padding: 28px 32px;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px 24px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.stat-card.blue::before { background: var(--primary-light); }
.stat-card.green::before { background: var(--success); }
.stat-card.amber::before { background: var(--accent); }
.stat-card.red::before { background: var(--danger); }

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.stat-icon {
  position: absolute;
  top: 18px; right: 20px;
  font-size: 28px;
  opacity: 0.12;
}

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 20px; }
.grid-3-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; margin-bottom: 20px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 20px; }

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
}

.card-body {
  padding: 20px;
}

/* Building card */
.building-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.building-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
}

.building-card:hover {
  border-color: var(--primary-light);
  box-shadow: 0 4px 20px rgba(37, 99, 168, 0.12);
  transform: translateY(-2px);
}

.building-card-header {
  background: var(--primary);
  color: white;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.building-card-name {
  font-size: 15px;
  font-weight: 700;
}

.building-card-address {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 2px;
}

.vacancy-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
}

.vacancy-badge.high { background: rgba(239,68,68,0.2); color: #fca5a5; }
.vacancy-badge.mid { background: rgba(245,158,11,0.2); color: #fcd34d; }
.vacancy-badge.low { background: rgba(16,185,129,0.2); color: #6ee7b7; }
.vacancy-badge.full { background: rgba(16,185,129,0.25); color: #34d399; }

.building-card-body { padding: 14px 16px; }

.building-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
}

.building-stat-row:last-child { border-bottom: none; }
.building-stat-label { color: var(--text-muted); }
.building-stat-value { font-weight: 700; color: var(--primary); }

/* Occupancy bar */
.occupancy-bar-wrap {
  margin: 10px 0 6px;
}

.occupancy-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.occupancy-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--success), #34d399);
  transition: width 0.6s ease;
}

.occupancy-fill.warning { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.occupancy-fill.danger { background: linear-gradient(90deg, var(--danger), #f87171); }

/* Unit table */
.unit-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.unit-table th {
  background: #f8fafc;
  padding: 9px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.unit-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.unit-table tr:last-child td { border-bottom: none; }
.unit-table tr:hover td { background: #f8fafc; }

.tenant-name { font-weight: 600; color: var(--primary); }
.vacant-label { color: var(--text-muted); font-style: italic; }

.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-dot.occupied { background: var(--success); }
.status-dot.vacant { background: var(--danger); }

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.status-pill.occupied { background: #d1fae5; color: #065f46; }
.status-pill.vacant { background: #fee2e2; color: #991b1b; }
.status-pill.expiring { background: #fef3c7; color: #92400e; }

/* Financial */
.fin-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.fin-box {
  border-radius: 12px;
  padding: 20px;
  border: 2px solid;
}

.fin-box.current { background: #f0f9ff; border-color: #bae6fd; }
.fin-box.potential { background: #f0fdf4; border-color: #bbf7d0; }

.fin-box-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.fin-box.current .fin-box-title { color: #0369a1; }
.fin-box.potential .fin-box-title { color: #065f46; }

.fin-metric { margin-bottom: 10px; }
.fin-metric-label { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.fin-metric-value { font-size: 20px; font-weight: 800; }
.fin-box.current .fin-metric-value { color: #0284c7; }
.fin-box.potential .fin-metric-value { color: #059669; }

.yield-meter {
  position: relative;
  height: 12px;
  background: #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
  margin: 8px 0;
}

.yield-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #10b981, #34d399);
}

/* Charts */
.chart-wrap { position: relative; padding: 8px 0; }

/* Alert list */
.alert-list { list-style: none; }
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.alert-item:last-child { border-bottom: none; }

.alert-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.alert-icon.warn { background: #fef3c7; color: #d97706; }
.alert-icon.danger { background: #fee2e2; color: #dc2626; }
.alert-icon.info { background: #dbeafe; color: #2563eb; }

.alert-content { flex: 1; }
.alert-title { font-weight: 600; color: var(--text); margin-bottom: 2px; }
.alert-desc { color: var(--text-muted); font-size: 12px; }

/* Page tabs */
.page-tabs {
  display: flex;
  gap: 4px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
  width: fit-content;
}

.page-tab {
  padding: 8px 20px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-muted);
  transition: all 0.15s;
}

.page-tab.active {
  background: var(--primary);
  color: white;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Select */
.form-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text);
  background: white;
  cursor: pointer;
  outline: none;
}

/* Upside calc table */
.upside-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.upside-table th {
  background: var(--primary);
  color: white;
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
}
.upside-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.upside-table tr:hover td { background: #f8fafc; }
.upside-table .positive { color: var(--success); font-weight: 700; }
.upside-table .negative { color: var(--danger); font-weight: 700; }

/* Legend */
.legend-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; }

/* Payment table */
.payment-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  font-size: 13px;
}

.pg-header, .pg-row { display: contents; }
.pg-cell {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
}
.pg-header .pg-cell {
  background: #f8fafc;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}

.paid-yes { color: var(--success); font-weight: 700; }
.paid-no { color: var(--danger); font-weight: 700; }

/* Responsive */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .building-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3, .grid-3-2, .grid-2-1 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-logo h1, .sidebar-logo p, .nav-section-title, .nav-link span { display: none; }
  .main-content { margin-left: 60px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .building-grid { grid-template-columns: 1fr; }
  .page-body { padding: 16px; }
  .fin-compare { grid-template-columns: 1fr; }
}

/* Print */
@media print {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .top-bar { position: static; }
}
