* { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    background: #f5f6f8;
    color: #1f2328;
    line-height: 1.5;
}
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    background: #1f2328;
    color: #fff;
}
.navbar a { color: #fff; text-decoration: none; margin-left: 16px; }
.navbar .brand { font-weight: 700; font-size: 18px; margin-left: 0; }
.navbar .user { color: #b0b4ba; margin-right: 8px; }
.container { max-width: 1240px; margin: 0 auto; padding: 24px; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.flash-error { background: #ffe5e5; color: #a40000; }
.flash-success { background: #e3f9e5; color: #176f2c; }

/* Auth */
.auth-card {
    max-width: 380px;
    margin: 60px auto;
    background: #fff;
    padding: 28px;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.auth-card h1 { margin-top: 0; }
.auth-card label { display: block; margin-bottom: 14px; font-size: 14px; color: #555; }
.auth-card input {
    width: 100%; padding: 9px 12px; margin-top: 4px;
    border: 1px solid #d0d7de; border-radius: 6px; font-size: 14px;
}
.btn-primary {
    background: #2563eb; color: #fff; border: 0;
    padding: 10px 18px; border-radius: 6px; cursor: pointer;
    font-size: 14px; font-weight: 600; width: 100%;
}
.btn-primary:hover { background: #1d4ed8; }
.muted { color: #6b7280; font-size: 14px; }

/* Dashboard */
.overall-card, .metric-card, .panel {
    background: #fff; padding: 22px; border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.overall-card {
    display: flex; gap: 24px; align-items: center;
    margin-bottom: 28px;
}
.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.metric-card { display: flex; flex-direction: column; gap: 8px; }
.metric-label {
    color: #4b5563;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}
.big-number { font-size: 32px; font-weight: 700; }
.progress-bar {
    flex: 1; background: #e5e7eb; height: 10px; border-radius: 999px; overflow: hidden;
}
.progress-bar.large { height: 16px; }
.progress-fill { background: #22c55e; height: 100%; transition: width .3s; }
.fill-blue { background: #2563eb; }
.fill-purple { background: #7c3aed; }

.action-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr;
    gap: 14px;
    margin: 18px 0 28px;
}
.panel h2 { margin-top: 0; font-size: 18px; }
.task-list { padding-left: 18px; margin: 0; }
.task-list li { margin-bottom: 10px; }
.task-list a { color: #2563eb; text-decoration: none; font-weight: 600; }
.task-list span { display: block; margin-top: 2px; }

.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}
.topic-card {
    background: #fff; padding: 16px; border-radius: 10px;
    text-decoration: none; color: inherit;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: transform .15s, box-shadow .15s;
    display: block;
}
.topic-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,0.08); }
.topic-card h3 { margin: 0 0 6px; font-size: 16px; }
.extension-line { margin-top: 8px; }

.roadmap { margin-top: 32px; background: #fff; padding: 16px 20px; border-radius: 10px; }
.roadmap pre { white-space: pre-wrap; font-family: inherit; font-size: 14px; }
.mock-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 12px;
}
.mock-card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
}
.mock-card h3 { margin: 0 0 6px; font-size: 15px; }
.mock-card ul { margin: 8px 0 0; padding-left: 18px; }

/* Topic */
.back-link { color: #2563eb; text-decoration: none; }
.guide-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 18px 0;
}
.guide-grid > div {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px;
}
.guide-grid h2 {
    font-size: 14px;
    margin: 0 0 8px;
}
.guide-grid p { margin: 0; font-size: 14px; color: #374151; }
.theory pre, .roadmap pre {
    background: #f9fafb; padding: 14px; border-radius: 8px;
    white-space: pre-wrap; font-family: inherit;
}
.tabs { display: flex; gap: 4px; margin-top: 12px; }
.tab-btn {
    padding: 8px 16px; border: 0; cursor: pointer;
    background: #e5e7eb; border-radius: 6px 6px 0 0;
    font-size: 14px; font-weight: 600;
}
.tab-btn.active { background: #1f2328; color: #fff; }
.code-block {
    background: #1f2328; color: #f0f6fc;
    padding: 16px; border-radius: 0 8px 8px 8px;
    overflow-x: auto; font-size: 13px;
    display: none; margin: 0;
}
.code-block.active { display: block; }
.code-block code { font-family: "Menlo", "Monaco", monospace; }

.problems-table {
    width: 100%; border-collapse: collapse; margin-top: 12px;
    background: #fff; border-radius: 10px; overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.problems-table th, .problems-table td {
    padding: 12px; text-align: left; border-bottom: 1px solid #eef0f2;
    font-size: 14px;
    vertical-align: top;
}
.problems-table th { background: #f9fafb; font-weight: 600; }
.problems-table tr.saved { background: #f0fdf4; transition: background .3s; }
.problems-table a { color: #2563eb; text-decoration: none; }
.problems-table a:hover { text-decoration: underline; }
.problem-subtitle, .review-meta {
    color: #6b7280;
    font-size: 12px;
    margin-top: 4px;
}
.problem-details {
    margin-top: 8px;
    color: #374151;
}
.problem-details summary {
    cursor: pointer;
    color: #2563eb;
    font-size: 13px;
}
.problem-details p { margin: 8px 0; }
.problem-details ol { margin: 8px 0 0; padding-left: 18px; }
.status-select, .outcome-select, .notes-input, .confidence-input, .time-input {
    padding: 6px 8px; border: 1px solid #d0d7de; border-radius: 5px;
    font-size: 13px; width: 100%;
}
.outcome-select { margin-top: 6px; }
.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 8px 0;
}
.field-row label {
    color: #6b7280;
    font-size: 12px;
}
.field-row input { margin-top: 3px; }
.notes-input {
    min-height: 112px;
    resize: vertical;
    line-height: 1.4;
}
.diff { padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.diff-easy { background: #d1fae5; color: #065f46; }
.diff-medium { background: #fef3c7; color: #92400e; }
.diff-hard { background: #fee2e2; color: #991b1b; }
.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 8px 0;
}
.tag {
    background: #eef2ff;
    color: #3730a3;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 12px;
}

@media (max-width: 920px) {
    .metric-grid, .action-grid, .guide-grid { grid-template-columns: 1fr 1fr; }
    .problems-table { display: block; overflow-x: auto; }
}

@media (max-width: 640px) {
    .metric-grid, .action-grid, .guide-grid, .topic-grid { grid-template-columns: 1fr; }
    .overall-card { display: block; }
    .navbar { padding: 12px 16px; }
    .container { padding: 16px; }
}
