@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --dd-blue: #518CB4;
  --dd-blue-dark: #3a6d8f;
  --dd-blue-light: #e8f1f8;
  --dd-gray: #9E9E9E;
  --dd-bg: #f0f0f0;
  --dd-card: #ffffff;
  --dd-text: #1a1a1a;
  --dd-text-light: #666666;
  --dd-green: #4caf50;
  --dd-orange: #f7931a;
  --dd-red: #e53935;
  --dd-border: #e0e0e0;
  --dd-radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--dd-bg); color: var(--dd-text); line-height: 1.6; min-height: 100vh; }

/* === LOGIN === */
.login-container { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 2rem; }
.login-card { background: var(--dd-card); border-radius: var(--dd-radius); border-left: 4px solid var(--dd-blue); padding: 3rem; max-width: 440px; width: 100%; box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.login-logo { font-family: 'JetBrains Mono', monospace; font-size: 1.5rem; font-weight: 600; color: var(--dd-blue); margin-bottom: 0.25rem; }
.login-subtitle { color: var(--dd-text-light); font-size: 0.9rem; margin-bottom: 2rem; }
.code-input { width: 100%; padding: 1rem; font-family: 'JetBrains Mono', monospace; font-size: 1.3rem; letter-spacing: 2px; text-align: center; border: 2px solid var(--dd-border); border-radius: var(--dd-radius); outline: none; transition: border-color 0.2s; }
.code-input:focus { border-color: var(--dd-blue); }
.code-input::placeholder { font-size: 0.9rem; letter-spacing: 0; color: var(--dd-gray); }
.login-btn { width: 100%; padding: 0.9rem; margin-top: 1.2rem; background: var(--dd-blue); color: white; border: none; border-radius: var(--dd-radius); font-size: 1rem; font-weight: 600; cursor: pointer; transition: background 0.2s; }
.login-btn:hover { background: var(--dd-blue-dark); }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.login-error { color: var(--dd-red); font-size: 0.85rem; margin-top: 0.8rem; text-align: center; display: none; }

/* === HEADER === */
.header { background: white; border-bottom: 3px solid var(--dd-blue); padding: 1rem 2rem; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; }
.header-brand { font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: 1.1rem; color: var(--dd-blue); }
.header-user { display: flex; align-items: center; gap: 1rem; font-size: 0.9rem; color: var(--dd-text-light); }
.header-logout { background: none; border: 1px solid var(--dd-border); padding: 0.4rem 0.8rem; border-radius: var(--dd-radius); cursor: pointer; font-size: 0.8rem; color: var(--dd-text-light); transition: all 0.2s; }
.header-logout:hover { border-color: var(--dd-red); color: var(--dd-red); }

/* === TOOL SELECTOR === */
.tool-selector { display: flex; gap: 0; margin: 1.5rem 2rem 0; background: white; border-radius: var(--dd-radius); overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.tool-tab { flex: 1; padding: 0.9rem; border: none; background: white; font-size: 0.9rem; font-weight: 600; cursor: pointer; color: var(--dd-text-light); transition: all 0.2s; border-bottom: 3px solid transparent; }
.tool-tab:hover { background: var(--dd-blue-light); }
.tool-tab.active { color: var(--dd-blue); border-bottom-color: var(--dd-blue); background: var(--dd-blue-light); }

/* === PROGRESS === */
.progress-overview { background: white; margin: 1.5rem 2rem; padding: 1.5rem 2rem; border-radius: var(--dd-radius); border-left: 4px solid var(--dd-blue); box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.progress-title { font-weight: 600; margin-bottom: 0.8rem; color: var(--dd-text); }
.progress-bar-container { background: var(--dd-bg); border-radius: 999px; height: 24px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--dd-blue), var(--dd-blue-dark)); border-radius: 999px; transition: width 0.5s ease; min-width: 2px; }
.progress-stats { display: flex; justify-content: space-between; margin-top: 0.5rem; font-size: 0.85rem; color: var(--dd-text-light); }
.progress-percent { font-family: 'JetBrains Mono', monospace; font-weight: 600; color: var(--dd-blue); }

/* === TM SCORE === */
.tm-score-display { text-align: center; padding: 1rem 0; }
.tm-score-value { font-family: 'JetBrains Mono', monospace; font-size: 2.5rem; font-weight: 800; }
.tm-score-value span { font-size: 0.9rem; font-weight: 400; color: var(--dd-gray); }
.tm-profile-name { font-size: 1.1rem; font-weight: 700; margin-top: 0.3rem; }
.tm-profile-summary { font-size: 0.9rem; color: var(--dd-text-light); margin-top: 0.5rem; max-width: 500px; margin-left: auto; margin-right: auto; }

/* === SECTIONS === */
.sections-container { padding: 0 2rem 3rem; }
.section { background: white; border-radius: var(--dd-radius); border-left: 4px solid var(--dd-blue); margin-bottom: 1rem; box-shadow: 0 1px 4px rgba(0,0,0,0.06); overflow: hidden; }
.section-header { padding: 1rem 1.5rem; cursor: pointer; display: flex; align-items: center; justify-content: space-between; user-select: none; transition: background 0.15s; }
.section-header:hover { background: var(--dd-blue-light); }
.section-header-left { display: flex; align-items: center; gap: 0.75rem; }
.section-icon { font-size: 1.3rem; }
.section-title { font-weight: 600; font-size: 1rem; }
.section-header-right { display: flex; align-items: center; gap: 1rem; }
.section-progress-mini { font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; color: var(--dd-text-light); }
.section-progress-mini.complete { color: var(--dd-green); font-weight: 600; }
.section-chevron { transition: transform 0.2s; color: var(--dd-gray); font-size: 0.8rem; }
.section.open .section-chevron { transform: rotate(90deg); }
.section-items { display: none; padding: 0 1.5rem 1rem; }
.section.open .section-items { display: block; }

/* === DD ITEMS === */
.checklist-item { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.6rem 0; border-bottom: 1px solid var(--dd-bg); }
.checklist-item:last-child { border-bottom: none; }
.checklist-item input[type="checkbox"] { appearance: none; -webkit-appearance: none; width: 20px; height: 20px; min-width: 20px; border: 2px solid var(--dd-border); border-radius: 4px; cursor: pointer; margin-top: 2px; transition: all 0.15s; position: relative; }
.checklist-item input[type="checkbox"]:checked { background: var(--dd-blue); border-color: var(--dd-blue); }
.checklist-item input[type="checkbox"]:checked::after { content: '✓'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: white; font-size: 12px; font-weight: bold; }
.checklist-item.checked .item-text { text-decoration: line-through; color: var(--dd-gray); }
.item-text { font-size: 0.9rem; line-height: 1.5; flex: 1; }
.item-priority { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; padding: 2px 6px; border-radius: 3px; white-space: nowrap; margin-top: 3px; }
.priority-essential { background: #fce4ec; color: var(--dd-red); }
.priority-recommended { background: #fff3e0; color: #e65100; }
.priority-optional { background: #e8f5e9; color: #2e7d32; }
.priority-advanced { background: #ede7f6; color: #4527a0; }

/* === TM QUESTIONS === */
.tm-question { padding: 1.2rem 0; border-bottom: 1px solid var(--dd-bg); }
.tm-question:last-child { border-bottom: none; }
.tm-question.answered { opacity: 0.85; }
.question-text { font-size: 0.95rem; font-weight: 600; color: var(--dd-text); margin-bottom: 4px; }
.question-context { font-size: 0.8rem; color: var(--dd-text-light); margin-bottom: 0.8rem; font-style: italic; }
.tm-options { display: flex; flex-direction: column; gap: 6px; }
.tm-option { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #f8f9fa; border: 2px solid transparent; border-radius: 6px; cursor: pointer; font-size: 0.85rem; color: #555; transition: all 0.2s; }
.tm-option:hover { background: var(--dd-blue-light); border-color: var(--dd-border); }
.tm-option.selected { border-color: var(--dd-blue); background: rgba(81,140,180,0.08); color: var(--dd-text); }
.tm-option .option-radio { width: 18px; height: 18px; border: 2px solid var(--dd-border); border-radius: 50%; flex-shrink: 0; position: relative; transition: all 0.2s; }
.tm-option.selected .option-radio { border-color: var(--dd-blue); }
.tm-option.selected .option-radio::after { content: ''; position: absolute; inset: 3px; background: var(--dd-blue); border-radius: 50%; }

/* === TM RESULTS === */
.tm-results-card { background: white; border-radius: var(--dd-radius); border-left: 4px solid var(--dd-blue); padding: 1.5rem 2rem; margin-bottom: 1rem; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.tm-results-title { font-weight: 700; font-size: 1.05rem; color: var(--dd-text); margin-bottom: 1rem; }

/* Risk grid */
.tm-risk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.tm-risk-item { background: var(--dd-bg); border-radius: 6px; padding: 1rem; }
.tm-risk-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; font-size: 0.85rem; font-weight: 600; }
.tm-risk-bar-track { height: 6px; background: #ddd; border-radius: 6px; overflow: hidden; margin-bottom: 0.4rem; }
.tm-risk-bar-fill { height: 100%; border-radius: 6px; transition: width 0.5s; }
.tm-risk-detail { font-size: 0.75rem; color: var(--dd-text-light); }

/* Threats */
.tm-threat-item { display: flex; gap: 0.75rem; padding: 0.8rem 0; border-bottom: 1px solid var(--dd-bg); }
.tm-threat-item:last-child { border-bottom: none; }
.tm-threat-num { width: 32px; height: 32px; border-radius: 50%; color: white; font-size: 0.75rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tm-threat-content { flex: 1; }
.tm-threat-q { font-size: 0.9rem; font-weight: 600; color: var(--dd-text); margin-bottom: 2px; }
.tm-threat-a { font-size: 0.8rem; color: var(--dd-text-light); }

/* Action plan */
.tm-action-item { display: flex; gap: 0.75rem; padding: 0.8rem 0; border-bottom: 1px solid var(--dd-bg); }
.tm-action-item:last-child { border-bottom: none; }
.tm-action-num { width: 28px; height: 28px; border-radius: 50%; background: var(--dd-blue); color: white; font-size: 0.75rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tm-action-content { flex: 1; }
.tm-action-text { font-size: 0.9rem; font-weight: 600; color: var(--dd-text); margin-bottom: 2px; }
.tm-action-why { font-size: 0.8rem; color: var(--dd-text-light); font-style: italic; }

/* === TM BADGES === */
.tm-badge { font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 4px; }
.badge-critical { background: rgba(211,47,47,0.1); color: #d32f2f; }
.badge-high { background: rgba(230,81,0,0.1); color: #e65100; }
.badge-medium { background: rgba(249,168,37,0.1); color: #f9a825; }
.badge-low { background: rgba(46,125,50,0.1); color: #2e7d32; }
.badge-none { background: var(--dd-bg); color: var(--dd-gray); }

/* === ADMIN === */
.admin-container { padding: 2rem; max-width: 960px; margin: 0 auto; }
.admin-title { font-family: 'JetBrains Mono', monospace; color: var(--dd-blue); margin-bottom: 1.5rem; }
.admin-login { max-width: 400px; margin: 4rem auto; }
.admin-form { display: flex; gap: 0.75rem; margin-bottom: 2rem; }
.admin-input { flex: 1; padding: 0.7rem 1rem; border: 2px solid var(--dd-border); border-radius: var(--dd-radius); font-size: 0.9rem; outline: none; }
.admin-input:focus { border-color: var(--dd-blue); }
.admin-btn { padding: 0.7rem 1.5rem; background: var(--dd-blue); color: white; border: none; border-radius: var(--dd-radius); font-weight: 600; cursor: pointer; font-size: 0.9rem; transition: background 0.2s; }
.admin-btn:hover { background: var(--dd-blue-dark); }
.admin-btn.danger { background: var(--dd-red); }
.admin-btn.danger:hover { background: #c62828; }
.admin-btn.small { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.client-card { background: white; border-radius: var(--dd-radius); border-left: 4px solid var(--dd-blue); padding: 1.2rem 1.5rem; margin-bottom: 0.8rem; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.client-card.inactive { opacity: 0.5; border-left-color: var(--dd-gray); }
.client-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; }
.client-info { flex: 1; min-width: 150px; }
.client-label { font-weight: 600; font-size: 1rem; }
.client-code { font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; color: var(--dd-text-light); margin-top: 0.2rem; }
.client-metrics { display: flex; gap: 1.5rem; align-items: center; }
.client-metric { display: flex; align-items: center; gap: 0.5rem; }
.metric-label { font-size: 0.75rem; font-weight: 600; color: var(--dd-text-light); min-width: 30px; }
.client-bar { width: 80px; height: 8px; background: var(--dd-bg); border-radius: 999px; overflow: hidden; }
.client-bar-fill { height: 100%; background: var(--dd-blue); border-radius: 999px; transition: width 0.3s; }
.client-percent { font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: 0.85rem; color: var(--dd-blue); min-width: 35px; text-align: right; }
.client-actions { display: flex; gap: 0.4rem; }

/* === RESPONSIVE === */
@media (max-width: 640px) {
  .header { padding: 0.8rem 1rem; }
  .tool-selector { margin: 1rem; }
  .progress-overview { margin: 1rem; padding: 1rem; }
  .sections-container { padding: 0 1rem 2rem; }
  .section-header { padding: 0.8rem 1rem; }
  .section-items { padding: 0 1rem 0.8rem; }
  .admin-container { padding: 1rem; }
  .admin-form { flex-direction: column; }
  .client-row { flex-direction: column; align-items: flex-start; }
  .client-metrics { flex-direction: column; gap: 0.5rem; }
  .client-actions { width: 100%; justify-content: flex-end; }
  .tool-tab { font-size: 0.8rem; padding: 0.7rem; }
  .tm-risk-grid { grid-template-columns: 1fr; }
  .tm-results-card { margin-left: 0; margin-right: 0; padding: 1rem; }
}

/* === PRINT === */
@media print {
  body:not(.printing-tm) { display: none; }
  .header, .tool-selector, .header-logout, #view-dd, #tm-sections, button { display: none !important; }
  .printing-tm #view-tm { display: block !important; }
  .printing-tm .progress-overview { border: 1px solid #ddd; box-shadow: none; margin: 0 0 1rem; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .printing-tm #tm-results { display: block !important; padding: 0; }
  .printing-tm .tm-results-card { box-shadow: none; border: 1px solid #ddd; page-break-inside: avoid; margin-bottom: 1rem; }
  .printing-tm .tm-risk-grid { grid-template-columns: 1fr 1fr; }
  .printing-tm .tm-risk-bar-fill, .printing-tm .progress-bar-fill, .printing-tm .tm-threat-num, .printing-tm .tm-action-num, .printing-tm .tm-badge { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .printing-tm .tm-score-value, .printing-tm .tm-profile-name { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  @page { margin: 1.5cm; size: A4; }
}
