:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --danger: #dc2626;
  --sidebar: #0f172a;
  --sidebar-text: #cbd5e1;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .18);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; }

/* layout */
.shell { display: flex; height: 100vh; }
.sidebar { width: 250px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; padding: 18px 12px; gap: 18px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 17px; padding: 4px 10px; }
.brand.big { justify-content: center; font-size: 22px; margin-bottom: 4px; }
.brand-mark { color: #818cf8; font-size: 20px; }
.sidebar-section { display: flex; flex-direction: column; gap: 4px; }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; text-transform: uppercase; font-size: 11px; letter-spacing: .08em; color: #64748b; padding: 0 10px 6px; font-weight: 600; }
.project-list { display: flex; flex-direction: column; gap: 2px; }
.project-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--sidebar-text); font-weight: 500; transition: background .15s; }
.project-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.project-link.active { background: rgba(129,140,248,.18); color: #fff; }
.project-key { width: 26px; height: 26px; border-radius: 6px; background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; flex-shrink: 0; }
.project-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid rgba(255,255,255,.08); }
.user-meta { flex: 1; min-width: 0; }
.user-name { color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .icon-btn { color: var(--sidebar-text); }
.sidebar .icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 28px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.crumb { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.page { padding: 24px 28px; overflow: auto; }
.page.narrow { max-width: 560px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 20px; align-content: start; }
.span-2 { grid-column: 1 / -1; }

/* components */
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #f472b6, #a78bfa); color: #fff; font-weight: 700; font-size: 12px; display: grid; place-items: center; flex-shrink: 0; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.xs { width: 22px; height: 22px; font-size: 9px; }
.avatar.more { background: #e2e8f0; color: var(--muted); }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; transition: all .15s; white-space: nowrap; }
.btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: #fef2f2; border-color: #fecaca; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.icon-btn { width: 26px; height: 26px; border-radius: 6px; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 15px; cursor: pointer; display: grid; place-items: center; transition: background .15s; }
.icon-btn:hover { background: #eef2ff; color: var(--primary); }
.icon-btn:disabled { opacity: .3; cursor: not-allowed; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #f1f5f9; color: var(--muted); font-size: 11px; font-weight: 600; }
.badge-admin { background: #eef2ff; color: var(--primary); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.danger-zone { border-color: #fecaca; }

.form { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: #334155; }
label.check { flex-direction: row; align-items: center; }
input, select, textarea { font: inherit; font-size: 14px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
input:disabled { background: #f8fafc; color: var(--muted); }
input[type=color] { width: 40px; height: 36px; padding: 2px; }
input[type=checkbox] { width: auto; }
textarea { resize: vertical; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.inline-form { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.list { list-style: none; margin: 0 0 4px; padding: 0; display: flex; flex-direction: column; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.state-row { display: flex; gap: 8px; align-items: center; flex: 1; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.cell-user { display: flex; align-items: center; gap: 10px; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.actions form { margin: 0; }
.flash-stack { padding: 14px 28px 0; }
.flash { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 8px; }
.flash-success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.flash-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.empty-state { margin: auto; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }

/* auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 20% 0%, #e0e7ff, transparent), radial-gradient(900px 500px at 100% 100%, #fce7f3, transparent), var(--bg); }
.auth-card { width: 360px; background: var(--surface); border-radius: 16px; padding: 32px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 14px; text-align: center; }
.auth-card .brand { color: var(--text); }
.auth-card label { text-align: left; }

/* filter bar */
.filter-bar { display: flex; align-items: center; gap: 6px; padding: 12px 28px 0; flex-wrap: wrap; }
.filter-bar > .muted { margin-right: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px 0 4px; border-radius: 999px; border: 1px solid transparent; background: #e7e9ef; font: inherit; font-size: 12px; font-weight: 500; color: #334155; cursor: pointer; transition: all .15s; line-height: 1; }
.chip:hover { background: #dfe3ea; }
.chip.active { background: var(--text); color: #fff; }
.chip .avatar { width: 20px; height: 20px; font-size: 8px; }
.chip[data-filter="all"], .chip[data-filter="none"] { padding-left: 10px; }
.filter-search { margin-left: auto; flex: 0 1 220px; height: 30px; padding: 0 12px; font-size: 13px; border-radius: 999px; }
.card-task.filtered-out { display: none; }

/* board */
.board { flex: 1; display: flex; gap: 16px; padding: 22px 28px; overflow-x: auto; align-items: flex-start; }
.column { width: 290px; flex-shrink: 0; background: #eceef3; border-radius: 12px; display: flex; flex-direction: column; max-height: 100%; }
.column-header { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; font-weight: 600; font-size: 13px; }
.column-title { text-transform: uppercase; letter-spacing: .04em; font-size: 12px; color: #334155; }
.count { background: #dfe3ea; color: var(--muted); border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 600; }
.column-header .icon-btn { margin-left: auto; }
.column-body { padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; overflow-y: auto; flex: 1; }
.card-task { background: var(--surface); border-radius: 8px; padding: 12px 12px 10px 14px; box-shadow: var(--shadow); cursor: grab; border-left: 3px solid #cbd5e1; transition: box-shadow .15s, transform .15s; }
.card-task:hover { box-shadow: 0 4px 12px rgba(15,23,42,.12); transform: translateY(-1px); }
.card-task.prio-urgent { border-left-color: #dc2626; }
.card-task.prio-high { border-left-color: #f97316; }
.card-task.prio-medium { border-left-color: #3b82f6; }
.card-task.prio-low { border-left-color: #94a3b8; }
.sortable-ghost { opacity: .35; }
.sortable-chosen { cursor: grabbing; }
.sortable-drag { box-shadow: var(--shadow-lg); transform: rotate(2deg); }
.task-title { font-weight: 500; line-height: 1.35; margin-bottom: 8px; word-break: break-word; }
.task-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.task-meta .avatar { margin-left: auto; }
.task-key { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .02em; white-space: nowrap; }
.prio-pill { font-size: 10px; text-transform: uppercase; font-weight: 700; letter-spacing: .05em; padding: 2px 6px; border-radius: 4px; background: #f1f5f9; color: var(--muted); }
.prio-pill.prio-urgent { background: #fee2e2; color: #b91c1c; }
.prio-pill.prio-high { background: #ffedd5; color: #c2410c; }
.prio-pill.prio-medium { background: #dbeafe; color: #1d4ed8; }
.due { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 4px; background: #f1f5f9; color: var(--muted); white-space: nowrap; }
.due::before { content: "📅 "; font-size: 10px; }
.due-later { background: #f1f5f9; color: #475569; }
.due-soon { background: #fef3c7; color: #b45309; }
.due-today { background: #ffedd5; color: #c2410c; }
.due-overdue { background: #fee2e2; color: #b91c1c; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; z-index: 50; backdrop-filter: blur(2px); }
.modal { width: 560px; max-width: calc(100vw - 32px); background: var(--surface); border-radius: 14px; padding: 22px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 14px; animation: pop .15s ease-out; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head .task-key { font-size: 13px; }
.modal .row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.modal-foot { display: flex; align-items: center; gap: 8px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow-lg); z-index: 60; }
.toast.error { background: var(--danger); }

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 10px; gap: 10px; overflow-x: auto; }
  .sidebar-section { flex-direction: row; align-items: center; }
  .project-list { flex-direction: row; }
  .sidebar-footer { margin-top: 0; border: 0; padding: 0; }
  .sidebar-heading, .user-meta { display: none; }
  .modal .row { grid-template-columns: 1fr; }
}

/* calendar */
.calendar-wrap { flex: 1; min-height: 0; padding: 18px 28px 24px; }
#calendar { height: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 10px; box-shadow: var(--shadow); --fc-border-color: #eef0f4; --fc-today-bg-color: #eef2ff; --fc-now-indicator-color: #ef4444; --fc-page-bg-color: #fff; --fc-neutral-bg-color: #f8fafc; --fc-list-event-hover-bg-color: #f8fafc; --fc-highlight-color: rgba(79,70,229,.12); --fc-event-border-color: transparent; }
.fc { font-family: inherit; font-size: 13px; }
.fc .fc-toolbar.fc-header-toolbar { margin-bottom: 14px; }
.fc .fc-toolbar-title { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.fc .fc-button { font: inherit; font-size: 13px; font-weight: 500; padding: 6px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); color: var(--text); box-shadow: none !important; text-transform: capitalize; }
.fc .fc-button:hover { background: #f8fafc; border-color: #cbd5e1; }
.fc .fc-button-primary:not(:disabled).fc-button-active, .fc .fc-button-primary:not(:disabled):active { background: var(--text); border-color: var(--text); color: #fff; }
.fc .fc-button:disabled { opacity: .5; background: var(--surface); color: var(--muted); }
.fc .fc-button-group > .fc-button { border-radius: 0; }
.fc .fc-button-group > .fc-button:first-child { border-radius: 8px 0 0 8px; }
.fc .fc-button-group > .fc-button:last-child { border-radius: 0 8px 8px 0; }
.fc .fc-today-button { margin-left: 8px !important; }
.fc .fc-prev-button, .fc .fc-next-button { padding: 6px 8px; }
.fc .fc-col-header-cell { padding: 8px 0; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.fc .fc-col-header-cell.fc-day-today { color: var(--primary); }
.fc .fc-daygrid-day-number, .fc .fc-col-header-cell-cushion, .fc .fc-list-day-text, .fc .fc-list-day-side-text { color: inherit; font-weight: 600; }
.fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-number { background: var(--primary); color: #fff; border-radius: 999px; width: 24px; height: 24px; display: inline-grid; place-items: center; margin: 4px; padding: 0; }
.fc .fc-timegrid-slot-label { font-size: 11px; color: var(--muted); }
.fc .fc-timegrid-slot { height: 2.4em; }
.fc .fc-event { border-radius: 6px; padding: 1px 4px; font-size: 12px; font-weight: 500; border: 0; cursor: pointer; box-shadow: 0 1px 2px rgba(15,23,42,.15); }
.fc .fc-daygrid-event { margin: 1px 3px; }
.fc .fc-daygrid-dot-event .fc-event-title { font-weight: 500; }
.fc .fc-timegrid-event .fc-event-main { padding: 2px 4px; }
.fc .fc-event-time { font-weight: 600; opacity: .9; }
.fc .fc-list { border-radius: 8px; overflow: hidden; }
.fc .fc-list-day-cushion { background: #f8fafc; }
.fc .fc-more-link { color: var(--primary); font-weight: 600; }
.fc .fc-popover { border-radius: 10px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.fc .fc-popover-header { background: #f8fafc; }

.event-modal { width: 520px; }
.event-title-input { font-size: 20px; font-weight: 600; border: 0; border-bottom: 2px solid var(--border); border-radius: 0; padding: 6px 2px; }
.event-title-input:focus { box-shadow: none; border-color: var(--primary); }
.modal .row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.color-field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 12px; font-weight: 600; color: #334155; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; outline: 2px solid transparent; outline-offset: 2px; transition: transform .1s; position: relative; }
.swatch:hover { transform: scale(1.1); }
.swatch.active { outline-color: var(--text); }
.swatch.active::after { content: "✓"; color: #fff; font-size: 13px; font-weight: 700; position: absolute; inset: 0; display: grid; place-items: center; }
.swatch-custom { background: conic-gradient(#ef4444, #f59e0b, #10b981, #0ea5e9, #8b5cf6, #ef4444); display: block; overflow: hidden; }
.swatch-custom input { opacity: 0; width: 100%; height: 100%; cursor: pointer; }
@media (max-width: 760px) { .modal .row-2 { grid-template-columns: 1fr; } .calendar-wrap { padding: 10px; } }
