/* Building Checklist — "Minimal & refined" (Option A).
   Off-white base, deep forest-green accent, hairline borders, tight modern type. */

:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #fcfcfb;
  --ink: #14201b;
  --muted: #6b746f;
  --line: #e7e7e2;
  --line-strong: #d7d8d1;
  --accent: #0f7a52;
  --accent-dark: #0b3d2e;
  --accent-tint: #f4faf7;
  --accent-line: #cfe6dc;
  --done: #0f7a52;
  --pending: #b9821a;
  --missed: #c0392b;

  --tap: 54px;
  --r: 16px;
  --r-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(20, 32, 27, 0.04);
  --shadow-md: 0 8px 30px rgba(20, 32, 27, 0.1);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter,
    Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  letter-spacing: -0.01em;
  min-height: 100vh;
  overscroll-behavior: none;
}

h1,
h2,
h3 {
  margin: 0 0 0.4rem;
  color: var(--ink);
  font-weight: 680;
  letter-spacing: -0.03em;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* ---- Layout ------------------------------------------------------------ */

.app {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .logo {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 9px;
}

.topbar h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.topbar .back {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  padding: 6px;
  margin-left: auto;
}

.screen {
  padding: 22px 18px 40px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.screen h2 {
  font-size: 25px;
}

.muted {
  color: var(--muted);
}

.subtitle {
  color: var(--muted);
  font-size: 14px;
  margin: -10px 0 4px;
}

.spacer {
  flex: 1;
}

/* ---- Buttons ----------------------------------------------------------- */

.btn {
  min-height: var(--tap);
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: -0.01em;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.04s ease;
}

.btn:active {
  transform: scale(0.99);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.btn-primary:disabled {
  background: #d9dcda;
  border-color: #d9dcda;
  color: #fff;
  cursor: not-allowed;
}

.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--accent-dark);
}

.btn-lg {
  min-height: 60px;
  font-size: 18px;
}

.btn-row {
  display: flex;
  gap: 10px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 15px;
  padding: 6px 0;
  width: auto;
  text-align: left;
  align-self: flex-start;
}

.link-btn:hover {
  color: var(--accent-dark);
}

/* ---- Form controls ----------------------------------------------------- */

select,
input[type="text"],
input[type="time"],
input[type="password"],
input[type="date"],
input[type="number"],
textarea {
  width: 100%;
  min-height: 52px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-size: 16px;
  font-family: inherit;
  padding: 0.7rem 0.9rem;
}

select:focus,
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 122, 82, 0.12);
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 7px;
}

/* ---- PIN keypad -------------------------------------------------------- */

.pin-display {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 8px 0 26px;
}

.pin-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid #cdd2cf;
  transition: background 0.1s ease, border-color 0.1s ease;
}

.pin-dot.filled {
  background: var(--accent);
  border-color: var(--accent);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.key {
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font-size: 21px;
  font-weight: 550;
  transition: background 0.1s ease, transform 0.04s ease;
}

.key:active {
  background: var(--accent-tint);
  border-color: var(--accent-line);
  transform: scale(0.97);
}

.key.key-action {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.pin-error {
  color: var(--missed);
  text-align: center;
  font-weight: 600;
  min-height: 1.4em;
}

/* ---- Status banner ----------------------------------------------------- */

.status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  font-size: 14px;
  background: var(--surface);
}

.status-banner .ico {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #fff;
  flex: 0 0 auto;
}

.status-banner.done {
  border-left-color: var(--done);
  background: var(--accent-tint);
}
.status-banner.done .ico {
  background: var(--done);
}
.status-banner.pending {
  border-left-color: var(--pending);
  background: #fffdf7;
}
.status-banner.pending .ico {
  background: var(--pending);
}
.status-banner.missed {
  border-left-color: var(--missed);
  background: #fdf6f5;
}
.status-banner.missed .ico {
  background: var(--missed);
}

/* ---- Checklist --------------------------------------------------------- */

.checklist {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.check-card {
  min-height: var(--tap);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  font-size: 15.5px;
  text-align: left;
  color: var(--ink);
  width: 100%;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.check-card .box {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 7px;
  border: 1.6px solid #cdd2cf;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
}

.check-card.ticked {
  border-color: var(--accent-line);
  background: var(--accent-tint);
}

.check-card.ticked .box {
  background: var(--accent);
  border-color: var(--accent);
}

.check-card.ticked .label {
  text-decoration: line-through;
  color: var(--muted);
}

/* ---- Confirmation ------------------------------------------------------ */

.confirm {
  text-align: center;
  padding-top: 3rem;
}

.confirm .tick {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent);
  font-size: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  border: 1px solid var(--accent-line);
}

/* ---- Notice ------------------------------------------------------------ */

.notice {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--accent-tint);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-sm);
  padding: 12px 14px;
}

.notice button {
  margin-left: auto;
  width: auto;
  white-space: nowrap;
}

/* ---- Admin ------------------------------------------------------------- */

.admin-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  width: 236px;
  flex: 0 0 auto;
  padding: 8px 0 20px;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  font-weight: 650;
  font-size: 15px;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.sidebar .brand img {
  width: 26px;
  height: 26px;
  border-radius: 8px;
}

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  padding: 11px 20px;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-item:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.nav-item.active {
  color: var(--accent-dark);
  background: var(--accent-tint);
  border-left-color: var(--accent);
}

.admin-main {
  flex: 1;
  padding: 28px 32px;
  max-width: 1120px;
}

.admin-main h2 {
  font-size: 26px;
  margin-bottom: 1.1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
  margin-bottom: 16px;
}

.toolbar > div {
  flex: 1;
  min-width: 150px;
}

.toolbar .btn {
  width: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

tbody tr:hover {
  background: var(--surface-2);
}

.table-wrap {
  overflow-x: auto;
}

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.pill.on {
  background: var(--accent-tint);
  color: var(--accent-dark);
}
.pill.off {
  background: #f0f0ec;
  color: var(--muted);
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}
.dot.green {
  background: var(--done);
}
.dot.amber {
  background: var(--pending);
}
.dot.red {
  background: var(--missed);
}

.btn-sm {
  min-height: 40px;
  width: auto;
  padding: 0 14px;
  font-size: 14px;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.drag-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  margin-bottom: 10px;
  cursor: grab;
}

.drag-item.dragging {
  opacity: 0.5;
}

.drag-item .handle {
  color: var(--muted);
  font-size: 20px;
  cursor: grab;
}

.drag-item.inactive {
  opacity: 0.55;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 32, 27, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: var(--r);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-md);
}

.login-wrap {
  max-width: 400px;
  margin: 12vh auto 0;
  padding: 1.5rem;
}

.login-wrap .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 1rem;
  font-weight: 650;
  color: var(--ink);
  font-size: 18px;
  letter-spacing: -0.02em;
}

.login-wrap .brand img {
  width: 32px;
  height: 32px;
  border-radius: 9px;
}

/* Door QR codes */
#doorList {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.door-card {
  text-align: center;
  margin-bottom: 0;
}

.door-card .door-qr {
  width: 220px;
  height: 220px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.door-card .btn-row {
  justify-content: center;
}

.door-card .door-dl {
  text-decoration: none;
}

/* Mobile admin: horizontal tab bar instead of sidebar */
@media (max-width: 720px) {
  .admin-shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    display: flex;
    overflow-x: auto;
    padding: 0;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .sidebar .brand {
    display: none;
  }
  .nav-item {
    white-space: nowrap;
    border-left: none;
    border-bottom: 3px solid transparent;
    width: auto;
  }
  .nav-item.active {
    border-left: none;
    border-bottom-color: var(--accent);
  }
  .admin-main {
    padding: 20px 16px;
  }
}
