:root {
  --red: #E31B23;
  --red-hover: #c41820;
  --green: #198754;
  --bg: #F3F4F6;
  --white: #FFFFFF;
  --text: #1F2937;
  --muted: #6B7280;
  --border: #E5E7EB;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Auth overlay ── */
#auth-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#auth-overlay.auth-pending {
  display: flex;
}
#auth-overlay.auth-pending .auth-card {
  visibility: hidden;
  pointer-events: none;
}
#auth-overlay.show {
  display: flex;
}
#auth-overlay.show .auth-card {
  visibility: visible;
  pointer-events: auto;
}

.auth-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px 32px;
  width: 400px;
  max-width: 100%;
  box-shadow: var(--shadow-md);
  text-align: center;
}
.auth-card .auth-logo-img {
  max-height: 48px;
  max-width: 220px;
  width: auto;
  height: auto;
  object-fit: contain;
  margin: 0 auto 16px;
  display: block;
}
.auth-sub {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 24px;
}
.auth-field {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 12px;
  font-family: inherit;
  color: var(--text);
}
.auth-field:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(227, 27, 35, 0.12);
}
.auth-btn {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease;
}
.auth-btn:hover { background: var(--red-hover); }
.auth-btn.full { width: 100%; }
.auth-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.auth-btn.secondary {
  background: var(--white);
  color: var(--text);
  border: 1px solid var(--border);
}
.auth-btn.secondary:hover { background: var(--bg); }
#auth-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
}

/* Settings page password gate (client-side guard rail only) */
.settings-gate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10001;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(31, 41, 55, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.settings-gate.show {
  display: flex;
}
.settings-gate-dialog {
  background: var(--white);
  border-radius: var(--radius);
  padding: 32px 28px 24px;
  width: 400px;
  max-width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border);
  text-align: center;
}
.settings-gate-dialog h2 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
}
.settings-gate-sub {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.settings-gate-back {
  display: inline-block;
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}
.settings-gate-back:hover {
  color: var(--red);
}
#settings-gate-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}

/* ── Top navigation ── */
.topnav {
  display: none;
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.topnav.show { display: block; }

.topnav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 64px;
}

.topnav-brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
}
.topnav-brand img {
  max-height: 40px;
  max-width: 180px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.topnav-toggle {
  display: none;
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.topnav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}

.topnav-links a {
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.topnav-links a:hover {
  color: var(--red);
  background: rgba(227, 27, 35, 0.04);
}
.topnav-links a.active {
  color: var(--red);
  border-bottom-color: var(--red);
}

.topnav-clover {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  margin-left: 2px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: default;
  line-height: 0;
}
.topnav-clover:hover {
  background: rgba(25, 135, 84, 0.1);
}
.topnav-clover svg {
  width: 22px;
  height: 22px;
  display: block;
}

.topnav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}
.topnav-user .user-email {
  font-size: 12px;
  color: var(--muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.logout-btn {
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--red);
  font-family: inherit;
}
.logout-btn:hover { background: #fef2f2; }

/* ── Main layout ── */
.page-wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.page-wrap--calendar {
  padding-top: 20px;
  max-width: 100%;
}

.page-header {
  margin-bottom: 28px;
}
.page-header h1 {
  margin: 0 0 8px;
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}
.page-header p {
  margin: 0;
  font-size: 16px;
  color: var(--muted);
  max-width: 640px;
}

.portal-hero {
  text-align: center;
  padding: 24px 20px 16px;
  background: var(--white);
}
.portal-hero h1 {
  font-size: 28px;
  font-weight: 800;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.02em;
}

.portal-banner {
  width: 100%;
  height: clamp(160px, 24vw, 300px);
  background-color: #2d6a4f;
  background-image:
    linear-gradient(
      180deg,
      rgba(25, 135, 84, 0.35) 0%,
      rgba(25, 135, 84, 0.12) 45%,
      rgba(31, 41, 55, 0.08) 100%
    ),
    url('https://static.vecteezy.com/system/resources/previews/035/896/337/original/ai-generated-beautiful-blurred-background-image-of-spring-nature-with-a-neatly-trimmed-lawn-surrounded-by-trees-against-a-blue-sky-with-clouds-on-a-bright-sunny-day-photo.jpg');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

.page-wrap--home {
  padding-top: 28px;
}

/* ── App launcher tiles ── */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 170px));
  gap: 14px;
  justify-content: center;
}

.app-grid-empty {
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  max-width: 480px;
  margin: 24px auto 0;
}
.app-grid-empty a {
  color: var(--red);
  font-weight: 600;
}

.app-card {
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  aspect-ratio: 1 / 1;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.app-card:hover,
.app-card:focus-visible {
  transform: translateY(-4px);
  border-color: var(--red);
  box-shadow: var(--shadow-md);
  outline: none;
}
.app-card h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}
.app-card p {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--muted);
}
.app-card .arrow {
  text-align: right;
  font-size: 18px;
  font-weight: 700;
  color: var(--red);
}
.app-card .icon {
  width: 40px;
  height: 40px;
  margin-bottom: 10px;
  flex-shrink: 0;
}
.app-card .icon svg {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.12));
}
.app-card:hover .icon svg,
.app-card:focus-visible .icon svg {
  filter: drop-shadow(0 3px 8px rgba(227, 27, 35, 0.28));
}

.luck-header {
  text-align: center;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}
.luck-clover-large {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
}
.luck-clover-large svg {
  width: 100%;
  height: 100%;
}

.luck-video-panel {
  max-width: 720px;
  margin: 8px auto 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  aspect-ratio: 16 / 9;
}
.luck-video-panel iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 360px;
  border: 0;
}

/* ── Product grid ── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
.product-card {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.1);
}
.product-card-img {
  aspect-ratio: 4 / 3;
  background: var(--bg);
  overflow: hidden;
}
.product-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.product-card-img.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 16px;
  text-align: center;
}
.product-card-body {
  padding: 16px 18px 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.product-card-body h3 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 700;
}
.product-card-body p {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--muted);
  flex: 1;
}
.product-card-body a {
  font-size: 14px;
  font-weight: 600;
  color: var(--red);
  text-decoration: none;
}
.product-card-body a:hover { text-decoration: underline; }

/* ── News ── */
.news-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.filter-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: all 0.15s ease;
}
.filter-btn:hover { border-color: var(--red); color: var(--red); }
.filter-btn.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.news-list { display: flex; flex-direction: column; gap: 16px; }

.news-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px;
}
.news-card.hidden { display: none; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-news { background: rgba(227, 27, 35, 0.1); color: var(--red); }
.badge-events { background: rgba(25, 135, 84, 0.12); color: var(--green); }

.news-card-content { flex: 1; min-width: 200px; }
.news-card h3 {
  margin: 8px 0 8px;
  font-size: 18px;
  font-weight: 700;
}
.news-card p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
}
.news-card .news-date {
  font-size: 12px;
  color: var(--muted);
}
.news-card a.btn-link {
  align-self: center;
  white-space: nowrap;
  padding: 10px 18px;
  background: var(--red);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}
.news-card a.btn-link:hover { background: var(--red-hover); }

/* ── Calendar ── */
.calendar-panel {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  overflow: hidden;
  min-height: 600px;
}
.calendar-panel iframe {
  width: 100%;
  height: 650px;
  border: none;
  display: block;
}
.calendar-placeholder {
  padding: 48px 32px;
  text-align: center;
  color: var(--muted);
}
.calendar-placeholder h3 {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 20px;
}
.calendar-placeholder a { color: var(--red); font-weight: 600; }

/* ── Help accordion ── */
.help-section { margin-bottom: 32px; }
.help-section h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--red);
  display: inline-block;
}

.accordion-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.accordion-item input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.accordion-item label {
  display: block;
  padding: 16px 20px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  position: relative;
  padding-right: 44px;
}
.accordion-item label::after {
  content: '+';
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--red);
  font-weight: 400;
}
.accordion-item input:checked + label::after { content: '−'; }
.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.accordion-item input:checked ~ .accordion-body {
  max-height: 400px;
}
.accordion-body-inner {
  padding: 0 20px 16px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

/* ── Suggestions ── */
.panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  box-shadow: var(--shadow-md);
  max-width: 720px;
}
.panel h2 {
  margin: 0 0 8px;
  font-size: 20px;
}
.panel-note {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 20px;
}
.form-row { margin-bottom: 16px; }
.form-row label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
.form-row input,
.form-row textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
}
.form-row input:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(227, 27, 35, 0.1);
}
.form-row input:disabled { background: var(--bg); color: var(--muted); }
.form-row textarea { min-height: 120px; resize: vertical; }

#suggestion-status,
#settings-status {
  font-size: 14px;
  margin-top: 12px;
  min-height: 20px;
}
#suggestion-status.ok,
#settings-status.ok { color: var(--green); }
#suggestion-status.error,
#settings-status.error { color: var(--red); }

.suggestions-admin {
  margin-top: 40px;
  max-width: 900px;
}
.suggestions-admin h2 {
  font-size: 20px;
  margin-bottom: 16px;
}
.suggestion-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.suggestion-item h4 {
  margin: 0 0 6px;
  font-size: 15px;
}
.suggestion-item .meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.suggestion-item p {
  margin: 0;
  font-size: 14px;
  color: var(--text);
}

/* ── Settings ── */
.settings-panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px 28px;
  box-shadow: var(--shadow-md);
  max-width: 720px;
  margin-bottom: 24px;
}
.settings-panel h2 {
  margin: 0 0 6px;
  font-size: 20px;
}
.settings-note {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 20px;
}
.settings-note.warn { color: #b45309; }
.settings-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 24px 0 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.settings-section-title:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.url-row { margin-bottom: 14px; }
.url-row label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}
.url-row input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
}
.url-row input:disabled { background: var(--bg); color: var(--muted); }
.settings-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.admin-only { display: none; }
.admin-only.show { display: block; }

.custom-card-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 14px;
  background: var(--bg);
}
.custom-card-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.custom-card-row-header strong {
  font-size: 14px;
  color: var(--text);
}
.custom-card-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.move-card-up,
.move-card-down,
.remove-custom-card-btn {
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
}
.move-card-up,
.move-card-down {
  color: var(--text);
  min-width: 34px;
}
.move-card-up:hover:not(:disabled),
.move-card-down:hover:not(:disabled) {
  background: var(--bg);
  border-color: var(--muted);
}
.move-card-up:disabled,
.move-card-down:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.remove-custom-card-btn {
  color: var(--red);
}
.remove-custom-card-btn:hover {
  background: #fef2f2;
}
.custom-card-icon {
  width: 100%;
  max-width: 320px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--white);
}

/* ── Toast & footer ── */
#toast {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  z-index: 10001;
  box-shadow: var(--shadow-md);
}
#toast.show { display: block; }

.site-footer {
  text-align: center;
  padding: 24px 20px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.site-footer a { color: var(--red); text-decoration: none; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .topnav-toggle { display: block; }
  .topnav-links {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: stretch;
    padding: 12px 20px 16px;
    box-shadow: var(--shadow-md);
  }
  .topnav-links.open { display: flex; }
  .topnav-inner { position: relative; flex-wrap: wrap; }
  .topnav-user {
    order: 3;
    width: 100%;
    justify-content: flex-end;
    padding-bottom: 8px;
  }
}

@media (max-width: 600px) {
  .page-header h1 { font-size: 26px; }
  .topnav-user .user-email { display: none; }
}
