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

:root {
    --green: #3d6b3d;
    --yellow: #b8960f;
    --red: #e67e22;
    --urgent: #c0392b;
    --bg: #fafafa;
    --card: #ffffff;
    --text: #1d1d1f;
    --text-secondary: #86868b;
    --border: #e8e8ed;
    --accent: #a6baa5;
    --accent-light: #e8efe8;
    --radius: 14px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
}

/* Readonly mode: hide all write buttons */
body.readonly .task-actions,
body.readonly #report-bar,
body.readonly .note-input-row,
body.readonly .note-delete {
    display: none !important;
}

body.readonly .task-notes {
    pointer-events: none;
}

.screen { min-height: 100vh; }
.hidden { display: none !important; }

/* ===== LOGIN ===== */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    min-height: 100vh;
}

.login-box {
    background: var(--card);
    border-radius: 20px;
    padding: 48px 36px;
    width: 88%;
    max-width: 340px;
    text-align: center;
    box-shadow: 0 8px 40px rgba(0,0,0,0.08);
}

.login-logo { margin-bottom: 8px; }

.login-box h1 {
    font-size: 17px;
    font-weight: 500;
    color: var(--accent);
    margin-bottom: 32px;
    letter-spacing: 3px;
    text-transform: uppercase;
}

#login-form input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    margin-bottom: 10px;
    outline: none;
    transition: border-color 0.2s;
    background: var(--bg);
    color: var(--text);
}

#login-form input:focus { border-color: var(--accent); }

#login-btn {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 6px;
    transition: opacity 0.2s;
}

#login-btn:active { opacity: 0.7; }
.error { color: var(--red); font-size: 13px; margin-top: 12px; }

/* ===== HEADER ===== */
#app-header {
    background: var(--card);
    color: var(--text);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
}

#app-header h1 {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--accent);
}

#logout-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

/* ===== TABS ===== */
#category-tabs {
    display: flex;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 57px;
    z-index: 99;
}

.tab {
    flex: 1;
    padding: 12px 8px;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab.active {
    color: var(--text);
    border-bottom-color: var(--accent);
}

/* ===== STATUS TOGGLE ===== */
#status-toggle {
    display: flex;
    padding: 12px 16px 4px;
    gap: 8px;
}

.toggle {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.toggle.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.toggle-urgent {
    width: 38px;
    padding: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    line-height: 1;
    color: var(--text-secondary);
}

.toggle-urgent.active {
    background: #c0392b;
    color: white;
    border-color: #c0392b;
}

.toggle-metrics {
    width: 38px;
    padding: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    line-height: 1;
    color: var(--text-secondary);
}

.toggle-metrics:active { opacity: 0.6; }

/* ===== STATS ===== */
#stats-bar {
    display: flex;
    justify-content: space-between;
    padding: 8px 16px 6px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ===== TASK LIST ===== */
#task-list {
    padding: 4px 12px 100px;
}

.task-card {
    background: var(--card);
    border-radius: var(--radius);
    margin-bottom: 6px;
    border-left: 3px solid var(--accent);
    overflow: hidden;
    transition: all 0.2s;
}

.task-card.age-green { border-left-color: var(--green); }
.task-card.age-yellow { border-left-color: var(--yellow); }
.task-card.age-red { border-left-color: var(--red); }
.task-card.done { opacity: 0.5; border-left-color: var(--border); }
.task-card.urgent { border-left-color: var(--urgent); border-left-width: 4px; }

/* Task header (always visible) */
.task-header {
    padding: 14px 16px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.task-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.task-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text);
    flex: 1;
}

.task-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    color: white;
    white-space: nowrap;
    flex-shrink: 0;
}

.badge-green { background: var(--green); }
.badge-yellow { background: var(--yellow); }
.badge-red { background: var(--red); }
.badge-urgent { background: var(--urgent); }

.task-reporter {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
    font-weight: 400;
}

.task-completed {
    font-size: 11px;
    color: var(--green);
    margin-top: 4px;
    font-weight: 400;
    font-style: italic;
}

.urgent-badge {
    color: var(--urgent);
    font-size: 16px;
    flex-shrink: 0;
    line-height: 1;
    margin-right: 4px;
}

.task-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
}

.task-meta {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 400;
}

.task-category {
    font-size: 10px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-light);
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.task-photos {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* Accordion body (expanded) */
.task-body {
    display: none;
    border-top: 1px solid var(--border);
    padding: 12px 16px 14px;
    background: var(--bg);
}

.task-card.expanded .task-body { display: block; }

.thread-msg {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    line-height: 1.5;
}

.thread-msg:last-child { border-bottom: none; }

.thread-sender {
    font-weight: 600;
    font-size: 12px;
    color: var(--text);
}

.thread-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-left: 8px;
}

.thread-text {
    color: var(--text);
    margin-top: 2px;
}

.thread-media {
    display: inline-block;
    font-size: 11px;
    color: var(--accent);
    background: var(--accent-light);
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 4px;
}

.thread-photos {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.thread-photos img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
}

.thread-thumb-vid {
    width: 80px;
    height: 80px;
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
}

.thread-thumb-vid img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thread-thumb-vid .play-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.3);
    color: white;
    font-size: 24px;
}

.thread-video {
    width: 80px;
    height: 80px;
    background: #1d1d1f;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thread-video .play-icon {
    color: white;
    font-size: 24px;
}

.thread-photo-placeholder {
    width: 80px;
    height: 80px;
    background: var(--accent-light);
    color: var(--text-secondary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

/* ===== GALLERY LIGHTBOX ===== */
.gallery-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    color: white;
    font-size: 36px;
    cursor: pointer;
    z-index: 10000;
    line-height: 1;
}

.gallery-counter {
    position: absolute;
    top: 20px;
    left: 20px;
    color: rgba(255,255,255,0.6);
    font-size: 14px;
}

.gallery-img-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 16px;
}

.gallery-img-wrap img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 4px;
}

.gallery-prev, .gallery-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 36px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-prev { left: 12px; }
.gallery-next { right: 12px; }

.gallery-video-wrap {
    width: 92%;
    height: 75%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-video-wrap iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
}

/* Action button in accordion */
.task-actions {
    padding: 10px 0 0;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.btn-done, .btn-reopen, .btn-priority, .btn-depriority, .btn-delete, .btn-play, .btn-stop {
    padding: 8px 20px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-done, .btn-priority, .btn-depriority, .btn-delete, .btn-play, .btn-stop { min-width: 90px; }
.btn-play { background: #0066cc; color: white; }
.btn-play:active { opacity: 0.7; }
.btn-stop { background: #d70015; color: white; animation: pulse 1.5s ease-in-out infinite; }
.btn-stop:active { opacity: 0.7; }
@keyframes pulse {
    0%,100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Timer menu (popover) */
.timer-menu {
    position: absolute;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.15);
    z-index: 9999;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.timer-menu-title {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 8px 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}
.timer-menu-opt {
    background: transparent;
    border: none;
    color: var(--text);
    padding: 10px 12px;
    text-align: left;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}
.timer-menu-opt:hover { background: var(--bg); }
.timer-menu-opt:last-child {
    border-top: 1px solid var(--border);
    margin-top: 4px;
    padding-top: 12px;
    color: #0066cc;
    font-weight: 500;
}

/* Completion report panel (minimizable, non-modal) */
.completion-panel {
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: 420px;
    max-width: calc(100vw - 32px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    z-index: 9000;
    overflow: hidden;
    animation: cp-slide-in 0.2s ease-out;
}
@keyframes cp-slide-in {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.cp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: var(--green);
    color: white;
}
.cp-title {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.cp-code {
    background: rgba(255,255,255,0.25);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
}
.cp-controls { display: flex; gap: 4px; }
.cp-btn-min, .cp-btn-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cp-btn-min:hover, .cp-btn-close:hover { background: rgba(255,255,255,0.35); }
.cp-task-title {
    padding: 10px 14px 6px;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}
.cp-textarea {
    width: 100%;
    border: none;
    background: var(--card);
    color: var(--text);
    padding: 14px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.45;
    resize: vertical;
    min-height: 120px;
    max-height: 50vh;
    box-sizing: border-box;
}
.cp-textarea:focus { outline: none; }
.cp-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}
.cp-hint {
    font-size: 11px;
    color: var(--text-secondary);
}
.cp-btn-done {
    background: var(--green);
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.cp-btn-done:disabled { opacity: 0.5; cursor: not-allowed; }

/* Chip bar (when minimized) */
.completion-chip-bar {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
}
.completion-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--green);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    cursor: pointer;
    font-size: 13px;
    transition: transform 0.15s;
}
.completion-chip:hover { transform: translateY(-2px); }
.completion-chip .chip-code {
    background: rgba(255,255,255,0.25);
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
}
.completion-chip .chip-title {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.completion-chip .chip-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}
.completion-chip .chip-close:hover { background: rgba(255,255,255,0.4); }

@media (max-width: 600px) {
    .completion-panel {
        right: 8px;
        left: 8px;
        bottom: 8px;
        width: auto;
    }
}

/* Timer label on card */
.task-timer {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #d70015;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    animation: pulse 1.5s ease-in-out infinite;
}
.task-timer-overrun {
    background: #ff6b00;
    animation: pulse 0.8s ease-in-out infinite;
}
.task-worked {
    display: inline-flex;
    align-items: center;
    background: var(--bg);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}
.task-worked::before { content: "⏱ "; opacity: 0.6; margin-right: 2px; }
.btn-done { background: var(--green); color: white; }
.btn-done:active { opacity: 0.7; }
.btn-priority { background: var(--urgent); color: white; }
.btn-priority:active { opacity: 0.7; }
.btn-depriority { background: var(--text-secondary); color: white; }
.btn-depriority:active { opacity: 0.7; }
.btn-delete { background: #1d1d1f; color: white; }
.btn-delete:active { opacity: 0.7; }
.btn-reopen { background: var(--bg); color: var(--text); border: 1px solid var(--border); }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}
.empty-state p { font-size: 15px; font-weight: 400; }

/* ===== TASK CODE (colored by category) ===== */
.task-code {
    font-size: 10px;
    font-weight: 700;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Menlo', monospace;
    letter-spacing: 0.5px;
}
.task-code.code-QE { background: #5a7a58; }
.task-code.code-CA { background: #7a6b58; }
.task-code.code-QS { background: #58707a; }
.task-code.code-AL { background: #7a5870; }

/* ===== REPORT FORM ===== */
#report-bar {
    padding: 10px 16px 0;
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.report-bar-btn {
    flex: 1;
    padding: 10px;
    background: none;
    border: 1px dashed var(--accent);
    border-radius: 8px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.report-bar-btn-secondary {
    border-color: var(--text-secondary);
    color: var(--text-secondary);
    flex: 1.2;
}

#add-task-form, #bug-form {
    padding: 12px 16px;
}

#add-task-form select, #add-task-form textarea, #bug-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 8px;
    background: var(--card);
    color: var(--text);
    font-family: inherit;
}

#task-submit, #bug-submit {
    width: 100%;
    padding: 10px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

#bug-submit { background: var(--text-secondary); }

#task-status, #bug-status {
    font-size: 13px;
    margin-top: 8px;
    text-align: center;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ===== ANIMATIONS ===== */
.task-card.removing {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeOut {
    to { opacity: 0; transform: scale(0.95); height: 0; margin: 0; padding: 0; }
}

#refresh-indicator {
    text-align: center;
    padding: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--card);
    position: fixed;
    top: 57px;
    left: 0; right: 0;
    z-index: 101;
}

@media (min-width: 600px) {
    #task-list, #category-tabs, #status-toggle, #stats-bar {
        max-width: 540px;
        margin-left: auto;
        margin-right: auto;
    }
}

/* ===== NOTES =====*/
.task-notes-section {
    margin-bottom: 10px;
}

.note-bubble {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px 12px 12px 2px;
    padding: 8px 12px;
    margin-bottom: 6px;
}

.note-author {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
}

.note-time {
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 4px;
}

.note-delete {
    float: right;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
}

.note-delete:hover { color: var(--red); }

.note-text {
    font-size: 13px;
    color: var(--text);
    margin-top: 2px;
    line-height: 1.4;
}

.note-input-row {
    display: flex;
    gap: 6px;
}

.note-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: var(--card);
    outline: none;
}

.note-input:focus {
    border-color: var(--accent);
}

.note-send {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.note-send:active { opacity: 0.7; }

/* ===== THREAD SUB-ACCORDION ===== */
.thread-accordion {
    margin-bottom: 10px;
}

.thread-accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    user-select: none;
    -webkit-user-select: none;
}

.thread-accordion-arrow {
    font-size: 10px;
    transition: transform 0.2s;
}

.thread-accordion.open .thread-accordion-arrow {
    transform: rotate(180deg);
}

.thread-accordion-body {
    display: none;
    padding: 8px 0 0;
}

.thread-accordion.open .thread-accordion-body {
    display: block;
}

.thread-accordion.open .thread-accordion-header {
    border-radius: 8px 8px 0 0;
    border-bottom: none;
}

/* ===== MONTH GROUPS (done/deleted) ===== */
.month-group {
    margin-bottom: 8px;
}

.month-header {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background: var(--card);
    border-radius: 10px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.month-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
}

.month-count {
    font-size: 12px;
    color: var(--text-secondary);
    margin-right: 8px;
}

.month-arrow {
    font-size: 12px;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.month-group.expanded .month-arrow {
    transform: rotate(180deg);
}

.month-body {
    display: none;
    padding-top: 4px;
}

.month-group.expanded .month-body {
    display: block;
}

.month-group.expanded .month-header {
    border-radius: 10px 10px 0 0;
    margin-bottom: 0;
}

/* ===== METRICS PANEL ===== */
.metrics-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.metrics-panel {
    background: var(--bg);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    padding: 20px 16px 40px;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
    position: relative;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.metrics-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}

.metrics-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.m-title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 16px;
}

/* Gamification */
.m-gamification {
    background: var(--card);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 14px;
    text-align: center;
}

.m-level {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.m-next-level {
    font-size: 12px;
    color: var(--text);
    margin-top: 6px;
}

.m-next-level strong {
    color: var(--text);
    font-weight: 700;
}

.m-max-level {
    color: var(--text);
    font-weight: 600;
}

.m-streak {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
}

.m-progress-wrap {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.m-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.m-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.5s;
}

.m-progress-text {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Cards grid */
.m-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 10px;
}

.m-card {
    background: var(--card);
    border-radius: 10px;
    padding: 10px 6px;
    text-align: center;
}

.m-card-val {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.m-card-green .m-card-val { color: var(--green); }

.m-card-label {
    font-size: 9px;
    color: var(--text-secondary);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Section headers */
.m-section {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 14px 0 8px;
}

/* Category bars */
.m-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.m-bar-label {
    font-size: 11px;
    color: var(--text);
    width: 110px;
    flex-shrink: 0;
}

.m-bar-track {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.m-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s;
}

.m-bar-val {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    width: 24px;
    text-align: right;
}

/* Period tabs */
.m-period-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
}

.m-period {
    flex: 1;
    padding: 6px 4px;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    text-align: center;
}

.m-period.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Category detail rows */
.m-cat-row {
    background: var(--card);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 6px;
}

.m-cat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.m-cat-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.m-cat-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.m-cat-stats {
    display: flex;
    gap: 12px;
}

.m-cat-stat {
    font-size: 11px;
    color: var(--text-secondary);
}

.m-cat-num {
    font-weight: 700;
    font-size: 13px;
}

.m-cat-created { color: var(--text); }
.m-cat-resolved { color: var(--green); }
.m-cat-pending { color: var(--red); }

/* Month chart */
.m-month-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    min-height: 80px;
    padding: 0 4px;
    overflow: hidden;
}

.m-month-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.m-month-bars {
    display: flex;
    gap: 2px;
    align-items: flex-end;
}

.m-month-bar {
    width: 12px;
    border-radius: 3px 3px 0 0;
    min-height: 2px;
}

.m-month-bar.m-month-total { background: var(--accent); }
.m-month-bar.m-month-done { background: var(--green); }

.m-month-label {
    font-size: 9px;
    color: var(--text-secondary);
    margin-top: 4px;
    text-transform: uppercase;
}

.m-month-legend {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
    margin-top: 6px;
    font-size: 10px;
    color: var(--text-secondary);
}

.m-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    display: inline-block;
    margin-left: 8px;
}

.m-legend-dot.m-month-total { background: var(--accent); }
.m-legend-dot.m-month-done { background: var(--green); }

/* Rank rows */
.m-rank-row {
    display: flex;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

.m-rank-row:last-child { border-bottom: none; }
.m-rank-row.m-empty { color: var(--text-secondary); font-style: italic; }

.m-rank-val {
    margin-left: auto;
    font-weight: 600;
    color: var(--accent);
}

/* Footer */
.m-footer {
    margin-top: 16px;
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary);
}

/* ===== DESKTOP ===== */
@media (min-width: 768px) and (max-width: 1199px) {
    #app-header {
        padding: 20px 40px;
    }

    #app-header h1 {
        font-size: 20px;
        letter-spacing: 3px;
    }

    #report-bar {
        max-width: 800px;
        margin: 0 auto 10px;
        padding: 12px 40px 0;
    }

    .report-bar-btn {
        font-size: 14px;
        padding: 12px;
    }

    #add-task-form, #bug-form {
        max-width: 800px;
        margin: 0 auto;
        padding: 12px 40px;
    }

    #category-tabs {
        max-width: 800px;
        margin: 0 auto;
        padding: 0 20px;
    }

    .tab {
        font-size: 14px;
        padding: 14px 12px;
    }

    #status-toggle {
        max-width: 800px;
        margin: 0 auto;
        padding: 14px 40px 6px;
    }

    .toggle {
        font-size: 14px;
        padding: 10px;
    }

    #stats-bar {
        max-width: 800px;
        margin: 0 auto;
        padding: 10px 40px 8px;
        font-size: 13px;
    }

    #task-list {
        max-width: 800px;
        margin: 0 auto;
        padding: 4px 40px 100px;
    }

    .task-card {
        margin-bottom: 8px;
        border-radius: 16px;
    }

    .task-header {
        padding: 18px 24px;
    }

    .task-title {
        font-size: 16px;
    }

    .task-badge {
        font-size: 11px;
        padding: 4px 10px;
    }

    .task-reporter {
        font-size: 13px;
    }

    .task-code {
        font-size: 11px;
        padding: 3px 10px;
    }

    .task-meta {
        font-size: 12px;
    }

    .task-body {
        padding: 16px 24px 18px;
    }

    .thread-photos img {
        width: 120px;
        height: 120px;
    }

    .thread-thumb-vid {
        width: 120px;
        height: 120px;
    }

    .thread-msg {
        font-size: 14px;
    }

    .thread-sender {
        font-size: 13px;
    }

    .note-bubble {
        padding: 10px 16px;
    }

    .note-text {
        font-size: 14px;
    }

    .note-input {
        font-size: 14px;
        padding: 10px 16px;
    }

    .btn-done, .btn-reopen, .btn-priority, .btn-depriority, .btn-delete {
        padding: 10px 24px;
        font-size: 14px;
    }

    .task-completed {
        font-size: 12px;
    }

    .thread-accordion-header {
        font-size: 13px;
        padding: 10px 16px;
    }

    /* Login desktop */
    .login-box {
        padding: 60px 48px;
        max-width: 400px;
    }

    /* Metrics panel desktop */
    .metrics-panel {
        max-width: 700px;
        border-radius: 20px;
        margin: 40px auto;
        max-height: 85vh;
    }

    .m-grid {
        gap: 10px;
    }

    .m-card-val {
        font-size: 22px;
    }

    .m-card-label {
        font-size: 10px;
    }

    /* Month groups desktop */
    .month-header {
        padding: 12px 20px;
    }

    .month-label {
        font-size: 15px;
    }
}

/* ===== LARGE DESKTOP (2 colunas) ===== */
@media (min-width: 1200px) {
    #app-header {
        padding: 24px 60px;
    }

    #app-header h1 {
        font-size: 22px;
        letter-spacing: 4px;
    }

    #report-bar {
        max-width: 1200px;
        margin: 0 auto 12px;
        padding: 14px 40px 0;
    }

    .report-bar-btn {
        font-size: 15px;
        padding: 14px;
    }

    #add-task-form, #bug-form {
        max-width: 1200px;
        margin: 0 auto;
        padding: 14px 40px;
    }

    #category-tabs {
        max-width: 1200px;
        margin: 0 auto;
        padding: 0 20px;
    }

    .tab {
        font-size: 15px;
        padding: 16px 14px;
    }

    #status-toggle {
        max-width: 1200px;
        margin: 0 auto;
        padding: 16px 40px 8px;
    }

    .toggle {
        font-size: 15px;
        padding: 12px;
    }

    #stats-bar {
        max-width: 1200px;
        margin: 0 auto;
        padding: 12px 40px 8px;
        font-size: 14px;
    }

    #task-list {
        max-width: 1200px;
        margin: 0 auto;
        padding: 6px 40px 100px;
        display: flex;
        gap: 10px;
        align-items: flex-start;
    }

    #task-list .task-col {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .task-card {
        margin-bottom: 0;
        border-radius: 18px;
    }

    .task-header {
        padding: 22px 30px;
    }

    .task-title {
        font-size: 18px;
        line-height: 1.5;
    }

    .task-badge {
        font-size: 12px;
        padding: 5px 12px;
    }

    .task-reporter {
        font-size: 14px;
        margin-top: 8px;
    }

    .task-code {
        font-size: 12px;
        padding: 4px 12px;
    }

    .task-meta {
        font-size: 13px;
    }

    .task-body {
        padding: 20px 30px 22px;
    }

    .thread-photos img {
        width: 160px;
        height: 160px;
    }

    .thread-thumb-vid {
        width: 160px;
        height: 160px;
    }

    .thread-msg {
        font-size: 15px;
        padding: 10px 0;
    }

    .thread-sender {
        font-size: 14px;
    }

    .thread-time {
        font-size: 12px;
    }

    .note-bubble {
        padding: 12px 18px;
        margin-bottom: 8px;
    }

    .note-author {
        font-size: 12px;
    }

    .note-text {
        font-size: 15px;
    }

    .note-input {
        font-size: 15px;
        padding: 12px 18px;
    }

    .note-send {
        width: 42px;
        height: 42px;
        font-size: 16px;
    }

    .btn-done, .btn-reopen, .btn-priority, .btn-depriority, .btn-delete {
        padding: 12px 28px;
        font-size: 15px;
        min-width: 110px;
    }

    .task-completed {
        font-size: 13px;
    }

    .urgent-badge {
        font-size: 18px;
    }

    .thread-accordion-header {
        font-size: 14px;
        padding: 12px 18px;
    }

    .login-box {
        padding: 70px 56px;
        max-width: 440px;
    }

    .login-box h1 {
        font-size: 19px;
    }

    #login-form input {
        font-size: 16px;
        padding: 16px 18px;
    }

    #login-btn {
        font-size: 16px;
        padding: 16px;
    }

    .metrics-panel {
        max-width: 800px;
        border-radius: 24px;
        margin: 50px auto;
        padding: 28px 24px 50px;
    }

    .m-title {
        font-size: 19px;
    }

    .m-card-val {
        font-size: 26px;
    }

    .m-card-label {
        font-size: 11px;
    }

    .m-section {
        font-size: 13px;
        margin: 18px 0 10px;
    }

    .m-bar-label {
        font-size: 13px;
        width: 140px;
    }

    .m-rank-row {
        font-size: 14px;
        padding: 8px 0;
    }

    .month-group {
        grid-column: 1 / -1;
    }

    .month-group.expanded .month-body {
        display: flex;
        gap: 10px;
        align-items: flex-start;
    }

    .month-body .task-col {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .month-header {
        padding: 14px 24px;
    }

    .month-label {
        font-size: 16px;
    }

    .month-count {
        font-size: 13px;
    }

    #task-list {
        align-items: start;
    }

    /* Empty state spans both columns */
    .empty-state {
        grid-column: 1 / -1;
    }
}
