:root {
  --bg: #0a0a0a;
  --panel: #111111;
  --panel-2: #171717;
  --line: #2a2a2a;
  --text: #f5f5f5;
  --muted: #a7a7a7;
  --red: #d9252a;
  --red-hover: #f03035;
  --green: #2bb673;
  --amber: #e4a11b;
  --radius: 16px;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(217,37,42,.10), transparent 30rem),
    var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px clamp(18px, 4vw, 48px);
  background: rgba(10,10,10,.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.topbar h1 { margin: 2px 0 0; font-size: 28px; }
.eyebrow { color: var(--red); font-weight: 800; letter-spacing: .14em; font-size: 11px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.user-chip { display: flex; align-items: center; gap: 8px; }
.link-btn {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-weight: 700;
}
.muted, .subtle { color: var(--muted); }
.subtle { margin: 4px 0 0; font-size: 13px; }

.page-shell { max-width: 1480px; margin: 0 auto; padding: 28px clamp(18px, 4vw, 48px) 80px; }
.card {
  background: linear-gradient(180deg, rgba(255,255,255,.025), rgba(255,255,255,.005)), var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 14px 40px rgba(0,0,0,.20);
}
.toolbar {
  padding: 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
}
.tab.active {
  color: white;
  border-color: rgba(217,37,42,.65);
  background: rgba(217,37,42,.16);
}
.count { opacity: .8; margin-left: 4px; }

.filters { display: flex; gap: 10px; align-items: center; }
.input {
  width: 100%;
  border: 1px solid #303030;
  background: #0e0e0e;
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
}
.input:focus { border-color: rgba(217,37,42,.8); box-shadow: 0 0 0 3px rgba(217,37,42,.12); }
.search { min-width: 360px; }
.select { appearance: auto; }
.textarea { resize: vertical; min-height: 110px; }

.table-card { overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 880px; }
th, td { text-align: left; padding: 16px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: rgba(255,255,255,.015); }
tbody tr:hover { background: rgba(255,255,255,.025); }
tbody tr:last-child td { border-bottom: 0; }
.property-link {
  border: 0;
  background: transparent;
  color: white;
  padding: 0;
  font-weight: 800;
  text-align: left;
}
.property-link:hover { color: #ff5b60; }
.address-cell { color: #cfcfcf; }
.empty-state { text-align: center; padding: 70px 20px; }
.empty-state h3 { margin: 0 0 6px; }

.btn {
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 11px 15px;
  font-weight: 800;
  transition: .18s ease;
}
.btn-primary { background: var(--red); color: white; }
.btn-primary:hover { background: var(--red-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--panel-2); color: white; border-color: var(--line); }
.btn-secondary:hover { border-color: #4a4a4a; background: #1d1d1d; }

.detail-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 12px; }
.detail-hero {
  padding: 26px;
  display: flex;
  justify-content: space-between;
  gap: 22px;
  align-items: end;
  margin-bottom: 18px;
}
.detail-hero h2 { margin: 8px 0 6px; font-size: clamp(28px, 4vw, 42px); }
.detail-address { margin: 0; color: var(--muted); font-size: 16px; }
.pill {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(217,37,42,.15);
  color: #ff7c80;
  font-weight: 800;
  font-size: 12px;
  border: 1px solid rgba(217,37,42,.3);
}
.detail-status-wrap { min-width: 220px; }
.detail-status-wrap label { color: var(--muted); font-size: 12px; display: block; margin-bottom: 6px; }
.status-select { font-weight: 800; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.detail-grid > .card, #detailView > .card { padding: 22px; margin-bottom: 18px; }
.section-heading { margin-bottom: 16px; }
.section-heading h3 { margin: 0; font-size: 18px; }
.section-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 30px;
  margin: 0;
}
.info-grid div { min-width: 0; }
dt { color: var(--muted); font-size: 12px; margin-bottom: 5px; }
dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }

.attachment-list, .notes-list { display: grid; gap: 10px; }
.attachment-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px;
}
.attachment-main { min-width: 0; }
.attachment-name { font-weight: 800; overflow-wrap: anywhere; }
.attachment-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.attachment-link { color: #ff7c80; text-decoration: none; font-weight: 800; }
.file-btn input { display: none; }

.note-card {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 12px;
  padding: 16px;
}
.initial-note { border-left: 4px solid var(--red); }
.note-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
}
.note-type { color: #ff7c80; font-weight: 800; }
.note-text { white-space: pre-wrap; line-height: 1.55; }
.no-content { color: var(--muted); padding: 8px 0; }

.dialog {
  width: min(820px, calc(100vw - 30px));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0;
  background: #101010;
  color: var(--text);
  box-shadow: 0 30px 100px rgba(0,0,0,.55);
}
.small-dialog { width: min(600px, calc(100vw - 30px)); }
.dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(6px); }
.dialog form { padding: 24px; }
.dialog-header {
  display: flex; align-items: start; justify-content: space-between; gap: 20px;
  margin-bottom: 22px;
}
.dialog-header h2 { margin: 3px 0 0; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel-2); color: white; font-size: 23px; line-height: 1;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid label, .dialog form > label { display: grid; gap: 7px; color: #d7d7d7; font-size: 13px; font-weight: 700; }
.form-grid .full { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  background: #171717;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  padding: 14px 16px;
  border-radius: 10px;
  box-shadow: 0 16px 50px rgba(0,0,0,.35);
  max-width: min(420px, calc(100vw - 40px));
}
.hidden { display: none !important; }

@media (max-width: 960px) {
  .toolbar { grid-template-columns: 1fr; }
  .filters { flex-wrap: wrap; }
  .search { min-width: 0; flex: 1 1 320px; }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .topbar { align-items: flex-start; }
  .topbar-actions { flex-direction: column; align-items: flex-end; }
  .user-chip { font-size: 13px; }
  .detail-hero { align-items: stretch; flex-direction: column; }
  .detail-status-wrap { min-width: 0; }
  .info-grid { grid-template-columns: 1fr; }
  .section-heading-row { align-items: flex-start; flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
}


.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top right, rgba(217,37,42,.16), transparent 32rem),
    #080808;
}
.login-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,.025), rgba(255,255,255,.005)), var(--panel);
  padding: 32px;
  box-shadow: 0 30px 90px rgba(0,0,0,.42);
}
.login-brand { margin-bottom: 24px; }
.login-brand h1 { margin: 5px 0 8px; font-size: 34px; }
.login-brand p { margin: 0; color: var(--muted); }
.login-form { display: grid; gap: 16px; }
.login-form label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; }
.login-submit { width: 100%; margin-top: 4px; }
.login-error {
  border: 1px solid rgba(217,37,42,.38);
  background: rgba(217,37,42,.10);
  color: #ff8a8e;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
}
.btn-compact { padding: 9px 12px; }

.signed-in-email {
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
}
