:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-strong: #f0f4f5;
  --ink: #151719;
  --muted: #667079;
  --line: #dde4e7;
  --teal: #087f7a;
  --teal-dark: #075f5b;
  --coral: #d94f45;
  --amber: #f0b84d;
  --shadow: 0 16px 40px rgba(26, 33, 38, 0.12);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.app-frame {
  width: 100%;
  min-height: 100svh;
  background:
    linear-gradient(180deg, rgba(8, 127, 122, 0.08), transparent 28%),
    var(--bg);
  overflow: hidden;
  position: relative;
}

.login-view,
.app-view {
  min-height: 100svh;
}

.login-view {
  display: grid;
  align-items: center;
  padding: 24px;
}

.login-panel {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 20px;
}

h1,
h2,
p {
  margin: 0;
}

.login-panel h1 {
  font-size: 1.55rem;
  line-height: 1.1;
  margin-bottom: 24px;
}

.login-form,
.sheet form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: 0;
  padding: 12px 13px;
  font-size: 1rem;
  text-transform: none;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 127, 122, 0.15);
}

.primary-btn,
.danger-btn {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
}

.primary-btn {
  background: var(--teal);
  color: #fff;
}

.primary-btn:active,
.floating-btn:active {
  background: var(--teal-dark);
}

.danger-btn {
  background: rgba(217, 79, 69, 0.1);
  color: var(--coral);
}

.form-error {
  min-height: 20px;
  color: var(--coral);
  font-size: 0.9rem;
  line-height: 1.35;
}

.app-view {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 14px calc(24px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px 14px;
}

.eyebrow {
  display: block;
  color: var(--teal);
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.topbar h1 {
  max-width: 70vw;
  font-size: 1.55rem;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.icon-btn,
.small-icon-btn,
.round-btn {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
  border-radius: 8px;
}

.icon-btn {
  width: 44px;
  height: 44px;
}

.small-icon-btn {
  width: 36px;
  height: 36px;
}

.round-btn {
  width: 42px;
  height: 42px;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tabs-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 -14px 12px;
  padding: 0 14px 2px;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  flex: 0 0 auto;
  max-width: 220px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  padding: 0 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.summary-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  box-shadow: 0 8px 20px rgba(26, 33, 38, 0.06);
}

.summary-bar strong {
  display: block;
  font-size: 1.05rem;
}

.summary-bar span {
  color: var(--muted);
  font-size: 0.75rem;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-strong);
  overflow: hidden;
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--amber));
  transition: width 180ms ease;
}

.items-list {
  display: grid;
  gap: 10px;
  padding-top: 12px;
}

.item-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 36px;
  gap: 9px;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  box-shadow: 0 8px 18px rgba(26, 33, 38, 0.06);
}

.item-card.done {
  background: #fbfdfd;
  border-color: rgba(8, 127, 122, 0.28);
}

.check-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: #fff;
  position: relative;
}

.item-card.done .check-btn {
  border-color: var(--teal);
  background: var(--teal);
}

.item-card.done .check-btn::after {
  content: "";
  position: absolute;
  left: 11px;
  top: 8px;
  width: 10px;
  height: 16px;
  border: solid #fff;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}

.item-content {
  min-width: 0;
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 7px;
}

.category-pill,
.status-pill {
  max-width: 100%;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.category-pill {
  color: var(--teal-dark);
  background: rgba(8, 127, 122, 0.12);
}

.status-pill {
  color: #8a5e10;
  background: rgba(240, 184, 77, 0.18);
}

.item-card.done .status-pill {
  color: var(--teal-dark);
  background: rgba(8, 127, 122, 0.1);
}

.item-card h2 {
  font-size: 1.02rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.item-details {
  color: var(--muted);
  font-size: 0.91rem;
  line-height: 1.42;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.item-card:not(.expanded) .item-details {
  display: none;
}

.details-toggle {
  border: 0;
  background: transparent;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 850;
  margin-top: 7px;
  padding: 0;
  text-align: left;
  text-transform: uppercase;
}

.date-row,
.date-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.single-date {
  grid-template-columns: 1fr;
}

.date-row {
  margin-top: 10px;
}

.item-card:not(.done) .date-row {
  grid-template-columns: 1fr;
}

.date-row input {
  padding: 9px 8px;
  font-size: 0.86rem;
}

.completion-date {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.completion-date strong {
  min-height: 39px;
  display: flex;
  align-items: center;
  border: 1px solid rgba(8, 127, 122, 0.24);
  border-radius: 8px;
  background: rgba(8, 127, 122, 0.08);
  color: var(--teal-dark);
  padding: 9px 10px;
  font-size: 0.9rem;
}

.complete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  margin-top: 10px;
  padding: 0 12px;
  font-weight: 850;
}

.complete-btn svg {
  width: 18px;
  height: 18px;
}

.complete-btn.done-action {
  background: rgba(8, 127, 122, 0.1);
  color: var(--teal-dark);
}

.item-actions {
  display: grid;
  gap: 7px;
}

.floating-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  margin-top: 12px;
  padding: 0 18px;
  font-weight: 850;
  box-shadow: 0 10px 22px rgba(8, 127, 122, 0.18);
}

.empty-state {
  display: grid;
  gap: 12px;
  place-items: center;
  min-height: 34svh;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 26px 18px;
}

.empty-state strong {
  color: var(--ink);
}

.sheet {
  width: min(100vw - 20px, 430px);
  border: 0;
  border-radius: 8px 8px 0 0;
  padding: 16px;
  margin: auto auto 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 -20px 45px rgba(26, 33, 38, 0.2);
}

.sheet::backdrop {
  background: rgba(12, 16, 18, 0.44);
}

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

.sheet-header h2 {
  font-size: 1.18rem;
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.toggle-row input {
  width: 22px;
  height: 22px;
}

@media (min-width: 760px) {
  body {
    background: var(--bg);
  }

  .app-frame {
    min-height: 100svh;
    overflow: visible;
  }

  .login-view {
    padding: 36px;
  }

  .app-view {
    padding: 32px 24px 40px;
  }

  .topbar h1 {
    max-width: none;
    font-size: 2rem;
  }

  .tabs-row {
    margin: 0 0 12px;
    padding: 0;
  }

  .summary-bar {
    min-height: 68px;
  }

  .floating-btn {
    width: auto;
    align-self: flex-end;
    margin-top: 12px;
    padding: 0 24px;
  }

  .items-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .sheet {
    border-radius: 8px;
    margin: auto;
    box-shadow: var(--shadow);
  }
}

@media (min-width: 1500px) {
  .app-view {
    max-width: 1360px;
    padding-inline: 32px;
  }

  .items-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
