:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #273548;
  --border: #334155;
  --text: #f1f5f9;
  --text2: #94a3b8;
  --primary: #0ea5e9;
  --primary-dark: #0284c7;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
  --header-h: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 16px; }

#app { height: 100%; display: flex; flex-direction: column; }

/* Header */
.app-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.app-header .logo { font-size: 20px; font-weight: 700; color: var(--primary); flex: 1; }
.app-header .back-btn { background: none; border: none; color: var(--text2); font-size: 22px; cursor: pointer; padding: 8px; margin-left: -8px; }

/* Main content */
.page { flex: 1; overflow-y: auto; padding: 16px; }
.page-title { font-size: 18px; font-weight: 600; margin-bottom: 16px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card-title { font-weight: 600; margin-bottom: 4px; }
.card-sub { font-size: 14px; color: var(--text2); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius);
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  text-decoration: none;
}
.btn:active { opacity: 0.8; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-full { width: 100%; }
.btn-lg { padding: 16px 24px; font-size: 17px; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* Complete All button */
.btn-complete-all {
  background: linear-gradient(135deg, var(--success), #16a34a);
  color: #fff;
  width: 100%;
  padding: 18px;
  font-size: 18px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  margin-bottom: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
  box-shadow: 0 4px 12px rgba(34,197,94,0.3);
}

/* Forms */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 6px; font-weight: 500; }
input, select, textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  font-size: 15px;
  appearance: none;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea { min-height: 80px; resize: vertical; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

/* Task list */
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.task-item:last-child { border-bottom: none; }
.task-check {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  margin-top: 1px;
}
.task-check.complete { background: var(--success); border-color: var(--success); }
.task-check.na { background: var(--surface2); border-color: var(--text2); }
.task-check svg { display: none; }
.task-check.complete svg { display: block; }
.task-name { flex: 1; font-size: 15px; line-height: 1.4; }
.task-name.complete { color: var(--text2); text-decoration: line-through; }
.task-na-btn { font-size: 12px; color: var(--text2); background: none; border: 1px solid var(--border); border-radius: 4px; padding: 3px 8px; cursor: pointer; flex-shrink: 0; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-primary { background: rgba(14,165,233,0.15); color: var(--primary); }
.badge-success { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-gray { background: var(--surface2); color: var(--text2); }

/* Login screen */
.login-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.login-logo { font-size: 32px; font-weight: 800; color: var(--primary); margin-bottom: 8px; }
.login-tagline { color: var(--text2); margin-bottom: 40px; font-size: 14px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; }

/* Offline banner */
.offline-banner { background: var(--warning); color: #1c1917; padding: 8px 16px; font-size: 13px; font-weight: 600; text-align: center; }

/* Nav tabs */
.nav-tabs { display: flex; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; }
.nav-tab { padding: 14px 20px; font-size: 14px; font-weight: 600; color: var(--text2); border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.nav-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Readings grid */
.readings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* NFC scan button */
.nfc-btn { background: var(--surface2); border: 2px dashed var(--border); border-radius: var(--radius); padding: 24px; text-align: center; cursor: pointer; color: var(--text2); font-size: 14px; margin-bottom: 16px; }
.nfc-btn:active { background: var(--surface); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 200; display: flex; align-items: flex-end; }
.modal { background: var(--surface); border-radius: 20px 20px 0 0; padding: 24px; width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }

/* Empty state */
.empty { text-align: center; padding: 48px 24px; color: var(--text2); }
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-text { font-size: 15px; }

/* Progress bar */
.progress-wrap { background: var(--surface2); border-radius: 4px; height: 8px; margin-bottom: 12px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.3s; }
.progress-bar.complete { background: var(--success); }

/* List item row */
.list-item { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; cursor: pointer; }
.list-item:active { background: var(--surface2); }
.list-item-icon { width: 40px; height: 40px; border-radius: 10px; background: rgba(14,165,233,0.15); display: flex; align-items: center; justify-content: center; color: var(--primary); font-size: 18px; flex-shrink: 0; }
.list-item-body { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-sub { font-size: 13px; color: var(--text2); margin-top: 2px; }
.list-item-arrow { color: var(--text2); font-size: 18px; flex-shrink: 0; }

/* Priority indicators */
.priority-urgent { border-left: 3px solid var(--danger); }
.priority-medium { border-left: 3px solid var(--warning); }
.priority-low { border-left: 3px solid var(--success); }

/* Divider */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* Section header */
.section-header { font-size: 12px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 10px; margin-top: 20px; }
.section-header:first-child { margin-top: 0; }

/* Offline indicator */
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); display: inline-block; margin-right: 6px; }
.dot.offline { background: var(--warning); }

@media (min-width: 600px) {
  .readings-grid { grid-template-columns: 1fr 1fr 1fr; }
}
