/* ====================================
   Lean Audit — PWA Styles
   Brand: Lean Akademija (navy + red)
   ==================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --navy: #0A2540;
  --navy-2: #143058;
  --red: #E8003D;
  --light: #F0F4F8;
  --gray: #6B7280;
  --gray-2: #94A3B8;
  --dark: #1F2937;
  --green: #15803D;
  --amber: #D97706;
  --orange: #EA580C;
  --blue: #2563EB;
  --purple: #7C3AED;
  --rose: #DC2626;
  --bg: #F8FAFC;
  --border: #E2E8F0;
  --border-2: #F1F5F9;

  /* level colors */
  --L1: #DC2626;
  --L2: #EA580C;
  --L3: #D97706;
  --L4: #65A30D;
  --L5: #15803D;

  /* classification colors */
  --cls-impl: #DC2626;
  --cls-upg:  #D97706;
  --cls-ok:   #15803D;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--dark);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
}
input, textarea, select { user-select: text; -webkit-user-select: text; }

#app {
  height: 100%; position: relative;
  max-width: 480px; margin: 0 auto;
  background: var(--bg); overflow: hidden;
}

/* === SCREENS === */
.screen { position: absolute; inset: 0; display: none; flex-direction: column; background: var(--bg); }
.screen.active { display: flex; }

/* === HEADER === */
.app-header {
  background: var(--navy); color: white;
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
  flex-shrink: 0; padding-top: max(14px, env(safe-area-inset-top));
}
.app-header .title { font-size: 16px; font-weight: 600; flex: 1; }
.header-btn { background: transparent; border: none; color: white; font-size: 22px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.header-btn:active { background: rgba(255,255,255,0.15); }
.header-btn.back::before { content: '←'; }

/* === PROGRESS === */
.progress-bar { height: 3px; background: rgba(232,0,61,0.15); flex-shrink: 0; }
.progress-fill { height: 100%; background: var(--red); width: 0%; transition: width 0.3s; }

/* === CONTENT === */
.content { flex: 1; overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }

/* === HEADINGS === */
h2 { font-size: 18px; margin: 4px 0 10px 0; color: var(--navy); line-height: 1.3; }
h3 { font-size: 14px; margin: 0 0 6px 0; color: var(--navy); }
.section-title {
  font-size: 12px; color: var(--gray);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin: 18px 0 10px 0; font-weight: 600;
}

/* === BUTTONS === */
.btn {
  width: 100%; padding: 14px 20px;
  border: none; border-radius: 12px;
  font-size: 16px; font-weight: 600;
  cursor: pointer; transition: transform 0.1s, opacity 0.2s;
  font-family: inherit;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--red); color: white; }
.btn-secondary { background: white; color: var(--navy); border: 2px solid var(--navy); }
.btn-success { background: var(--green); color: white; }
.btn-warning { background: var(--amber); color: white; }
.btn-danger { background: #EF4444; color: white; }
.btn-ghost { background: transparent; color: var(--gray); }

/* === FORMS === */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--gray); margin-bottom: 6px; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 12px 14px;
  border: 2px solid var(--border); border-radius: 10px;
  font-size: 15px; background: white; font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--navy); }

textarea {
  width: 100%; padding: 12px 14px;
  border: 2px solid var(--border); border-radius: 10px;
  font-size: 14px; background: white; font-family: inherit;
  resize: vertical; min-height: 60px;
}
textarea:focus { outline: none; border-color: var(--navy); }

/* === HOME WELCOME === */
.welcome-card {
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  color: white; border-radius: 14px; padding: 18px;
  margin-bottom: 16px; position: relative; overflow: hidden;
}
.welcome-card::before {
  content: ''; position: absolute; right: -20px; top: -20px;
  width: 140px; height: 140px;
  background: rgba(232,0,61,0.18); border-radius: 50%; pointer-events: none;
}
.welcome-label { font-size: 11px; opacity: 0.7; letter-spacing: 1.5px; text-transform: uppercase; }
.welcome-name { font-size: 22px; font-weight: 700; margin-top: 4px; position: relative; }
.welcome-meta { font-size: 13px; opacity: 0.85; margin-top: 4px; position: relative; }

/* === TABS === */
.tab-row { display: flex; gap: 8px; margin: 22px 0 12px 0; border-bottom: 1px solid var(--border); }
.tab-btn {
  flex: 1; background: transparent; border: none;
  padding: 10px 12px; font-size: 14px; font-weight: 600;
  color: var(--gray); cursor: pointer;
  border-bottom: 2px solid transparent; font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.tab-btn.active { color: var(--navy); border-bottom-color: var(--red); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* === HISTORY === */
.history-item {
  background: white; border-radius: 12px; padding: 14px;
  margin-bottom: 10px; display: flex; justify-content: space-between;
  align-items: center; cursor: pointer; position: relative;
}
.history-item:active { background: var(--border-2); }
.history-item .info { flex: 1; min-width: 0; }
.history-item .name { font-weight: 600; font-size: 15px; color: var(--navy); }
.history-item .date { font-size: 12px; color: var(--gray); margin-top: 2px; }
.history-item .score-pill {
  background: var(--border-2);
  padding: 6px 12px; border-radius: 10px;
  font-weight: 700; font-size: 13px;
}
.score-pill.grade-1 { background: #FEE2E2; color: #991B1B; }
.score-pill.grade-2 { background: #FFEDD5; color: #9A3412; }
.score-pill.grade-3 { background: #FEF3C7; color: #92400E; }
.score-pill.grade-4 { background: #D9F99D; color: #3F6212; }
.score-pill.grade-5 { background: #D1FAE5; color: #065F46; }

.history-item .btn-delete {
  background: transparent; border: none; font-size: 18px;
  color: #cbd5e1; cursor: pointer; padding: 4px 8px;
  border-radius: 6px; margin-left: 8px;
}
.history-item .btn-delete:hover { color: #ef4444; background: #fee2e2; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--gray); }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; line-height: 1.5; }

/* === INFO BOX === */
.info-box {
  background: var(--border-2); padding: 12px 14px;
  border-radius: 10px; margin-top: 16px;
  font-size: 13px; color: var(--gray); line-height: 1.5;
}
.info-box strong { color: var(--navy); }

.info-block {
  background: white; border-radius: 12px; padding: 14px;
  margin-bottom: 10px; border-left: 3px solid var(--red);
}
.info-block h3 { font-size: 14px; color: var(--navy); margin-bottom: 6px; }
.info-block p, .info-block ul { font-size: 13px; color: var(--gray); line-height: 1.5; }
.info-block ul { padding-left: 18px; }
.info-block ul li { margin-bottom: 4px; }
.info-block strong { color: var(--navy); }

/* === BOTTOM BAR === */
.bottom-bar {
  background: white; padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; flex-shrink: 0;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.bottom-bar .btn { flex: 1; padding: 12px; font-size: 14px; }
.bottom-bar.two-col .btn { flex: 1; }

/* === QUESTION SCREEN === */
.dim-pill {
  display: inline-block;
  background: var(--navy); color: white;
  font-size: 11px; font-weight: 700;
  padding: 4px 10px; border-radius: 6px;
  letter-spacing: 0.5px; text-transform: uppercase;
  margin-bottom: 8px;
}
.q-focus { font-size: 13px; color: var(--gray); line-height: 1.5; margin-bottom: 8px; }

/* === INFO CARDS (assess / expect / evidence) === */
.info-card {
  background: white;
  border: 1px solid var(--border);
  border-left: 3px solid var(--gray-2);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.5;
}
.info-card.assess-card  { border-left-color: var(--blue);   background: #EFF6FF; }
.info-card.expect-card  { border-left-color: var(--L5);     background: #ECFDF5; }
.info-card.evidence-card{ border-left-color: var(--amber);  background: #FFFBEB; }
.info-card-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--navy); margin-bottom: 4px;
}
.info-card-icon {
  width: 22px; height: 22px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.info-card-icon.assess   { background: var(--blue);  color: white; }
.info-card-icon.expect   { background: var(--L5);    color: white; }
.info-card-icon.evidence { background: var(--amber); color: white; }
.info-card-body { color: var(--dark); }

/* === RUBRIC CARDS === */
.rubric-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.rubric-card {
  background: white;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex; gap: 12px; align-items: flex-start;
  cursor: pointer;
  transition: all 0.12s;
}
.rubric-card:active { transform: scale(0.99); }
.rubric-card .lvl-badge {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 16px; font-weight: 700;
}
.rubric-card .rubric-body { flex: 1; min-width: 0; }
.rubric-card .rubric-name { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray); margin-bottom: 2px; font-weight: 700; }
.rubric-card .rubric-desc { font-size: 13px; line-height: 1.45; color: var(--dark); }

.rubric-card.lvl-1 .lvl-badge { background: var(--L1); }
.rubric-card.lvl-2 .lvl-badge { background: var(--L2); }
.rubric-card.lvl-3 .lvl-badge { background: var(--L3); }
.rubric-card.lvl-4 .lvl-badge { background: var(--L4); }
.rubric-card.lvl-5 .lvl-badge { background: var(--L5); }

.rubric-card.selected { border-color: var(--navy); box-shadow: 0 4px 14px rgba(10,37,64,0.15); background: var(--border-2); }
.rubric-card.selected.lvl-1 { border-color: var(--L1); box-shadow: 0 4px 14px rgba(220,38,38,0.18); }
.rubric-card.selected.lvl-2 { border-color: var(--L2); box-shadow: 0 4px 14px rgba(234,88,12,0.18); }
.rubric-card.selected.lvl-3 { border-color: var(--L3); box-shadow: 0 4px 14px rgba(217,119,6,0.18); }
.rubric-card.selected.lvl-4 { border-color: var(--L4); box-shadow: 0 4px 14px rgba(101,163,13,0.18); }
.rubric-card.selected.lvl-5 { border-color: var(--L5); box-shadow: 0 4px 14px rgba(21,128,61,0.18); }

/* === EVIDENCE === */
.evidence-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn-evidence { width: auto; padding: 10px 14px; font-size: 13px; border: 2px solid var(--border); border-radius: 10px; background: white; color: var(--navy); }
.evidence-preview { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.evidence-thumb {
  width: 56px; height: 56px;
  background-size: cover; background-position: center;
  border-radius: 8px; position: relative;
}
.evidence-thumb-x {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #EF4444; color: white; border: 2px solid white;
  font-size: 11px; cursor: pointer; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.evidence-hint { font-size: 12px; color: var(--gray); margin-top: 8px; line-height: 1.4; }
.req-mark { color: var(--red); }

/* === OVERVIEW === */
.overview-summary {
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  color: white; border-radius: 12px; padding: 14px;
  margin-bottom: 14px;
}
.overview-summary .row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.overview-summary .row:last-child { margin-bottom: 0; }
.overview-summary .lbl { font-size: 12px; opacity: 0.8; }
.overview-summary .val { font-size: 16px; font-weight: 700; }
.overview-summary .val.big { font-size: 28px; }

.overview-q-row {
  background: white; border-radius: 8px; padding: 10px 12px;
  margin-bottom: 6px; display: flex; gap: 10px; align-items: center;
  font-size: 13px; cursor: pointer;
}
.overview-q-row:active { background: var(--border-2); }
.overview-q-row .q-id { font-weight: 700; color: var(--navy); width: 30px; flex-shrink: 0; font-size: 12px; }
.overview-q-row .q-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dark); }
.overview-q-row .q-lvl {
  width: 26px; height: 22px; border-radius: 5px;
  color: white; font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
}
.overview-q-row .q-lvl.empty { background: var(--gray-2); color: white; }

/* === RESULTS === */
.result-meta {
  background: white; border-radius: 12px; padding: 12px 14px;
  margin-bottom: 14px; font-size: 13px; color: var(--dark);
}
.result-meta .meta-line { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.result-meta .meta-line .lbl { color: var(--gray); }

.overall-score {
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  color: white; border-radius: 14px; padding: 18px;
  margin-bottom: 18px; text-align: center; position: relative; overflow: hidden;
}
.overall-score::before {
  content: ''; position: absolute; right: -20px; top: -20px;
  width: 140px; height: 140px;
  background: rgba(232,0,61,0.15); border-radius: 50%;
}
.overall-score-num { font-size: 56px; font-weight: 700; line-height: 1; position: relative; }
.overall-score-label { font-size: 14px; opacity: 0.85; margin-top: 6px; position: relative; }

/* === RADAR (POLAR CHART) === */
.radar-wrap {
  background: white; border-radius: 12px; padding: 8px;
  margin-bottom: 6px;
}
.radar-wrap svg { width: 100%; height: auto; display: block; }
.radar-axis { stroke: #E2E8F0; stroke-width: 1; fill: none; }
.radar-axis-line { stroke: #CBD5E1; stroke-width: 1; }
.radar-fill {
  fill: rgba(232,0,61,0.18);
  stroke: var(--red);
  stroke-width: 2;
  stroke-linejoin: round;
}
.radar-target {
  fill: none;
  stroke: rgba(21,128,61,0.5);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
}
.radar-label { font-size: 9px; fill: var(--navy); font-weight: 600; }
.radar-label-2 { font-size: 7px; fill: var(--gray); }
.radar-tick { font-size: 7px; fill: var(--gray-2); }

/* === CLASSIFICATION TABS === */
.cls-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.cls-tab {
  flex: 1; padding: 10px 6px; border-radius: 10px;
  border: 2px solid var(--border); background: white;
  cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--gray);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.cls-tab .cls-count {
  background: var(--border-2); color: var(--navy);
  border-radius: 8px; padding: 1px 7px;
  font-size: 11px; font-weight: 700; min-width: 20px;
}
.cls-tab[data-cls="implement"].active { border-color: var(--cls-impl); color: var(--cls-impl); background: #FEE2E2; }
.cls-tab[data-cls="implement"].active .cls-count { background: var(--cls-impl); color: white; }
.cls-tab[data-cls="upgrade"].active { border-color: var(--cls-upg); color: var(--cls-upg); background: #FEF3C7; }
.cls-tab[data-cls="upgrade"].active .cls-count { background: var(--cls-upg); color: white; }
.cls-tab[data-cls="ok"].active { border-color: var(--cls-ok); color: var(--cls-ok); background: #D1FAE5; }
.cls-tab[data-cls="ok"].active .cls-count { background: var(--cls-ok); color: white; }

.cls-list { display: flex; flex-direction: column; gap: 8px; }
.cls-item {
  background: white; border-radius: 10px; padding: 12px;
  border-left: 3px solid var(--gray);
  display: flex; gap: 10px; align-items: center;
}
.cls-item.impl { border-left-color: var(--cls-impl); }
.cls-item.upg  { border-left-color: var(--cls-upg);  }
.cls-item.ok   { border-left-color: var(--cls-ok);   }
.cls-item .ci-id { font-size: 11px; color: var(--gray); font-weight: 700; width: 28px; flex-shrink: 0; }
.cls-item .ci-name { flex: 1; min-width: 0; font-size: 13px; color: var(--navy); font-weight: 600; }
.cls-item .ci-method { font-size: 11px; color: var(--gray); margin-top: 2px; }
.cls-item .ci-score {
  font-size: 12px; font-weight: 700;
  padding: 4px 8px; border-radius: 6px;
  background: var(--border-2); color: var(--navy);
}
.cls-item.impl .ci-score { background: #FEE2E2; color: #991B1B; }
.cls-item.upg  .ci-score { background: #FEF3C7; color: #92400E; }
.cls-item.ok   .ci-score { background: #D1FAE5; color: #065F46; }

/* === ACTION PLAN === */
.action-dim {
  background: white; border-radius: 12px; padding: 12px 14px; margin-bottom: 10px;
  border-left: 3px solid var(--navy);
}
.action-dim-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.action-dim-name { font-size: 14px; font-weight: 600; color: var(--navy); }
.action-dim-score { font-size: 13px; font-weight: 700; padding: 4px 9px; border-radius: 7px; }
.action-dim-list { font-size: 12px; color: var(--gray); line-height: 1.5; margin-top: 6px; }
.action-dim-list .item { margin-bottom: 3px; }
.action-dim-list .item.impl::before { content: '⚠ '; color: var(--cls-impl); }
.action-dim-list .item.upg::before  { content: '↑ '; color: var(--cls-upg);  }
.action-dim-list .item.ok::before   { content: '✓ '; color: var(--cls-ok);   }

/* === HEATMAP === */
.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}
.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 10px; font-weight: 700;
  cursor: pointer; position: relative;
}
.heatmap-cell.lvl-1 { background: var(--L1); }
.heatmap-cell.lvl-2 { background: var(--L2); }
.heatmap-cell.lvl-3 { background: var(--L3); }
.heatmap-cell.lvl-4 { background: var(--L4); }
.heatmap-cell.lvl-5 { background: var(--L5); }
.heatmap-cell.empty { background: var(--border); color: var(--gray-2); }
.heatmap-legend { display: flex; justify-content: space-between; font-size: 11px; color: var(--gray); margin-top: 4px; }

/* === TOAST === */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: white; padding: 10px 16px;
  border-radius: 10px; font-size: 13px; z-index: 100;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* === FOOTER === */
.app-footer {
  background: white; padding: 8px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--gray); text-align: center;
  flex-shrink: 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.app-footer a { color: var(--navy); text-decoration: none; font-weight: 600; }

/* === RESPONSIVE: tablet/desktop wide === */
@media (min-width: 768px) {
  #app { max-width: 720px; }
  .heatmap-grid { grid-template-columns: repeat(7, 1fr); }
}
