/* MyA.Homes — Mercury-style dark sidebar, light content area. No external assets. */

:root {
  --sidebar-bg: #0f1115;
  --sidebar-bg-2: #171a21;
  --sidebar-text: #e8eaf0;
  --sidebar-muted: #9aa0b0;
  --sidebar-active: #232833;
  --accent: #6c5ce7;
  --accent-2: #7c6cf0;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1e24;
  --muted: #6b7280;
  --border: #e3e5ea;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --ok: #137333;
  --ok-bg: #e6f4ea;
  --warn: #8a5a00;
  --warn-bg: #fef3d6;
  --radius: 12px;
  --sidebar-w: 280px;
}

* { box-sizing: border-box; }

/* The `hidden` attribute alone loses to any author `display` rule (e.g.
   .modal-backdrop { display: flex } and .shell { display: flex }), which
   left the Detail modal — and the sidebar — permanently visible and
   unclosable on the login page. This restores `hidden` everywhere. */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

a { color: var(--accent); }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 0 0 6px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Login ---------- */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--sidebar-bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}
.login-brand { font-size: 28px; font-weight: 700; letter-spacing: -.5px; }
.login-sub { color: var(--muted); margin: 4px 0 20px; }
.login-card label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 4px; }
.login-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.login-note { text-align: center; color: var(--muted); font-size: 13px; margin: 16px 0 0; }
.error-text { color: var(--danger); font-size: 13px; margin-top: 10px; }

/* ---------- Buttons / forms ---------- */
.btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  text-decoration: none;
}
.btn:hover { background: #f0f1f4; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-primary:disabled { opacity: .6; cursor: wait; }
.btn-ghost { background: transparent; border-color: transparent; color: inherit; }
.btn-block { width: 100%; text-align: center; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 13px; }

input[type="text"], input[type="email"], input[type="number"], input[type="password"],
select, textarea {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 4px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > * { flex: 1 1 160px; }

/* ---------- Shell / sidebar ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
.sidebar-brand { font-size: 22px; font-weight: 700; padding: 4px 10px 16px; letter-spacing: -.5px; }
.sidebar-user { padding: 0 10px 14px; color: var(--sidebar-muted); font-size: 13px; border-bottom: 1px solid #232833; margin-bottom: 12px; }
.sidebar-user strong { display: block; color: var(--sidebar-text); font-size: 14px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--sidebar-text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 15px;
}
.nav button:hover { background: var(--sidebar-bg-2); }
.nav button.active { background: var(--sidebar-active); font-weight: 700; }
.sidebar-foot { border-top: 1px solid #232833; padding-top: 12px; }
.sidebar-foot .btn { color: var(--sidebar-text); }
.sidebar-foot .btn:hover { background: var(--sidebar-bg-2); }
.sidebar-backdrop { display: none; }

.topbar {
  display: none;
  align-items: center;
  gap: 10px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 10px 14px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.menu-toggle { background: transparent; border: 0; color: var(--sidebar-text); font-size: 22px; padding: 4px 8px; }
.topbar-brand { font-weight: 700; font-size: 18px; flex: 1; }
.topbar-user { font-size: 13px; color: var(--sidebar-muted); }

.main { flex: 1; min-width: 0; padding: 28px 32px 48px; }
.view { max-width: 980px; }

/* ---------- Banner ---------- */
.banner {
  max-width: 980px;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #f5c6c2;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
}
.banner.info { background: var(--warn-bg); color: var(--warn); border-color: #f2d98c; }

/* ---------- Cards / grids / tables ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card h2 { margin-bottom: 4px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat .stat-label { font-size: 13px; color: var(--muted); }
.stat .stat-value { font-size: 24px; font-weight: 700; margin-top: 2px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f7f7fa; }
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }

.pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: #eceef2;
  color: #444;
  white-space: nowrap;
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--danger-bg); color: var(--danger); }

.money { margin: 0; }
.money dt, .money dd { display: inline; }
.money dd { margin: 0; font-weight: 700; }
.money-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.money-row:last-child { border-bottom: 0; }
.money-row.total { font-weight: 700; font-size: 16px; }
.money-row span:first-child { color: var(--muted); }
.money-row.total span:first-child { color: var(--text); }

.task-list { list-style: none; margin: 8px 0 0; padding: 0; }
.task-list li { padding: 7px 0 7px 26px; border-bottom: 1px solid var(--border); position: relative; }
.task-list li:last-child { border-bottom: 0; }
.task-list li.done::before { content: "\2713"; position: absolute; left: 2px; color: var(--ok); font-weight: 700; }
.task-list li.open::before { content: "\25CB"; position: absolute; left: 2px; color: var(--muted); }
.task-list .sub { color: var(--muted); font-size: 13px; }

.search-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.search-row input { flex: 1 1 240px; }
.match-count { color: var(--muted); font-size: 13px; white-space: nowrap; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 11px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.feed li:hover { background: #f7f7fa; }
.feed li:last-child { border-bottom: 0; }
.feed .feed-time { color: var(--muted); font-size: 13px; margin-right: 8px; white-space: nowrap; }

.empty { color: var(--muted); padding: 18px 4px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .btn.active { background: var(--sidebar-bg); color: #fff; border-color: var(--sidebar-bg); }

.temp-password {
  background: var(--warn-bg);
  border: 1px solid #f2d98c;
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 14px;
}
.temp-password code { font-size: 16px; font-weight: 700; word-break: break-all; }

.kv { margin: 0; }
.kv > div { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { flex: 0 0 180px; color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; word-break: break-word; }
.kv pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 21, .55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 100;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .35);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 12px 20px 20px; overflow-y: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .shell { display: block; }
  .topbar { display: flex; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform .2s ease;
    height: 100dvh;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 21, .5);
    z-index: 50;
  }
  .main { padding: 20px 16px 40px; }
  .kv dt { flex-basis: 120px; }
}
