/* ─── Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg-primary:    #ffffff;
  --bg-secondary:  #f6f4ee;
  --bg-tertiary:   #f0ede5;
  --bg-info:       #E6F1FB;
  --text-primary:  #1a1915;
  --text-secondary:#5F5E5A;
  --text-tertiary: #888780;
  --text-info:     #296089;
  --border-weak:   rgba(0,0,0,0.10);
  --border-mid:    rgba(0,0,0,0.22);
  --border-info:   rgba(41,96,137,0.4);
  --accent:        #296089;
  --accent-hover:  #1f4e72;
  --available:     #22c55e;
  --reserved:      #f59e0b;
  --sold:          #ef4444;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
  --header-h: 52px;
  --sidebar-w: 260px;
  --prop-w: 280px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary:    #1c1b18;
    --bg-secondary:  #252420;
    --bg-tertiary:   #2a2924;
    --bg-info:       #042C53;
    --text-primary:  #e8e6df;
    --text-secondary:#aaa8a0;
    --text-tertiary: #777570;
    --text-info:     #85B7EB;
    --border-weak:   rgba(255,255,255,0.08);
    --border-mid:    rgba(255,255,255,0.20);
  }
}

/* ─── Reset / Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: var(--font); background: var(--bg-tertiary); color: var(--text-primary); min-height: 100vh; }
a { color: inherit; text-decoration: none; }
input, button, select, textarea { font-family: inherit; color: inherit; font-size: inherit; }
button { background: none; border: none; cursor: pointer; }
textarea { resize: vertical; }

/* ─── Header ────────────────────────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-weak);
  height: var(--header-h);
}
.app-header__inner {
  max-width: 1600px; margin: 0 auto;
  height: 100%; padding: 0 16px;
  display: flex; align-items: center; gap: 16px;
}
.app-logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 15px; white-space: nowrap;
}
.app-logo img { display: block; }
.app-nav { display: flex; gap: 4px; flex: 1; }
.app-nav a {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: var(--radius-md);
  color: var(--text-secondary); font-size: 13px;
}
.app-nav a:hover, .app-nav a.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.app-header__user { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.user-name { font-size: 13px; color: var(--text-secondary); }

/* ─── Main ───────────────────────────────────────────────────────────────── */
.app-main { max-width: 1600px; margin: 0 auto; padding: 20px 16px; }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary, .btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: .15s;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: var(--bg-primary); color: var(--text-primary);
  border-color: var(--border-mid);
}
.btn-secondary:hover { background: var(--bg-secondary); }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-md);
  color: var(--text-secondary); transition: .15s;
}
.btn-icon:hover { background: var(--bg-secondary); color: var(--text-primary); }
.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn-danger { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.btn-danger:hover { background: #fecaca; }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.form-group label { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.flex-2 { grid-column: span 2; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password],
textarea, select {
  background: var(--bg-primary); border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm); padding: 7px 10px; width: 100%;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); pointer-events: none; }
.input-icon > input { padding-left: 34px; }
.input-icon .toggle-pass { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); }

/* ─── Cards / Panels ─────────────────────────────────────────────────────── */
.card {
  background: var(--bg-primary); border: 1px solid var(--border-weak);
  border-radius: var(--radius-lg); padding: 20px;
}

/* ─── Page header ────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px;
}
.page-header h2 { font-size: 18px; font-weight: 600; }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.page-header .btn-primary { margin-left: auto; }
.page-narrow { max-width: 560px; margin: 0 auto; }

/* ─── Badge ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  background: var(--bg-secondary); font-size: 11px; font-weight: 500;
  color: var(--text-secondary);
}

/* ─── Status dots ────────────────────────────────────────────────────────── */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.status-dot.available { background: var(--available); }
.status-dot.reserved  { background: var(--reserved); }
.status-dot.sold      { background: var(--sold); }

/* ─── Progress bar ───────────────────────────────────────────────────────── */
.progress-bar {
  display: flex; height: 6px; border-radius: 4px;
  background: var(--bg-secondary); overflow: hidden; margin-top: 8px;
}
.progress-bar__fill { height: 100%; transition: width .3s; }
.progress-bar__fill.sold     { background: var(--sold); }
.progress-bar__fill.reserved { background: var(--reserved); }

/* ─── Dashboard Projects Grid ───────────────────────────────────────────── */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.project-card {
  display: flex; flex-direction: column;
  background: var(--bg-primary); border: 1px solid var(--border-weak);
  border-radius: var(--radius-lg); overflow: hidden;
  transition: box-shadow .2s, transform .2s;
}
.project-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.1); transform: translateY(-2px); }
.project-card__thumb { height: 140px; overflow: hidden; background: var(--bg-secondary); }
.project-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.project-card__no-plan {
  height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--text-tertiary); font-size: 40px;
}
.project-card__body { padding: 14px; flex: 1; }
.project-card__body h3 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.project-card__stats {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  font-size: 12px; color: var(--text-secondary); margin-top: 8px;
}

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-secondary);
}
.empty-state i { font-size: 56px; color: var(--text-tertiary); margin-bottom: 12px; display: block; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; color: var(--text-primary); }
.empty-state .btn-primary { margin-top: 16px; }

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); backdrop-filter: blur(2px); }
.modal__box {
  position: relative; background: var(--bg-primary);
  border-radius: var(--radius-lg); width: 100%; max-width: 500px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  margin: 16px;
}
.modal__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px; border-bottom: 1px solid var(--border-weak);
}
.modal__header h3 { font-size: 15px; font-weight: 600; }
.modal__body { padding: 20px; }
.modal__footer { display: flex; gap: 8px; justify-content: flex-end; padding-top: 12px; border-top: 1px solid var(--border-weak); margin-top: 8px; }

/* ─── Dropdown ───────────────────────────────────────────────────────────── */
.dropdown { position: relative; }
.dropdown__menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 50;
  background: var(--bg-primary); border: 1px solid var(--border-mid);
  border-radius: var(--radius-md); min-width: 160px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  overflow: hidden; display: none;
}
.dropdown:hover .dropdown__menu, .dropdown.open .dropdown__menu { display: block; }
.dropdown__menu a, .dropdown__menu button {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; font-size: 13px; width: 100%;
  color: var(--text-primary);
}
.dropdown__menu a:hover, .dropdown__menu button:hover { background: var(--bg-secondary); }

/* ─── Context Menu ───────────────────────────────────────────────────────── */
.ctx-menu {
  position: fixed; z-index: 300;
  background: var(--bg-primary); border: 1px solid var(--border-mid);
  border-radius: var(--radius-md); min-width: 180px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15); overflow: hidden;
}
.ctx-menu[hidden] { display: none; }
.ctx-menu button {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; font-size: 13px; width: 100%;
  color: var(--text-primary);
}
.ctx-menu button:hover { background: var(--bg-secondary); }
.ctx-menu button.danger { color: #ef4444; }
.ctx-menu hr { border: none; border-top: 1px solid var(--border-weak); margin: 4px 0; }

/* ─── Float tooltip ──────────────────────────────────────────────────────── */
.float-tip {
  position: fixed; z-index: 400;
  background: var(--bg-primary); border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm); padding: 4px 10px;
  font-size: 12px; font-weight: 500; pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.float-tip[hidden] { display: none; }

/* ─── Toggle ─────────────────────────────────────────────────────────────── */
.toggle-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.toggle-label input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }

/* ─── File Drop ──────────────────────────────────────────────────────────── */
.file-drop {
  border: 2px dashed var(--border-mid); border-radius: var(--radius-md);
  padding: 32px; text-align: center; cursor: pointer;
  color: var(--text-secondary); transition: .2s;
}
.file-drop:hover, .file-drop.drag-over { border-color: var(--accent); background: var(--bg-info); color: var(--text-info); }
.file-drop i { font-size: 40px; display: block; margin-bottom: 10px; }
.file-drop__info { font-size: 12px; color: var(--text-tertiary); display: block; margin-top: 6px; }

/* ─── Upload progress ────────────────────────────────────────────────────── */
.upload-progress {
  margin-top: 12px; background: var(--bg-secondary);
  border-radius: 6px; height: 8px; overflow: hidden; position: relative;
}
.upload-progress__bar {
  height: 100%; background: var(--accent);
  width: 0; transition: width .3s; border-radius: 6px;
}

/* ─── Chip group ──────────────────────────────────────────────────────────── */
.chip-group { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 20px; font-size: 11px;
  cursor: pointer; border: 1px solid transparent; user-select: none;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.chip.off { opacity: .35; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-main { padding: 12px 10px; }
  .projects-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .flex-2 { grid-column: span 1; }
}
