* { box-sizing: border-box; }
html { color-scheme: light dark; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; }
p { margin: 0; }
a { color: inherit; }
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
ul { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip-link { position: absolute; top: -48px; left: 8px; background: var(--accent-fill); color: var(--on-accent); padding: .6rem 1rem; border-radius: var(--radius-sm); z-index: 999; }
.skip-link:focus { top: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

.app-shell { display: flex; min-height: 100vh; }

.sidebar { width: var(--sidebar-w); flex-shrink: 0; background: var(--bg-elevated); border-right: 1px solid var(--border); display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; }
.sidebar-brand { height: var(--topbar-h); display: flex; align-items: center; gap: .7rem; padding: 0 1.3rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.sidebar-brand .mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), #8a91ff); color: #fff; display: grid; place-items: center; font-weight: 800; font-family: var(--font-display); }
.sidebar-brand .name { font-weight: 700; font-family: var(--font-display); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem .8rem; }
.sidebar-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); font-weight: 700; padding: .9rem .7rem .4rem; }
.nav-item { display: flex; align-items: center; gap: .8rem; padding: .6rem .7rem; border-radius: var(--radius-sm); color: var(--text-soft); cursor: pointer; margin-bottom: .1rem; font-weight: 500; border: none; background: none; width: 100%; text-align: left; }
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: var(--bg-sunken); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--info-text); }
.nav-item .count { margin-left: auto; font-size: .72rem; color: var(--text-faint); }
.project-mini { display: flex; align-items: center; gap: .6rem; padding: .5rem .7rem; border-radius: var(--radius-sm); cursor: pointer; font-size: .84rem; border: none; background: none; width: 100%; text-align: left; color: var(--text-soft); font-family: inherit; }
.project-mini:hover { background: var(--bg-sunken); color: var(--text); }
.project-mini.active { background: var(--accent-soft); color: var(--info-text); font-weight: 600; }
.project-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.project-dot.c1 { background: var(--avatar-1); }
.project-dot.c2 { background: var(--avatar-2); }
.project-dot.c3 { background: var(--avatar-3); }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); display: flex; align-items: center; gap: 1rem; padding: 0 1.4rem; background: var(--bg); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar h2 { font-size: 1.15rem; }
.topbar .sub { font-size: .78rem; color: var(--text-faint); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.icon-btn { width: 40px; height: 40px; border-radius: var(--radius-sm); display: grid; place-items: center; border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text-soft); cursor: pointer; }
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.avatar { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; font-size: .74rem; color: var(--on-accent); flex-shrink: 0; background: var(--accent-fill); }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -8px; border: 2px solid var(--bg-elevated); }
.avatar-stack .avatar:first-child { margin-left: 0; }
.avatar.avatar-sm { width: 24px; height: 24px; font-size: .6rem; }
.avatar.avatar-1 { background: linear-gradient(135deg, var(--avatar-1), var(--avatar-1-deep)); }
.avatar.avatar-2 { background: linear-gradient(135deg, var(--avatar-2), var(--avatar-2-deep)); }
.avatar.avatar-3 { background: linear-gradient(135deg, var(--avatar-3), var(--avatar-3-deep)); }
.avatar.avatar-4 { background: linear-gradient(135deg, var(--avatar-4), var(--avatar-4-deep)); }
.avatar.avatar-5 { background: linear-gradient(135deg, var(--avatar-5), var(--avatar-5-deep)); }
.avatar.avatar-6 { background: linear-gradient(135deg, var(--avatar-6), var(--avatar-6-deep)); }

.content { flex: 1; padding: 1.6rem; max-width: 1360px; width: 100%; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

.btn { display: inline-flex; align-items: center; gap: .5rem; border-radius: var(--radius-sm); padding: .6rem 1.1rem; font-weight: 600; font-size: .85rem; cursor: pointer; border: 1px solid transparent; }
.btn-primary { background: var(--accent-fill); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-outline { background: none; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--info-text); }
.btn-sm { padding: .4rem .8rem; font-size: .78rem; min-height: 40px; }

.grid { display: grid; gap: 1.2rem; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 650px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.3rem; box-shadow: var(--shadow-sm); }

/* Project card */
.project-card { display: flex; flex-direction: column; gap: .8rem; }
.project-top { display: flex; justify-content: space-between; align-items: flex-start; }
.project-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 1.1rem; flex-shrink: 0; }
.project-icon.c1 { background: var(--accent-soft); color: var(--accent); }
.project-icon.c2 { background: rgba(14,160,141,.14); color: var(--avatar-2); }
.project-icon.c3 { background: var(--warn-soft); color: var(--warn-text); }
.project-card h3 { font-size: 1rem; }
.project-desc { color: var(--text-soft); font-size: .82rem; }
.progress-bar { height: 7px; border-radius: 999px; background: var(--bg-sunken); overflow: hidden; }
.progress-bar .fill { height: 100%; border-radius: 999px; background: var(--accent); }
.progress-bar .fill.c2 { background: var(--avatar-2); }
.progress-bar .fill.c3 { background: var(--warn); }
.progress-bar .fill.danger { background: var(--danger); }
.progress-bar .fill.success { background: var(--success); }
.progress-bar .fill.warn { background: var(--warn); }
.project-foot { display: flex; justify-content: space-between; align-items: center; margin-top: .3rem; }
.project-meta { font-size: .74rem; color: var(--text-faint); }

.badge { font-size: .7rem; font-weight: 700; padding: .18rem .5rem; border-radius: 999px; display: inline-block; }
.badge-success { background: var(--success-soft); color: var(--success-text); }
.badge-warn { background: var(--warn-soft); color: var(--warn-text); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); }
.badge-info { background: var(--accent-soft); color: var(--info-text); }

/* Kanban */
.kanban-board { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: .5rem; align-items: flex-start; }
.kanban-board.list-layout { flex-direction: column; }
.kanban-board.list-layout .kanban-col { flex: 1 1 auto; width: 100%; }
.kanban-board.list-layout .kanban-cards { display: flex; flex-direction: column; gap: .5rem; }
.kanban-col { flex: 0 0 290px; background: var(--bg-sunken); border-radius: var(--radius-md); padding: .9rem; }
.kanban-col.wip-exceeded { outline: 1px solid var(--danger); }
.kanban-col-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.kanban-col-header h4 { font-size: .82rem; }
.wip-label { font-weight: 400; color: var(--text-faint); font-size: .72rem; }
.view-switch { display: flex; background: var(--bg-sunken); border-radius: var(--radius-sm); padding: .2rem; }
.view-switch-btn { background: none; border: none; padding: .55rem .9rem; font-size: .8rem; font-weight: 600; color: var(--text-faint); border-radius: var(--radius-sm); cursor: pointer; min-height: 40px; }
.view-switch-btn.active { background: var(--bg-elevated); color: var(--text); box-shadow: var(--shadow-sm); }
.kanban-count { background: var(--bg-elevated); border: 1px solid var(--border); font-size: .7rem; padding: .1rem .5rem; border-radius: 999px; color: var(--text-faint); }
.kanban-cards { display: flex; flex-direction: column; gap: .7rem; min-height: 60px; }
.kanban-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8rem; cursor: grab; box-shadow: var(--shadow-sm); text-align: left; width: 100%; font-family: inherit; color: inherit; }
.kanban-card:hover { border-color: var(--accent); }
.kanban-card.dragging { opacity: .4; }
.kanban-col.drag-over { outline: 2px dashed var(--accent); outline-offset: 2px; }
.kanban-card-title { font-weight: 600; font-size: .84rem; margin-bottom: .5rem; }
.kanban-card-meta { display: flex; align-items: center; justify-content: space-between; margin-top: .5rem; gap: .4rem; }
.checklist-progress { height: 4px; border-radius: 999px; background: var(--border); overflow: hidden; }
.checklist-progress .fill { height: 100%; background: var(--accent); border-radius: 999px; }
.checklist-label { font-size: .68rem; color: var(--text-faint); }
.kanban-card.filtered-out { display: none; }
.kanban-add { width: 100%; margin-top: .7rem; background: none; border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: .5rem; color: var(--text-faint); cursor: pointer; font-size: .8rem; min-height: 40px; }
.kanban-add:hover { border-color: var(--accent); color: var(--info-text); }
.kanban-empty { text-align: center; padding: 1.2rem .6rem; color: var(--text-faint); font-size: .78rem; border: 1px dashed var(--border); border-radius: var(--radius-sm); }
.project-switcher-wrap { position: relative; }
.project-switcher-menu { display: none; position: absolute; top: calc(100% + 6px); right: 0; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); min-width: 190px; padding: .35rem; z-index: 30; }
.project-switcher-menu.open { display: block; }
.project-switcher-menu button { display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left; background: none; border: none; padding: .5rem .6rem; border-radius: var(--radius-sm); cursor: pointer; color: var(--text); font-size: .82rem; font-family: inherit; }
.project-switcher-menu button:hover, .project-switcher-menu button.active { background: var(--bg-sunken); }
.board-empty { text-align: center; padding: 3rem 1rem; color: var(--text-soft); }
.board-empty h3 { font-size: 1rem; margin-bottom: .4rem; color: var(--text); }
.board-empty p { font-size: .84rem; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(10,13,19,.55); display: none; align-items: center; justify-content: center; z-index: 200; padding: 1rem; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--bg-elevated); border-radius: var(--radius-lg); padding: 1.6rem; width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg); position: relative; }
.modal-close { position: absolute; top: 1rem; right: 1rem; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-sunken); color: var(--text-soft); cursor: pointer; }
.modal-box h2 { font-size: 1.05rem; margin-bottom: 1.1rem; padding-right: 2rem; }
.modal-field { margin-bottom: .9rem; }
.modal-field label { display: block; font-size: .78rem; font-weight: 600; color: var(--text-soft); margin-bottom: .35rem; }
.modal-field input[type="text"], .modal-field select, .modal-field textarea { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .7rem; background: var(--bg); color: var(--text); font-size: .86rem; min-height: 40px; }
.modal-field textarea { min-height: 70px; resize: vertical; }
.modal-row { display: flex; gap: .7rem; }
.modal-row .modal-field { flex: 1; }
.modal-actions { display: flex; justify-content: space-between; gap: .6rem; margin-top: 1.2rem; }
.checklist-editor { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .6rem; }
.checklist-editor-item { display: flex; align-items: center; gap: .5rem; font-size: .84rem; }
.checklist-editor-item input[type="text"] { flex: 1; border: none; background: none; padding: .2rem 0; min-height: auto; }
.checklist-editor-item .cl-remove { background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: .9rem; padding: .2rem; }
.checklist-editor-item .cl-remove:hover { color: var(--danger); }
.checklist-add-row { display: flex; gap: .5rem; }
.checklist-add-row input { flex: 1; }

/* Team */
.team-row { display: flex; align-items: center; gap: .8rem; padding: .9rem 0; border-bottom: 1px solid var(--border); }
.team-row:last-child { border-bottom: none; }
.team-info { flex: 1; }
.team-name { font-weight: 700; font-size: .88rem; }
.team-role { font-size: .78rem; color: var(--text-faint); }
.team-load { width: 120px; }
.team-load .label { font-size: .7rem; color: var(--text-faint); margin-bottom: .2rem; display: flex; justify-content: space-between; }

/* Calendar */
.calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: .7rem; font-weight: 700; color: var(--text-faint); padding: .4rem 0; }
.cal-day { aspect-ratio: 1; border: 1px solid var(--border); border-radius: 10px; padding: .4rem; font-size: .78rem; display: flex; flex-direction: column; gap: .2rem; cursor: pointer; background: var(--bg-elevated); text-align: left; font-family: inherit; color: inherit; width: 100%; }
.cal-day:hover, .cal-day:focus-visible { border-color: var(--accent); }
.cal-day.other-month { opacity: .35; }
.cal-day.today { border-color: var(--accent); background: var(--accent-soft); }
.cal-day .num { font-weight: 700; }
.cal-event { font-size: .64rem; background: var(--accent-soft); color: var(--info-text); border-radius: 4px; padding: 1px 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Activity feed */
.activity-row { display: flex; gap: .9rem; padding: .9rem 0; border-bottom: 1px solid var(--border); }
.activity-row:last-child { border-bottom: none; }
.activity-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.activity-time { font-size: .74rem; color: var(--text-faint); margin-top: .15rem; }

/* Toast */
.toast-stack { position: fixed; bottom: 1.3rem; right: 1.3rem; display: flex; flex-direction: column; gap: .6rem; z-index: 100; }
.toast { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8rem 1rem; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: .6rem; font-size: .82rem; min-width: 220px; }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { position: fixed; z-index: 40; height: 100vh; transform: translateX(-100%); transition: transform .2s ease; }
  .app-shell.mobile-nav-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(10,13,19,.5); z-index: 35; }
  .app-shell.mobile-nav-open .sidebar-backdrop { display: block; }
  .mobile-nav-toggle { display: grid !important; }
}
.mobile-nav-toggle { display: none; }
