﻿:root {
    --primary: #2563EB;
    --primary-dark: #1E40AF;
    --primary-light: #DBEAFE;
    --accent-sky: #38BDF8;
    --accent-teal: #06B6D4;
    --bg-canvas: #F1F5F9;
    --bg-surface: #FFFFFF;
    --text-main: #0F172A;
    --text-muted: #475569;
    --text-light: #94A3B8;
    --border-color: #E2E8F0;

    --status-baik: #10B981;
    --status-baik-bg: #D1FAE5;
    --status-ringan: #F59E0B;
    --status-ringan-bg: #FEF3C7;
    --status-berat: #EF4444;
    --status-berat-bg: #FEE2E2;
    --status-mutasi: #8B5CF6;
    --status-mutasi-bg: #EDE9FE;

    --radius-card: 16px;
    --radius-btn: 12px;
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 8px 24px rgba(30, 64, 175, 0.10);
    --bottom-nav-h: 72px;
  }

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

  body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-canvas);
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
  }

  h1, h2, h3, h4, .font-poppins { font-family: 'Poppins', sans-serif; font-weight: 700; }
  .hidden { display: none !important; }

  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    min-width: 44px;
    padding: 10px 18px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 14px;
    border-radius: var(--radius-btn);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1.5px solid transparent;
    text-decoration: none;
    user-select: none;
  }
  .btn:disabled { opacity: 0.55; cursor: not-allowed; }
  .btn-primary { background: var(--primary); color: #FFFFFF; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25); }
  .btn-primary:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(30, 64, 175, 0.32); }
  .btn-secondary { background: #FFFFFF; color: var(--primary); border-color: var(--primary); }
  .btn-secondary:hover:not(:disabled) { background: var(--primary-light); }
  .btn-teal { background: var(--accent-teal); color: #FFFFFF; }
  .btn-teal:hover:not(:disabled) { background: #0891B2; }
  .btn-danger { background: var(--status-berat); color: #FFFFFF; }
  .btn-danger:hover:not(:disabled) { background: #DC2626; }
  .btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border-color); }
  .btn-ghost:hover:not(:disabled) { background: #E2E8F0; color: var(--text-main); }
  .btn-sm { min-height: 40px; padding: 7px 13px; font-size: 12.5px; }

  .form-group { margin-bottom: 14px; }
  .form-label { display: block; font-weight: 600; font-size: 13px; color: var(--text-main); margin-bottom: 6px; }
  .form-label .req { color: var(--status-berat); }
  .form-control {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--text-main);
    background: #FFFFFF;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
  }
  .form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
  textarea.form-control { min-height: 84px; resize: vertical; }

  .pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
  }
  .pill-baik { background: var(--status-baik-bg); color: #065F46; }
  .pill-ringan { background: var(--status-ringan-bg); color: #92400E; }
  .pill-berat { background: var(--status-berat-bg); color: #991B1B; }
  .pill-mutasi { background: var(--status-mutasi-bg); color: #5B21B6; }
  .pill-info { background: #E0F2FE; color: #0369A1; }
  .pill-neutral { background: #E2E8F0; color: #334155; }

  .card {
    background: var(--bg-surface);
    border-radius: var(--radius-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 16px;
  }

  .skeleton {
    background: linear-gradient(90deg, #E2E8F0 25%, #F1F5F9 50%, #E2E8F0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: 10px;
  }
  @keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

  .empty-state {
    text-align: center;
    padding: 36px 20px;
    background: #FFFFFF;
    border: 2px dashed #CBD5E1;
    border-radius: var(--radius-card);
    color: var(--text-muted);
  }
  .empty-state-icon { font-size: 40px; margin-bottom: 10px; }
  .error-banner {
    background: #FEF2F2;
    border: 1.5px solid #FECACA;
    color: #991B1B;
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 14px;
    font-weight: 500;
  }
  .info-banner {
    background: #EFF6FF;
    border: 1.5px solid #BFDBFE;
    color: #1E40AF;
    padding: 10px 14px;
    border-radius: 12px;
    margin-bottom: 14px;
    font-size: 13px;
    font-weight: 600;
  }

  /* Login */
  .login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #1E40AF 0%, #2563EB 55%, #06B6D4 100%);
  }
  .login-card {
    width: 100%;
    max-width: 420px;
    background: #FFFFFF;
    border-radius: 22px;
    padding: 28px 24px;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.25);
  }
  .login-logo {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    background: linear-gradient(135deg, #1E40AF, #38BDF8);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 14px;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.3);
  }

  /* Header & Shell */
  .app-header {
    background: linear-gradient(135deg, #1E40AF, #2563EB);
    color: #FFFFFF;
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 90;
    box-shadow: 0 4px 14px rgba(30, 64, 175, 0.22);
  }
  .header-top-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .brand-box { display: flex; align-items: center; gap: 10px; }
  .brand-badge {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
  }
  .brand-title { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 15px; line-height: 1.2; }
  .brand-sub { font-size: 11px; color: #BAE6FD; }
  .desktop-nav, .desktop-user-box { display: none; }
  .header-mobile-actions { display: flex; align-items: center; gap: 8px; }
  .btn-header-icon {
    min-width: 44px;
    min-height: 44px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.16);
    color: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.25);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
  }

  .main-container { padding: 14px 14px calc(var(--bottom-nav-h) + 24px); max-width: 1480px; margin: 0 auto; }

  .offline-bar {
    background: #FEF3C7;
    border: 1.5px solid #F59E0B;
    color: #92400E;
    padding: 10px 14px;
    border-radius: 12px;
    margin-bottom: 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-weight: 600;
    font-size: 13px;
  }

  /* KPI & RME Pillars */
  .kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .kpi-card {
    background: #FFFFFF;
    border-radius: 16px;
    padding: 14px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
  }
  .kpi-card::after { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--primary); }
  .kpi-card.teal::after { background: var(--accent-teal); }
  .kpi-card.green::after { background: var(--status-baik); }
  .kpi-card.red::after { background: var(--status-berat); }
  .kpi-card.orange::after { background: var(--status-ringan); }
  .kpi-card.sky::after { background: var(--accent-sky); }
  .kpi-val { font-family: 'Poppins', sans-serif; font-size: 22px; font-weight: 700; color: var(--text-main); line-height: 1.15; }
  .kpi-lbl { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; font-weight: 500; }

  .rme-pillar-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
  .rme-pillar-card { background: #F8FAFC; border: 1px solid #E2E8F0; border-radius: 12px; padding: 12px; }
  .progress-track { height: 8px; background: #E2E8F0; border-radius: 999px; overflow: hidden; margin-top: 6px; }
  .progress-fill { height: 100%; border-radius: 999px; transition: width 0.4s ease; }

  .charts-grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 16px; }
  .chart-box { height: 245px; position: relative; }

  /* Workspace Devices */
  .workspace-split { display: block; }
  .device-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
  .device-card {
    background: #FFFFFF;
    border-radius: 16px;
    padding: 14px;
    border: 1.5px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    gap: 12px;
    align-items: flex-start;
  }
  .device-card:hover { border-color: var(--accent-sky); transform: translateY(-1px); }
  .device-card.active { border-color: var(--primary); background: #EFF6FF; box-shadow: 0 4px 14px rgba(37, 99, 235, 0.14); }
  .device-icon-box {
    width: 46px;
    height: 46px;
    border-radius: 13px;
    background: linear-gradient(135deg, #DBEAFE, #E0F2FE);
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
  }
  .device-card-body { flex: 1; min-width: 0; }
  .device-code { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 14px; color: var(--primary-dark); }
  .device-title { font-weight: 600; font-size: 13px; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .device-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

  /* Slide-Over Detail Pane */
  .detail-panel-overlay { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); z-index: 120; }
  .detail-panel-overlay.open { display: block; }
  .detail-pane {
    display: none;
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 100%; max-width: 100%;
    background: #F8FAFC;
    z-index: 130;
    overflow-y: auto;
    padding: 16px 16px 90px;
    box-shadow: -8px 0 30px rgba(15, 23, 42, 0.18);
  }
  .detail-pane.open { display: block; }

  /* Stepper */
  .stepper-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
    padding: 10px 14px;
    border-radius: 12px;
    margin-bottom: 14px;
  }
  .step-pill-btn {
    min-height: 42px;
    padding: 6px 12px;
    border-radius: 10px;
    border: 1.5px solid var(--border-color);
    background: #FFFFFF;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    cursor: pointer;
  }
  .step-pill-btn.active { background: var(--primary); color: #FFFFFF; border-color: var(--primary); }
  .audit-step-section { display: none; }
  .audit-step-section.active { display: block; }
  .stepper-footer-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border-color); }

  /* Mobile Bottom Nav & Drawer */
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-h);
    background: #FFFFFF;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 4px 6px;
    z-index: 100;
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08);
  }
  .bnav-item {
    flex: 1; min-height: 54px; min-width: 48px;
    border: none; background: transparent;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; font-size: 11px; font-weight: 600; color: var(--text-muted);
    cursor: pointer; border-radius: 12px;
  }
  .bnav-item.active { color: var(--primary); }
  .bnav-item .bnav-icon { font-size: 20px; line-height: 1; }
  .bnav-scan-center {
    position: relative; top: -12px;
    background: linear-gradient(135deg, #2563EB, #06B6D4);
    color: #FFFFFF !important;
    border-radius: 18px;
    padding: 8px 10px;
    min-width: 64px; min-height: 60px;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.38);
  }
  .mobile-drawer {
    position: fixed; left: 0; right: 0; bottom: 0;
    background: #FFFFFF;
    border-top-left-radius: 24px; border-top-right-radius: 24px;
    padding: 20px 16px 28px;
    z-index: 150;
    box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.25);
    transform: translateY(105%);
    transition: transform 0.25s ease;
  }
  .mobile-drawer.open { transform: translateY(0); }
  .drawer-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 14px; }

  /* Modals & Tables */
  .modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex; align-items: center; justify-content: center;
    padding: 14px; z-index: 200;
  }
  .modal-box {
    background: #FFFFFF;
    border-radius: 20px;
    width: 100%; max-width: 680px; max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.28);
  }

  .table-wrap { width: 100%; overflow-x: auto; border-radius: 12px; border: 1px solid var(--border-color); }
  table.data-table { width: 100%; border-collapse: collapse; background: #FFFFFF; font-size: 13px; }
  table.data-table th {
    background: #F1F5F9; color: var(--text-main); font-weight: 600;
    text-align: left; padding: 10px 12px; border-bottom: 1.5px solid var(--border-color); white-space: nowrap;
  }
  table.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-color); vertical-align: top; }
  tr.row-clickable { cursor: pointer; transition: background 0.15s; }
  tr.row-clickable:hover { background: #EFF6FF; }

  .form-grid-2 { display: grid; grid-template-columns: 1fr; gap: 12px; }

  @media (min-width: 768px) {
    .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; }
    .charts-grid { grid-template-columns: repeat(2, 1fr); }
    .device-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .detail-pane { width: 72%; max-width: 680px; border-top-left-radius: 22px; border-bottom-left-radius: 22px; padding: 22px; }
    .form-grid-2 { grid-template-columns: repeat(2, 1fr); }
  }

  @media (min-width: 1024px) {
    .app-header { padding: 12px 28px; }
    .header-mobile-actions, .mobile-bottom-nav, .mobile-drawer, .detail-panel-overlay { display: none !important; }
    .desktop-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
    .dnav-btn {
      min-height: 40px; padding: 7px 12px; border-radius: 11px; border: none;
      background: transparent; color: #E0F2FE; font-family: 'Inter', sans-serif;
      font-weight: 600; font-size: 12.5px; cursor: pointer; transition: all 0.2s; white-space: nowrap;
    }
    .dnav-btn:hover { background: rgba(255, 255, 255, 0.14); color: #FFFFFF; }
    .dnav-btn.active { background: #FFFFFF; color: var(--primary-dark); box-shadow: 0 3px 10px rgba(15, 23, 42, 0.15); }
    .desktop-user-box { display: flex; align-items: center; gap: 8px; }
    .main-container { padding: 20px 28px 36px; }
    .kpi-grid { grid-template-columns: repeat(5, 1fr); }

    .workspace-split { display: grid; grid-template-columns: 38% 1fr; gap: 20px; align-items: start; }
    .device-grid { grid-template-columns: 1fr; max-height: calc(100vh - 300px); overflow-y: auto; padding-right: 4px; }
    .detail-pane {
      display: block !important; position: sticky; top: 84px; width: 100%; max-width: 100%;
      max-height: calc(100vh - 104px); background: #FFFFFF; border-radius: var(--radius-card);
      border: 1px solid var(--border-color); box-shadow: var(--shadow-sm); padding: 20px; z-index: 1;
    }
    .btn-close-detail-mobile { display: none !important; }
    .stepper-header, .stepper-footer-nav { display: none; }
    .audit-step-section {
      display: block !important; border: 1px solid var(--border-color); border-radius: 14px;
      padding: 16px; margin-bottom: 14px; background: #F8FAFC;
    }
  }

  @media print {
    body * { visibility: hidden; }
    #printAreaWrapper, #printAreaWrapper * { visibility: visible; }
    #printAreaWrapper { position: absolute; left: 0; top: 0; width: 100%; background: #FFFFFF; }
    .no-print { display: none !important; }
    .qr-label-grid { display: flex; flex-wrap: wrap; gap: 4mm; }
    .qr-label-item { border: 1px solid #000000; page-break-inside: avoid; break-inside: avoid; }
  }
  .qr-label-grid { display: flex; flex-wrap: wrap; gap: 10px; }
  .qr-label-item {
    border: 1.5px solid #0F172A; border-radius: 6px; padding: 6px 8px;
    background: #FFFFFF; display: flex; align-items: center; gap: 8px; overflow: hidden;
  }
