/* ===== Kanban Light theme ===== */
:root {
  --indigo: #4338CA;
  --indigo-soft: #EEF2FF;
  --bg: #F5F7FB;
  --ink: #1E2A3A;
  --text: #475569;
  --muted: #64748B;
  --line: #E2E8F0;
  --border: #CBD5E1;
  --row: #F8FAFC;
  --column: #E9ECF3;
  --red: #DC2626;
  --green: #15803D;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.4 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow-wrap: anywhere;
}
h1 { font-size: 26px; line-height: 1.2; margin: 0; }
h2 { font-size: 16px; margin: 0; }
p  { margin: 0; }
a  { color: var(--indigo); font-weight: 600; text-decoration: none; }
.muted { color: var(--muted); font-size: 14px; }
:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }

/* ===== Buttons ===== */
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 42px; padding: 9px 18px; border-radius: 10px;
  border: 1px solid var(--border); background: #fff; color: var(--ink);
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
.btn:hover { background: var(--row); }
.btn.primary { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.btn.primary:hover { background: #3730A3; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.small { min-height: 38px; padding: 6px 14px; border-radius: 8px; }
.btn.wide { width: 100%; }
.link { border: 0; background: none; padding: 8px 0; color: var(--indigo); font-weight: 600; font-size: 13px; }
.link.danger { color: var(--red); }

/* ===== Forms ===== */
form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--text); }
input, textarea, select {
  width: 100%; padding: 12px 13px; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--ink); font: inherit; font-size: 16px; /* 16px stops iPhone zooming */
}
textarea { min-height: 84px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--indigo); outline-offset: -1px; border-color: var(--indigo); }
input[readonly] { background: var(--row); color: var(--muted); }
.error { color: #B91C1C; background: #FEF2F2; border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.error:empty { display: none; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.actions .push-left { margin-right: auto; }

/* ===== 1-2 Login and Create account ===== */
.login { display: flex; min-height: 100vh; min-height: 100dvh; }
.login-hero {
  flex: 1; background: var(--indigo); color: #fff; padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 24px;
}
.login-hero b { font-size: 22px; }
.login-hero strong { font-size: 40px; line-height: 1.2; max-width: 480px; }
.login-hero span { opacity: .9; }
.login-form { width: 520px; padding: 64px; background: #fff; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.login-form h1 { font-size: 28px; }
.center { text-align: center; font-size: 14px; color: var(--text); }
.signup { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.signup-card { width: 480px; max-width: 100%; background: #fff; border-radius: 18px; padding: 44px; box-shadow: 0 10px 30px rgba(15,23,42,.08); display: flex; flex-direction: column; gap: 14px; }
.signup-card h1 { font-size: 24px; }

/* ===== App layout ===== */
#app { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  width: 220px; flex: none; position: sticky; top: 0; height: 100vh; height: 100dvh;
  background: #fff; border-right: 1px solid var(--line); padding: 24px 18px;
  display: flex; flex-direction: column; gap: 6px;
}
.brand { font-weight: 700; font-size: 18px; margin-bottom: 16px; }
.sidebar a { padding: 10px 12px; border-radius: 8px; color: var(--text); font-weight: 400; }
.sidebar a:hover { background: var(--row); }
.sidebar a.active { background: var(--indigo-soft); color: var(--indigo); font-weight: 600; }
.signed-in { margin-top: auto; padding: 12px; background: var(--row); border-radius: 10px; font-size: 13px; color: var(--text); }
#page { flex: 1; min-width: 0; padding: 32px; display: flex; flex-direction: column; gap: 20px; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.bell { position: relative; width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; background: #fff; font-size: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.bell[aria-expanded="true"] { background: var(--indigo-soft); }
.badge {
  position: absolute; top: -2px; right: -3px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--red); color: #fff; font-size: 12px; font-weight: 700; line-height: 20px; text-align: center;
}
.avatar {
  width: 32px; height: 32px; flex: none; border-radius: 50%; color: #fff; font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.avatar.m { width: 38px; height: 38px; font-size: 13px; }
.avatar.l { width: 44px; height: 44px; font-size: 15px; }
.avatar.xl { width: 60px; height: 60px; font-size: 20px; }

/* ===== Cards, rows, pills ===== */
.card { background: #fff; border-radius: 14px; padding: 22px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px; background: var(--row); border-radius: 10px; color: var(--ink); font-weight: 400; min-height: 46px; }
.row .muted { text-align: right; flex: none; max-width: 55%; }
a.row:hover { background: var(--indigo-soft); }
.empty { color: var(--muted); font-size: 14px; padding: 10px 0; }
.pill { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: #F1F5F9; color: var(--text); white-space: nowrap; }
.pill.leader { background: var(--indigo-soft); color: var(--indigo); }
.late { color: var(--red) !important; }
.online { color: var(--green); font-weight: 600; font-size: 14px; }

/* ===== 3 Dashboard ===== */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stats .card { padding: 20px; gap: 0; }
.stats .label { font-size: 13px; color: var(--muted); }
.stats .number { font-size: 30px; font-weight: 700; }

/* ===== 4 Notifications ===== */
.notif-panel {
  position: fixed; z-index: 20; top: 84px; right: 32px; width: 400px; max-height: calc(100vh - 110px); overflow: auto;
  background: #fff; border-radius: 16px; box-shadow: 0 16px 40px rgba(15,23,42,.18); padding: 18px;
  display: flex; flex-direction: column; gap: 8px;
}
.notif-head { display: flex; justify-content: space-between; align-items: center; }
.notif-head h2 { font-size: 17px; }
.notif { padding: 14px; border-radius: 12px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.notif.unread { background: var(--indigo-soft); }
.notif time { font-size: 12px; color: var(--muted); }
.notif-open { border: 0; background: none; padding: 0; text-align: left; display: flex; flex-direction: column; gap: 6px; }
.split { display: flex; gap: 8px; margin-top: 4px; }
.split .btn { flex: 1; }

/* ===== 5 and 8 Kanban ===== */
.kanban { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; flex: 1; }
.column { background: var(--column); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; min-height: 120px; }
.column.over { box-shadow: inset 0 0 0 2px var(--indigo); }
.column h3 { margin: 0; font-size: 13px; color: var(--text); text-transform: uppercase; }
.task { background: #fff; border-radius: 10px; padding: 10px 14px; border-left: 4px solid transparent; }
.task[draggable="true"] { cursor: grab; }
.task.doing { border-left-color: var(--indigo); }
.task.dragging { opacity: .4; }
.task-title { width: 100%; border: 0; background: none; padding: 4px 0; text-align: left; font-size: 15px; }
.task.done .task-title { color: var(--muted); text-decoration: line-through; }
.task-foot { display: flex; flex-wrap: wrap; overflow-wrap: normal; justify-content: space-between; align-items: center; gap: 8px; min-height: 24px; font-size: 12px; color: var(--muted); }
.move { margin-left: auto; display: flex; gap: 4px; }
.move button { width: 36px; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); font-size: 15px; line-height: 1; }
.move button:hover { border-color: var(--indigo); color: var(--indigo); }

/* ===== 6 and 8 Groups ===== */
.group-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.group-card { color: var(--ink); font-weight: 400; }
.group-card:hover { box-shadow: 0 4px 14px rgba(15,23,42,.08); }
.group-card .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.group-card b { font-size: 18px; }
.avatars { display: flex; gap: 6px; }
.group-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(220px, 1fr); gap: 16px; flex: 1; }
.group-layout .card { padding: 18px; }
.group-layout .kanban { gap: 10px; }
.group-layout .column { padding: 10px; }
.person { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.person.box { padding: 12px; border-radius: 10px; background: var(--row); }
.person .name { flex: 1; min-width: 0; }
.person .name b { font-size: 15px; display: block; }
.bottom { margin-top: auto; }

/* ===== 7 and 9 Dialogs ===== */
dialog {
  width: 560px; max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); overflow: auto;
  border: 0; border-radius: 18px; padding: 32px; color: var(--ink); box-shadow: 0 16px 40px rgba(15,23,42,.2);
}
dialog::backdrop { background: rgba(30,42,58,.35); }
dialog h1 { font-size: 22px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.list { display: flex; flex-direction: column; gap: 8px; }

/* ===== 10 Profile ===== */
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; color: var(--text); min-height: 40px; cursor: pointer; }
.setting input { width: 44px; height: 26px; flex: none; margin: 0; padding: 0; appearance: none; border: 0; border-radius: 13px; background: var(--border); position: relative; cursor: pointer; }
.setting input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; }
.setting input:checked { background: var(--indigo); }
.setting input:checked::after { left: 21px; }

.toast {
  position: fixed; z-index: 50; inset: auto auto 28px 50%; transform: translateX(-50%); margin: 0; border: 0;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px; max-width: calc(100vw - 32px); width: max-content;
}

/* ===== Tablet: group members go under the tasks ===== */
@media (max-width: 1000px) {
  .group-layout { grid-template-columns: minmax(0, 1fr); }
}

/* ===== Phone ===== */
@media (max-width: 760px) {
  .login { flex-direction: column; background: #fff; }
  .login-hero { flex: none; padding: 32px 24px; gap: 12px; }
  .login-hero strong { font-size: 28px; }
  .login-form { width: 100%; padding: 32px 24px; justify-content: flex-start; }
  .signup-card { padding: 28px 22px; }

  /* Sidebar becomes a tab bar at the bottom */
  #app { display: block; }
  .sidebar {
    position: fixed; z-index: 10; top: auto; bottom: 0; left: 0; right: 0; width: auto; height: auto;
    flex-direction: row; border-right: 0; border-top: 1px solid var(--line);
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); gap: 4px;
  }
  .brand, .signed-in { display: none; }
  .sidebar a { flex: 1; text-align: center; padding: 12px 2px; font-size: 13px; }
  #page { min-height: 100dvh; padding: 20px 16px calc(92px + env(safe-area-inset-bottom)); gap: 16px; }

  h1 { font-size: 22px; }
  .topbar { flex-wrap: wrap; }
  .topbar-right.many { width: 100%; justify-content: flex-end; flex-wrap: wrap; }
  .stats { gap: 10px; }
  .stats .card { padding: 14px 12px; }
  .stats .number { font-size: 24px; }
  .kanban, .group-grid, .two { grid-template-columns: minmax(0, 1fr); }
  .card, .group-layout .card { padding: 16px; }
  .notif-panel { top: 72px; left: 12px; right: 12px; width: auto; max-height: calc(100dvh - 160px); }
  dialog { padding: 22px; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
