* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, system-ui, 'Segoe UI', sans-serif; background: #f5f7fa; color: #1f2937; }
h1, h2, h3 { margin: 0 0 12px; }
.muted { color: #6b7280; font-size: 14px; }
.error { color: #dc2626; font-size: 14px; margin-top: 8px; min-height: 20px; }
button, .btn { cursor: pointer; border: 0; background: #2563eb; color: #fff; padding: 8px 16px; border-radius: 6px; font-size: 14px; text-decoration: none; display: inline-block; }
button:hover, .btn:hover { background: #1d4ed8; }
button.secondary { background: #e5e7eb; color: #1f2937; }
button.secondary:hover { background: #d1d5db; }
button.danger { background: #dc2626; }
button.danger:hover { background: #b91c1c; }
input, select, textarea { padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; font-family: inherit; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #2563eb; }
label { display: block; margin: 8px 0; font-size: 14px; }
label input, label select, label textarea { width: 100%; margin-top: 4px; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%); }
.login-box { background: #fff; padding: 40px; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); width: 380px; }
.login-box h1 { font-size: 24px; margin-bottom: 4px; }
.login-box input { width: 100%; margin: 8px 0; }
.login-box button { width: 100%; padding: 12px; margin-top: 12px; font-size: 16px; }

/* App layout */
#app { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #111827; color: #e5e7eb; display: flex; flex-direction: column; }
.sidebar .brand { padding: 24px; font-size: 20px; font-weight: 700; letter-spacing: 2px; border-bottom: 1px solid #1f2937; }
.sidebar .brand span { font-size: 12px; font-weight: 400; letter-spacing: 6px; color: #9ca3af; }
.sidebar nav { flex: 1; padding: 12px 0; }
.sidebar nav a { display: block; padding: 12px 24px; color: #e5e7eb; text-decoration: none; font-size: 14px; }
.sidebar nav a:hover { background: #1f2937; }
.sidebar nav a.active { background: #2563eb; color: #fff; }
.sidebar .bottom { padding: 16px 24px; border-top: 1px solid #1f2937; font-size: 13px; display: flex; justify-content: space-between; }
.sidebar .bottom a { color: #9ca3af; }

main { flex: 1; padding: 32px; overflow-y: auto; }
.tab { display: none; }
.tab.active { display: block; }
.tab header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }

.card { background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
table th, table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e7eb; font-size: 14px; }
table th { background: #f9fafb; font-weight: 600; color: #374151; }
table tr:hover td { background: #f9fafb; }

/* Inner tabs (inbox status) */
.tabs-inner { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid #e5e7eb; }
.status-tab { background: none; color: #6b7280; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 16px; }
.status-tab.active { color: #2563eb; border-bottom-color: #2563eb; }
.status-tab:hover { background: none; color: #1d4ed8; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; align-items: center; }

/* Response item */
.response { background: #fff; border-radius: 8px; padding: 16px 20px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.response .head { display: flex; justify-content: space-between; font-size: 13px; color: #6b7280; margin-bottom: 8px; }
.response .rating { font-size: 24px; }
.response .answer { margin: 4px 0; }
.response .answer b { color: #374151; }
.response .actions { margin-top: 12px; display: flex; gap: 8px; }

/* PIN display */
.pin-display { font-family: 'SF Mono', Menlo, monospace; font-size: 22px; letter-spacing: 4px; background: #f3f4f6; padding: 8px 16px; border-radius: 6px; display: inline-block; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-box { background: #fff; border-radius: 12px; padding: 32px; max-width: 600px; width: 90%; max-height: 90vh; overflow-y: auto; position: relative; }
.modal-close { position: absolute; top: 12px; right: 12px; background: none; color: #6b7280; font-size: 28px; padding: 4px 12px; }

/* Questions list in survey edit */
.question-item { background: #f9fafb; padding: 16px; border-radius: 8px; margin-bottom: 12px; border-left: 4px solid #2563eb; }
.question-item .q-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.q-type-badge { background: #dbeafe; color: #1e40af; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; }

/* Stats charts */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 20px; }
.chart-box { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.chart-box h3 { font-size: 16px; margin-top: 0; }
.chart-box.chart-wide { grid-column: 1 / -1; }
.stat-big { font-size: 36px; font-weight: 700; color: #2563eb; }

/* KPI cards */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi-card { background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); border-left: 4px solid #2563eb; }
.kpi-card.kpi-neg { border-left-color: #dc2626; }
.kpi-card.kpi-pos { border-left-color: #10b981; }
.kpi-label { font-size: 13px; color: #64748b; text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px; }
.kpi-value { font-size: 32px; font-weight: 700; color: #0f172a; margin-top: 6px; line-height: 1.1; }
.kpi-sub { font-size: 12px; color: #94a3b8; margin-top: 4px; }
.delta { font-size: 13px; font-weight: 600; padding: 2px 8px; border-radius: 6px; display: inline-block; vertical-align: middle; margin-left: 6px; }
.delta-pos { background: #dcfce7; color: #166534; }
.delta-neg { background: #fee2e2; color: #991b1b; }
.delta-neu { background: #f1f5f9; color: #475569; }

/* Stats table */
.stats-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.stats-table th, .stats-table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid #f1f5f9; }
.stats-table th { font-size: 12px; color: #64748b; text-transform: uppercase; }

/* Negative feed */
.neg-feed { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; margin-top: 14px; }
.neg-card { background: #fff; border-radius: 10px; padding: 14px 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); border-left: 4px solid #dc2626; }
.neg-card.neg-rating-2 { border-left-color: #f59e0b; }
.neg-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.neg-emoji { font-size: 24px; }
.neg-place { flex: 1; font-size: 14px; }
.neg-date { font-size: 12px; color: #94a3b8; }
.neg-clarify { font-size: 13px; color: #475569; margin: 6px 0; }
.neg-clarify > div { margin-bottom: 4px; }
.neg-tag { display: inline-block; background: #f1f5f9; padding: 2px 8px; border-radius: 6px; margin-right: 4px; }
.neg-text { font-size: 14px; color: #1e293b; font-style: italic; background: #fef2f2; padding: 8px 12px; border-radius: 6px; margin-top: 8px; }

/* QR */
.qr-box { text-align: center; padding: 20px; }
.qr-box img { max-width: 320px; width: 100%; }

/* Clarify option editor rows */
.clarify-opt-row { display: flex; gap: 8px; margin-bottom: 6px; align-items: center; }
.clarify-opt-row .co-emoji { width: 56px; text-align: center; font-size: 20px; }
.clarify-opt-row .co-label { flex: 1.2; }
.clarify-opt-row .co-value { flex: 1; font-family: monospace; font-size: 12px; }

/* Print */
@media print {
  .sidebar, header button, .filters, .tabs-inner { display: none !important; }
  main { padding: 0; }
  .card, .chart-box { box-shadow: none; border: 1px solid #e5e7eb; break-inside: avoid; }
}
