:root {
  --bg: #efe9dd;
  --card: #fffdf8;
  --text: #2a251d;
  --muted: #74695b;
  --accent: #4f7f49;
  --accent-2: #3f683a;
  --brown: #5f4735;
  --danger: #a3482f;
  --border: #e6dccb;
  --success: #2f8f3e;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  font-family: "Avenir Next", "Nunito", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, #dceacb 0%, transparent 36%),
    radial-gradient(circle at top right, #f3ead9 0%, transparent 42%),
    var(--bg);
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

.login-wrap {
  min-height: 90vh;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(460px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 18px 34px rgba(69, 53, 37, 0.12);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}

.topbar h1 {
  margin: 0;
}

.mobile-menu-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-name {
  font-weight: 700;
  color: var(--brown);
}

.icon-btn {
  border: 1px solid var(--border);
  background: #9a7759;
  color: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 1.05rem;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(95, 71, 53, 0.25);
}

.icon-btn:hover {
  background: #8b6a4f !important;
}

.mobile-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  display: grid;
  gap: 4px;
  width: 190px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 8px 18px rgba(80, 61, 42, 0.12);
  z-index: 50;
}

.mobile-menu button {
  text-align: left;
  background: #f8f2e6;
  color: var(--brown);
  border: 1px solid var(--border);
}

.desktop-nav {
  display: flex;
  gap: 8px;
  margin: 10px 0 14px;
  flex-wrap: wrap;
}

.tab-btn {
  border: 1px solid var(--border);
  background: #f6f0e5;
  color: var(--brown);
  border-radius: 10px;
  padding: 10px 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.tab-btn.active,
.tab-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.badge {
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #fef3c7;
  color: #8a4b08;
  font-size: 0.75rem;
  line-height: 20px;
  text-align: center;
  padding: 0 6px;
  font-weight: 700;
}

.card {
  background: #f6f1e7;
  border: 0;
  border-radius: 14px;
  padding: 15px;
  margin-bottom: 14px;
  box-shadow: 0 3px 10px rgba(80, 61, 42, 0.06);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

h2 { margin-top: 0; }

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

.one-col { grid-template-columns: 1fr; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.95rem;
}

input, select, button {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px;
  font: inherit;
  color: inherit;
}

button {
  background: var(--accent);
  color: white;
  border: none;
  font-weight: 700;
  cursor: pointer;
}

button:hover { background: var(--accent-2); }
button.secondary { background: var(--brown); }
button.warn { background: var(--danger); }
button.ghost {
  background: #f5eee1;
  color: var(--brown);
  border: 1px solid var(--border);
}

.icon-small {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  line-height: 32px;
  text-align: center;
  background: transparent !important;
  border: 1px solid var(--border);
  color: var(--brown);
}

.icon-small.warn {
  color: var(--danger);
}

.tick {
  min-width: 56px;
  height: 30px;
  border-radius: 8px;
  padding: 0 10px;
  background: transparent !important;
  border: 1px solid #d9d9d9;
  color: #2f6d2e;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 28px;
}

.tick:hover {
  background: #eef8ea !important;
}

.room-block {
  border: 0;
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
  background: #fbf8f2;
}

.room-title {
  margin: 0;
  padding: 9px 12px;
  background: #f4eee4;
  color: var(--brown);
  font-size: 0.95rem;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.table th, .table td {
  border: 0;
  padding: 7px 6px;
  text-align: left;
  font-size: 0.86rem;
  vertical-align: middle;
}

.table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table input,
.table select {
  width: 100%;
  min-width: 0;
  padding: 6px;
  font-size: 0.84rem;
}

.table .freq-edit {
  display: grid;
  grid-template-columns: 1fr 68px;
  gap: 4px;
}

.table .actions {
  display: flex;
  gap: 5px;
  justify-content: flex-start;
}

.table thead th {
  border: 0;
  color: #6b5947;
  font-weight: 600;
  background: transparent;
}

.table tbody td {
  background: transparent;
}

.pill {
  background: #d9ecd3;
  color: #1f5f1f;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.76rem;
  display: inline-block;
}

.overdue {
  color: #a33724;
  font-weight: 700;
}

.switch-row {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background-color: #cbc1b2;
  transition: 0.2s;
  border-radius: 999px;
}

.slider:before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  top: 3px;
  background-color: #fff;
  transition: 0.2s;
  border-radius: 50%;
}

.switch input:checked + .slider { background-color: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(24px); }

.mobile-cards {
  display: block;
}

.task-card {
  border: 0;
  border-radius: 12px;
  padding: 8px 9px;
  margin-bottom: 6px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(80, 61, 42, 0.1);
}

.task-card .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}

.task-card .row strong {
  font-size: 0.92rem;
}

.task-card .row span,
.task-card .row small {
  color: var(--muted);
  font-size: 0.8rem;
}

.task-card .actions {
  display: flex;
  gap: 6px;
  margin-top: 5px;
}

.room-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #e8f2e3;
  color: #2e6a2b;
  font-size: 0.75rem;
  font-weight: 700;
}

.room-content {
  padding: 0 6px 4px;
}

.table-wrap {
  display: none !important;
}

.success-msg {
  margin: 6px 0;
  border: 1px solid #d8ebd2;
  background: #eef8ea;
  color: #2f6d2e;
  border-radius: 10px;
  padding: 12px;
  font-weight: 700;
}

.reminder-item {
  grid-column: 1 / -1;
  background: #faf5ea;
  border-radius: 10px;
  padding: 10px;
}

.reminder-inline {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 8px;
  margin-top: 6px;
}

@media (max-width: 920px) {
  .app-shell {
    padding: 12px;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
  }
  .desktop-nav { display: none; }

  .table-wrap { display: none !important; }
  .mobile-cards { display: block; }
}

@media (min-width: 921px) {
  .mobile-menu-wrap { display: none; }
}
