:root {
      --primary: #0284c7;
      --primary-hover: #0369a1;
      --primary-light: #e0f2fe;
      --primary-dark: #075985;
      --sky-vibrant: #38bdf8;
      --sky-glow: rgba(56, 189, 248, 0.25);
      --accent-yellow: #f59e0b;
      --accent-yellow-light: #fef3c7;
      --accent-green: #10b981;
      --accent-green-light: #d1fae5;
      --bg-page: #f0f9ff;
      --bg-card: #ffffff;
      --text-main: #0f172a;
      --text-muted: #64748b;
      --border: #e0f2fe;
      --border-focus: #38bdf8;
      --success: #10b981;
      --success-bg: #d1fae5;
      --danger: #ef4444;
      --danger-bg: #fee2e2;
      --warning: #f59e0b;
      --warning-bg: #fef3c7;
      --shadow-sm: 0 2px 6px rgba(14, 165, 233, 0.06);
      --shadow-md: 0 10px 25px -5px rgba(14, 165, 233, 0.12), 0 8px 10px -6px rgba(14, 165, 233, 0.07);
      --shadow-lg: 0 20px 30px -10px rgba(14, 165, 233, 0.18);
      --radius-sm: 10px;
      --radius-md: 16px;
      --radius-lg: 24px;
      --radius-full: 9999px;
    }

    * { box-sizing: border-box; margin: 0; padding: 0; }
    body {
      font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
      background: var(--bg-page);
      color: var(--text-main);
      min-height: 100vh;
      line-height: 1.5;
      -webkit-font-smoothing: antialiased;
      overflow-x: hidden;
    }

    /* Container */
    .app-container {
      max-width: 1100px;
      margin: 0 auto;
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      position: relative;
      overflow-x: hidden;
    }

    /* Header Nav */
    header.top-header {
      background: rgba(255, 255, 255, 0.88);
      backdrop-filter: blur(16px);
      position: sticky;
      top: 0;
      z-index: 40;
      border-bottom: 1px solid rgba(255, 255, 255, 0.4);
      box-shadow: 0 4px 24px -6px rgba(14, 165, 233, 0.1);
      padding: 16px 24px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      transition: all 0.3s;
    }
    @media (max-width: 639px) {
      header.top-header {
        padding: 12px 16px;
        position: static !important;
      }
    }
    .brand {
      display: flex;
      align-items: center;
      gap: 14px;
      text-decoration: none;
      color: inherit;
    }
    .brand-logo-img {
      width: 48px;
      height: 48px;
      object-fit: contain;
      filter: drop-shadow(0 4px 6px rgba(0,0,0,0.08));
    }
    .brand-title {
      font-size: 18px;
      font-weight: 800;
      color: #0F172A;
      line-height: 1.2;
      letter-spacing: -0.3px;
    }
    .brand-subtitle {
      font-size: 12.5px;
      color: #64748B;
      font-weight: 600;
      letter-spacing: 0.2px;
    }
    @media (max-width: 639px) {
      .brand-logo-img { width: 36px; height: 36px; }
      .brand-title { font-size: 13px; max-width: 140px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.2; }
      .brand-subtitle { font-size: 9.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
    }
    .user-badge {
      display: flex;
      align-items: center;
      gap: 10px;
      background: #f1f5f9;
      padding: 6px 12px;
      border-radius: var(--radius-full);
      font-size: 13px;
      font-weight: 600;
    }
    @media (max-width: 639px) {
      .user-badge { padding: 4px 8px; font-size: 11px; gap: 6px; }
    }
    .role-tag {
      font-size: 10px;
      padding: 3px 8px;
      border-radius: var(--radius-full);
      text-transform: uppercase;
      font-weight: 700;
      letter-spacing: 0.5px;
    }
    .role-tag.siswa { background: var(--primary-light); color: var(--primary-dark); }
    .role-tag.wali { background: var(--accent-light); color: #b45309; }
    .role-tag.super { background: #ede9fe; color: #6d28d9; }

    /* Main Area */
    main.main-content {
      flex: 1;
      padding: 20px 16px 80px;
      max-width: 100%;
    }

    /* Cards */
    .card {
      background: var(--bg-card);
      border-radius: var(--radius-lg);
      padding: 20px;
      border: 1px solid var(--border);
      box-shadow: var(--shadow-sm);
      margin-bottom: 20px;
      transition: all 0.2s ease;
    }
    .card:hover {
      box-shadow: var(--shadow-md);
    }
    .card-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 16px;
      flex-wrap: wrap;
      gap: 10px;
    }
    .card-title {
      font-size: 17px;
      font-weight: 700;
      color: var(--text-main);
      display: flex;
      align-items: center;
      gap: 8px;
    }

    /* Badges & Chips */
    .badge {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 4px 10px;
      border-radius: var(--radius-full);
      font-size: 12px;
      font-weight: 600;
    }
    .badge-success { background: var(--success-bg); color: #065f46; }
    .badge-warning { background: var(--warning-bg); color: #92400e; }
    .badge-danger { background: var(--danger-bg); color: #991b1b; }
    .badge-neutral { background: #f1f5f9; color: var(--text-muted); }

    /* Button System */
    .btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      padding: 10px 18px;
      border-radius: var(--radius-md);
      font-size: 14px;
      font-weight: 600;
      border: none;
      cursor: pointer;
      transition: all 0.15s ease;
      text-decoration: none;
    }
    .btn-primary {
      background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
      color: white;
      box-shadow: 0 4px 14px rgba(14, 165, 233, 0.3);
    }
    .btn-primary:hover { background: linear-gradient(135deg, #0369a1 0%, #0284c7 100%); transform: translateY(-1px); }
    .btn-secondary { background: #f1f5f9; color: var(--text-main); }
    .btn-secondary:hover { background: #e2e8f0; }
    .btn-danger { background: var(--danger-bg); color: var(--danger); }
    .btn-danger:hover { background: #fecaca; }
    .btn-sm { padding: 6px 12px; font-size: 12px; border-radius: var(--radius-sm); }
    .btn-full { width: 100%; }

    /* Forms */
    .form-group { margin-bottom: 14px; text-align: left; }
    .form-label {
      display: block;
      font-size: 13px;
      font-weight: 600;
      color: #334155;
      margin-bottom: 6px;
    }
    .form-control {
      width: 100%;
      padding: 11px 14px;
      border: 1.5px solid var(--border);
      border-radius: var(--radius-md);
      font-size: 14px;
      font-family: inherit;
      color: var(--text-main);
      background: #ffffff;
      outline: none;
      transition: border-color 0.2s;
    }
    .form-control:focus {
      border-color: var(--border-focus);
      box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
    }

    /* Progress Bar */
    .progress-bar-wrap {
      height: 10px;
      background: #e2e8f0;
      border-radius: var(--radius-full);
      overflow: hidden;
      margin-top: 8px;
    }
    .progress-bar-fill {
      height: 100%;
      background: linear-gradient(90deg, #14b8a6, #0d9488);
      border-radius: var(--radius-full);
      transition: width 0.4s ease;
    }

    /* Grid Layouts */
    .grid-habits {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
      gap: 12px;
      margin-top: 14px;
    }
    @media (max-width: 400px) {
      .grid-habits {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
      }
    }
    @media (min-width: 640px) {
      .grid-habits {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
      }
    }
    @media (min-width: 900px) {
      .grid-habits {
        grid-template-columns: repeat(7, 1fr);
      }
    }

    /* Habit Tile 3D Claymorphic Style */
    .habit-tile {
      background: #ffffff;
      border: 2px solid #e0f2fe;
      border-radius: 22px;
      padding: 18px 12px;
      text-align: center;
      cursor: pointer;
      position: relative;
      transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: space-between;
      min-height: 155px;
      box-shadow: 0 10px 20px -5px rgba(14, 165, 233, 0.1), inset 0 2px 4px rgba(255, 255, 255, 0.8);
    }
    @media (max-width: 639px) {
      .habit-tile {
        padding: 12px 8px;
        min-height: 135px;
        border-radius: 18px;
      }
    }
    .habit-tile:hover {
      transform: translateY(-6px) scale(1.03);
      box-shadow: 0 18px 30px -5px rgba(14, 165, 233, 0.22), inset 0 2px 4px rgba(255, 255, 255, 0.9);
    }
    .habit-tile.completed {
      border-color: #34d399;
      background: linear-gradient(145deg, #f0fdf4 0%, #dcfce7 100%);
      box-shadow: 0 12px 24px -5px rgba(16, 185, 129, 0.22), inset 0 2px 4px rgba(255, 255, 255, 0.9);
    }
    .habit-icon-wrap {
      width: 60px;
      height: 60px;
      border-radius: 18px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 34px;
      margin-bottom: 8px;
      background: linear-gradient(145deg, #ffffff, #e0f2fe);
      box-shadow: 0 6px 14px rgba(14, 165, 233, 0.15), inset 0 2px 3px rgba(255, 255, 255, 0.9);
      transition: transform 0.3s ease;
    }
    @media (max-width: 639px) {
      .habit-icon-wrap {
        width: 48px;
        height: 48px;
        font-size: 26px;
        border-radius: 14px;
        margin-bottom: 6px;
      }
    }
    .habit-tile:hover .habit-icon-wrap {
      transform: scale(1.12) rotate(4deg);
    }
    .habit-tile.completed .habit-icon-wrap {
      background: linear-gradient(145deg, #ffffff, #d1fae5);
      box-shadow: 0 6px 14px rgba(16, 185, 129, 0.2);
    }
    .habit-name {
      font-size: 13.5px;
      font-weight: 800;
      color: var(--text-main);
      margin-bottom: 8px;
      line-height: 1.25;
    }
    @media (max-width: 639px) {
      .habit-name {
        font-size: 12px;
        margin-bottom: 6px;
      }
    }
    .habit-status-pill {
      font-size: 11.5px;
      font-weight: 800;
      padding: 6px 12px;
      border-radius: 14px;
      width: 100%;
      max-width: 110px;
      transition: all 0.2s;
    }
    .habit-tile.completed .habit-status-pill {
      background: linear-gradient(135deg, #10b981 0%, #059669 100%);
      color: white;
      box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
    }
    .habit-tile.pending .habit-status-pill {
      background: #fef3c7;
      color: #d97706;
      border: 1px solid #fde68a;
      box-shadow: 0 4px 10px rgba(245, 158, 11, 0.15);
    }

    /* Stats Grid */
    .stats-row {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
      gap: 14px;
      margin-bottom: 20px;
    }
    .stat-card {
      background: white;
      border-radius: var(--radius-md);
      padding: 16px;
      border: 1px solid var(--border);
      box-shadow: var(--shadow-sm);
    }
    .stat-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
    .stat-value { font-size: 26px; font-weight: 800; color: var(--primary-dark); margin-top: 4px; }
    .stat-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

    /* Tables */
    .table-responsive {
      width: 100%;
      overflow-x: auto;
      border-radius: var(--radius-md);
      border: 1px solid var(--border);
    }
    table.data-table {
      width: 100%;
      border-collapse: collapse;
      text-align: left;
      font-size: 13.5px;
    }
    table.data-table th {
      background: #f8fafc;
      padding: 12px 14px;
      font-weight: 700;
      color: #475569;
      border-bottom: 1.5px solid var(--border);
      white-space: nowrap;
    }
    table.data-table td {
      padding: 12px 14px;
      border-bottom: 1px solid var(--border);
      vertical-align: middle;
    }
    table.data-table tbody tr:hover {
      background: #f8fafc;
    }

    /* Habit Mini Dots */
    .habit-dots {
      display: flex;
      gap: 4px;
      align-items: center;
    }
    .habit-dot {
      width: 22px;
      height: 22px;
      border-radius: 6px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 11px;
      font-weight: 700;
      color: white;
    }
    .habit-dot.done { background: var(--success); }
    .habit-dot.undone { background: #cbd5e1; color: #64748b; }

    /* Tabs Bar */
    .tabs-bar {
      display: flex;
      background: #e2e8f0;
      padding: 4px;
      border-radius: var(--radius-md);
      gap: 4px;
      margin-bottom: 18px;
      overflow-x: auto;
    }
    .tab-item {
      flex: 1;
      padding: 9px 16px;
      font-size: 13.5px;
      font-weight: 600;
      color: var(--text-muted);
      border-radius: calc(var(--radius-md) - 2px);
      border: none;
      background: transparent;
      cursor: pointer;
      white-space: nowrap;
      transition: all 0.15s ease;
      text-align: center;
    }
    .tab-item.active {
      background: white;
      color: var(--primary-dark);
      box-shadow: 0 2px 4px rgba(0,0,0,0.06);
    }

    /* Modal Sheet */
    .modal-overlay {
      position: fixed;
      inset: 0;
      background: rgba(15, 23, 42, 0.6);
      backdrop-filter: blur(4px);
      z-index: 100;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 16px;
    }
    .modal-overlay.show { display: flex; }
    .modal-content {
      background: white;
      width: 100%;
      max-width: 520px;
      border-radius: var(--radius-lg);
      padding: 24px;
      max-height: 90vh;
      overflow-y: auto;
      box-shadow: var(--shadow-lg);
      position: relative;
      animation: modalUp 0.25s ease-out;
    }
    @keyframes modalUp {
      from { opacity: 0; transform: translateY(16px); }
      to { opacity: 1; transform: translateY(0); }
    }
    .modal-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 16px;
      border-bottom: 1px solid var(--border);
      padding-bottom: 12px;
    }
    .modal-close {
      background: none;
      border: none;
      font-size: 22px;
      color: var(--text-muted);
      cursor: pointer;
      line-height: 1;
    }

    /* Photo Preview Box */
    .photo-preview {
      width: 100%;
      max-height: 220px;
      object-fit: cover;
      border-radius: var(--radius-md);
      margin-top: 10px;
      border: 1px solid var(--border);
      display: none;
    }

    /* Sync Status Indicator */
    .sync-indicator {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-size: 11.5px;
      font-weight: 600;
      padding: 4px 10px;
      border-radius: var(--radius-full);
      background: #e2e8f0;
      color: var(--text-muted);
    }
    .sync-indicator.online { background: #dcfce7; color: #15803d; }
    .sync-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: currentColor;
    }

    /* Code Snippet Box in Settings */
    .code-box {
      background: #0f172a;
      color: #e2e8f0;
      padding: 12px;
      border-radius: var(--radius-sm);
      font-family: monospace;
      font-size: 12px;
      overflow-x: auto;
      margin: 10px 0;
      white-space: pre-wrap;
      word-break: break-all;
    }

    /* Siswa Header Card Extracted Classes */
    .siswa-header-card {
      background: linear-gradient(135deg, #0284C7 0%, #38BDF8 55%, #0EA5E9 100%);
      color: white;
      border: none;
      position: relative;
      overflow: hidden;
      border-radius: 28px;
      box-shadow: 0 16px 32px -8px rgba(2, 132, 199, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.4);
      padding: 26px;
    }
    .siswa-header-content {
      position: relative;
      z-index: 1;
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      flex-wrap: wrap;
      gap: 16px;
    }
    .siswa-tag {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      background: rgba(254, 240, 138, 0.28);
      color: #FEF08A;
      padding: 6px 16px;
      border-radius: var(--radius-full);
      font-size: 13px;
      font-weight: 800;
      margin-bottom: 12px;
      backdrop-filter: blur(10px);
      border: 1px solid rgba(254, 240, 138, 0.5);
      box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    }
    .siswa-greeting {
      font-size: 28px;
      font-weight: 900;
      line-height: 1.2;
      letter-spacing: -0.5px;
      text-shadow: 0 2px 6px rgba(0,0,0,0.18);
    }
    .siswa-desc {
      opacity: 0.95;
      font-size: 14.5px;
      margin-top: 6px;
      font-weight: 600;
      color: #E0F2FE;
    }
    .siswa-meta {
      font-size: 13px;
      opacity: 0.9;
      margin-top: 6px;
      color: #BAE6FD;
      font-weight: 600;
    }
    .siswa-score-box {
      background: rgba(255, 255, 255, 0.22);
      padding: 16px 22px;
      border-radius: 24px;
      backdrop-filter: blur(16px);
      text-align: center;
      border: 1.5px solid rgba(255, 255, 255, 0.45);
      box-shadow: 0 10px 20px rgba(0,0,0,0.12), inset 0 2px 4px rgba(255,255,255,0.4);
    }
    .score-title {
      font-size: 11.5px;
      color: #FEF08A;
      text-transform: uppercase;
      font-weight: 900;
      letter-spacing: 0.8px;
      margin-bottom: 2px;
      text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    }
    .score-value {
      font-size: 32px;
      font-weight: 900;
      color: #FFFFFF;
      text-shadow: 0 3px 10px rgba(0,0,0,0.25);
    }
    .score-badge {
      display: inline-block;
      background: linear-gradient(135deg, #10B981, #059669);
      color: white;
      font-size: 11px;
      font-weight: 800;
      padding: 3px 10px;
      border-radius: 12px;
      margin-top: 4px;
      box-shadow: 0 4px 8px rgba(16,185,129,0.3);
    }
    
    @media (max-width: 639px) {
      .siswa-header-card { padding: 18px !important; border-radius: 20px !important; }
      .siswa-greeting { font-size: 20px !important; }
      .siswa-desc { font-size: 13px !important; }
      .siswa-meta { font-size: 12px !important; }
      .siswa-score-box { padding: 12px 18px !important; border-radius: 16px !important; width: 100% !important; }
      .score-value { font-size: 26px !important; }
      .score-title { font-size: 10px !important; }
    }