  :root {
    --bg: #fbfbfd;
    --surface: #ffffff;
    --text: #1d1d1f;
    --text-secondary: #6e6e73;
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --success: #34c759;
    --warning: #ff9500;
    --danger: #ff3b30;
    --border: rgba(0,0,0,0.08);
    --shadow: 0 4px 24px rgba(0,0,0,0.06);
    --radius: 16px;
    --radius-sm: 10px;
    --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  }

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

  body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
  }

  .loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 16px;
    color: var(--text-secondary);
  }

  .spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }

  @keyframes spin { to { transform: rotate(360deg); } }

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

  .topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(251,251,253,0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
  }

  .brand {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
  }

  .brand-sub { font-size: 12px; color: var(--text-secondary); font-weight: 400; }

  .nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

  .nav-btn {
    background: none;
    border: none;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 14px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
  }

  .nav-btn:hover, .nav-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

  .main { flex: 1; padding: 24px 20px 48px; max-width: 1100px; margin: 0 auto; width: 100%; }

  .hero {
    margin-bottom: 32px;
  }

  .hero h1 {
    font-size: clamp(28px, 5vw, 40px);
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 8px;
  }

  .hero p { color: var(--text-secondary); font-size: 17px; }

  .grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
  }

  .card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
  }

  .card:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(0,0,0,0.08); }

  .card-emoji { font-size: 32px; margin-bottom: 12px; }

  .card h3 { font-size: 18px; font-weight: 600; margin-bottom: 6px; letter-spacing: -0.02em; }

  .card-meta { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }

  .progress-bar {
    height: 6px;
    background: #e8e8ed;
    border-radius: 999px;
    overflow: hidden;
    margin-top: 12px;
  }

  .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #40a9ff);
    border-radius: 999px;
    transition: width 0.4s ease;
  }

  .badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    background: #f5f5f7;
    color: var(--text-secondary);
  }

  .badge.due-soon { background: #fff4e5; color: #b86e00; }
  .badge.overdue { background: #ffebea; color: var(--danger); }
  .badge.done { background: #e8f9ed; color: #248a3d; }

  .section-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 16px;
    letter-spacing: -0.02em;
  }

  .search-box {
    width: 100%;
    max-width: 400px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    background: var(--surface);
    margin-bottom: 24px;
  }

  .search-box:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,113,227,0.15); }

  .module-block {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    overflow: hidden;
  }

  .module-header {
    padding: 16px 20px;
    font-weight: 600;
    background: #fafafa;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .task-list { list-style: none; }

  .task-item {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.15s;
  }

  .task-item:last-child { border-bottom: none; }
  .task-item:hover { background: #fafafa; }

  .task-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: #f5f5f7;
    flex-shrink: 0;
  }

  .task-icon.done { background: #e8f9ed; }
  .task-info { flex: 1; min-width: 0; }
  .task-title { font-weight: 500; font-size: 15px; }
  .task-type { font-size: 12px; color: var(--text-secondary); }

  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
  }

  .btn-primary { background: var(--accent); color: white; }
  .btn-primary:hover { background: var(--accent-hover); }
  .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

  .btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
  }

  .btn-secondary:hover { background: #f5f5f7; }

  .btn-block { width: 100%; }

  .task-view {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
  }

  .task-content { margin: 20px 0; font-size: 16px; line-height: 1.6; }
  .task-content ul { margin: 12px 0 12px 20px; }

  .doc-frame {
    width: 100%;
    height: 500px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin: 16px 0;
  }

  .checklist { list-style: none; margin: 16px 0; }
  .checklist li {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
  }

  .checklist li.checked { background: #e8f9ed; border-color: #34c759; }

  .quiz-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 14px 16px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    font-size: 15px;
  }

  .quiz-option.selected { border-color: var(--accent); background: rgba(0,113,227,0.06); }
  .quiz-option.correct { border-color: var(--success); background: #e8f9ed; }
  .quiz-option.wrong { border-color: var(--danger); background: #ffebea; }

  textarea, input[type="text"], input[type="email"], input[type="date"], select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    margin-bottom: 12px;
  }

  textarea { min-height: 160px; resize: vertical; }

  .dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    color: var(--text-secondary);
    margin: 16px 0;
    transition: border-color 0.2s;
  }

  .dropzone.dragover { border-color: var(--accent); background: rgba(0,113,227,0.04); }

  .auth-screen {
    max-width: 440px;
    margin: 80px auto;
    text-align: center;
    padding: 40px 24px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }

  .auth-screen h1 { font-size: 28px; margin-bottom: 12px; }
  .auth-screen p { color: var(--text-secondary); margin-bottom: 24px; }

  .admin-layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; }

  @media (max-width: 768px) {
    .admin-layout { grid-template-columns: 1fr; }
  }

  .admin-sidebar {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    border: 1px solid var(--border);
    height: fit-content;
  }

  .admin-sidebar button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: none;
    background: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    margin-bottom: 4px;
  }

  .admin-sidebar button.active, .admin-sidebar button:hover { background: #f5f5f7; }

  .admin-panel {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
  }

  .table-wrap { overflow-x: auto; }

  table { width: 100%; border-collapse: collapse; font-size: 14px; }
  th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
  th { font-weight: 600; color: var(--text-secondary); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }

  .form-row { margin-bottom: 16px; }
  .form-row label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text-secondary); }

  .toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #1d1d1f;
    color: white;
    padding: 12px 24px;
    border-radius: 999px;
    font-size: 14px;
    z-index: 1000;
    transition: opacity 0.3s;
  }

  .toast.hidden { opacity: 0; pointer-events: none; }

  .back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--accent);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 16px;
    cursor: pointer;
    border: none;
    background: none;
  }

  .empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
  }

  .empty-state .emoji { font-size: 48px; margin-bottom: 16px; }

  .track-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 32px;
    box-shadow: var(--shadow);
  }

  .track-panel-header h2 {
    font-size: 20px;
    margin-bottom: 4px;
  }

  .track-panel-header p {
    color: var(--text-secondary);
    font-size: 14px;
  }

  .track-progress-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0 24px;
  }

  .track-progress-label {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
  }

  .track-timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .track-step {
    display: flex;
    gap: 16px;
    position: relative;
    padding-bottom: 20px;
  }

  .track-step-marker {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f5f5f7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    z-index: 1;
  }

  .track-step--completed .track-step-marker {
    background: var(--success);
    color: #fff;
  }

  .track-step--active .track-step-marker {
    background: var(--accent);
    color: #fff;
  }

  .track-step--locked .track-step-marker {
    opacity: 0.5;
  }

  .track-step-line {
    position: absolute;
    left: 17px;
    top: 36px;
    bottom: 0;
    width: 2px;
    background: var(--border);
  }

  .track-step--completed .track-step-line {
    background: var(--success);
  }

  .track-step-body {
    flex: 1;
    padding-top: 6px;
  }

  .track-step-title {
    font-weight: 600;
    font-size: 15px;
  }

  .track-step-meta {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
  }

  .track-step--clickable {
    cursor: pointer;
  }

  .track-step--clickable:hover .track-step-title {
    color: var(--accent);
  }

  .skeleton {
    background: linear-gradient(90deg, #eee 25%, #f5f5f7 50%, #eee 75%);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
    border-radius: var(--radius-sm);
    height: 120px;
  }

  @keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

  .hidden { display: none !important; }

  .cert-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: var(--radius);
    font-weight: 600;
    margin-top: 16px;
  }

  .btn-google {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-top: 20px;
  }

  .btn-google:hover {
    background: #f5f5f7;
  }
