:root {
  --ink: #1A2433;
  --ink-soft: #5B6B80;
  --paper: #F5F7FA;
  --surface: #FFFFFF;
  --line: #E3E7ED;
  --brand: #28457A;
  --brand-dark: #1C3355;
  --brand-soft: #E2E8F0;
  --red: #BD2722;
  --red-soft: #FBEAE7;
  --orange: #D1501E;
  --orange-soft: #FBE4D8;
  --green: #3F7256;
  --green-soft: #E3EEE7;
  --slate-soft: #EAECF0;
  --font-display: 'Source Sans 3', sans-serif;
  --font-display-weight: 800;
  --font-body: 'Source Sans 3', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font-family: var(--font-body); font-size: 14px; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
a { color: inherit; }

/* ---------- Loading ---------- */
.loading-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.loading-inner { display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--brand); }
.loading-label { font-family: var(--font-mono); color: var(--ink-soft); font-size: 13px; }

/* ---------- Buttons ---------- */
.btn-primary, .btn-secondary, .btn-icon {
  cursor: pointer;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn-primary {
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 9px 16px;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 8px 15px;
}
.btn-secondary:hover { background: var(--slate-soft); }
.btn-danger { color: var(--red); border-color: var(--red-soft); }
.btn-icon {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 8px;
  justify-content: center;
}
.btn-icon:hover { background: var(--slate-soft); }
.btn-icon.bare { border: none; }
.btn-link {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label, .field-label { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.input, textarea.input, select.input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  width: 100%;
  background: var(--surface);
  color: var(--ink);
}
textarea.input { resize: vertical; font-family: var(--font-body); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.password-wrap { position: relative; }
.password-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--ink-soft); cursor: pointer;
  display: flex; align-items: center;
}

/* ---------- Icons (inline SVG helper sizing) ---------- */
.icon { display: inline-flex; align-items: center; justify-content: center; }

/* ---------- Auth screen ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { width: 100%; max-width: 820px; display: flex; border-radius: 20px; overflow: hidden; box-shadow: 0 20px 50px rgba(18,24,31,0.12); background: var(--surface); }
.auth-brand { display: none; flex-direction: column; justify-content: space-between; padding: 32px; width: 320px; background: var(--brand); color: #fff; }
.auth-brand .brand-tagline { font-family: var(--font-mono); font-size: 12px; letter-spacing: 1px; opacity: 0.8; margin-top: 14px; }
.auth-brand .brand-desc { font-size: 14px; opacity: 0.9; margin-top: 10px; line-height: 1.6; }
.auth-brand .brand-note { font-size: 12px; opacity: 0.8; line-height: 1.6; }
.auth-form-side { flex: 1; padding: 24px; display: flex; flex-direction: column; justify-content: center; }
.auth-mobile-logo { display: flex; align-items: center; margin-bottom: 24px; }
.tab-switch { display: flex; gap: 4px; margin-bottom: 20px; border-radius: 10px; padding: 4px; background: var(--paper); }
.tab-btn { flex: 1; padding: 8px 0; border-radius: 8px; border: none; cursor: pointer; font-weight: 600; font-size: 13px; background: transparent; color: var(--ink-soft); }
.tab-btn.active { background: var(--surface); color: var(--ink); }
.auth-hint { border-radius: 8px; padding: 8px 12px; margin-bottom: 16px; background: var(--brand-soft); color: var(--brand-dark); font-size: 12px; }
.auth-error { font-size: 12px; color: var(--red); margin: -4px 0 8px; }
@media (min-width: 768px) {
  .auth-brand { display: flex; }
  .auth-mobile-logo { display: none; }
}

/* ---------- App shell ---------- */
.app-shell { min-height: 100vh; display: flex; background: var(--paper); color: var(--ink); }
.sidebar {
  display: none;
  width: 256px;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 24px 16px;
}
.sidebar-logo { display: flex; align-items: center; margin-bottom: 32px; padding: 0 8px; }
.nav-list { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  border: none; cursor: pointer; font-size: 14px; font-weight: 500; text-align: left;
  background: transparent; color: var(--ink-soft); width: 100%;
}
.nav-item.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; }
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }
.sidebar-user { display: flex; align-items: center; gap: 8px; padding: 8px; }
.sidebar-user-name { font-size: 12px; font-weight: 600; }

.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--surface);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-family: var(--font-display); font-weight: 700; font-size: 18px; display: none; }
.topbar-mobile-logo { display: flex; align-items: center; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.main-content { flex: 1; overflow-y: auto; padding: 16px; padding-bottom: 88px; }

.mobile-nav {
  display: flex; position: fixed; bottom: 0; left: 0; right: 0;
  justify-content: space-around; align-items: center; height: 64px;
  background: var(--surface); border-top: 1px solid var(--line); z-index: 30;
}
.mobile-nav-item { background: none; border: none; cursor: pointer; color: var(--ink-soft); padding: 10px; }
.mobile-nav-item.active { color: var(--brand); }

@media (min-width: 768px) {
  .sidebar { display: flex; }
  .topbar-title { display: block; }
  .topbar-mobile-logo, .topbar-user-mobile, .mobile-nav { display: none; }
  .main-content { padding: 32px; padding-bottom: 32px; }
}

/* ---------- Avatar / tags ---------- */
.avatar {
  border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; flex-shrink: 0;
}
.role-tag {
  border-radius: 999px; font-size: 10px; font-weight: 700; padding: 2px 8px; letter-spacing: 0.4px;
  display: inline-block;
}
.role-tag.manager { background: var(--brand-soft); color: var(--brand-dark); }
.role-tag.member { background: var(--slate-soft); color: var(--ink-soft); }
.pill { border-radius: 999px; font-size: 11px; font-weight: 600; padding: 3px 10px; display: inline-block; }
.pill-outline { border-radius: 999px; font-size: 11px; font-weight: 600; padding: 3px 10px; display: inline-block; border: 1px solid; }

/* ---------- Dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 768px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-card { border-radius: 16px; border: 1px solid var(--line); background: var(--surface); padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 11px; color: var(--ink-soft); font-family: var(--font-mono); letter-spacing: 0.4px; }
.stat-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; }

.flow-card { border-radius: 16px; border: 1px solid var(--line); background: var(--surface); padding: 20px; margin-top: 16px; }
.flow-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.flow-title { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.flow-total { font-size: 12px; font-family: var(--font-mono); color: var(--ink-soft); }
.flow-track { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--slate-soft); }
.flow-seg { transition: width 0.6s ease; }
.flow-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; }
.flow-legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-soft); }
.flow-dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; }

.dash-grid { display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 16px; }
@media (min-width: 768px) { .dash-grid { grid-template-columns: 1fr 1fr; } }
.panel { border-radius: 16px; border: 1px solid var(--line); background: var(--surface); padding: 16px; }
.panel-title { font-family: var(--font-display); font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.list-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.list-row:last-child { border-bottom: none; }
.empty-note { font-size: 13px; color: var(--ink-soft); }

.workload-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.workload-bar-track { width: 80px; height: 6px; background: var(--slate-soft); border-radius: 4px; overflow: hidden; }
.workload-bar-fill { height: 100%; background: var(--brand); }

/* ---------- Board ---------- */
.board-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.board-count { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); }
.board-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.board-col { border-radius: 16px; padding: 12px; background: var(--paper); border: 1px solid var(--line); min-height: 160px; }
.board-col-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding: 0 4px; }
.board-col-head .title { font-weight: 700; font-size: 13px; }
.board-col-head .count { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); }
.board-col.drag-over { outline: 2px dashed var(--brand); outline-offset: -2px; }

.task-card { border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 12px; margin-bottom: 8px; cursor: pointer; transition: box-shadow 0.15s ease; }
.task-card:hover { box-shadow: 0 4px 14px rgba(18,24,31,0.08); }
.task-card-title { font-size: 13px; font-weight: 600; }
.task-card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.task-card-meta { display: flex; align-items: center; gap: 6px; }
.due-badge { font-size: 11px; padding: 2px 6px; border-radius: 6px; font-family: var(--font-mono); }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.cal-head-left { display: flex; align-items: center; gap: 8px; }
.cal-month-label { font-family: var(--font-display); font-weight: 600; font-size: 15px; min-width: 150px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-weekday { font-size: 11px; font-weight: 700; color: var(--ink-soft); text-align: center; padding: 2px 0; }
.cal-cell { border-radius: 8px; padding: 6px; min-height: 74px; background: var(--surface); border: 1px solid var(--line); cursor: pointer; }
.cal-cell.today { border-color: var(--brand); }
.cal-cell.empty { background: transparent; border: none; cursor: default; }
.cal-date { font-size: 11px; font-family: var(--font-mono); color: var(--ink-soft); }
.cal-date.today { color: var(--brand); font-weight: 700; }
.cal-task-chip { font-size: 10px; padding: 1px 4px; border-radius: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.cal-more { font-size: 10px; color: var(--ink-soft); }
.cal-day-panel { border-radius: 16px; border: 1px solid var(--line); background: var(--surface); padding: 16px; margin-top: 16px; }

/* ---------- Team ---------- */
.team-note { font-size: 12px; color: var(--ink-soft); line-height: 1.6; margin-bottom: 12px; }
.team-list { border-radius: 16px; border: 1px solid var(--line); overflow: hidden; }
.team-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; gap: 8px; }
.team-row:first-child { border-top: none; }
.team-row-left { display: flex; align-items: center; gap: 12px; }
.team-row-name { font-size: 14px; font-weight: 600; }
.team-row-sub { font-size: 11px; color: var(--ink-soft); font-family: var(--font-mono); }
.team-row-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Modals ---------- */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(18,24,31,0.45); z-index: 150; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; display: flex; flex-direction: column; max-height: 85vh; }
.modal.narrow { max-width: 460px; }
.modal.wide { max-width: 640px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head .title { font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.confirm-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(18,24,31,0.45); z-index: 200; }
.confirm-box { background: var(--surface); border-radius: 18px; padding: 20px; max-width: 380px; width: 100%; }
.confirm-msg { font-size: 14px; margin-bottom: 16px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Status changer / detail ---------- */
.status-btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.status-btn { border-radius: 10px; font-size: 12px; font-weight: 600; padding: 6px 12px; cursor: pointer; background: transparent; }
.detail-meta { font-size: 12px; color: var(--ink-soft); }
.detail-desc { font-size: 14px; line-height: 1.5; margin: 0; }
.detail-actions { display: flex; gap: 8px; padding-top: 4px; }

/* ---------- Chat / comments ---------- */
.chat-section { border-top: 1px solid var(--line); padding-top: 12px; }
.chat-label { font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 8px; }
.chat-list { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.chat-bubble { border-radius: 12px; padding: 8px 12px; background: var(--paper); }
.chat-bubble-head { display: flex; align-items: center; justify-content: space-between; }
.chat-author { font-size: 12px; font-weight: 700; }
.chat-time { font-size: 11px; font-family: var(--font-mono); color: var(--ink-soft); }
.chat-text { font-size: 13px; margin-top: 2px; }
.chat-input-row { display: flex; gap: 8px; margin-top: 12px; }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; top: 16px; right: 16px; left: 16px; max-width: 340px; margin-left: auto; z-index: 300; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { border-radius: 12px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; box-shadow: 0 6px 20px rgba(18,24,31,0.12); pointer-events: auto; }
.toast.error { border-color: var(--red); }
.toast.reminder { border-color: var(--orange); }

/* ---------- Utility ---------- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.wrap { flex-wrap: wrap; }
.mt-1 { margin-top: 8px; }
.hidden { display: none !important; }
