* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #0284c7;
  --primary-dark: #0369a1;
  --primary-light: #e0f2fe;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --radius: 8px;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
}

/* Topbar */
.admin-topbar {
  background: #0f172a;
  color: #ffffff;
  border-bottom: 1px solid #1e293b;
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-badge {
  background: #0284c7;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.portal-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sheet-sync-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: #94a3b8;
  background: #1e293b;
  padding: 6px 12px;
  border-radius: 6px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 8px #22c55e;
}

.user-pill {
  font-size: 0.85rem;
  font-weight: 600;
  background: #334155;
  padding: 6px 12px;
  border-radius: 6px;
}

/* Nav Tabs */
.tab-nav {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.tab-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.nav-tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 16px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.2s;
}

.nav-tab:hover {
  color: var(--text-main);
}

.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Main Area */
.admin-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.card-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 16px;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f172a;
}

.card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Calendar Matrix */
.calendar-legend {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  font-weight: 600;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.box-legend {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.box-legend.free {
  background: #dcfce7;
  border: 1px solid #86efac;
}

.box-legend.booked {
  background: #fee2e2;
  border: 1px solid #fca5a5;
}

.calendar-scroll-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.calendar-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.calendar-table th, .calendar-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: center;
  white-space: nowrap;
}

.calendar-table th {
  background: #f8fafc;
  font-weight: 700;
  color: #334155;
}

.calendar-table td.apt-header-cell {
  text-align: left;
  font-weight: 700;
  background: #f8fafc;
  min-width: 180px;
}

.day-cell {
  cursor: pointer;
  transition: opacity 0.15s;
}

.day-cell:hover {
  opacity: 0.8;
}

.day-cell.free {
  background: #dcfce7;
  color: #15803d;
  font-weight: 600;
}

.day-cell.booked {
  background: #fee2e2;
  color: #b91c1c;
  font-weight: 600;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-card.highlight {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.stat-val {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.2;
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.text-primary { color: #0284c7; }
.text-danger { color: #dc2626; }
.text-success { color: #16a34a; }
.text-right { text-align: right; }

.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* Data Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  font-weight: 700;
  color: #334155;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.data-table tr:hover {
  background: #f8fafc;
}

/* Buttons */
.btn-primary-sm {
  background: #0284c7;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary-sm:hover {
  background: #0369a1;
}

.btn-secondary-custom {
  background: #f1f5f9;
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: var(--radius);
  padding: 8px 16px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-primary-custom {
  background: #0284c7;
  border: none;
  color: #ffffff;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-action-zalo {
  background: #0284c7;
  color: #ffffff;
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-action-call {
  background: #16a34a;
  color: #ffffff;
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  margin-left: 6px;
}

/* Apartments Tab Admin List */
.admin-apt-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.admin-apt-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  gap: 20px;
  align-items: center;
}

.admin-apt-thumb {
  width: 140px;
  height: 95px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.admin-apt-info {
  flex: 1;
}

.admin-apt-title {
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.admin-apt-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.admin-apt-photos-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
}

.admin-apt-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.active {
  display: flex;
}

.modal-box {
  background: #ffffff;
  border-radius: var(--radius);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-md {
  max-width: 550px;
}

.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
}

.btn-close-modal {
  background: #f1f5f9;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.form-control-custom {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 0.9rem;
}

.input-with-btn {
  display: flex;
  gap: 8px;
}

.current-photos-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 14px;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: 6px;
}

.photo-item-box {
  position: relative;
  height: 70px;
  border-radius: 4px;
  overflow: hidden;
}

.photo-item-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.btn-del-photo {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(220, 38, 38, 0.9);
  color: #fff;
  border: none;
  width: 20px;
  height: 20px;
  font-size: 0.7rem;
  border-radius: 2px;
  cursor: pointer;
}

.modal-actions {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .grid-2col {
    grid-template-columns: 1fr;
  }
}
