*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-muted: #718096;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --danger: #dc2626;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
  --sidebar-w: 240px;
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #334155;
  --sidebar-hover: #283548;
}

body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; overflow-x: hidden; -webkit-text-size-adjust: 100%; }
html { overflow-x: hidden; }
.hidden { display: none !important; }
/* Prevent iOS zoom on input focus */
input, select, textarea { font-size: 16px !important; }

/* ── Login ── */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%); }
.login-box { background: var(--surface); border-radius: 16px; padding: 48px 40px; width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.3); text-align: center; }
.login-box h1 { font-size: 32px; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
.login-box .subtitle { color: var(--text-muted); margin-bottom: 28px; font-size: 13px; }
.login-box input { width: 100%; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; font-size: 14px; outline: none; transition: border .15s; }
.login-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.login-box button { width: 100%; background: var(--primary); color: #fff; border: none; border-radius: var(--radius); padding: 12px; font-size: 15px; font-weight: 600; cursor: pointer; transition: background .15s; }
.login-box button:hover { background: var(--primary-hover); }
.error { color: var(--danger); margin-top: 10px; font-size: 13px; min-height: 18px; }

/* ── Sidebar ── */
.sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; z-index: 100; overflow-y: auto; }
.sidebar-top { flex: 1; padding: 0; overflow-y: auto; }
.sidebar-logo { font-size: 24px; font-weight: 800; color: #fff; padding: 20px 20px 16px; letter-spacing: -1px; }
.sidebar-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: #64748b; padding: 16px 20px 8px; }
.sidebar-item { display: flex; align-items: center; gap: 12px; padding: 10px 20px; cursor: pointer; transition: all .15s; color: var(--sidebar-text); text-decoration: none; font-size: 14px; border-left: 3px solid transparent; }
.sidebar-item:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-item.active { background: var(--sidebar-active); color: #fff; border-left-color: var(--primary); font-weight: 600; }
.sidebar-item.sidebar-back { color: #64748b; font-size: 13px; margin-top: 8px; }
.sidebar-item.sidebar-back:hover { color: var(--sidebar-text); }
.si-icon { font-size: 16px; width: 22px; text-align: center; flex-shrink: 0; }
.si-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-divider { height: 1px; background: #334155; margin: 12px 16px; }
.sidebar-project-name { padding: 6px 20px 10px; font-size: 14px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Sidebar user area */
.sidebar-bottom { padding: 8px 12px 12px; border-top: 1px solid #334155; position: relative; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius); cursor: pointer; transition: background .15s; }
.sidebar-user:hover { background: var(--sidebar-hover); }
.sidebar-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: #64748b; text-transform: capitalize; }

.user-dropdown { position: absolute; left: 12px; right: 12px; bottom: 72px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); z-index: 300; overflow: hidden; }
.user-dropdown button { display: block; width: 100%; text-align: left; background: none; border: none; padding: 11px 16px; font-size: 13px; cursor: pointer; color: var(--text); transition: background .1s; }
.user-dropdown button:hover { background: var(--bg); }

/* ── Main area ── */
.main-area { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

/* ── Topbar ── */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; min-height: 48px; position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow); gap: 12px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-title { font-size: 16px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.topbar-select { border: 1px solid var(--border); border-radius: var(--radius); padding: 5px 8px; font-size: 12px; background: var(--bg); cursor: pointer; outline: none; max-width: 160px; }
.topbar-select:focus { border-color: var(--primary); }
.view-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.vt-btn { background: var(--surface); border: none; padding: 4px 8px; cursor: pointer; font-size: 13px; color: var(--text-muted); transition: all .1s; }
.vt-btn:not(:last-child) { border-right: 1px solid var(--border); }
.vt-btn.active { background: var(--primary); color: #fff; }
.vt-btn:hover:not(.active) { background: var(--bg); }

/* ── Buttons ── */
.btn-primary { background: var(--primary); color: #fff; border: none; border-radius: var(--radius); padding: 6px 14px; font-size: 12px; font-weight: 600; cursor: pointer; transition: background .15s; white-space: nowrap; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: none; border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 16px; font-size: 13px; cursor: pointer; color: var(--text-muted); transition: all .15s; }
.btn-ghost:hover { border-color: #aaa; color: var(--text); }
.btn-sm { background: var(--primary); color: #fff; border: none; border-radius: 6px; padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer; }
.btn-sm:hover { background: var(--primary-hover); }
.btn-icon { background: none; border: none; cursor: pointer; font-size: 14px; padding: 4px 6px; border-radius: 4px; transition: background .1s; }
.btn-icon:hover { background: var(--bg); }
.btn-icon.danger:hover { background: #fee2e2; }

/* ── Main content ── */
main { padding: 28px; max-width: 1400px; width: 100%; flex: 1; }
.empty { text-align: center; color: var(--text-muted); padding: 80px 20px; font-size: 16px; }

/* ── List View ── */
.task-list table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.task-list thead th { background: #f8fafc; padding: 12px 16px; text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); border-bottom: 1px solid var(--border); font-weight: 700; }
.task-list tbody tr { border-bottom: 1px solid var(--border); }
.task-row { cursor: pointer; transition: background .1s; }
.task-row:hover { background: #f8fafc; }
.task-list td { padding: 12px 16px; vertical-align: middle; }

/* ── Status Chip ── */
.status-chip { display: inline-block; color: #fff; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 12px; white-space: nowrap; }
.status-chip.sm { font-size: 10px; padding: 2px 7px; }

/* ── Badge ── */
.badge { display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; }
.qa-badge { background: #fef3c7; color: #92400e; }

/* ── Kanban ── */
.kanban { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 16px; }
.kanban-col { flex: 0 0 260px; background: var(--bg); border-radius: var(--radius); padding: 12px; }
.kanban-col-header { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; border-left: 4px solid; padding-left: 8px; margin-bottom: 12px; color: var(--text); }
.kanban-col-header .count { background: var(--border); border-radius: 10px; padding: 1px 7px; font-size: 11px; }
.kanban-cards { display: flex; flex-direction: column; gap: 8px; }
.kanban-card { background: var(--surface); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); cursor: pointer; transition: box-shadow .15s; }
.kanban-card:hover { box-shadow: var(--shadow-md); }
.card-title { font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.card-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); }

/* ── Modal ── */
#modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
#modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 780px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ── Form Elements ── */
label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 14px; }
label input, label select, label textarea { display: block; width: 100%; margin-top: 4px; border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 12px; font-size: 14px; font-family: inherit; outline: none; transition: border .15s, box-shadow .15s; }
label input:focus, label select:focus, label textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; color: var(--text); margin-bottom: 14px; }
.checkbox-label input { width: auto; display: inline; margin: 0; }
form textarea { width: 100%; border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 12px; font-size: 14px; font-family: inherit; resize: vertical; margin-top: 4px; outline: none; transition: border .15s, box-shadow .15s; }
form textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

/* ── Task Detail ── */
.task-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; font-size: 13px; color: var(--text-muted); }
.task-desc { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; white-space: pre-wrap; line-height: 1.6; }
.detail-section { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.section-header h3, .detail-section > h3 { font-size: 14px; font-weight: 700; margin-bottom: 10px; }

/* ── Subtask Row ── */
.subtask-row { background: var(--bg); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; }
.subtask-info { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.subtask-title { font-weight: 600; cursor: pointer; color: var(--primary); }
.subtask-title:hover { text-decoration: underline; }
.subtask-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; }
.empty-sm { color: var(--text-muted); font-size: 13px; }

/* ── Comments ── */
.comments-list { max-height: 280px; overflow-y: auto; margin-bottom: 12px; }
.comment { border-bottom: 1px solid var(--border); padding: 10px 0; }
.comment:last-child { border: none; }
.comment strong { font-size: 13px; }
.comment-date { font-size: 11px; color: var(--text-muted); margin-left: 8px; }
.comment p { margin-top: 4px; color: var(--text); white-space: pre-wrap; line-height: 1.5; }
#comment-form, #subtask-comment-form { display: flex; gap: 8px; align-items: flex-end; }
#comment-form textarea, #subtask-comment-form textarea { flex: 1; }

/* ── Priority ── */
.priority-badge { font-size: 12px; font-weight: 700; }
.priority-dot { font-size: 14px; font-weight: 700; margin-right: 2px; }
.card-priority { font-size: 11px; font-weight: 600; margin-bottom: 4px; }

/* ── Hours bar ── */
.hours-bar-wrap { margin: 8px 0 16px; }
.hours-bar { height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; margin-bottom: 4px; }
.hours-bar-fill { height: 100%; background: #2563eb; border-radius: 4px; transition: width .3s; }
.hours-bar-fill.over { background: #dc2626; }
.hours-bar-label { font-size: 12px; color: var(--text-muted); }
.over-badge { background: #fee2e2; color: #b91c1c; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 8px; }

/* ── Checklist ── */
.checklist-progress { font-weight: 400; font-size: 12px; color: var(--text-muted); margin-left: 6px; }
.checklist-bar { height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; margin-bottom: 10px; }
.checklist-bar-fill { height: 100%; background: #16a34a; border-radius: 3px; transition: width .3s; }
.checklist-item { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-bottom: 1px solid var(--border); }
.checklist-item:last-of-type { border: none; }
.checklist-item input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; accent-color: #16a34a; }
.checklist-text { flex: 1; font-size: 13px; }
.checklist-item.done .checklist-text { text-decoration: line-through; color: var(--text-muted); }
.checklist-add-form { display: flex; gap: 8px; margin-top: 10px; align-items: center; }

/* ── Deadline colors ── */
.deadline-past { color: #dc2626; font-weight: 600; }
.deadline-ok { color: var(--text-muted); }

/* ── My Tasks ── */
.mytasks-header { margin-bottom: 20px; }
.mytasks-header h2 { font-size: 20px; font-weight: 700; }
.mytasks-group { margin-bottom: 24px; }
.mytasks-group-header { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); border-left: 4px solid; padding-left: 8px; margin-bottom: 10px; }
.mytask-row { background: var(--surface); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 8px; cursor: pointer; box-shadow: var(--shadow); transition: box-shadow .15s; }
.mytask-row:hover { box-shadow: var(--shadow-md); }
.mytask-main { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 14px; }
.mytask-meta { display: flex; gap: 16px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; }

/* ── Breadcrumb ── */
.breadcrumb-sep { color: var(--text-muted); font-size: 18px; margin: 0 -4px; }

/* ── Projects ── */
.project-group { margin-bottom: 32px; }
.project-group-header { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--border); }
.project-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.project-card { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); cursor: pointer; transition: box-shadow .15s, transform .1s; border: 2px solid transparent; }
.project-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: var(--primary); }
.project-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.project-card-header h3 { font-size: 16px; font-weight: 700; color: var(--text); }
.project-card-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.project-card:hover .project-card-actions { opacity: 1; }
.project-desc { color: var(--text-muted); font-size: 13px; line-height: 1.5; margin-bottom: 12px; }
.project-card-footer { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-muted); margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }

/* ── Admin ── */
.admin-wrap { max-width: 960px; margin: 0 auto; }
.admin-tabs { display: flex; gap: 8px; margin-bottom: 24px; border-bottom: 2px solid var(--border); padding-bottom: 0; }
.tab-btn { background: none; border: none; border-bottom: 3px solid transparent; padding: 10px 20px; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--text-muted); margin-bottom: -2px; transition: all .15s; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:hover:not(.active) { color: var(--text); }
.admin-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.admin-section-header h2 { font-size: 18px; font-weight: 700; }
.admin-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.admin-table thead th { background: #f8fafc; padding: 11px 16px; text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); border-bottom: 1px solid var(--border); font-weight: 700; }
.admin-table tbody tr { border-bottom: 1px solid var(--border); }
.admin-table tbody tr:last-child { border: none; }
.admin-table td { padding: 12px 16px; vertical-align: middle; }
.admin-table td:last-child { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.role-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 12px; }
.role-admin { background: #fee2e2; color: #991b1b; }
.role-organizer { background: #ede9fe; color: #5b21b6; }
.role-user { background: #e0f2fe; color: #0369a1; }
.status-dot { font-size: 12px; font-weight: 600; }
.status-dot.active { color: #16a34a; }
.status-dot.inactive { color: #9ca3af; }
.btn-danger { background: #fee2e2; color: #b91c1c; border: none; border-radius: 6px; padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer; }
.btn-danger:hover { background: #fecaca; }
.btn-success { background: #dcfce7; color: #15803d; border: none; border-radius: 6px; padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer; }
.btn-success:hover { background: #bbf7d0; }
.ctx-badge { background: #f0f9ff; color: #0369a1; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 12px; }

/* Context type legend cards */
.ctx-type-legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 20px; }
.ctx-type-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.ctx-type-header { margin-bottom: 8px; }
.ctx-type-desc { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.ctx-hint { font-size: 11px; color: var(--text-muted); line-height: 1.4; margin-top: 4px; max-width: 280px; }
.ctx-modal-hint { background: var(--primary-light); border-radius: var(--radius); padding: 10px 14px; font-size: 12px; color: #1e40af; line-height: 1.5; margin-bottom: 14px; }

/* ── Wiki ── */
.wiki-list { display: flex; flex-direction: column; gap: 12px; }
.wiki-card { background: var(--surface); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow); cursor: pointer; border-left: 4px solid var(--primary); transition: box-shadow .15s; }
.wiki-card:hover { box-shadow: var(--shadow-md); }
.wiki-card-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.wiki-card-meta { display: flex; gap: 16px; font-size: 12px; color: var(--text-muted); }
.wiki-content { line-height: 1.8; padding: 4px 0; }
.wiki-content h1 { font-size: 22px; margin: 16px 0 8px; }
.wiki-content h2 { font-size: 18px; margin: 14px 0 6px; }
.wiki-content h3 { font-size: 15px; margin: 12px 0 4px; }
.wiki-content strong { font-weight: 700; }
.wiki-content em { font-style: italic; }
.wiki-content code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-family: monospace; font-size: 13px; }
.wiki-content hr { border: none; border-top: 2px solid var(--border); margin: 16px 0; }
.wiki-content li { margin-left: 20px; }
.wiki-toolbar { display: flex; gap: 4px; margin-bottom: 6px; flex-wrap: wrap; }
.toolbar-btn { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 3px 9px; font-size: 12px; cursor: pointer; }
.toolbar-btn:hover { background: var(--border); }
#wiki-content { font-family: monospace; font-size: 13px; }

/* ── Files ── */
.upload-area { border: 2px dashed var(--border); border-radius: var(--radius); padding: 40px; text-align: center; cursor: pointer; transition: all .15s; margin-bottom: 16px; }
.upload-area:hover, .upload-area.drag-over { border-color: var(--primary); background: var(--primary-light); }
.upload-area p { color: var(--text-muted); margin-top: 8px; }
.upload-file-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.file-size { color: var(--text-muted); font-size: 11px; margin-left: auto; }
.file-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; cursor: pointer; border: 1px solid var(--border); }
.file-link { color: var(--primary); text-decoration: none; font-weight: 500; }
.file-link:hover { text-decoration: underline; }
.file-icon-lg { font-size: 32px; width: 48px; text-align: center; }
.task-files { display: flex; flex-direction: column; gap: 8px; }
.task-file-row { display: flex; align-items: center; gap: 12px; padding: 8px; background: var(--bg); border-radius: var(--radius); }
.task-file-info { flex: 1; min-width: 0; }
.task-file-info .file-link { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 11px; color: var(--text-muted); }

/* ── Time Logs ── */
.time-logs { margin-bottom: 8px; }
.time-entry { display: flex; gap: 16px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.time-entry:last-child { border: none; }

/* ── Sprint cards ── */
.sprints-list { display: flex; flex-direction: column; gap: 14px; }
.sprint-card { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border-left: 4px solid var(--border); }
.sprint-card.sprint-active { border-left-color: #16a34a; }
.sprint-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.sprint-card-header h3 { font-size: 16px; font-weight: 700; }
.sprint-card-actions { display: flex; gap: 6px; align-items: center; }
.sprint-dates { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.sprint-goal { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; line-height: 1.5; }
.sprint-progress { margin-top: 8px; }

/* ── WIP warning ── */
.kanban-col.wip-exceeded { background: #fef2f2; }
.wip-warning { background: #fee2e2; color: #b91c1c; font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 6px; margin-bottom: 8px; text-align: center; }

/* ── Tournament ── */
.tournament-header { margin-bottom: 20px; }
.tournament-countdown { font-size: 20px; font-weight: 700; margin-bottom: 12px; }
.tournament-phases { display: flex; gap: 10px; flex-wrap: wrap; }
.phase-chip { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 6px 14px; border-radius: 20px; background: var(--surface); border: 2px solid; box-shadow: var(--shadow); }

/* ── Sidebar countdown ── */
.sidebar-countdown { padding: 4px 20px 8px; font-size: 12px; }

/* ── Project card extras ── */
.project-card-event { font-size: 12px; margin-bottom: 8px; }
.project-card-wip { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; background: #f0f9ff; padding: 4px 10px; border-radius: 6px; display: inline-block; }

/* ── AI Task Generator ── */
.btn-ai { background: linear-gradient(135deg, #8b5cf6, #6d28d9); color: #fff; border: none; border-radius: var(--radius); padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer; transition: all .15s; white-space: nowrap; }
.btn-ai:hover { background: linear-gradient(135deg, #7c3aed, #5b21b6); box-shadow: 0 2px 8px rgba(109,40,217,.3); }
.btn-ai:disabled { opacity: .6; cursor: not-allowed; }

.ai-hint { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 14px; }
.ai-textarea { width: 100%; border: 2px solid var(--border); border-radius: var(--radius); padding: 14px; font-size: 14px; font-family: inherit; resize: vertical; outline: none; transition: border .15s; }
.ai-textarea:focus { border-color: #8b5cf6; box-shadow: 0 0 0 3px rgba(139,92,246,.1); }

.ai-spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; vertical-align: middle; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

.ai-preview-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.ai-preview-header h3 { font-size: 16px; font-weight: 700; }
.ai-preview-content { display: flex; flex-direction: column; gap: 12px; }
.ai-field { display: flex; flex-direction: column; gap: 4px; }
.ai-field label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 0; }
.ai-field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.ai-input { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; font-size: 14px; font-family: inherit; outline: none; transition: border .15s; width: 100%; }
.ai-input:focus { border-color: var(--primary); }

.ai-subtasks-section { margin-top: 8px; }
.ai-subtasks-section h4 { font-size: 13px; font-weight: 700; margin-bottom: 10px; color: var(--text-muted); }
.ai-subtask-card { background: var(--bg); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; border-left: 3px solid #8b5cf6; }
.ai-subtask-header { display: flex; align-items: center; gap: 8px; }
.ai-subtask-header input { border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 13px; font-family: inherit; outline: none; }
.ai-subtask-header select { border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; font-size: 12px; background: var(--surface); max-width: 160px; }
.ai-st-hours { font-size: 12px; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.ai-st-desc { font-size: 12px; color: var(--text-muted); margin-top: 6px; line-height: 1.4; }

/* ── Team ── */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.team-card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px; }
.team-card-avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; flex-shrink: 0; }
.team-card-info { flex: 1; min-width: 0; }
.team-card-name { font-weight: 700; font-size: 14px; }
.team-card-role { font-size: 12px; color: var(--primary); font-weight: 600; margin-top: 2px; }
.team-card-email { font-size: 12px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Inbox ── */
.inbox-badge { background: #dc2626; color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px; margin-left: auto; }
.inbox-items { display: flex; flex-direction: column; gap: 10px; }
.inbox-item { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border-left: 4px solid #d97706; }
.inbox-item.triaged { border-left-color: #16a34a; opacity: .7; }
.inbox-item.dismissed { border-left-color: #9ca3af; opacity: .5; }
.inbox-item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.inbox-item-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 8px; white-space: pre-wrap; }
.inbox-item-meta { display: flex; gap: 14px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; margin-bottom: 8px; }
.inbox-item-actions { display: flex; gap: 8px; }
.inbox-item-link { margin-top: 6px; }
.inbox-item-link a { color: var(--primary); font-size: 13px; font-weight: 600; text-decoration: none; }
.inbox-item-link a:hover { text-decoration: underline; }
.intake-key-code { background: #f1f5f9; padding: 3px 8px; border-radius: 4px; font-size: 12px; cursor: pointer; user-select: all; }
.intake-key-code:hover { background: #e2e8f0; }
.log-stack-trace { background: #1e293b; color: #fbbf24; padding: 10px; border-radius: 6px; font-family: 'SF Mono', monospace; font-size: 11px; line-height: 1.5; overflow-x: auto; margin-top: 6px; white-space: pre-wrap; word-break: break-word; }
.inbox-badge-inline { background: #dc2626; color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px; margin-left: 4px; }

/* ── File Preview ── */
.file-preview-body { padding: 8px 0; }
.file-preview-frame { width: 100%; height: 70vh; border: none; border-radius: var(--radius); }
.file-preview-code { background: #1e293b; color: #e2e8f0; padding: 16px; border-radius: var(--radius); font-family: 'SF Mono', 'Fira Code', monospace; font-size: 13px; line-height: 1.6; overflow: auto; max-height: 70vh; white-space: pre-wrap; word-break: break-word; }
.preview-badge { font-size: 10px; color: var(--primary); margin-left: 6px; opacity: .6; }

/* ── Responsive ── */
/* ── Deploy ── */
.deploy-status { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 20px; }
.deploy-status-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; font-size: 14px; }
.deploy-status-row:not(:last-child) { border-bottom: 1px solid var(--border); }
.deploy-commits { margin-bottom: 20px; }
.deploy-commits h4 { font-size: 13px; font-weight: 700; color: var(--text-muted); margin-bottom: 10px; }
.deploy-commit { padding: 6px 0; border-bottom: 1px solid var(--border); }
.deploy-commit code { font-size: 12px; font-family: 'SF Mono', monospace; color: var(--text); }
.deploy-actions { margin-bottom: 20px; }
.deploy-log { background: #1e293b; color: #e2e8f0; border-radius: var(--radius); padding: 16px; margin-top: 16px; }
.deploy-log-step { margin-bottom: 10px; }
.deploy-log-step pre { background: #0f172a; padding: 8px 10px; border-radius: 6px; font-size: 12px; margin-top: 4px; overflow-x: auto; white-space: pre-wrap; }

/* ── Floating Action Button (sticky bug report) ── */
.fab-btn { position: fixed; bottom: 24px; right: 24px; width: 52px; height: 52px; border-radius: 50%; background: linear-gradient(135deg, #8b5cf6, #6d28d9); color: #fff; border: none; font-size: 24px; cursor: pointer; box-shadow: 0 4px 14px rgba(109,40,217,.35); z-index: 90; transition: all .2s; display: flex; align-items: center; justify-content: center; }
.fab-btn:hover { transform: scale(1.1); box-shadow: 0 6px 20px rgba(109,40,217,.45); }
.fab-btn:active { transform: scale(0.95); }

/* ── Hamburger button (hidden on desktop) ── */
.hamburger { display: none; background: none; border: none; font-size: 22px; cursor: pointer; padding: 4px 8px; color: var(--text); }

/* ── Tablet (sidebar collapsed to icons) ── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 56px; }
  .sidebar-label, .si-text, .sidebar-project-name, .sidebar-user-info, .sidebar-countdown { display: none; }
  .sidebar-logo { font-size: 18px; padding: 16px 12px; text-align: center; }
  .sidebar-item { padding: 12px 0; justify-content: center; border-left: none; }
  .sidebar-item.active { border-left: none; background: var(--sidebar-active); }
  .si-icon { width: auto; }
  .sidebar-user { justify-content: center; padding: 8px 4px; }
  .user-dropdown { left: 56px; bottom: 4px; right: auto; min-width: 180px; }
  .inbox-badge { position: absolute; top: 4px; right: 4px; font-size: 9px; padding: 0 4px; }
  .sidebar-item { position: relative; }
  .kanban-col { flex: 0 0 220px; }
  .project-cards { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .team-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

/* ── Mobile (sidebar as overlay) ── */
@media (max-width: 768px) {
  :root { --sidebar-w: 280px; }
  .hamburger { display: block; }

  /* Sidebar hidden by default, slides in */
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: none;
    width: var(--sidebar-w);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
  }
  .sidebar-label, .si-text, .sidebar-project-name, .sidebar-user-info, .sidebar-countdown { display: block; }
  .sidebar-logo { font-size: 24px; padding: 20px 20px 16px; text-align: left; }
  .sidebar-item { padding: 10px 20px; justify-content: flex-start; border-left: 3px solid transparent; }
  .sidebar-item.active { border-left-color: var(--primary); }
  .si-icon { width: 22px; text-align: center; }
  .sidebar-user { justify-content: flex-start; padding: 8px; }
  .user-dropdown { left: 12px; right: 12px; bottom: 72px; }

  /* Overlay behind sidebar */
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; }
  .sidebar-overlay.open { display: block; }

  /* Main area takes full width */
  .main-area { margin-left: 0; width: 100%; max-width: 100vw; overflow-x: hidden; }
  main { padding: 12px; max-width: 100%; overflow-x: hidden; }

  /* Topbar compact */
  .topbar { padding: 6px 10px; gap: 6px; min-height: 44px; flex-wrap: wrap; }
  .topbar-left { gap: 8px; }
  .page-title { font-size: 13px; max-width: 140px; }
  .topbar-right { gap: 4px; flex-wrap: wrap; }
  .topbar-select { max-width: 110px; padding: 4px 6px; }
  .btn-primary { padding: 5px 10px; font-size: 11px; }
  .btn-ai { padding: 5px 10px; font-size: 11px; }
  .vt-btn { padding: 3px 6px; font-size: 12px; }

  /* Login responsive */
  .login-box { width: 92vw; max-width: 380px; padding: 32px 24px; }

  /* Modal full width */
  #modal-overlay { padding: 8px; }
  #modal { max-width: 100%; padding: 16px; border-radius: 10px; max-height: 90vh; overflow-y: auto; }
  .modal-header { flex-wrap: wrap; gap: 8px; }
  .modal-header h2 { font-size: 16px; }
  .modal-actions { flex-wrap: wrap; }

  /* Forms */
  label { font-size: 12px; margin-bottom: 10px; }
  form textarea { font-size: 14px; }

  /* Tables scroll horizontally */
  .task-list { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .task-list table { min-width: 550px; }
  .admin-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Kanban scroll */
  .kanban { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 8px; }
  .kanban-col { flex: 0 0 200px; }

  /* Project cards single column */
  .project-cards { grid-template-columns: 1fr; gap: 10px; }
  .project-card { padding: 14px; }
  .project-card-header h3 { font-size: 14px; }
  .project-desc { font-size: 12px; }

  /* Team grid */
  .team-grid { grid-template-columns: 1fr; gap: 10px; }
  .team-card { padding: 12px; }

  /* Sprint cards */
  .sprint-card { padding: 14px; }
  .sprint-card-header { flex-direction: column; gap: 8px; }
  .sprint-card-actions { align-self: flex-start; flex-wrap: wrap; }

  /* My tasks */
  .mytask-row { padding: 10px 12px; }
  .mytask-main { font-size: 13px; }
  .mytask-meta { gap: 8px; font-size: 11px; }

  /* Inbox */
  .inbox-item { padding: 12px; }
  .inbox-item-meta { gap: 8px; font-size: 11px; flex-direction: column; }
  .inbox-item-actions { flex-wrap: wrap; }

  /* Task detail */
  .task-meta { font-size: 12px; gap: 6px; }
  .subtask-row { padding: 8px 10px; }
  .subtask-meta { font-size: 11px; gap: 6px; flex-wrap: wrap; }

  /* Wiki */
  .wiki-card { padding: 12px 14px; }
  .wiki-content { font-size: 13px; }

  /* Files */
  .file-preview-frame { height: 50vh; }
  .file-preview-code { max-height: 50vh; font-size: 11px; }

  /* AI modal */
  .ai-field-row { grid-template-columns: 1fr; }
  .ai-subtask-header { flex-wrap: wrap; gap: 6px; }
  .ai-subtask-header input { min-width: 0; }
  .ai-subtask-header select { max-width: 100%; }
  .ai-textarea { font-size: 14px; }

  /* Comments */
  #comment-form, #subtask-comment-form { flex-direction: column; }
  #comment-form textarea, #subtask-comment-form textarea { width: 100%; }

  /* Hours bar */
  .hours-bar-wrap { margin: 6px 0 12px; }

  /* Checklist */
  .checklist-add-form { flex-wrap: wrap; }
  .checklist-add-form input { min-width: 0; }

  /* Context type legend */
  .ctx-type-legend { grid-template-columns: 1fr; }

  /* Admin section */
  .admin-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-btn { padding: 8px 14px; font-size: 13px; white-space: nowrap; }

  /* Empty state */
  .empty { padding: 40px 16px; font-size: 14px; }
}

/* ── Small phones (iPhone SE, etc) ── */
@media (max-width: 400px) {
  :root { --sidebar-w: 260px; }
  .page-title { font-size: 12px; max-width: 100px; }
  .topbar-select { max-width: 90px; }
  .kanban-col { flex: 0 0 170px; }
  .modal-header h2 { font-size: 14px; }
  #modal { padding: 12px; }
}
