@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --navy: #0A1F3D;
  --navy-teal: #0F3B5C;
  --teal: #1B8A8C;
  --bright-teal: #4FC3C0;
  --bg: #F4F8F8;
  --border: #E1E8E8;
  --text: #16242E;
  --text-muted: #5A6B72;
  --danger: #B3261E;
  --danger-bg: #FCEEED;
  --font-display: 'Fraunces', serif;
  --shadow-sm: 0 1px 3px rgba(10,31,61,0.07);
  --shadow-md: 0 8px 24px rgba(10,31,61,0.09), 0 2px 6px rgba(10,31,61,0.06);
  --shadow-lg: 0 16px 40px rgba(10,31,61,0.12);
  --radius: 12px;
  --radius-lg: 20px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1200px 420px at 15% -10%, rgba(27,138,140,0.08), transparent 60%),
    radial-gradient(900px 380px at 100% 0%, rgba(15,59,92,0.07), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--navy);
}

a { color: var(--teal); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--navy-teal); text-decoration: underline; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.narrow { max-width: 480px; margin: 0 auto; padding: 0 24px; }

/* ---- Top nav (dashboard) ---- */
.topbar {
  background: linear-gradient(120deg, var(--navy) 0%, var(--navy-teal) 100%);
  color: white;
  padding: 0;
  box-shadow: 0 4px 20px rgba(10,31,61,0.25);
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar .container { display: flex; align-items: center; justify-content: space-between; padding-top: 14px; padding-bottom: 14px; max-width: 1440px; }
.topbar-brand { display: flex; align-items: center; gap: 9px; color: white; transition: opacity 0.15s ease; }
.topbar-brand:hover { opacity: 0.85; text-decoration: none; }
.topbar-brand img.brand-icon { height: 26px; width: auto; display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2)); }
.topbar-brand img.brand-wordmark { height: 13px; width: auto; display: block; filter: brightness(0) invert(1); }
.topbar-brand img.brand-logo { height: 32px; width: auto; max-width: 160px; display: block; object-fit: contain; }
.brand-credit { font-size: 10.5px; color: rgba(255,255,255,0.45); letter-spacing: 0.02em; margin-top: 1px; }
.brand-credit img { height: 9px; width: auto; vertical-align: -1px; opacity: 0.75; filter: brightness(0) invert(1); margin-left: 2px; }
.topbar-nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.topbar-links { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; }
.topbar-nav a {
  color: rgba(255,255,255,0.72);
  font-size: 13.5px;
  font-weight: 500;
  padding: 7px 11px;
  border-radius: 100px;
  transition: background 0.15s ease, color 0.15s ease;
}
.topbar-nav a:hover { color: white; background: rgba(255,255,255,0.08); text-decoration: none; }
.topbar-nav a.active { color: var(--navy); font-weight: 600; background: linear-gradient(120deg, white, #E7F4F1); }
.topbar-nav form { margin: 0; }

.topbar-divider { width: 1px; align-self: stretch; margin: 4px 6px; background: rgba(255,255,255,0.16); }

.topbar-dropdown { position: relative; }
.topbar-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.72);
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  padding: 7px 11px;
  border-radius: 100px;
  transition: background 0.15s ease, color 0.15s ease;
}
.topbar-dropdown-toggle svg { width: 9px; height: 9px; transition: transform 0.15s ease; flex-shrink: 0; }
.topbar-dropdown-toggle:hover, .topbar-dropdown-toggle.active { color: white; background: rgba(255,255,255,0.08); }
.topbar-dropdown-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.topbar-dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: white;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  min-width: 180px;
  z-index: 50;
}
.topbar-dropdown-menu a {
  display: block;
  padding: 9px 14px;
  border-radius: 8px;
  color: var(--text) !important;
  font-size: 13.5px;
  font-weight: 500;
}
.topbar-dropdown-menu a:hover { background: var(--bg); text-decoration: none; }
.topbar-dropdown-menu a.active { color: var(--teal) !important; font-weight: 600; background: #E7F4F1; }

.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(120deg, var(--teal), var(--bright-teal));
  color: white;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.topbar-user-name { font-size: 13px; color: rgba(255,255,255,0.55); font-weight: 500; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-logout {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.16);
  color: rgba(255,255,255,0.8);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 100px;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.topbar-logout:hover { background: rgba(255,255,255,0.18); color: white; border-color: rgba(255,255,255,0.3); }

[x-cloak] { display: none !important; }

/* ---- Guest (auth) shell ---- */
.guest-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  background:
    radial-gradient(900px 500px at 50% -15%, rgba(27,138,140,0.14), transparent 60%),
    var(--bg);
}
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}
.card-wide { max-width: 640px; }
.card h1 { margin-top: 0; font-size: 26px; color: var(--navy); }
.card .subtitle { color: var(--text-muted); font-size: 14px; margin-top: -8px; margin-bottom: 20px; }

/* ---- Forms ---- */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--navy-teal); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=number],
textarea, select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 16px;
  font-family: inherit;
  background: white;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:hover, textarea:hover, select:hover { border-color: #C7D3D3; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(27,138,140,0.14);
}
input[type=file] { display: block; margin-bottom: 16px; font-size: 13px; }
.field-row { display: flex; gap: 12px; }
.field-row > * { flex: 1; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.checkbox-row input { width: auto; margin: 0; }
.checkbox-row label { margin: 0; }
.help-text { font-size: 12px; color: var(--text-muted); margin-top: -12px; margin-bottom: 16px; }
.error-text { font-size: 13px; color: var(--danger); margin-top: -12px; margin-bottom: 16px; }

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  background: linear-gradient(120deg, var(--navy-teal), var(--teal));
  color: white;
  border: none;
  padding: 11px 22px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 2px 10px rgba(27,138,140,0.28);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; transform: translateY(-1px); box-shadow: 0 6px 18px rgba(27,138,140,0.38); color: white; }
.btn:active { transform: translateY(0); }
.btn-secondary { background: white; color: var(--navy-teal); border: 1.5px solid var(--border); box-shadow: none; }
.btn-secondary:hover { background: var(--bg); border-color: var(--teal); box-shadow: none; transform: none; filter: none; color: var(--navy-teal); }
.btn-danger { background: var(--danger); box-shadow: 0 2px 10px rgba(179,38,30,0.25); }
.btn-danger:hover { box-shadow: 0 6px 18px rgba(179,38,30,0.32); }
.btn-block { width: 100%; text-align: center; }
.btn-sm { padding: 7px 16px; font-size: 13px; }

/* ---- Alerts ---- */
.alert { padding: 13px 18px; border-radius: 10px; font-size: 14px; margin-bottom: 20px; border-left: 3px solid transparent; }
.alert-status { background: #E7F4F1; color: #10554F; border-left-color: #10554F; }
.alert-error { background: var(--danger-bg); color: var(--danger); border-left-color: var(--danger); }

/* ---- Layout helpers ---- */
.page-header { display: flex; align-items: center; justify-content: space-between; margin: 36px 0 24px; }
.page-header h1 { margin: 0; font-size: 28px; color: var(--navy); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--teal), var(--bright-teal));
}
a.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); text-decoration: none; }
.stat-card .num { font-family: var(--font-display); font-size: 30px; font-weight: 600; color: var(--navy); line-height: 1.1; }
.stat-card .label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

table { width: 100%; border-collapse: collapse; background: white; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: var(--bg); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 700; }
tr { transition: background 0.1s ease; }
tbody tr:hover { background: #FAFCFC; }
tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 3px 12px; border-radius: 100px; font-size: 12px; font-weight: 700; letter-spacing: 0.01em; }
.badge-published { background: #E7F4F1; color: #10554F; }
.badge-draft { background: #F1EEE7; color: #7A6A3A; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-muted);
  background: white;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-lg);
}

.field-builder-row { display: flex; gap: 10px; align-items: flex-start; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.field-builder-row .grow { flex: 1; }
.field-builder-actions { display: flex; gap: 6px; }
.iframe-snippet { background: var(--navy); color: #CFE8E8; padding: 12px; border-radius: 8px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }

.calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.calendar-nav { display: flex; align-items: center; gap: 10px; }
.calendar-nav h2 { margin: 0; font-size: 19px; color: var(--navy); min-width: 160px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.calendar-weekday { background: var(--bg); padding: 8px; text-align: center; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.calendar-day { background: white; min-height: 108px; padding: 6px; font-size: 12px; }
.calendar-day.is-outside { background: #FAFBFB; color: var(--text-muted); }
.calendar-day-number { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; font-weight: 700; margin-bottom: 4px; }
.calendar-day.is-today .calendar-day-number { background: linear-gradient(120deg, var(--navy-teal), var(--teal)); color: white; }
.calendar-day-link { float: right; font-size: 11px; color: var(--teal); }
.calendar-event { display: block; background: #E7F4F1; color: #10554F; border-radius: 5px; padding: 2px 6px; margin-bottom: 2px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calendar-event.is-public { background: #E9F0FB; color: #1E4E8C; }
.calendar-more summary { font-size: 11px; color: var(--text-muted); cursor: pointer; list-style: none; }
.calendar-more summary::-webkit-details-marker { display: none; }
