:root {
  --brand: #0f766e;
  --brand-dark: #115e59;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --ok: #22c55e;
  --shadow: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
a { color: var(--brand); }
.loading { padding: 60px; text-align: center; color: var(--muted); }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow);
  padding: 36px; width: 100%; max-width: 400px;
}
.auth-card h1 { color: var(--brand); font-size: 22px; margin: 0 0 4px; }
.auth-card .sub { color: var(--muted); margin: 0 0 24px; }

/* ---------- Layout ---------- */
.topbar {
  background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 58px;
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 800; color: var(--brand); font-size: 18px; white-space: nowrap; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav button {
  background: none; border: 0; padding: 8px 14px; border-radius: 8px;
  color: var(--muted); font-weight: 600; cursor: pointer; font-size: 14px;
}
.nav button:hover { background: var(--bg); }
.nav button.active { background: var(--brand); color: #fff; }
.user-menu { display: flex; align-items: center; gap: 10px; color: var(--muted); white-space: nowrap; }
.badge-role { font-size: 11px; background: var(--bg); padding: 2px 8px; border-radius: 20px; text-transform: uppercase; letter-spacing: .04em; }
.main { padding: 20px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 20px; }

/* ---------- Buttons & forms ---------- */
.btn {
  background: var(--brand); color: #fff; border: 0; padding: 9px 16px;
  border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 14px;
}
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: var(--bg); color: var(--text); }
.btn.secondary:hover { background: var(--border); }
.btn.danger { background: var(--danger); }
.btn.ghost { background: none; color: var(--muted); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; display: block; }
.btn-google {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #fff; color: #3c4043; border: 1px solid var(--border);
  padding: 10px; border-radius: 8px; font-weight: 600; cursor: pointer; margin-top: 10px;
}
.btn-google:hover { background: #f8fafc; }
label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 5px; color: #334155; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
textarea { resize: vertical; min-height: 70px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.divider { text-align: center; color: var(--muted); margin: 16px 0; font-size: 12px; position: relative; }
.error-box { background: #fee2e2; color: #991b1b; padding: 10px 12px; border-radius: 8px; margin: 10px 0; font-size: 13px; }

/* ---------- Kanban ---------- */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.column { background: #e9eef3; border-radius: 12px; min-width: 260px; max-width: 260px; padding: 10px; }
.column-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; padding: 4px 6px 10px; }
.column-head .count { background: #fff; color: var(--muted); border-radius: 20px; padding: 1px 9px; font-size: 12px; }
.column.dragover { outline: 2px dashed var(--brand); }
.card {
  background: var(--card); border-radius: 10px; padding: 11px 12px; margin-bottom: 9px;
  box-shadow: var(--shadow); cursor: grab; border-left: 3px solid var(--brand);
}
.card:hover { box-shadow: 0 4px 10px rgba(15,23,42,.12); }
.card .name { font-weight: 700; }
.card .meta { color: var(--muted); font-size: 12px; margin-top: 4px; display: flex; flex-direction: column; gap: 2px; }
.chip { display: inline-block; background: var(--bg); border-radius: 20px; padding: 1px 8px; font-size: 11px; color: var(--muted); }
.chip.unassigned { background: #fef3c7; color: #92400e; }

/* ---------- Table ---------- */
table.list { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
table.list th, table.list td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); }
table.list th { background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.done td { color: var(--muted); text-decoration: line-through; }

/* ---------- Cards / stats ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--card); border-radius: 12px; padding: 18px; box-shadow: var(--shadow); }
.stat .n { font-size: 28px; font-weight: 800; color: var(--brand); }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 4px; }
.panel { background: var(--card); border-radius: 12px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.panel h3 { margin: 0 0 14px; font-size: 15px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bar-row .lbl { width: 180px; font-size: 13px; }
.bar-track { flex: 1; background: var(--bg); border-radius: 6px; height: 18px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; }
.bar-row .val { width: 40px; text-align: right; font-weight: 700; font-size: 13px; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: flex-start; justify-content: center; padding: 30px 16px; z-index: 100; overflow-y: auto; }
.modal { background: var(--card); border-radius: 16px; width: 100%; max-width: 640px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card); border-radius: 16px 16px 0 0; }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-body { padding: 22px; }
.modal-close { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button { background: none; border: 0; padding: 8px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.timeline-item { border-left: 2px solid var(--border); padding: 0 0 14px 14px; position: relative; }
.timeline-item::before { content: ''; position: absolute; left: -5px; top: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.timeline-item .when { color: var(--muted); font-size: 12px; }
.list-item { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); gap: 10px; }
.list-item:last-child { border-bottom: 0; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1e293b; color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; animation: slidein .2s ease; }
.toast.err { background: var(--danger); }
@keyframes slidein { from { transform: translateY(10px); opacity: 0; } }

@media (max-width: 640px) {
  .brand { font-size: 15px; }
  .user-menu .who { display: none; }
}
