@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;600;700&display=swap');

:root {
  /* Surfaces */
  --bg-base: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;

  /* Borders */
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-active: #0d9488;
  --border-glow: 0 0 0 3px rgba(13, 148, 136, 0.14);

  /* Zensia teal */
  --primary: #0d9488;
  --primary-hover: #0f766e;
  --primary-subtle: #f0fdfa;
  --primary-border: #b6f0e6;
  --primary-light: #14b8a6;
  --primary-gradient: linear-gradient(135deg, #14b8a6 0%, #0d9488 52%, #0e7490 100%);

  --accent-indigo: #4f46e5;
  --accent-cyan: #0284c7;

  /* Status Tokens */
  --emerald: #059669;
  --emerald-bg: #ecfdf5;
  --emerald-border: #a7f3d0;
  --emerald-text: #065f46;

  --amber: #d97706;
  --amber-bg: #fffbeb;
  --amber-border: #fde68a;
  --amber-text: #92400e;

  --rose: #e11d48;
  --rose-bg: #fff1f2;
  --rose-border: #fecdd3;
  --rose-text: #9f1239;

  --slate-bg: #f1f5f9;
  --slate-border: #e2e8f0;
  --slate-text: #475569;

  /* Type */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;

  /* Elevation */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.06), 0 1px 2px -1px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

/* Login screen */
.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.login-card {
  width: 400px;
  max-width: 100%;
  padding: 40px 36px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.login-logo-img {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  margin: 0 auto 18px;
  display: block;
  object-fit: cover;
  box-shadow: 0 6px 16px rgba(13, 148, 136, 0.3);
}

.brand-icon {
  width: 52px;
  height: 52px;
  background: var(--primary-gradient);
  color: #fff;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  box-shadow: 0 6px 14px rgba(13, 148, 136, 0.25);
}

h1 { font-size: 1.35rem; font-weight: 800; margin: 0 0 6px; color: var(--text-primary); letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; font-weight: 700; margin: 0 0 4px; color: var(--text-primary); }
p.subtitle { color: var(--text-muted); font-size: 0.86rem; margin: 0 0 28px; }

label {
  display: block;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 6px;
  text-align: left;
}

.field { margin-bottom: 16px; }

input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: #ffffff;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-sans);
  outline: none;
  transition: all .15s ease;
}

textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--border-active);
  box-shadow: var(--border-glow);
}

button {
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all .15s ease;
  font-family: var(--font-sans);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(13, 148, 136, 0.25);
  padding: 10px 18px;
}
.btn-primary:hover {
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.35);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }

.btn-secondary {
  background: #ffffff;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  padding: 9px 15px;
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.btn-secondary:active { background: #e2e8f0; }

.btn-danger {
  background: var(--rose-bg);
  color: var(--rose-text);
  border: 1px solid var(--rose-border);
  padding: 9px 15px;
  font-weight: 700;
}
.btn-danger:hover {
  background: #ffe4e6;
  border-color: #fda4af;
}

.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 0.8rem; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }

.error-msg { color: var(--rose); font-size: 0.82rem; margin-top: 12px; min-height: 1em; font-weight: 600; }
.result-msg { font-size: 0.82rem; margin-top: 10px; min-height: 1em; color: var(--text-muted); }
.result-msg.ok { color: var(--emerald-text); font-weight: 700; }
.result-msg.err { color: var(--rose-text); font-weight: 700; }

/* App layout */
.app { display: flex; min-height: 100vh; background: #f8fafc; }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: 1px 0 4px rgba(0, 0, 0, 0.02);
  z-index: 20;
}

.sidebar-brand-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 20px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}
.sidebar-logo-img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  object-fit: cover;
  box-shadow: 0 4px 10px rgba(13, 148, 136, 0.25);
}
.sidebar-brand-text {
  display: flex;
  flex-direction: column;
}
.brand-name {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.2;
}
.brand-tagline {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  margin-top: 2px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.86rem;
  transition: all .15s ease;
  border: 1px solid transparent;
}
.nav-item:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}
.nav-item.active {
  background: #f0fdfa;
  color: var(--primary);
  border-color: rgba(182, 240, 230, 0.7);
  font-weight: 700;
}
.nav-item.active .nav-icon {
  color: var(--primary);
}
.nav-icon {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-profile-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
}
.user-avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #0f766e;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-info-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.user-role-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.user-email-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-signout {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 7px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all .15s ease;
  width: 100%;
}
.btn-signout:hover {
  background: #fff1f2;
  border-color: #fecdd3;
  color: var(--rose-text);
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 24px 36px 60px;
  max-width: 1380px;
}

/* Global Top Navigation Bar */
.topbar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 20px;
  flex-wrap: wrap;
}
.topbar-title-wrap {
  flex: 1;
  min-width: 280px;
}
.page-title {
  font-size: 1.55rem;
  font-weight: 800;
  margin: 0 0 4px;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}
.title-highlight {
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.page-sub {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.global-search-pill {
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 6px 14px;
  gap: 8px;
  width: 290px;
  box-shadow: var(--shadow-xs);
  transition: border-color .15s ease;
}
.global-search-pill:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}
.global-search-pill input {
  border: none;
  background: transparent;
  padding: 0;
  font-size: 0.82rem;
  outline: none;
  width: 100%;
}
.kbd-badge {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.68rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.icon-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: all .15s ease;
  box-shadow: var(--shadow-xs);
}
.icon-action-btn:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}
.notification-dot-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  background: var(--rose);
  color: #ffffff;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
}
.status-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  margin-right: 3px;
}

.live-clock-badge {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 7px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  box-shadow: var(--shadow-xs);
  white-space: nowrap;
}

.breadcrumb { font-size: 0.84rem; color: var(--text-muted); margin-bottom: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.breadcrumb:hover { color: var(--primary-hover); }

/* Panels & Grid */
.panel { padding: 24px 28px; }
.panel .desc { font-size: 0.82rem; color: var(--text-secondary); margin: 0 0 18px; line-height: 1.45; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 12px; align-items: flex-end; }
.row .field { flex: 1; margin-bottom: 0; }

