* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text-main);
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at 14% 12%, rgba(183, 102, 32, 0.22), transparent 30%),
    radial-gradient(circle at 84% 8%, rgba(28, 115, 96, 0.18), transparent 32%),
    linear-gradient(135deg, #201007 0%, #6e3516 46%, #e9d2a0 100%);
}

body.dark {
  background:
    radial-gradient(circle at 16% 10%, rgba(226, 164, 70, 0.2), transparent 28%),
    radial-gradient(circle at 78% 12%, rgba(29, 127, 113, 0.12), transparent 28%),
    linear-gradient(135deg, #190903 0%, #351406 54%, #120703 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--stroke-dark);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text-main);
  background: rgba(255, 250, 224, 0.76);
  outline: none;
}

body.dark input,
body.dark select,
body.dark textarea {
  background: rgba(11, 15, 22, 0.52);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(184, 95, 32, 0.58);
  box-shadow: 0 0 0 4px rgba(184, 95, 32, 0.14);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  color: var(--text-strong);
  font-size: 18px;
  letter-spacing: 0;
}

h2 {
  color: var(--text-strong);
  font-size: clamp(28px, 4vw, 48px);
  letter-spacing: 0;
}

h3 {
  color: var(--text-strong);
  font-size: 18px;
}

.wallpaper {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: -2;
}

.wallpaper::before,
.wallpaper::after {
  content: "";
  position: absolute;
  width: 44vw;
  height: 44vw;
  min-width: 360px;
  min-height: 360px;
  border-radius: 50%;
  filter: blur(44px);
  opacity: 0.35;
}

.wallpaper::before {
  left: -14vw;
  top: 12vh;
  background: linear-gradient(145deg, rgba(227, 163, 67, 0.24), rgba(29, 127, 113, 0.14));
}

.wallpaper::after {
  right: -18vw;
  bottom: -8vh;
  background: linear-gradient(145deg, rgba(29, 127, 113, 0.18), rgba(184, 95, 32, 0.16));
}

.app-shell {
  width: min(var(--max-width), calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 40px;
}

.topbar {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  gap: 16px;
  align-items: center;
  padding: 12px;
  margin-bottom: 28px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 16px;
  color: white;
  font-weight: 800;
  background: linear-gradient(135deg, #b86924, #1e7b68);
  box-shadow: 0 12px 24px rgba(94, 39, 8, 0.28);
}

.eyebrow {
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.module-switcher {
  display: flex;
  gap: 6px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(83, 36, 10, 0.22);
  border: 1px solid var(--stroke);
}

.module-tab {
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  color: var(--text-muted);
  background: transparent;
  transition: 180ms ease;
}

.module-tab.is-active {
  color: var(--text-strong);
  background: linear-gradient(180deg, #ffe9ad, #d69d4f);
  box-shadow: 0 8px 22px rgba(63, 28, 7, 0.16);
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.liquid-button,
.icon-button {
  border: 1px solid var(--stroke);
  color: var(--text-strong);
  background: linear-gradient(180deg, #ffe9ad, #c98232);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.32), 0 10px 24px rgba(63, 28, 7, 0.16);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

body.dark .liquid-button,
body.dark .icon-button {
  background: linear-gradient(180deg, rgba(156, 75, 22, 0.92), rgba(76, 29, 9, 0.9));
}

.liquid-button {
  min-height: 42px;
  border-radius: 999px;
  padding: 0 18px;
  font-weight: 700;
}

.liquid-button.secondary {
  color: var(--text-main);
  background: linear-gradient(180deg, rgba(255, 245, 212, 0.88), rgba(218, 172, 94, 0.5));
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  font-weight: 700;
}

.liquid-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.34), 0 14px 28px rgba(63, 28, 7, 0.2);
}

.page {
  display: none;
  animation: pageIn 260ms ease;
}

.page.is-active {
  display: block;
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.date-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--text-muted);
  background: var(--surface-subtle);
}

.search-box {
  width: min(420px, 42vw);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(12, 17, 25, 0.28);
  backdrop-filter: blur(8px);
}

.task-dialog {
  z-index: 50;
  width: min(760px, calc(100% - 30px));
  border: 1px solid var(--stroke);
  padding: 0;
  color: var(--text-main);
}

.login-screen[hidden],
.app-shell[hidden] {
  display: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 235, 180, 0.36), transparent 34%),
    linear-gradient(135deg, #2c1205, #7b3b17 54%, #1f4037);
}

.login-card,
.admin-panel,
.reminder-popover {
  border: 1px solid rgba(255, 229, 164, 0.42);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 241, 198, 0.94), rgba(221, 173, 93, 0.9)),
    #ecd09a;
  box-shadow: 0 28px 70px rgba(47, 22, 7, 0.28);
}

.login-card {
  display: grid;
  gap: 16px;
  width: min(430px, 100%);
  padding: 28px;
  text-align: center;
}

.login-card p {
  color: #6a3a18;
  line-height: 1.6;
}

.login-card label {
  display: grid;
  gap: 7px;
  color: #5a2a0e;
  font-weight: 800;
  text-align: left;
}

.login-card form {
  display: grid;
  gap: 14px;
}

.login-seal {
  display: grid;
  width: 76px;
  height: 76px;
  margin: 0 auto;
  place-items: center;
  border: 2px solid rgba(255, 235, 185, 0.62);
  border-radius: 24px;
  color: #fff8dc;
  font-size: 34px;
  font-weight: 900;
  background: linear-gradient(135deg, #9a4318, #1f7764);
}

.login-error {
  min-height: 20px;
  color: #b42318;
  font-size: 13px;
}

.bell-button {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 232, 164, 0.5);
  border-radius: 50%;
  color: #fff8dc;
  font-weight: 900;
  background: linear-gradient(180deg, rgba(156, 75, 22, 0.96), rgba(80, 32, 10, 0.95));
}

.bell-button i {
  position: absolute;
  top: 2px;
  right: 3px;
  width: 11px;
  height: 11px;
  border: 2px solid #fff5d4;
  border-radius: 50%;
  background: #ff3b30;
}

.reminder-popover {
  position: fixed;
  top: 76px;
  right: 24px;
  z-index: 60;
  width: min(360px, calc(100vw - 32px));
  padding: 14px;
}

.reminder-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  color: #4f230c;
}

.reminder-item {
  display: grid;
  gap: 5px;
  width: 100%;
  border: 1px solid rgba(108, 52, 16, 0.24);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 8px;
  color: #5c2c10;
  text-align: left;
  background: rgba(255, 250, 224, 0.66);
}

.reminder-item strong {
  color: #4f230c;
}

.reminder-item span {
  color: #7b4b24;
  font-size: 12px;
}

.input-error {
  border-color: #ff3b30;
  box-shadow: 0 0 0 4px rgba(255, 59, 48, 0.16);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.admin-panel {
  padding: 18px;
}

.admin-panel.wide {
  grid-column: 1 / -1;
}

.admin-panel textarea {
  min-height: 240px;
  margin-bottom: 12px;
  color: #4f230c;
  background: rgba(255, 250, 224, 0.74);
  border-color: rgba(108, 52, 16, 0.22);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.task-dialog::backdrop {
  background: rgba(12, 17, 25, 0.28);
  backdrop-filter: blur(8px);
}

.task-dialog form {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.task-dialog label {
  display: grid;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.dialog-header,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.task-drawer {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 35;
  width: min(420px, calc(100vw - 36px));
  max-height: min(680px, calc(100vh - 36px));
  overflow: auto;
  padding: 18px;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .topbar {
    position: static;
    grid-template-columns: 1fr;
  }

  .module-switcher,
  .top-actions {
    justify-content: stretch;
  }

  .module-switcher {
    overflow-x: auto;
  }

  .module-tab,
  .liquid-button {
    white-space: nowrap;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box {
    width: 100%;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 18px, var(--max-width));
    padding-top: 10px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}
