:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --border: #e5e5ea;
  --border-strong: #d8d8dd;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #8e8e93;
  --accent: #0a5fc4;
  --accent-hover: #0950a7;
  --high-bg: #fdecec;
  --high-fg: #b3261e;
  --low-bg: #f0f0f3;
  --low-fg: #6e6e73;
  --radius-lg: 14px;
  --radius: 12px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 1px 10px rgba(0, 0, 0, .03);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.boot {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  color: var(--text-3);
  font-size: 14px;
}

/* Buttons */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-weight: 590;
  font-size: 15px;
  cursor: pointer;
  transition: background .15s ease;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-primary.small { padding: 7px 14px; font-size: 14px; }

.btn-quiet {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.btn-quiet:hover { background: #ececf0; color: var(--text); }
.btn-quiet.small { padding: 6px 12px; font-size: 13px; }

/* Brand mark */
.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #1d1d1f;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 650;
  letter-spacing: .5px;
  font-size: 16px;
}
.brand-mark.small { width: 28px; height: 28px; border-radius: 8px; font-size: 12px; }

/* Login */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card .brand-mark { margin: 0 auto 4px; }
.login-card h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.3px;
  text-align: center;
}
.login-sub {
  margin: 0 0 6px;
  text-align: center;
  color: var(--text-2);
  font-size: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; color: var(--text-2); }
.field input {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #fff;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10, 95, 196, .12);
}
.login-error {
  margin: 0;
  color: var(--high-fg);
  font-size: 13px;
  text-align: center;
}
.login-card .btn-primary { margin-top: 4px; }

/* App shell */
.app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: #fafafc;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sidebar-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 6px 4px;
}
.brand-name { font-weight: 600; font-size: 14px; letter-spacing: -.2px; }

.client-list { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.client-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  color: var(--text);
  transition: background .12s ease;
}
.client-item:hover { background: #ededf1; }
.client-item.is-active { background: #e6eefa; color: var(--accent); font-weight: 590; }
.client-item .count {
  font-size: 12px;
  color: var(--text-3);
  background: #ececf0;
  border-radius: 999px;
  padding: 1px 8px;
  min-width: 22px;
  text-align: center;
}
.client-item.is-active .count { background: #d6e4f7; color: var(--accent); }
.client-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; }
.sidebar-foot .btn-quiet { width: 100%; }
.new-client-form { display: flex; flex-direction: column; gap: 8px; }
.new-client-form input {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  outline: none;
}
.new-client-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10, 95, 196, .12); }
.new-client-actions { display: flex; gap: 8px; }
.inline-error { margin: 0; color: var(--high-fg); font-size: 13px; }

/* Main */
.main { padding: 22px 28px 60px; max-width: 940px; width: 100%; }
.main-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.main-head h1 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -.5px; }
.scope-sub { margin: 2px 0 0; color: var(--text-2); font-size: 13px; }
.head-right { display: flex; align-items: center; gap: 10px; }
.user-name { font-size: 13px; color: var(--text-2); }

.filter-row { margin: 16px 0 14px; }
.pills {
  display: inline-flex;
  gap: 2px;
  background: #ececf0;
  border-radius: 999px;
  padding: 3px;
}
.pill {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 5px 15px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.pill.is-active { background: #fff; color: var(--text); font-weight: 590; box-shadow: 0 1px 2px rgba(0,0,0,.06); }

/* Composer */
.composer {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}
.composer-title {
  border: 0;
  outline: none;
  font-size: 16px;
  padding: 4px 2px;
  background: transparent;
}
.composer-title::placeholder { color: var(--text-3); }
.composer-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.composer-row .btn-primary { margin-left: auto; }
.select {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  background: #fff;
  font-size: 13px;
  color: var(--text-2);
  outline: none;
  max-width: 180px;
}
.select:focus { border-color: var(--accent); }
.composer-notes {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  outline: none;
  resize: vertical;
  font-size: 14px;
}
.composer-notes:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10, 95, 196, .12); }

/* Task list */
.task-list { display: flex; flex-direction: column; gap: 8px; }

.task {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.task.is-done { background: #fbfbfd; }

.check {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  min-width: 20px;
  margin-top: 2px;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  transition: background .12s ease, border-color .12s ease;
}
.check:hover { border-color: var(--accent); }
.check:checked { background: var(--accent); border-color: var(--accent); }
.check:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2.5px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(43deg);
}

.task-body { flex: 1; min-width: 0; }
.task-title {
  font-size: 15px;
  cursor: default;
  word-break: break-word;
}
.task.is-done .task-title { text-decoration: line-through; color: var(--text-3); }
.task-title.has-notes { cursor: pointer; }

.task-notes {
  margin: 6px 0 0;
  white-space: pre-wrap;
  color: var(--text-2);
  font-size: 14px;
  background: #f7f7f9;
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  word-break: break-word;
}

.task-meta {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
}
.task-meta .dot { color: var(--border-strong); }
.chip {
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 590;
  letter-spacing: .1px;
}
.chip.high { background: var(--high-bg); color: var(--high-fg); }
.chip.low { background: var(--low-bg); color: var(--low-fg); }
.notes-hint { color: var(--accent); cursor: pointer; }

.task-actions { display: flex; align-items: center; gap: 6px; }
.del {
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-size: 17px;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 8px;
  cursor: pointer;
}
.del:hover { background: #f2f2f5; color: var(--high-fg); }
.del.confirming {
  background: var(--high-bg);
  color: var(--high-fg);
  font-size: 12px;
  font-weight: 590;
  padding: 4px 10px;
}

.empty {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
}

.section-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-3);
  margin: 14px 0 2px;
}

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 14px 14px 12px;
  }
  .client-list {
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .client-item {
    width: auto;
    flex: 0 0 auto;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
  }
  .client-item .count { background: transparent; padding: 0 0 0 2px; }
  .sidebar-foot { border-top: 0; padding-top: 0; }
  .sidebar-foot .btn-quiet { width: auto; }
  .main { padding: 18px 16px 60px; }
  .main-head h1 { font-size: 22px; }
  .select { flex: 1 1 40%; max-width: none; }
  .composer-row .btn-primary { margin-left: 0; flex: 1 1 100%; }
}
