:root {
  --bg: #0b0d1a;
  --bg2: #12152a;
  --card: #171a30;
  --card2: #1e2240;
  --line: #2a2f52;
  --txt: #eef0ff;
  --muted: #9aa0c8;
  --accent: #7c5cff;
  --accent2: #22d3ee;
  --green: #34d399;
  --red: #fb7185;
  --amber: #fbbf24;
  --cat-negocio: #7c5cff;
  --cat-pessoal: #22d3ee;
  --cat-estudos: #34d399;
  --cat-criativo: #fb7185;
  --radius: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 800px at 80% -10%, #1a1f45 0%, var(--bg) 55%);
  color: var(--txt);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
button { font-family: inherit; cursor: pointer; border: none; }
input, textarea, select {
  font-family: inherit; background: var(--bg2); color: var(--txt);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; font-size: 15px;
  width: 100%; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }

/* ---------- LOGIN ---------- */
.login-wrap { display: grid; place-items: center; height: 100vh; padding: 20px; }
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  padding: 38px 30px; width: 100%; max-width: 360px; text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.login-logo { font-size: 46px; }
.login-card h1 { font-size: 30px; margin: 8px 0 2px; }
.login-card input { margin: 20px 0 12px; text-align: center; }
.login-card button {
  width: 100%; padding: 13px; border-radius: 12px; font-size: 16px; font-weight: 600;
  color: #fff; background: linear-gradient(135deg, var(--accent), #5a3ff0);
}
.err { color: var(--red); font-size: 14px; margin-top: 10px; min-height: 18px; }

/* ---------- LAYOUT ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--bg2), var(--bg));
  border-right: 1px solid var(--line); padding: 22px 16px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; padding: 0 8px 22px; }
.brand-ico { font-size: 24px; }
nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; background: transparent; color: var(--muted);
  padding: 12px 14px; border-radius: 12px; font-size: 15px; font-weight: 500; text-align: left; transition: .15s;
}
.nav-item span { font-size: 18px; }
.nav-item:hover { background: var(--card); color: var(--txt); }
.nav-item.active { background: var(--card2); color: var(--txt); box-shadow: inset 0 0 0 1px var(--line); }
.sidebar-foot { margin-top: auto; }
.main { padding: 30px 34px 60px; max-width: 1180px; width: 100%; }

/* ---------- generic ---------- */
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.view-head h2 { font-size: 26px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.grid { display: grid; gap: 16px; }
.btn {
  background: linear-gradient(135deg, var(--accent), #5a3ff0); color: #fff; font-weight: 600;
  padding: 11px 18px; border-radius: 11px; font-size: 14px; display: inline-flex; align-items: center; gap: 8px;
}
.btn.sec { background: var(--card2); box-shadow: inset 0 0 0 1px var(--line); }
.ghost { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); padding: 10px 14px; border-radius: 10px; font-weight: 500; }
.ghost:hover { color: var(--txt); }
.small { font-size: 13px; padding: 7px 11px; }
.chip { font-size: 12px; padding: 3px 10px; border-radius: 999px; font-weight: 600; display: inline-block; }
.row { display: flex; gap: 10px; align-items: center; }
.spread { justify-content: space-between; }
label.fld { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty .big { font-size: 40px; display: block; margin-bottom: 10px; }

/* ---------- DASHBOARD ---------- */
.clock-card {
  background: linear-gradient(135deg, #1c1f3d, #14172e);
  border: 1px solid var(--line); border-radius: 22px; padding: 30px 32px; margin-bottom: 20px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 20px;
  position: relative; overflow: hidden;
}
.clock-card::after { content: ""; position: absolute; right: -60px; top: -60px; width: 240px; height: 240px;
  background: radial-gradient(circle, rgba(124,92,255,.35), transparent 65%); }
.clock-time { font-size: 62px; font-weight: 700; letter-spacing: 2px; font-variant-numeric: tabular-nums; }
.clock-sec { color: var(--accent2); }
.clock-date { color: var(--muted); font-size: 16px; margin-top: 4px; text-transform: capitalize; }
.clock-hi { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat .n { font-size: 34px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 14px; }
.progress { height: 10px; background: var(--bg2); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 999px; transition: width .4s; }
.today-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.today-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg2); border-radius: 10px; }
.today-item .t { font-size: 13px; color: var(--accent2); font-variant-numeric: tabular-nums; min-width: 42px; }
.tick { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--line); flex: none; cursor: pointer; }
.tick.on { background: var(--green); border-color: var(--green); }
.done-txt { text-decoration: line-through; color: var(--muted); }

/* pomodoro */
.pomo { text-align: center; }
.pomo-time { font-size: 52px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 6px 0 14px; }
.pomo-btns { display: flex; gap: 8px; justify-content: center; }

/* ---------- METAS ---------- */
.cats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.cat-pill { padding: 8px 15px; border-radius: 999px; background: var(--card); color: var(--muted); font-size: 14px; font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.cat-pill.active { color: #fff; }
.goals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.goal-card { display: flex; flex-direction: column; gap: 12px; }
.goal-top { display: flex; justify-content: space-between; gap: 10px; }
.goal-title { font-size: 18px; font-weight: 700; }
.goal-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.etapa { background: var(--bg2); border-radius: 12px; padding: 12px 14px; margin-top: 8px; }
.etapa-h { font-weight: 600; font-size: 14px; margin-bottom: 8px; display: flex; justify-content: space-between; }
.task { display: flex; align-items: center; gap: 9px; padding: 6px 0; font-size: 14px; }
.task .meta { margin-left: auto; font-size: 11px; color: var(--muted); }
.goal-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; }
.iconbtn { background: transparent; color: var(--muted); font-size: 15px; padding: 4px 7px; border-radius: 8px; }
.iconbtn:hover { background: var(--bg2); color: var(--txt); }

/* ---------- CALENDAR ---------- */
.cal-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; color: var(--muted); font-size: 12px; font-weight: 700; padding: 4px 0; text-transform: uppercase; }
.cal-cell { background: var(--card); border: 1px solid var(--line); border-radius: 10px; min-height: 82px; padding: 6px 7px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; transition: .12s; }
.cal-cell:hover { border-color: var(--accent); }
.cal-cell.out { opacity: .32; }
.cal-cell.today { border-color: var(--accent2); box-shadow: 0 0 0 1px var(--accent2); }
.cal-num { font-size: 13px; font-weight: 600; }
.cal-ev { font-size: 10px; padding: 2px 5px; border-radius: 5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: #fff; }

/* ---------- ALARMS ---------- */
.alarm-row { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 10px; }
.alarm-time { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.alarm-info { flex: 1; }
.alarm-days { display: flex; gap: 4px; margin-top: 6px; }
.dayb { width: 26px; height: 26px; border-radius: 8px; font-size: 11px; font-weight: 700; background: var(--bg2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.dayb.on { background: var(--accent); color: #fff; }
.switch { width: 46px; height: 26px; border-radius: 999px; background: var(--line); position: relative; transition: .2s; flex: none; }
.switch.on { background: var(--green); }
.switch::after { content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: .2s; }
.switch.on::after { left: 23px; }

/* ---------- IA ---------- */
.ia-wrap { display: grid; grid-template-columns: 1fr; gap: 16px; }
.quick-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.chat { display: flex; flex-direction: column; gap: 12px; max-height: 52vh; overflow-y: auto; padding: 4px; }
.msg { padding: 12px 15px; border-radius: 14px; max-width: 88%; font-size: 15px; line-height: 1.5; white-space: pre-wrap; }
.msg.me { background: linear-gradient(135deg, var(--accent), #5a3ff0); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.ia { background: var(--card2); align-self: flex-start; border-bottom-left-radius: 4px; box-shadow: inset 0 0 0 1px var(--line); }
.chat-input { display: flex; gap: 8px; margin-top: 12px; }
.typing { display: inline-flex; gap: 4px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,60%,100% { opacity: .3; } 30% { opacity: 1; } }

/* ---------- HISTÓRICO ---------- */
.hist-item { display: flex; gap: 12px; align-items: flex-start; padding: 9px 0; border-top: 1px solid var(--line); }
.hist-item:first-child { border-top: none; }
.hist-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 16px; flex: none; }
.hist-body { flex: 1; min-width: 0; }
.hist-txt { font-size: 14px; }
.hist-time { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- MODAL ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(4,6,16,.72); display: grid; place-items: center; padding: 18px; z-index: 60; backdrop-filter: blur(3px); }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px; width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; }
.modal h3 { font-size: 20px; margin-bottom: 6px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; }
.seg button { padding: 8px 12px; border-radius: 9px; background: var(--bg2); color: var(--muted); font-size: 13px; font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.seg button.on { color: #fff; }

/* ---------- RINGING ---------- */
.ringing { position: fixed; inset: 0; background: rgba(6,8,20,.92); display: grid; place-items: center; z-index: 100; }
.ringing-card { text-align: center; }
.ringing-ico { font-size: 80px; animation: shake .6s infinite; }
.ringing-label { font-size: 30px; font-weight: 700; margin-top: 10px; }
.ringing-time { font-size: 20px; color: var(--accent2); margin: 4px 0 24px; }
.big-btn { padding: 16px 44px; border-radius: 14px; font-size: 18px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--red), #e11d48); }
@keyframes shake { 0%,100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg); } }

/* ---------- TOAST ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--card2); color: var(--txt); padding: 12px 20px; border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.5), inset 0 0 0 1px var(--line); z-index: 120; font-size: 14px; }

/* ---------- bottom nav (mobile) ---------- */
.bottomnav { display: none; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 18px 16px 90px; }
  .clock-time { font-size: 48px; }
  .view-head h2 { font-size: 22px; }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: var(--bg2); border-top: 1px solid var(--line); padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  }
  .bn { flex: 1; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px; }
  .bn span { font-size: 20px; }
  .bn small { font-size: 10px; }
  .bn.active { color: var(--accent2); }
  .goals-grid, .dash-grid { grid-template-columns: 1fr; }
  .cal-cell { min-height: 60px; }
}
