:root {
  --bg: #100E0C;
  --bg-glow: rgba(216, 90, 48, .16);
  --surface: #1A1613;
  --surface-2: #211C18;
  --surface-3: #282119;
  --border: #2C251E;
  --border-strong: #3E352B;
  --text: #F7F4EF;
  --text-dim: #A29889;
  --text-faint: #6E6459;
  --accent: #E4622F;
  --accent-soft: rgba(228, 98, 47, .14);
  --up: #A3D15F;
  --up-soft: rgba(163, 209, 95, .13);
  --down: #F28A8A;
  --down-soft: rgba(242, 138, 138, .13);
  --warn: #F0A62E;
  --warn-soft: rgba(240, 166, 46, .13);
  --radius: 11px;
  --radius-lg: 16px;
  --display: 'Manrope', 'Inter', system-ui, sans-serif;
  --ui: 'Inter', system-ui, -apple-system, sans-serif;
  --lift: inset 0 1px 0 rgba(255, 255, 255, .045);
  --ease: cubic-bezier(.2, .7, .3, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: '';
  position: fixed;
  inset: -30vh 0 auto 0;
  height: 70vh;
  background: radial-gradient(58% 60% at 50% 42%, var(--bg-glow), transparent 72%);
  pointer-events: none;
  z-index: 0;
}

body > * { position: relative; z-index: 1; }

button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }

/* ---------------------------------------------------------------- login */

.login {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  box-shadow: var(--lift), 0 30px 70px -30px rgba(0, 0, 0, .9);
  padding: 34px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.login-mark {
  font-family: var(--display);
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -.03em;
}
.login-sub { margin: -10px 0 10px; color: var(--text-dim); font-size: 13.5px; }

.login-card input {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  outline: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

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

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 22px 22px 90px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 0 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -.03em;
  margin-right: auto;
}
.brand-dot {
  width: 11px;
  height: 11px;
  border-radius: 4px;
  background: var(--accent);
  box-shadow: 0 0 16px rgba(228, 98, 47, .75);
}

.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ---------------------------------------------------------------- buttons */

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 9px 15px;
  cursor: pointer;
  background: transparent;
  font-size: 14px;
  transition: background .15s var(--ease), border-color .15s var(--ease),
              color .15s var(--ease), transform .1s var(--ease), box-shadow .15s var(--ease);
  white-space: nowrap;
}
.btn:active { transform: scale(.975); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 20px -8px rgba(228, 98, 47, .9);
}
.btn-primary:hover { background: #F06E38; box-shadow: 0 8px 26px -8px rgba(228, 98, 47, 1); }

.btn-ghost { border-color: var(--border-strong); color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-faint); background: var(--surface); }

.btn-danger-ghost { color: var(--down); }
.btn-danger-ghost:hover { background: var(--down-soft); }
.btn-block { width: 100%; padding: 12px; }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 9px;
  border-radius: 9px;
  transition: color .15s var(--ease), background .15s var(--ease);
}
.icon-btn:hover { color: var(--text); background: var(--surface-3); }

.linkish {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
}
.linkish:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- stats */

.stats {
  display: grid;
  grid-template-columns: 1.55fr 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 26px;
}

.stat {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--lift);
  padding: 16px 18px;
  overflow: hidden;
}

.stat-label {
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .09em;
  text-transform: uppercase;
  margin-bottom: 7px;
}
.stat-value {
  font-family: var(--display);
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -.035em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-note { color: var(--text-faint); font-size: 12px; margin-top: 6px; }

.stat-hero {
  grid-row: span 1;
  background: linear-gradient(150deg, var(--surface-2) 0%, var(--surface) 62%);
  border-color: var(--border-strong);
  display: flex;
  flex-direction: column;
}
.stat-hero .stat-value { font-size: 40px; }
.stat-hero .stat-note { margin-top: auto; padding-top: 12px; }

.spark { display: block; width: 100%; height: 46px; margin-top: 14px; }
.spark-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark-area { stroke: none; }

.up { color: var(--up); }
.down { color: var(--down); }
.warn { color: var(--warn); }

.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--ui);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 7px;
  vertical-align: middle;
  margin-left: 8px;
  letter-spacing: 0;
}
.delta-up { background: var(--up-soft); color: var(--up); }
.delta-down { background: var(--down-soft); color: var(--down); }
.delta-flat { background: var(--surface-3); color: var(--text-dim); }

/* ---------------------------------------------------------------- toolbar */

.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 22px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.is-active {
  background: var(--accent-soft);
  border-color: rgba(228, 98, 47, .45);
  color: #FFAE86;
}

.toolbar-right { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }

.input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 13px;
  outline: none;
  width: 100%;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--text-faint); }
.input-sm { padding: 8px 12px; font-size: 13px; width: auto; }
#search { min-width: 240px; }
select.input {
  appearance: none;
  cursor: pointer;
  padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-faint) 50%), linear-gradient(135deg, var(--text-faint) 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
textarea.input { resize: vertical; min-height: 78px; line-height: 1.55; }

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

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--lift);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: border-color .2s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease);
}
.card:hover {
  border-color: var(--border-strong);
  transform: translateY(-3px);
  box-shadow: var(--lift), 0 22px 44px -24px rgba(0, 0, 0, .95);
}

.card-photo {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .45s var(--ease);
}
.card:hover .card-photo img { transform: scale(1.06); }

.card-photo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(16, 14, 12, .55) 0%, transparent 34%, transparent 58%, rgba(16, 14, 12, .82) 100%);
  pointer-events: none;
}

.card-photo-empty {
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.photo-count {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 2;
  background: rgba(12, 10, 8, .68);
  backdrop-filter: blur(6px);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 7px;
}

.badge {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 2;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 7px;
  backdrop-filter: blur(6px);
  letter-spacing: .01em;
}
.badge-open { background: rgba(240, 166, 46, .2); color: #FFC46B; }
.badge-sold { background: rgba(163, 209, 95, .2); color: #BFE188; }
.badge-cancelled { background: rgba(120, 112, 102, .28); color: #C3BBB0; }

.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-title {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.25;
}
.card-meta { color: var(--text-faint); font-size: 12px; display: flex; gap: 7px; flex-wrap: wrap; }
.card-meta span:not(:last-child)::after { content: '·'; margin-left: 7px; opacity: .55; }
.card-prices { color: var(--text-dim); font-size: 13px; font-variant-numeric: tabular-nums; }

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.card-profit {
  font-family: var(--display);
  font-size: 21px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.03em;
}
.card-roi { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

.card-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.tag {
  background: var(--surface-3);
  color: var(--text-dim);
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 6px;
}

.empty { text-align: center; padding: 84px 20px; }
.empty-title { font-family: var(--display); font-size: 21px; font-weight: 800; letter-spacing: -.03em; margin: 0 0 8px; }
.empty-sub { color: var(--text-dim); font-size: 14.5px; margin: 0 0 22px; }

/* ---------------------------------------------------------------- modal */

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 34px 16px;
  overflow-y: auto;
}
.modal-backdrop { position: fixed; inset: 0; background: rgba(8, 6, 5, .74); backdrop-filter: blur(3px); }

.modal-card {
  position: relative;
  width: 100%;
  max-width: 640px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, .95);
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 68px);
}
.modal-narrow { max-width: 420px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-family: var(--display); font-size: 18px; font-weight: 800; letter-spacing: -.025em; }

.modal-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; }

.modal-foot {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 15px 20px;
  border-top: 1px solid var(--border);
}

.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.hint { color: var(--text-faint); font-size: 11.5px; margin: 0; font-weight: 400; letter-spacing: 0; text-transform: none; }

.profit-preview {
  background: linear-gradient(135deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 16px;
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.profit-preview strong {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}

.form-error { color: var(--down); font-size: 13px; }

/* ---------------------------------------------------------------- photos */

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 22px 14px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  outline: none;
  transition: border-color .15s var(--ease), background .15s var(--ease), color .15s var(--ease);
}
.dropzone:hover, .dropzone:focus, .dropzone.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.kbd {
  display: inline-block;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
}

.thumbs { display: flex; gap: 9px; flex-wrap: wrap; }
.thumb {
  position: relative;
  width: 84px;
  height: 62px;
  border-radius: 9px;
  overflow: hidden;
  background: var(--surface-3);
  border: 1px solid var(--border);
  cursor: zoom-in;
  transition: border-color .15s var(--ease);
}
.thumb:hover { border-color: var(--border-strong); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(10, 8, 6, .82);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s var(--ease);
}
.thumb-remove:hover { background: var(--down); color: #3A1111; }

/* ---------------------------------------------------------------- lightbox */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(6, 5, 4, .95);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 44px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }
.lightbox-close { position: absolute; top: 16px; right: 20px; font-size: 32px; }
.lightbox-nav {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 46px;
  cursor: pointer;
  padding: 0 20px;
  line-height: 1;
  transition: color .15s var(--ease);
}
.lightbox-nav:hover { color: var(--text); }

/* ---------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--lift), 0 18px 40px -20px rgba(0, 0, 0, .95);
  padding: 11px 20px;
  font-size: 13.5px;
  z-index: 80;
  animation: rise .22s var(--ease);
}

@keyframes rise {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------------------------------------------------------------- mobile */

@media (max-width: 900px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat-hero { grid-column: span 2; }
}

@media (max-width: 640px) {
  .app { padding: 16px 14px 64px; }
  .topbar { flex-wrap: wrap; }
  .topbar-actions { width: 100%; }
  .topbar-actions .btn-primary { margin-left: auto; }
  .stat-hero .stat-value { font-size: 33px; }
  .toolbar-right { margin-left: 0; width: 100%; }
  #search { min-width: 0; flex: 1; }
  .row { grid-template-columns: 1fr; }
  .modal { padding: 0; }
  .modal-card { max-height: 100dvh; height: 100dvh; border-radius: 0; border: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .card:hover { transform: none; }
  .card:hover .card-photo img { transform: none; }
}
