:root {
  --ink: #12172b;
  --ink-soft: #4a5170;
  --muted: #6c7390;
  --line: #e6e8f2;
  --bg: #f4f5fb;
  --card: #ffffff;

  --primary: #4338ca;
  --primary-dark: #332a9e;
  --primary-soft: #eef0ff;
  --accent: #0ea5a5;

  --red: #d92d20;
  --red-soft: #fdecea;
  --green: #12805c;
  --green-soft: #e6f7ef;
  --amber: #b45309;
  --amber-soft: #fef3e2;

  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(18, 23, 43, 0.06);
  --shadow-md: 0 8px 24px rgba(24, 24, 63, 0.08);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1200px 480px at 15% -10%, rgba(67, 56, 202, 0.10), transparent 60%),
    radial-gradient(900px 400px at 100% 0%, rgba(14, 165, 165, 0.08), transparent 55%),
    var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 14px 24px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}
.brand svg { color: var(--primary); }

nav { display: flex; align-items: center; gap: 4px; }
nav a {
  color: var(--ink-soft);
  text-decoration: none;
  margin-left: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}
nav a:hover { color: var(--primary); background: var(--primary-soft); }
nav .nav-user {
  margin-left: 10px;
  font-size: 0.86rem;
  color: var(--muted);
  padding: 7px 4px;
}
nav .nav-user em { font-style: normal; color: var(--primary); font-weight: 700; }

.install-btn {
  margin-left: 10px;
  padding: 7px 14px;
  font-size: 0.84rem;
  font-weight: 700;
}
.install-btn[hidden] { display: none; }

/* ---------- Layout ---------- */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 36px 18px 64px;
}
.container.wide { max-width: 980px; }

.hero { margin-bottom: 22px; }

.hero-image {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin-bottom: 26px;
}
.hero-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 900 / 280;
  object-fit: cover;
}
.hero-image::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(18, 23, 43, 0) 35%, rgba(18, 23, 43, 0.62) 100%);
}
.hero-text {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 2;
  padding: 20px 26px;
}
.hero-text h1 { color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }
.hero-text p.lead { color: rgba(255, 255, 255, 0.94); }

.login-card-wrap { width: 100%; max-width: 380px; }
.login-img {
  display: block;
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow-md);
}
.login-card-wrap .login-card {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  box-shadow: var(--shadow-md);
  margin-top: -1px;
}

h1 { font-size: 1.7rem; margin: 0 0 6px; letter-spacing: -0.02em; font-weight: 800; }
h2 { font-size: 1.2rem; margin: 34px 0 4px; letter-spacing: -0.01em; font-weight: 700; }
h3 { font-size: 0.98rem; margin: 22px 0 10px; font-weight: 700; color: var(--ink-soft); }
p.lead { color: var(--muted); margin: 0; font-size: 1rem; }
p.section-note { color: var(--muted); font-size: 0.9rem; margin: 4px 0 12px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.form-card { box-shadow: var(--shadow-md); }

/* ---------- Forms ---------- */
label {
  display: block;
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--ink-soft);
  margin: 16px 0 6px;
}
label:first-child { margin-top: 0; }

.grid-form > div:first-child label { margin-top: 0; }

input[type=text], input[type=tel], input[type=email], input[type=password], select, textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  font-size: 0.98rem;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(67, 56, 202, 0.14);
}

textarea { min-height: 108px; resize: vertical; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .two-col { grid-template-columns: 1fr; } }

.hint { color: var(--muted); font-size: 0.82rem; margin-top: 6px; }

/* ---------- Buttons ---------- */
button, .btn {
  display: inline-block;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 9px;
  font-size: 0.96rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  box-shadow: 0 1px 2px rgba(67, 56, 202, 0.25), 0 6px 14px rgba(67, 56, 202, 0.18);
  transition: transform 0.1s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
button:hover, .btn:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(67, 56, 202, 0.28), 0 10px 20px rgba(67, 56, 202, 0.22); }
button:active, .btn:active { transform: translateY(0); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.btn.secondary { background: #fff; color: var(--ink); border: 1.5px solid var(--line); box-shadow: none; }
.btn.secondary:hover { background: #f7f8fc; border-color: #d3d6e6; box-shadow: none; }

.btn.danger { background: #fff; color: var(--red); border: 1.5px solid #f3c9c4; box-shadow: none; }
.btn.danger:hover { background: var(--red-soft); box-shadow: none; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Steps (renter form) ---------- */
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 28px 0;
}
@media (max-width: 640px) { .steps { grid-template-columns: 1fr; } }
.step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 4px 2px;
}
.step-num {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
  font-size: 0.82rem;
  display: flex; align-items: center; justify-content: center;
}
.step strong { font-size: 0.92rem; }
.step p { margin: 3px 0 0; color: var(--muted); font-size: 0.85rem; }

.page-footer { text-align: center; margin-top: 30px; }

/* ---------- Login ---------- */
.login-wrap { display: flex; justify-content: center; padding-top: 20px; }
.login-card { width: 100%; max-width: 380px; box-shadow: var(--shadow-md); }
.login-card h1 { text-align: center; }
.login-card p.lead { text-align: center; margin-bottom: 18px; }

/* ---------- Stat tiles (dashboard) ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 26px;
}
@media (max-width: 720px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow-sm);
}
.stat-num { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.stat-label { color: var(--muted); font-size: 0.82rem; font-weight: 600; margin-top: 2px; }
.stat-open .stat-num { color: var(--red); }
.stat-resolved .stat-num { color: var(--green); }
.stat-total .stat-num { color: var(--primary); }
.stat-channels .stat-num { font-size: 1.3rem; }
.stat-channels .stat-label { font-size: 0.76rem; }

/* ---------- Message list ---------- */
.msg-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 12px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.msg-item.new { border-left: 4px solid var(--red); }
.msg-item.resolved { border-left: 4px solid var(--green); opacity: 0.8; }

.msg-top { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.msg-title { font-weight: 700; font-size: 1rem; }
.msg-time { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
.msg-meta { color: var(--muted); font-size: 0.87rem; margin: 6px 0 0; }
.msg-body { margin: 10px 0; white-space: pre-wrap; font-size: 0.94rem; line-height: 1.5; }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 999px;
}
.badge.new { background: var(--red-soft); color: var(--red); }
.badge.resolved { background: var(--green-soft); color: var(--green); }
.badge.role-admin { background: var(--primary-soft); color: var(--primary); text-transform: capitalize; }
.badge.role-staff { background: #eef1f8; color: var(--ink-soft); text-transform: capitalize; }

.role-select {
  width: auto;
  min-width: 100px;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: 999px;
  border: none;
  cursor: pointer;
}
.role-select.role-admin { background: var(--primary-soft); color: var(--primary); }
.role-select.role-staff { background: #eef1f8; color: var(--ink-soft); }
.role-select:disabled { cursor: not-allowed; opacity: 0.6; }

.alert-status { margin: 10px 0; display: flex; flex-wrap: wrap; gap: 6px; }
.alert-status.pending { color: var(--muted); font-size: 0.85rem; font-style: italic; }
.chip {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}
.chip-ok { background: var(--green-soft); color: var(--green); }
.chip-warn { background: var(--amber-soft); color: var(--amber); }

/* ---------- Staff notes (internal collaboration) ---------- */
.notes-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.notes-toggle {
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.notes-toggle:hover { text-decoration: underline; box-shadow: none; transform: none; }
.notes-list { margin: 12px 0; display: flex; flex-direction: column; gap: 10px; }
.note-item {
  background: var(--primary-soft);
  border-radius: 10px;
  padding: 10px 12px;
}
.note-meta { font-size: 0.76rem; font-weight: 700; color: var(--primary-dark); margin-bottom: 3px; }
.note-meta span { font-weight: 500; color: var(--muted); margin-left: 6px; }
.note-text { font-size: 0.9rem; white-space: pre-wrap; line-height: 1.45; }
.no-notes { color: var(--muted); font-size: 0.86rem; font-style: italic; margin: 8px 0; }
.note-form { display: flex; gap: 8px; margin-top: 10px; align-items: flex-start; }
.note-form textarea { min-height: 44px; font-size: 0.88rem; }
.note-form button { padding: 10px 16px; font-size: 0.86rem; flex: none; }

/* ---------- Alerts / banners ---------- */
.alert {
  padding: 13px 16px;
  border-radius: 10px;
  margin-bottom: 18px;
  font-size: 0.92rem;
  font-weight: 500;
}
.alert.success { background: var(--green-soft); color: var(--green); }
.alert.error { background: var(--red-soft); color: var(--red); }
.alert.info { background: var(--primary-soft); color: var(--primary-dark); }

/* ---------- Tables (admin) ---------- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 4px; min-width: 480px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 0.9rem; vertical-align: middle; }
th { color: var(--muted); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }

.actions-cell { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions-cell form { display: flex; align-items: center; gap: 6px; }
.actions-cell .btn, .actions-cell button { padding: 7px 12px; font-size: 0.82rem; }
.reset-pw-form input { width: 130px; padding: 7px 9px; font-size: 0.82rem; }

.inline-form { display: inline; }

.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px 16px; align-items: end; }

.empty-state { color: var(--muted); text-align: center; padding: 46px 0; font-size: 0.95rem; line-height: 2; }

@media (max-width: 640px) {
  .topbar { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  nav .nav-user { display: none; }
  .container { padding: 24px 14px 50px; }
}
