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

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
}

html {
  font-size: 16px;
  font-family: var(--font-family);
  color: var(--color-ink);
  background-color: var(--color-canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--color-canvas);
  color: var(--color-ink);
  line-height: 1.45;
  padding-bottom: calc(var(--bottom-nav-height) + 16px);
}

/* SVG Vector Icon Styling */
.svg-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

/* App Container */
.app-container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 12px;
}

@media (min-width: 480px) {
  .app-container {
    padding: 0 16px;
  }
}

@media (min-width: 768px) {
  .app-container {
    padding: 0 24px;
  }
}

/* Typography Hierarchy per DESIGN.md */
.display-xl {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-ink);
  letter-spacing: -0.4px;
}

.display-lg {
  font-size: 19px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--color-ink);
  letter-spacing: -0.3px;
}

.display-md {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-ink);
}

@media (min-width: 640px) {
  .display-xl { font-size: 28px; }
  .display-lg { font-size: 22px; }
  .display-md { font-size: 19px; }
}

.title-md {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--color-ink);
}

.title-sm {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-ink);
}

.body-md {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--color-body);
}

.body-sm {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--color-body);
}

.caption {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--color-muted);
}

.caption-sm {
  font-size: 11px;
  font-weight: 400;
  line-height: 1.25;
  color: var(--color-muted-soft);
}

.micro-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Compact, Professional Header (52px) */
.app-header {
  height: var(--header-height);
  background-color: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-hairline);
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
}

.brand-logo-mark {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 2px 4px rgba(255, 56, 92, 0.25));
  flex-shrink: 0;
}

.brand-title-group {
  display: flex;
  flex-direction: column;
}

.brand-title-main {
  font-size: 15px;
  font-weight: 800;
  color: var(--color-ink);
  letter-spacing: -0.3px;
  line-height: 1;
}

.brand-title-accent {
  color: var(--color-primary);
}

.brand-title-tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--color-muted);
  line-height: 1;
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Header Avatar / Persona Trigger */
.header-profile-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--color-surface-soft);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-full);
  padding: 3px 10px 3px 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.header-profile-btn:active {
  transform: scale(0.96);
  background-color: var(--color-surface-strong);
}

.header-profile-avatar {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  background-color: var(--color-ink);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  position: relative;
}

.role-indicator-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  border: 1.5px solid #ffffff;
}

.role-indicator-dot.super_admin { background-color: #8b5cf6; }
.role-indicator-dot.admin { background-color: #0ea5e9; }
.role-indicator-dot.data_registrar { background-color: #f59e0b; }

.header-profile-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-ink);
  max-width: 90px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 480px) {
  .header-profile-name {
    max-width: 130px;
  }
}

/* Bottom Tab Navigation Bar (Mobile) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--color-hairline);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 40;
  padding: 0 4px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.03);
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--color-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 0;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
}

.nav-tab .svg-icon {
  margin-bottom: 2px;
  transition: transform 0.15s ease, stroke 0.15s ease;
}

.nav-tab.active {
  color: var(--color-primary);
  font-weight: 700;
}

.nav-tab.active .svg-icon {
  stroke: var(--color-primary);
  transform: translateY(-1px);
}

/* Desktop Navigation */
.desktop-nav {
  display: none;
  gap: 4px;
  margin-left: 20px;
}

@media (min-width: 768px) {
  .desktop-nav {
    display: flex;
    align-items: center;
  }
}

.desktop-nav-link {
  text-decoration: none;
  color: var(--color-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  transition: all 0.15s ease;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.desktop-nav-link:hover {
  color: var(--color-ink);
  background-color: var(--color-surface-soft);
}

.desktop-nav-link.active {
  color: var(--color-ink);
  font-weight: 700;
  background-color: var(--color-surface-soft);
}

/* View Sections */
.view-section {
  display: none;
  padding-top: var(--spacing-sm);
  padding-bottom: var(--spacing-xl);
  animation: fadeIn 0.15s ease-out;
  width: 100%;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}
