:root {
  --bg-start: #f8f4ff;
  --bg-end: #f1ecff;
  --surface: #ffffff;
  --surface-soft: #f7f2ff;
  --text-main: #281d4c;
  --text-muted: #6e6297;
  --accent: #7e57ff;
  --accent-dark: #5f35e6;
  --accent-soft: #ede5ff;
  --border: #ddd0ff;
  --danger: #d73a49;
  --shadow-soft: 0 12px 30px rgba(89, 62, 180, 0.14);
  --shadow-sm: 0 8px 20px rgba(89, 62, 180, 0.1);
  --radius-lg: 16px;
  --radius-md: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  color: var(--text-main);
  background: linear-gradient(160deg, var(--bg-start), var(--bg-end));
  min-height: 100vh;
}

main {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  width: min(100%, 480px);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 32px;
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 3vw, 2.2rem);
}

.subtitle {
  margin: 0 0 24px;
  color: var(--text-muted);
  line-height: 1.5;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.tab-btn {
  border: 1px solid var(--border);
  background: #f7f3ff;
  color: var(--text-main);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active,
.tab-btn:hover { background: #ece2ff; }

.form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

label {
  font-size: 0.95rem;
  font-weight: 600;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-main);
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(126, 87, 255, 0.15);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: none;
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.btn:focus-visible,
.icon-btn:focus-visible,
.text-btn:focus-visible,
.menu-btn:focus-visible,
.ghost-btn:focus-visible,
.add-btn:focus-visible {
  outline: 3px solid rgba(126, 87, 255, 0.24);
  outline-offset: 2px;
}

.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 8px 18px rgba(95, 53, 230, 0.32);
}

.secondary {
  background: #efe7ff;
  color: var(--text-main);
}

.form-message {
  min-height: 1.2em;
  color: var(--danger);
  margin: 4px 0 0;
}

.hidden { display: none; }

.day-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.day-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #eee7ff;
}

.day-header-inner {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 14px 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
}

.brand {
  font-size: 1.5rem;
  font-weight: 800;
}

.date-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.icon-btn,
.text-btn,
.menu-btn,
.checkbox-btn,
.date-chip,
.ghost-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-main);
  font: inherit;
  cursor: pointer;
}

.icon-btn,
.menu-btn,
.checkbox-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover,
.menu-btn:hover,
.checkbox-btn:hover,
.text-btn:hover,
.ghost-btn:hover { background: #f0e9ff; }

.date-chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 9px 16px;
  min-width: 170px;
  font-weight: 700;
}

.header-actions {
  justify-self: end;
}

.text-btn {
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 600;
}

.tracker-main {
  min-height: auto;
  display: block;
  padding: 26px 24px 32px;
}

.layout-grid {
  width: min(100%, 1180px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 24px;
  align-items: start;
}

.left-col { grid-column: span 7; }
.right-col {
  grid-column: span 5;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.tasks-card,
.efficiency-card,
.summary-card {
  background: var(--surface);
  border: 1px solid #ece3ff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 20px;
}

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

.tasks-title,
.card-title {
  margin: 0;
  font-size: 1.45rem;
}

.add-btn {
  border: none;
  border-radius: 12px;
  background: #1f192f;
  color: #fff;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(20, 14, 34, 0.28);
}

.tasks-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.task-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  border: 1px solid #e9e0ff;
  border-radius: 13px;
  padding: 12px;
  background: #fff;
}

.checkbox-btn {
  border: 1.5px solid #cab6ff;
  background: #fff;
}

.checkbox-btn.done {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.task-main { min-width: 0; }

.task-title {
  font-size: 1.02rem;
  font-weight: 700;
}

.task-title.done {
  text-decoration: line-through;
  color: #9486bc;
}

.task-description {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.weight-badge {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.84rem;
  font-weight: 700;
}

.task-menu-wrap {
  position: relative;
  overflow: visible;
}

.task-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 164px;
  border: 1px solid #e6dcff;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 14px 28px rgba(48, 31, 104, 0.2);
  padding: 6px;
  z-index: 35;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.task-menu button {
  border: none;
  background: transparent;
  text-align: left;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  cursor: pointer;
}

.task-menu button:hover { background: #f2eaff; }

.empty-box {
  border: 1px dashed #cfbefa;
  border-radius: 12px;
  padding: 22px;
  text-align: center;
  color: var(--text-muted);
}

.efficiency-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.ring {
  --progress: 0;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--progress) * 1%), #ede7fb 0);
  display: grid;
  place-items: center;
}

.ring-inner {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px #efe8ff;
  display: grid;
  place-items: center;
  text-align: center;
}

.ring-value {
  font-size: 2.8rem;
  font-weight: 800;
}

.ring-label {
  margin-top: 2px;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.metrics {
  width: 100%;
  max-width: 380px;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.metric { flex: 1; text-align: center; }
.metric-value { font-size: 1.9rem; font-weight: 800; }
.metric-label { color: var(--text-muted); }
.metric-divider { width: 1px; background: #e2d9fd; margin: 0 10px; }

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.summary-plan {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.summary-plan h4,
.summary-result h4 {
  margin: 4px 0;
}

.summary-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.save-message {
  min-height: 1.2em;
  color: var(--text-muted);
  margin: 10px 0 0;
}

.summary-result {
  margin-top: 8px;
  border-radius: 12px;
  border: 1px solid #e9dfff;
  background: #fbf8ff;
  padding: 12px;
}

.summary-result p {
  margin: 0;
  line-height: 1.5;
  color: #50457a;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(25, 19, 36, 0.5);
  padding: 16px;
}

.modal,
.dialog {
  width: min(100%, 540px);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 52px rgba(12, 8, 25, 0.35);
  padding: 20px;
}

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

.modal-title,
.dialog h3 {
  margin: 0;
  font-size: 1.65rem;
}

.modal-subtitle,
.dialog p {
  margin: 8px 0 0;
  color: var(--text-muted);
}

.modal-close {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  background: #f4efff;
  cursor: pointer;
}

.modal-form {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.modal-actions,
.dialog-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.ghost-btn {
  border-radius: 10px;
  padding: 10px 12px;
}

.calendar-popover {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  width: 360px;
  border: 1px solid #e8ddff;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  padding: 12px;
  z-index: 50;
}

.calendar-stats {
  display: grid;
  gap: 4px;
  padding: 8px;
  border-radius: 10px;
  background: #f8f4ff;
  border: 1px solid #ece2ff;
  color: #4d4177;
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.calendar-title { font-weight: 700; }

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.calendar-weekdays {
  font-size: 0.84rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 6px;
}

.calendar-cell {
  height: 34px;
  border: none;
  border-radius: 9px;
  font: inherit;
  background: transparent;
}

.calendar-cell.day {
  border: 1px solid transparent;
  cursor: pointer;
  position: relative;
}

.calendar-cell.day.neutral:hover { background: #f4edff; }
.calendar-cell.day.tasks { border-color: #cdbbff; }
.calendar-cell.day.saved {
  border-color: #a58bff;
  background: #f1ebff;
}

.calendar-cell.day.saved-high {
  border-color: #7e57ff;
  background: #e4d7ff;
  color: #3a208f;
  font-weight: 700;
}

.calendar-cell.day.active {
  outline: 2px solid #3f2b8f;
  outline-offset: -2px;
}

.calendar-tooltip {
  position: absolute;
  transform: translate(-50%, -100%);
  pointer-events: none;
  border-radius: 8px;
  background: #291b55;
  color: #fff;
  font-size: 0.8rem;
  padding: 6px 8px;
  max-width: 240px;
  white-space: nowrap;
  z-index: 60;
}

.account-card { width: min(100%, 560px); }

.account-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px;
  margin-bottom: 10px;
  border-radius: 12px;
  border: 1px solid #e7deff;
  background: #fcfaff;
}

.account-label { color: var(--text-muted); font-weight: 600; }
.account-value { font-weight: 700; }

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

@media (max-width: 1023px) {
  .day-header-inner {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 10px;
  }

  .header-actions { justify-self: center; }

  .layout-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .left-col,
  .right-col { grid-column: auto; }

  .right-col {
    order: -1;
    gap: 20px;
  }
}

@media (max-width: 760px) {
  .tracker-main { padding: 20px 14px 26px; }
  .day-header-inner { padding: 12px 14px; }
  .tasks-head { flex-direction: column; align-items: stretch; }
  .add-btn { width: 100%; }
  .summary-grid { grid-template-columns: 1fr; }

  .task-item {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "check title"
      "badge menu";
    row-gap: 8px;
  }

  .task-item .checkbox-btn { grid-area: check; }
  .task-item .task-main { grid-area: title; }
  .task-item .weight-badge { grid-area: badge; justify-self: start; }
  .task-item .task-menu-wrap { grid-area: menu; justify-self: end; }

  .calendar-popover { width: min(95vw, 360px); }
}
