:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #16213a;
  --muted: #6b7590;
  --line: #e3e8f2;
  --accent: #2f5cff;
  --accent-soft: #e8eeff;
  --good: #17a673;
  --bad: #d64550;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(22, 33, 58, 0.07), 0 8px 24px rgba(22, 33, 58, 0.05);
  font-size: 16px;
}
* { box-sizing: border-box; margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.error { color: var(--bad); font-size: 0.9rem; margin-top: 0.6rem; }

/* ---- login ---- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, #eef2ff 0%, #f4f6fb 45%, #e7f6f1 100%);
  padding: 1rem;
}
.login-card {
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow);
  padding: 2.4rem 2.2rem; width: 100%; max-width: 380px; text-align: center;
}
.login-logo { width: 64px; height: 64px; margin-bottom: 0.8rem; }
.login-card h1 { font-size: 1.35rem; letter-spacing: 0.01em; }
.login-card h1 span { color: var(--accent); font-weight: 600; }
.login-card p { margin: 0.3rem 0 1.4rem; }
.login-card input {
  width: 100%; padding: 0.75rem 0.9rem; margin-bottom: 0.8rem;
  border: 1px solid var(--line); border-radius: 10px; font-size: 1rem;
  background: #fafbfe;
}
.login-card input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* ---- buttons ---- */
.btn {
  border: none; border-radius: 10px; padding: 0.65rem 1.1rem;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  background: var(--accent-soft); color: var(--accent);
  transition: filter 0.15s;
}
.btn:hover { filter: brightness(0.96); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); }
.btn.full { width: 100%; }
.btn.danger-ghost { background: transparent; color: var(--bad); padding: 0.3rem 0.5rem; }

/* ---- topbar ---- */
.topbar {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 0.7rem 1.4rem; position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 0.7rem; }
.brand img { width: 38px; height: 38px; }
.brand strong { display: block; font-size: 1rem; line-height: 1.1; }
.brand span { font-size: 0.75rem; color: var(--muted); }
#tabs { display: flex; gap: 0.3rem; flex: 1; }
.tab {
  border: none; background: transparent; padding: 0.55rem 1rem;
  border-radius: 10px; font-size: 0.95rem; font-weight: 600;
  color: var(--muted); cursor: pointer;
}
.tab.active { background: var(--accent-soft); color: var(--accent); }
.user-menu { display: flex; align-items: center; gap: 0.5rem; }
#hello { color: var(--muted); font-size: 0.9rem; }

main { max-width: 980px; margin: 0 auto; padding: 1.6rem 1.2rem 4rem; }

/* ---- cards ---- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.3rem 1.4rem; margin-bottom: 1.2rem;
}
.card h3 { font-size: 1rem; margin-bottom: 0.9rem; color: var(--ink); }

/* ---- today ---- */
.today-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.2rem; gap: 1rem;
}
.today-head h2 { font-size: 1.45rem; }
.progress-ring-wrap { position: relative; width: 80px; height: 80px; }
.progress-ring { width: 80px; height: 80px; transform: rotate(-90deg); }
.ring-bg, .ring-fg { fill: none; stroke-width: 8; }
.ring-bg { stroke: var(--line); }
.ring-fg {
  stroke: var(--accent); stroke-linecap: round;
  stroke-dasharray: 213.6; stroke-dashoffset: 213.6;
  transition: stroke-dashoffset 0.4s ease;
}
#ring-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.95rem;
}
.task-list { list-style: none; }
.task-list li {
  display: flex; align-items: flex-start; gap: 0.8rem;
  padding: 0.7rem 0.2rem; border-bottom: 1px solid var(--line);
}
.task-list li:last-child { border-bottom: none; }
.task-check {
  width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--line);
  background: #fff; cursor: pointer; flex-shrink: 0; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: #fff; transition: all 0.15s;
}
.task-check.done { background: var(--good); border-color: var(--good); }
.task-body { flex: 1; }
.task-title { font-weight: 600; }
li.done .task-title { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.task-meta { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.chip {
  display: inline-block; font-size: 0.72rem; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 0.1rem 0.6rem; margin-right: 0.4rem;
}

/* ---- links ---- */
#tab-links h2 { margin-bottom: 1rem; }
.links-cat { margin-bottom: 1.4rem; }
.links-cat h4 { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.6rem; }
.links-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0.7rem; }
.link-card {
  display: flex; align-items: center; gap: 0.6rem;
  background: var(--card); border-radius: 12px; box-shadow: var(--shadow);
  padding: 0.8rem 1rem; text-decoration: none; color: var(--ink); font-weight: 600;
  border: 1px solid transparent; transition: border-color 0.15s, transform 0.1s;
}
.link-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.link-card .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.link-card small { display: block; color: var(--muted); font-weight: 400; font-size: 0.75rem; word-break: break-all; }

/* ---- history ---- */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.2rem; }
.stat { text-align: center; padding: 1.1rem 0.5rem; }
.stat span { font-size: 1.7rem; font-weight: 800; color: var(--accent); display: block; }
.stat label { color: var(--muted); font-size: 0.82rem; }
.hist-day { border-bottom: 1px solid var(--line); padding: 0.65rem 0.2rem; }
.hist-day:last-child { border-bottom: none; }
.hist-head { display: flex; align-items: center; gap: 0.8rem; cursor: pointer; }
.hist-head .date { font-weight: 600; min-width: 110px; }
.hist-bar { flex: 1; height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.hist-bar i { display: block; height: 100%; background: var(--good); border-radius: 999px; }
.hist-count { font-size: 0.85rem; color: var(--muted); min-width: 46px; text-align: right; }
.hist-items { margin: 0.5rem 0 0.2rem 118px; font-size: 0.85rem; color: var(--muted); }
.hist-items div { padding: 2px 0; }

/* ---- admin ---- */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.admin-grid .wide { grid-column: 1 / -1; }
.admin-list { list-style: none; margin-bottom: 1rem; }
.admin-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  padding: 0.5rem 0.2rem; border-bottom: 1px solid var(--line); font-size: 0.93rem;
}
.admin-list li:last-child { border-bottom: none; }
.inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.inline-form input[type="text"] { flex: 1; min-width: 120px; }
.stack-form { display: flex; flex-direction: column; gap: 0.6rem; }
.inline-form input, .stack-form input {
  padding: 0.6rem 0.8rem; border: 1px solid var(--line); border-radius: 10px;
  font-size: 0.95rem; background: #fafbfe;
}
.activity { max-height: 320px; overflow-y: auto; font-size: 0.87rem; }
.activity div { padding: 0.4rem 0.2rem; border-bottom: 1px solid var(--line); }
.activity time { color: var(--muted); font-size: 0.78rem; margin-right: 0.6rem; }
.activity b { font-weight: 600; }

/* ---- modal ---- */
.modal-wrap {
  position: fixed; inset: 0; background: rgba(22, 33, 58, 0.4);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem;
}
.modal { width: 100%; max-width: 360px; }
.row-right { display: flex; justify-content: flex-end; gap: 0.5rem; }

@media (max-width: 720px) {
  .admin-grid { grid-template-columns: 1fr; }
  .topbar { gap: 0.6rem; }
  #tabs { order: 3; width: 100%; overflow-x: auto; }
  .hist-items { margin-left: 0; }
  .stats-row { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
}

