:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-hover: #f8fbff;
  --border: #d9e2ec;
  --text: #16202a;
  --text-muted: #5f6f82;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --error: #dc2626;
  --radius: 12px;
  --max-width: 960px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Nav --- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.nav-links { display: flex; gap: 2rem; }
.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); }
.nav-toggle { display: none; background: none; border: none; color: var(--text); font-size: 1.4rem; cursor: pointer; }

/* --- Main --- */
main {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
}

/* --- Hero --- */
.hero {
  text-align: center;
  padding: 4rem 0 3rem;
}
.hero h1 {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #0f172a 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto;
}

/* --- Cards --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 2.5rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}
.card:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.08);
}
.card h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.card p { font-size: 0.9rem; color: var(--text-muted); }
.card .icon { font-size: 1.8rem; margin-bottom: 0.75rem; }
.card img {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: cover;
}

/* --- App page --- */
.app-header {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.app-icon {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.app-icon img {
  display: block;
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 22px;
}
.app-meta h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; }
.app-meta p { color: var(--text-muted); margin-top: 0.25rem; }
.store-badges { display: flex; gap: 0.75rem; margin-top: 1rem; flex-wrap: wrap; align-items: center; }
.store-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 40px;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  color: var(--text);
  text-decoration: none;
  transition: transform 0.2s, opacity 0.2s;
}
.store-badge img {
  width: 120px;
  height: 40px;
  display: block;
}
.store-badge:hover {
  transform: translateY(-1px);
  opacity: 0.92;
}

.features { margin-top: 2.5rem; }
.features h2 { font-size: 1.4rem; margin-bottom: 1.25rem; }
.feature-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; }
.feature-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}
.feature-item h4 { font-size: 0.95rem; margin-bottom: 0.35rem; }
.feature-item p { font-size: 0.85rem; color: var(--text-muted); }

/* --- Guides --- */
.guide-list { list-style: none; }
.guide-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}
.guide-list li a {
  display: block;
  padding: 1.25rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  transition: background 0.2s;
}
.guide-list li a:hover { background: var(--surface-hover); }

.guide-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  line-height: 1.8;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}
.guide-content h1, .guide-content h2, .guide-content h3 { margin: 1.5rem 0 0.75rem; }
.guide-content p { margin-bottom: 1rem; }
.guide-content code {
  background: var(--bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
}
.guide-content ul, .guide-content ol { margin: 0.5rem 0 1rem 1.5rem; }
.back-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.back-link:hover { text-decoration: underline; }

/* --- Support form --- */
.support-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 600px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-group textarea { min-height: 140px; resize: vertical; }
.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.7rem 1.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.alert {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-success { background: rgba(34, 197, 94, 0.1); border: 1px solid var(--success); color: var(--success); }
.alert-error { background: rgba(239, 68, 68, 0.1); border: 1px solid var(--error); color: var(--error); }

/* --- Section titles --- */
.section-title {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}
.section-subtitle {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

/* --- Footer --- */
.footer {
  border-top: 1px solid var(--border);
  margin-top: auto;
  background: #fafafa;
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 2rem;
}
.footer-col h4 {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
}
.footer-col p {
  margin: 0 0 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
}
.footer-col a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
}
.footer-col a:hover { color: var(--text); }
.footer-links { display: flex; flex-direction: column; gap: 0.4rem; }
.footer-bottom {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  text-align: center;
}
.footer-bottom p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.footer[hidden] { display: none; }

/* --- Responsive --- */
@media (max-width: 640px) {
  .nav-links { display: none; }
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    gap: 1rem;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  }
  .nav-toggle { display: block; }
  .hero h1 { font-size: 2rem; }
  .app-header { flex-direction: column; align-items: center; text-align: center; }
  .footer-inner { flex-direction: column; text-align: center; }
}

/* --- Admin support: two-pane sidebar layout --- */
.admin-shell {
  /* Let the admin page break out of the global narrow content width. */
  max-width: 1320px;
  margin: 0 auto;
}
.admin-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.25rem;
  align-items: start;
  margin-top: 1rem;
}
.admin-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.admin-sidebar-header {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.admin-sidebar-header input[type="search"] {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
}
.admin-filter-chips {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.admin-filter-chips button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  cursor: pointer;
}
.admin-filter-chips button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.admin-ticket-list {
  overflow-y: auto;
  flex: 1;
}
.admin-ticket-row {
  display: block;
  width: 100%;
  text-align: left;
  appearance: none;
  border: none;
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  color: var(--text);
}
.admin-ticket-row:hover { background: var(--surface-hover); }
.admin-ticket-row.active {
  background: #eef4ff;
  border-left: 3px solid var(--accent);
  padding-left: calc(0.85rem - 3px);
}
.admin-ticket-row .row-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
  margin-bottom: 0.15rem;
}
.admin-ticket-row .row-subject {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.admin-ticket-row .row-age {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.admin-ticket-row .row-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-status-badge {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-right: 0.35rem;
  vertical-align: middle;
}
.admin-status-badge.status-open { background: #dcfce7; color: #166534; }
.admin-status-badge.status-closed { background: #e5e7eb; color: #374151; }
.admin-detail {
  min-width: 0; /* allow inner content to shrink */
}
.admin-empty {
  padding: 1.25rem;
  color: var(--text-muted);
  text-align: center;
}
.admin-signed-in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.85rem;
  margin-bottom: 1rem;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius);
  color: #065f46;
  font-size: 0.9rem;
}
.admin-signed-in-text strong { color: #065f46; }
.btn.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}
.btn.btn-ghost:hover {
  background: var(--surface-hover);
}
@media (max-width: 900px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }
  .admin-sidebar {
    position: static;
    max-height: 50vh;
  }
  .admin-ticket-row .row-subject { max-width: none; }
}
