:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #1c2421;
  --muted: #66736e;
  --line: #e2e7e5;
  --primary: #0f766e;
  --primary-soft: #e6f4f2;
  --danger: #c2410c;
  --bday: #db2777;
  --bday-soft: #fdf0f6;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111615;
    --card: #1a2120;
    --text: #e6ecea;
    --muted: #93a19c;
    --line: #2a3331;
    --primary: #2dd4bf;
    --primary-soft: #16302d;
    --danger: #fb923c;
    --bday: #f472b6;
    --bday-soft: #33192a;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
main { max-width: 860px; margin: 0 auto; padding: 16px 16px 80px; }
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 16px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--primary); color: #fff;
}
.topbar .brand { color: #fff; font-weight: 700; font-size: 17px; }
.topbar nav { display: flex; gap: 14px; align-items: center; }
.topbar nav a, .topbar nav button { color: #fff; font-size: 20px; }
@media (prefers-color-scheme: dark) { .topbar { background: #134e4a; } }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
}

/* Buttons & inputs */
button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--line);
  background: var(--card); color: var(--text);
  padding: 8px 14px; border-radius: 10px; display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-primary { color: #06201d; } }
.btn-danger { color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
button.link { background: none; border: none; padding: 0; }
button:disabled { opacity: .6; cursor: default; }

input, textarea, select {
  font: inherit; width: 100%; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--text);
}
input:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }

/* Search */
.search { display: grid; gap: 10px; }
.date-filter { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.date-filter input { flex: 1 1 160px; width: auto; }
.filter-note {
  background: var(--primary-soft); color: var(--primary);
  padding: 8px 12px; border-radius: 10px; font-size: 14px; margin-bottom: 12px;
}

/* Birthday */
.bday { background: var(--bday-soft); border-color: transparent; }
.bday h2 { color: var(--bday); }
.bday-item { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px dashed var(--line); }
.bday-item:first-of-type { border-top: none; }
.pill { font-size: 12px; padding: 2px 9px; border-radius: 999px; white-space: nowrap; align-self: center; }
.pill-today { background: var(--bday); color: #fff; }
.pill-soon { background: var(--card); color: var(--bday); border: 1px solid var(--bday); }

/* Customer list */
.list-head { display: flex; justify-content: space-between; align-items: center; margin: 18px 0 10px; }
.cust {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 8px; color: var(--text);
}
.cust:hover { border-color: var(--primary); }
.cust .name { font-weight: 600; }
.cust .meta { color: var(--muted); font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }

/* Status badges */
.badge { font-size: 12px; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.st-active { background: #dcfce7; color: #166534; }
.st-upcoming { background: #e0f2fe; color: #075985; }
.st-done { background: var(--line); color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .st-active { background: #14532d; color: #bbf7d0; }
  .st-upcoming { background: #0c4a6e; color: #bae6fd; }
}

/* Detail */
.detail-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.info-grid { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin-top: 6px; }
.info-grid dt { color: var(--muted); }
.info-grid dd { margin: 0; }
.photo-sec-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.photo { position: relative; aspect-ratio: 4/3; border-radius: 8px; overflow: hidden; background: var(--line); }
.photo img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.photo .pdf { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 13px; color: var(--text); }
.photo .del {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; padding: 0;
  justify-content: center; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; border: none; font-size: 12px;
}
.no-photo { color: var(--muted); font-size: 13px; padding: 6px 0; }
.upload-btn { position: relative; overflow: hidden; }
.upload-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.rental { border-top: 1px solid var(--line); padding: 12px 0; }
.rental:first-of-type { border-top: none; padding-top: 0; }
.rental-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.rental-dates { font-weight: 600; }

/* Login */
.login { max-width: 340px; margin: 12vh auto 0; text-align: center; }
.login .card { text-align: left; }
.login button { width: 100%; justify-content: center; margin-top: 12px; }
.error { color: var(--danger); font-size: 14px; margin-top: 8px; }

/* Modal */
dialog {
  border: none; border-radius: 16px; padding: 0; width: min(460px, calc(100vw - 32px));
  background: var(--card); color: var(--text);
}
dialog::backdrop { background: rgba(0,0,0,.45); }
#modalForm { padding: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.92);
  display: flex; align-items: center; justify-content: center;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100vw; max-height: 100vh; object-fit: contain; }
.lb-close, .lb-nav { position: absolute; background: rgba(255,255,255,.15); color: #fff; border: none; font-size: 22px; }
.lb-close { top: 12px; right: 12px; }
.lb-prev { left: 8px; } .lb-next { right: 8px; }
.lb-nav { top: 50%; transform: translateY(-50%); font-size: 30px; padding: 6px 14px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: #1c2421; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 90vw;
}
.toast.err { background: var(--danger); }
.fab { position: fixed; right: 18px; bottom: 22px; border-radius: 999px; padding: 12px 18px; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.rental-actions { display: flex; gap: 6px; }
