/* ===== Soph's Planner — TeuxDeux-inspired ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #1a1a1a;
  --muted: #9aa0a6;
  --line: #ececec;
  --accent: #2563eb;
  --bg: #ffffff;
  --hover: #f7f7f7;
  --st-waiting: #9ca3af;
  --st-ready: #eab308;
  --st-inprogress: #22c55e;
  --st-overdue: #ef4444;
  --st-quickfire: #ec4899;
  --st-meeting: #111827;
  --st-review: #3b82f6;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Login ---------- */
.login-wrap { height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { width: 320px; text-align: center; }
.login-box h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 4px; }
.dot { color: var(--accent); }
.login-sub { color: var(--muted); margin-bottom: 24px; font-size: 14px; }
.login-box input {
  width: 100%; padding: 12px 14px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 15px; outline: none;
}
.login-box input:focus { border-color: var(--accent); }
.login-box button {
  width: 100%; padding: 12px; background: var(--ink); color: #fff;
  border: 0; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.login-error { color: var(--st-overdue); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---------- Layout ---------- */
#app { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { font-weight: 800; font-size: 18px; letter-spacing: -0.4px; }
.views { display: flex; gap: 2px; background: #f1f1f1; border-radius: 8px; padding: 3px; }
.views button {
  border: 0; background: transparent; padding: 6px 14px; font-size: 13px; font-weight: 600;
  color: var(--muted); border-radius: 6px; cursor: pointer;
}
.views button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.topbar-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.nav-arrows { display: flex; gap: 2px; }
.nav-arrows button {
  border: 1px solid var(--line); background: #fff; padding: 6px 12px; cursor: pointer;
  font-size: 14px; color: var(--ink);
}
.nav-arrows button:first-child { border-radius: 6px 0 0 6px; }
.nav-arrows button:last-child { border-radius: 0 6px 6px 0; }
.nav-arrows button:hover { background: var(--hover); }
.btn-new {
  background: var(--ink); color: #fff; border: 0; padding: 8px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-logout { border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; }

main { flex: 1; overflow: auto; }

/* ---------- Week view ---------- */
.week {
  display: grid; grid-template-columns: repeat(7, 1fr);
  min-height: 100%;
}
.day-col { border-right: 1px solid var(--line); padding: 18px 14px; min-width: 150px; }
.day-col:last-child { border-right: 0; }
.day-col.weekend { background: #fafafa; }
.day-date { font-size: 10px; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
.day-name { font-size: 20px; font-weight: 800; letter-spacing: -0.4px; margin: 2px 0 14px; }
.day-col.today .day-name { color: var(--accent); }
.day-tasks { min-height: 60px; }

.task {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 7px 4px; border-bottom: 1px solid var(--line);
  cursor: grab; font-size: 13.5px; line-height: 1.35;
  border-radius: 4px;
}
.task:hover { background: var(--hover); }
.task.dragging { opacity: 0.4; }
.task .chk {
  flex: none; width: 15px; height: 15px; margin-top: 2px;
  border: 1.5px solid #c9c9c9; border-radius: 4px; cursor: pointer; background: #fff;
}
.task .chk:hover { border-color: var(--ink); }
.task.done .chk { background: var(--ink); border-color: var(--ink); position: relative; }
.task.done .chk::after {
  content: "✓"; color: #fff; font-size: 10px; position: absolute; top: -1px; left: 2px;
}
.task .t-body { flex: 1; min-width: 0; }
.task .t-title { word-wrap: break-word; }
.task.done .t-title { text-decoration: line-through; color: var(--muted); }
.task .t-meta { font-size: 11px; color: var(--muted); margin-top: 1px; display: flex; gap: 6px; flex-wrap: wrap; }
.task .t-meta .due-warn { color: var(--st-overdue); font-weight: 600; }
.status-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; }
.rolled-flag { font-size: 10px; color: var(--st-overdue); }
.recur-flag { font-size: 10px; color: var(--accent); }

.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; border-radius: 6px; background: #eff6ff; }
.day-add {
  border: 0; background: none; color: #d0d0d0; font-size: 13px; cursor: pointer;
  padding: 8px 4px; width: 100%; text-align: left;
}
.day-add:hover { color: var(--accent); }

/* ---------- Month view ---------- */
.month { padding: 14px 20px; }
.month-title { font-size: 22px; font-weight: 800; margin-bottom: 12px; letter-spacing: -0.4px; }
.month-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border-top: 1px solid var(--line); border-left: 1px solid var(--line);
}
.month-head {
  padding: 6px 8px; font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--muted); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: #fafafa;
}
.mday {
  min-height: 108px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 6px; font-size: 12px; overflow: hidden;
}
.mday.dim { background: #fafafa; color: var(--muted); }
.mday .mday-num { font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.mday.today .mday-num {
  color: #fff; background: var(--accent); display: inline-flex; width: 18px; height: 18px;
  align-items: center; justify-content: center; border-radius: 50%;
}
.mtask {
  display: flex; align-items: center; gap: 5px; padding: 2px 4px; margin-bottom: 2px;
  border-radius: 4px; cursor: grab; font-size: 11.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mtask:hover { background: var(--hover); }
.mtask .status-dot { margin-top: 0; width: 7px; height: 7px; }
.mtask.done { text-decoration: line-through; color: var(--muted); }
.mtask-more { font-size: 10px; color: var(--muted); padding-left: 4px; }

/* ---------- Hours / Clients pages ---------- */
.page { max-width: 860px; margin: 0 auto; padding: 28px 20px; }
.page h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.4px; margin-bottom: 4px; }
.page .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.month-picker { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; }
.month-picker button {
  border: 1px solid var(--line); background: #fff; padding: 5px 11px; border-radius: 6px; cursor: pointer;
}
.month-picker .mp-label { font-weight: 700; font-size: 16px; min-width: 150px; text-align: center; }

table.report { width: 100%; border-collapse: collapse; font-size: 14px; }
table.report th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line);
}
table.report td { padding: 10px; border-bottom: 1px solid var(--line); }
table.report td.num, table.report th.num { text-align: right; font-variant-numeric: tabular-nums; }
.bar-wrap { background: #f1f1f1; border-radius: 99px; height: 8px; width: 140px; overflow: hidden; }
.bar { height: 100%; border-radius: 99px; background: var(--st-inprogress); }
.bar.warn { background: var(--st-ready); }
.bar.over { background: var(--st-overdue); }
.over-label { color: var(--st-overdue); font-weight: 700; }

/* ---------- Billing page ---------- */
.bill-client { margin-bottom: 28px; }
.bill-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.bill-head h2 { font-size: 16px; font-weight: 800; letter-spacing: -0.3px; }
.bill-meta { color: var(--muted); font-size: 12px; }
.bill-badge {
  background: #fef2f2; color: var(--st-overdue); font-weight: 700; font-size: 12px;
  padding: 2px 9px; border-radius: 99px;
}
.bill-ok { color: var(--st-inprogress); font-size: 12px; font-weight: 600; }
.bill-num { color: var(--st-overdue); font-weight: 700; }
.bill-date { color: var(--muted); white-space: nowrap; }
.bill-total { color: var(--st-overdue); }

.client-row-form { display: flex; gap: 8px; margin-top: 18px; }
.client-row-form input[type=text] { flex: 1; }
.page input, .page select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; outline: none;
}
.page input:focus { border-color: var(--accent); }
.page .btn-primary { padding: 8px 16px; }
.icon-btn { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 14px; }
.icon-btn:hover { color: var(--ink); }

/* ---------- Legend ---------- */
.legend {
  display: flex; gap: 14px; flex-wrap: wrap; padding: 8px 20px;
  border-top: 1px solid var(--line); font-size: 11px; color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: #fff; border-radius: 14px; padding: 24px; width: 560px; max-width: calc(100vw - 32px);
  max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-small { width: 340px; }
#seriesModal .modal { width: 440px; }
.modal h2 { font-size: 18px; font-weight: 800; margin-bottom: 16px; letter-spacing: -0.3px; }
.done-name { color: var(--muted); font-size: 14px; margin: -8px 0 14px; }
.modal label { display: block; font-size: 12px; font-weight: 600; color: #555; margin-bottom: 12px; }
.modal label > input, .modal label > select, .modal label > textarea {
  display: block; width: 100%; margin-top: 4px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 14px; outline: none;
  font-family: inherit; background: #fff;
}
.modal label > input:focus, .modal label > select:focus, .modal label > textarea:focus { border-color: var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.time-input { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.time-input input {
  width: 64px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; outline: none;
}
.time-input input:focus { border-color: var(--accent); }
.time-input span { color: var(--muted); font-size: 13px; }
.hint { font-weight: 400; color: var(--muted); font-size: 11px; }
.modal-actions { display: flex; gap: 8px; row-gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.modal-actions .spacer { flex: 1; }
.btn-primary {
  background: var(--ink); color: #fff; border: 0; padding: 9px 18px; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-plain {
  background: #fff; border: 1px solid var(--line); padding: 9px 14px; border-radius: 8px;
  font-size: 14px; cursor: pointer;
}
.btn-danger {
  background: #fff; border: 1px solid #fecaca; color: var(--st-overdue);
  padding: 9px 14px; border-radius: 8px; font-size: 14px; cursor: pointer;
}
.btn-danger:hover { background: #fef2f2; }
.btn-secondary {
  background: #fff; color: var(--ink); border: 1.5px solid var(--ink);
  padding: 8px 14px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-secondary:hover { background: var(--hover); }

/* Task-modal footer: Delete/Duplicate as quiet text buttons so all five
   actions sit on one row; primary Save stays rightmost (and is the Enter default) */
#tDelete, #tDup { border: 0; background: none; padding: 9px 4px; font-size: 13px; }
#tDelete:hover { background: none; text-decoration: underline; }
#tDup { color: var(--muted); }
#tDup:hover { color: var(--ink); background: none; text-decoration: underline; }
#tSave { order: 1; }

/* ---------- Recurrence (repeat) controls ---------- */
.recur-opts {
  border: 1px solid var(--line); border-radius: 8px; padding: 12px;
  margin: -6px 0 12px; font-size: 12.5px; color: #555; background: #fafafa;
  display: flex; flex-direction: column; gap: 10px;
}
.recur-opts[hidden] { display: none; }
.recur-row { display: flex; flex-direction: column; gap: 6px; }
.recur-row[hidden] { display: none; }
.recur-opts .inline {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-weight: 400; margin: 0; font-size: 12.5px;
}
.recur-opts label.inline > input, .recur-opts label.inline > select {
  display: inline-block; width: auto; margin-top: 0;
}
.recur-opts input[type=number] {
  width: 58px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; font-size: 12.5px;
}
.recur-opts input[type=date] {
  padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; font-size: 12.5px;
}
.recur-opts select {
  padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 12.5px; background: #fff;
}
.recur-opts input[type=radio] { accent-color: var(--ink); }
.recur-opts .hint { margin-top: 2px; }
.wd-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.wd-chips .wd {
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  padding: 4px 8px; font-size: 11px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.wd-chips .wd.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.recur-hint { margin: -6px 0 10px; }
.recur-hint:empty { display: none; }

@media (max-width: 900px) {
  .week { grid-template-columns: 1fr; }
  .day-col { border-right: 0; border-bottom: 1px solid var(--line); }
}
