:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #1c2430;
  --text-muted: #5c6778;
  --border: #e2e6ed;
  --accent: #2f6f68;
  --accent-hover: #255a54;
  --accent-soft: #e8f2f0;
  --success: #2d6a4f;
  --success-soft: #eaf4ee;
  --shadow: 0 1px 3px rgba(28, 36, 48, 0.06), 0 8px 24px rgba(28, 36, 48, 0.04);
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.header {
  text-align: center;
  margin-bottom: 1.1rem;
  padding-top: 0.35rem;
}

.header-logo {
  display: block;
  height: 40px;
  width: auto;
  margin: 0 auto 0.85rem;
}

.header h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header p {
  margin: 0.4rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.privacy-note {
  background: var(--accent-soft);
  border: 1px solid #cfe4df;
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  font-size: 0.875rem;
  color: #2a4f4a;
  margin-bottom: 1.5rem;
  line-height: 1.45;
}

.privacy-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 36, 48, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 40;
}

.privacy-dialog {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(28, 36, 48, 0.18);
  padding: 1.35rem 1.25rem 1.2rem;
}

.privacy-dialog h2 {
  margin: 0 2rem 0.55rem 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  text-transform: none;
  letter-spacing: -0.01em;
}

.privacy-dialog p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
  color: #2a4f4a;
}

.privacy-close {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  width: 2rem;
  height: 2rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
}

.privacy-close:hover {
  background: var(--bg);
  color: var(--text);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

textarea, input[type="password"], input[type="text"] {
  width: 100%;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  background: #fff;
  color: var(--text);
  resize: vertical;
}

textarea:focus, input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 104, 0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: #eef1f5; }

.btn-danger {
  background: #fff;
  color: #9b1c1c;
  border: 1px solid #f1c0c0;
}

.btn-danger:hover { background: #fef2f2; }

.btn-block { width: 100%; margin-top: 0.6rem; }

.entry-actions {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.entry-actions .btn {
  flex: 1;
  margin-top: 0;
  padding: 0.45rem 0.7rem;
  font-size: 0.82rem;
}

.confirm-actions { margin-top: 1rem; }

.empty.compact {
  padding: 0.65rem 0.2rem 0.15rem;
  font-size: 0.88rem;
}

.archive-card { padding: 0; }

.archive-toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  margin: 0;
  padding: 0.7rem 0.9rem;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
}

.archive-toggle:hover { background: rgba(28, 36, 48, 0.03); }

.archive-count {
  margin-left: auto;
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  letter-spacing: 0;
  text-transform: none;
}

.archive-body { display: none; padding: 0 0.65rem 0.65rem; }

.archive-card.open .archive-body { display: block; }

.archive-card.open .archive-toggle .entry-chevron { transform: rotate(90deg); }

.entries { display: flex; flex-direction: column; gap: 0.35rem; }

.entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
}

.entry.answered {
  border-color: #c8e0d2;
  background: var(--success-soft);
}

.entry-summary {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.65rem;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.entry-summary:hover { background: rgba(28, 36, 48, 0.03); }

.entry-chevron {
  flex: 0 0 auto;
  width: 0.7rem;
  margin-top: 0.2rem;
  color: var(--text-muted);
  transition: transform 0.15s;
}

.entry.open .entry-chevron { transform: rotate(90deg); }

.entry-text {
  margin: 0;
  flex: 1;
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.35;
}

.entry:not(.open) .entry-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
}

.entry-status {
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--success);
  margin-top: 0.15rem;
}

.entry-details {
  display: none;
  padding: 0 0.65rem 0.65rem 1.8rem;
}

.entry.open .entry-details { display: block; }

.entry-meta {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.entry-note {
  margin: 0.45rem 0 0;
  padding-top: 0.45rem;
  border-top: 1px dashed var(--border);
  font-size: 0.88rem;
  color: #3d4f5f;
}

.entry-note strong {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--success);
  margin-bottom: 0.2rem;
}

.answer-form {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.answer-form .btn-block { margin-top: 0.5rem; }

.answer-step { margin-top: 0.45rem; }

.answer-step textarea {
  padding: 0.5rem 0.65rem;
  font-size: 0.9rem;
}

.empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

.admin-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-box {
  background: var(--bg);
  border-radius: 8px;
  padding: 0.85rem;
  text-align: center;
}

.stat-box .value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-box .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.15rem;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.chart-header h2 { margin: 0; }

.chart-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.chart-range {
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: none;
  background: #fff;
  color: var(--text-muted);
  padding: 0.4rem 0.65rem;
  cursor: pointer;
}

.chart-range.is-active {
  background: var(--accent);
  color: #fff;
}

.chart-legend {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.legend-item::before {
  content: "";
  display: inline-block;
  width: 0.7rem;
  height: 3px;
  margin-right: 0.35rem;
  vertical-align: middle;
  border-radius: 2px;
}

.legend-item.requests::before { background: var(--accent); }
.legend-item.answered::before { background: var(--success); }

.admin-chart { width: 100%; }

.line-chart {
  width: 100%;
  height: auto;
  display: block;
}

.line-chart .grid {
  stroke: var(--border);
  stroke-width: 1;
}

.line-chart .line {
  fill: none;
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.line-chart .line.requests { stroke: var(--accent); }
.line-chart .line.answered { stroke: var(--success); }
.line-chart .dot.requests { fill: var(--accent); }
.line-chart .dot.answered { fill: var(--success); }

.line-chart text {
  font-size: 10px;
  fill: var(--text-muted);
}

.footer-link {
  display: block;
  text-align: center;
  margin-top: 2rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-link a {
  color: var(--accent);
  text-decoration: none;
}

.footer-link a:hover { text-decoration: underline; }

@media (min-width: 480px) {
  .app { padding: 2rem 1.5rem 3rem; }
  .header h1 { font-size: 1.85rem; }
}
