:root {
  --cr-cyan: #009EE2;
  --cr-blue-light: #5BC4F1;
  --cr-blue: #006EB7;
  --cr-blue-dark: #004884;
  --cr-gray-50: #EDECE6;
  --cr-gray-300: #B5B5B5;
  --cr-gray-500: #7F7F7F;
  --cr-gray-800: #4C4C4C;
  --cr-t-purple: #A763A4;
  --cr-t-coral: #E05469;
  --cr-t-yellow: #DDDF4A;
  --cr-t-mint: #8ACAC1;
  --cr-esg: #00998C;
  --cr-bg: #FFFFFF;
  --cr-surface: #FFFFFF;
  --cr-text: #4C4C4C;
  --cr-text-strong: #004884;
  --cr-border: #E1E5E8;
  --cr-success: #00998C;
  --cr-error: #E05469;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(0,72,132,.06), 0 1px 3px rgba(0,72,132,.08);
  --shadow-md: 0 4px 12px rgba(0,72,132,.10);
  --shadow-lg: 0 12px 32px rgba(0,72,132,.14);
  --ease: cubic-bezier(.4,0,.2,1);
  --dur-fast: 140ms;
  --dur: 240ms;
  --font-body: "Open Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Open Sans", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--cr-text);
  background: var(--cr-gray-50);
  line-height: 1.55;
  min-height: 100vh;
}
a { color: var(--cr-cyan); text-decoration: none; transition: color var(--dur-fast) var(--ease); }
a:hover { color: var(--cr-blue); }
h1, h2, h3 { color: var(--cr-text-strong); font-family: var(--font-display); line-height: 1.2; }
h1 { font-size: clamp(1.75rem, 4vw, 2.25rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.75rem); }

.topbar {
  background: var(--cr-blue-dark);
  color: #fff;
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}
.brand { font-weight: 700; font-size: 1.25rem; color: #fff; }
.brand-crefo { color: var(--cr-cyan); }
.brand-mail { color: #fff; }
.topbar nav a { color: rgba(255,255,255,.85); margin-left: 1rem; font-size: .9rem; }
.topbar nav a:hover { color: #fff; }
.topbar-user { font-size: .875rem; opacity: .9; }

.app-shell { display: flex; min-height: calc(100vh - 120px); }
.sidebar {
  width: 220px;
  background: var(--cr-surface);
  border-right: 1px solid var(--cr-border);
  padding: 1rem 0;
  flex-shrink: 0;
}
.sidebar a {
  display: block;
  padding: .6rem 1.25rem;
  color: var(--cr-text);
  border-left: 3px solid transparent;
  transition: all var(--dur-fast) var(--ease);
}
.sidebar a:hover, .sidebar a.active {
  background: rgba(91,196,241,.12);
  border-left-color: var(--cr-cyan);
  color: var(--cr-blue-dark);
}
.main-content { flex: 1; padding: 1.5rem; max-width: 1200px; }

.card {
  background: var(--cr-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--cr-cyan);
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--cr-text-strong);
}
.stat-label { font-size: .875rem; color: var(--cr-gray-500); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .6rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: .9rem;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  font-family: inherit;
}
.btn-primary {
  background: var(--cr-cyan);
  color: #fff;
  border-color: var(--cr-cyan);
}
.btn-primary:hover {
  background: var(--cr-blue);
  border-color: var(--cr-blue);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
  background: transparent;
  color: var(--cr-cyan);
  border-color: var(--cr-cyan);
}
.btn-secondary:hover { background: rgba(0,158,226,.08); }
.btn-danger { background: var(--cr-error); color: #fff; border-color: var(--cr-error); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-text { background: none; border: none; color: var(--cr-blue); padding: .25rem .5rem; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .9rem; }
.form-control {
  width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--cr-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.form-control:focus {
  outline: none;
  border-color: var(--cr-cyan);
  box-shadow: 0 0 0 3px rgba(0,158,226,.2);
}
.form-error { color: var(--cr-error); font-size: .85rem; margin-top: .25rem; }
.form-hint { color: var(--cr-gray-500); font-size: .85rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--cr-border); }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--cr-gray-500); }
tr:hover td { background: rgba(91,196,241,.06); }

.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}
.alert-success { background: rgba(0,153,140,.12); color: var(--cr-success); border: 1px solid rgba(0,153,140,.3); }
.alert-error { background: rgba(224,84,105,.1); color: var(--cr-error); border: 1px solid rgba(224,84,105,.3); }
.alert-info { background: rgba(0,158,226,.1); color: var(--cr-blue); border: 1px solid rgba(0,158,226,.3); }

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
}
.toast {
  background: var(--cr-blue-dark);
  color: #fff;
  padding: .75rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  margin-top: .5rem;
  animation: toast-in var(--dur) var(--ease);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.guest-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.guest-card {
  width: 100%;
  max-width: 420px;
  background: var(--cr-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
}
.guest-card h1 { text-align: center; margin-top: 0; }

.footer {
  text-align: center;
  padding: 1rem;
  font-size: .8rem;
  color: var(--cr-gray-500);
}

.signal-pulse {
  position: relative;
  display: inline-block;
  width: 12px;
  height: 12px;
}
.signal-pulse::before, .signal-pulse::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--cr-cyan);
}
.signal-pulse::after {
  animation: signal-ring 2s var(--ease) infinite;
}
@keyframes signal-ring {
  0% { transform: scale(1); opacity: .6; }
  100% { transform: scale(3); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .signal-pulse::after { animation: none; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.pw-rules { list-style: none; padding: 0; margin: .5rem 0; font-size: .85rem; }
.pw-rules li::before { content: '○ '; color: var(--cr-gray-300); }
.pw-rules li.valid::before { content: '✓ '; color: var(--cr-success); }

.cta-link-box {
  display: flex;
  gap: .5rem;
  margin-top: 1rem;
}
.cta-link-box input { flex: 1; font-family: monospace; font-size: .85rem; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--cr-gray-500);
}

.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }
.toolbar .form-control { width: auto; min-width: 200px; }

@media (max-width: 768px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--cr-border); }
  .sidebar a { display: inline-block; padding: .5rem 1rem; border-left: none; border-bottom: 2px solid transparent; }
}
