:root {
  /* ── Brand palette ── */
  --sage:        #A8C6B4;
  --sage-hover:  #8FB5A0;
  --sage-dark:   #4A7A65;
  --sage-deep:   #2D4A3E;
  --sage-light:  #D4E6DC;
  --sage-pale:   #EDF5F0;

  --cream:       #F5F1E8;
  --cream-dark:  #EDE7D6;

  --sand:        #E9DDC7;
  --sand-dark:   #D4C8A8;
  --sand-pale:   #F5F0E6;

  /* ── Semantic tokens ── */
  --color-primary:       var(--sage);
  --color-primary-hover: var(--sage-hover);
  --color-primary-dark:  var(--sage-dark);
  --color-primary-deep:  var(--sage-deep);
  --color-primary-light: var(--sage-light);
  --color-primary-pale:  var(--sage-pale);

  --color-bg:            var(--cream);
  --color-surface:       #FFFFFF;
  --color-surface-2:     #FDFCF8;
  --color-border:        var(--sand);
  --color-border-strong: var(--sand-dark);

  --color-text:          #2C3A30;
  --color-text-muted:    #6B7C6F;
  --color-text-light:    #A0B0A4;

  --color-success:       #4A9B70;
  --color-success-bg:    #E8F5EE;
  --color-warning:       #C9874A;
  --color-warning-bg:    #FBF0E4;
  --color-danger:        #B85454;
  --color-danger-bg:     #FAE8E8;
  --color-info:          #4A7A9B;
  --color-info-bg:       #E8F0F8;

  /* ── Layout ── */
  --sidebar-width: 260px;

  /* ── Radius ── */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  20px;
  --radius-2xl: 28px;

  /* ── Shadows (warm-tinted) ── */
  --shadow-xs: 0 1px 2px rgba(44,58,48,.05);
  --shadow-sm: 0 2px 8px rgba(44,58,48,.07);
  --shadow-md: 0 4px 20px rgba(44,58,48,.09);
  --shadow-lg: 0 10px 40px rgba(44,58,48,.12);

  /* ── Transition ── */
  --transition: 180ms ease;

  /* ── Font ── */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: var(--font-sans); }
input, select, textarea { font-family: var(--font-sans); }

/* ── Utilities ──────────────────────────────────────────────────────────── */
.hidden   { display: none !important; }
.text-muted   { color: var(--color-text-muted); }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.flex         { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center  { display: flex; align-items: center; }
.gap-1 { gap: 0.375rem; }
.gap-2 { gap: 0.625rem; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }
.mt-1  { margin-top: 0.5rem; }
.mt-2  { margin-top: 1rem; }
.mt-4  { margin-top: 2rem; }
.fw-600 { font-weight: 600; }

/* ── App shell ──────────────────────────────────────────────────────────── */
#app { height: 100vh; display: flex; overflow: hidden; }

/* ── Login ──────────────────────────────────────────────────────────────── */
.login-screen {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
  position: relative;
  overflow: hidden;
}

.login-screen::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--sage-light) 0%, transparent 70%);
  top: -200px;
  right: -150px;
  opacity: .5;
}
.login-screen::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--sand) 0%, transparent 70%);
  bottom: -100px;
  left: -100px;
  opacity: .5;
}

.login-card {
  background: var(--color-surface);
  border: 1px solid var(--sand);
  border-radius: var(--radius-2xl);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 2.25rem;
}
.login-logo .logo-mark {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--sage), var(--sage-dark));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  margin: 0 auto 1rem;
  box-shadow: 0 4px 12px rgba(74,122,101,.3);
}
.login-logo h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--color-text);
  letter-spacing: -.02em;
}
.login-logo p {
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  margin-top: 0.25rem;
}

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--sand);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition), width var(--transition);
  position: relative;
  z-index: 20;
}

.sidebar__logo {
  padding: 1.5rem 1.25rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--sand);
}

.logo-mark-sm {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--sage), var(--sage-dark));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(74,122,101,.25);
}

.logo-text {
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--color-text);
  letter-spacing: -.02em;
}

.sidebar__section {
  padding: 1.25rem 0.875rem 0.5rem;
}

.sidebar__section-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--color-text-light);
  padding: 0 0.5rem;
  margin-bottom: 0.375rem;
}

.sidebar__nav {
  padding: 0 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

.nav-item .nav-icon {
  font-size: 1.05rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--sage-pale);
  color: var(--color-text);
}

.nav-item.active {
  background: var(--sage-light);
  color: var(--sage-deep);
  font-weight: 600;
}

.nav-item.active .nav-icon { opacity: 1; }

.sidebar__footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--sand);
  margin-top: auto;
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.75rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sage-light), var(--sand));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--sage-deep);
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name  { font-size: 0.875rem; font-weight: 600; color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { font-size: 0.75rem; color: var(--color-text-muted); }

/* ── Mobile hamburger ───────────────────────────────────────────────────── */
.hamburger {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 30;
  width: 40px;
  height: 40px;
  background: var(--color-surface);
  border: 1px solid var(--sand);
  border-radius: var(--radius-md);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  flex-direction: column;
  gap: 5px;
  padding: 10px;
}

.hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
  transition: all var(--transition);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 15;
  backdrop-filter: blur(2px);
}

/* ── Main content ───────────────────────────────────────────────────────── */
#main-app { width: 100%; display: flex; height: 100vh; overflow: hidden; }

.main-content {
  flex: 1;
  overflow-y: auto;
  background: var(--color-bg);
}

#page-container {
  padding: 2rem 2.5rem;
  max-width: 1280px;
}

/* ── Page header ────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header__left h2 {
  font-size: 1.625rem;
  font-weight: 800;
  color: var(--color-text);
  letter-spacing: -.025em;
}

.page-header__left p {
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  margin-top: 0.2rem;
}

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius-lg);
  background: var(--color-text);
  color: white;
  box-shadow: var(--shadow-md);
  font-size: 0.875rem;
  font-weight: 500;
  max-width: 340px;
  pointer-events: all;
  border-left: 4px solid rgba(255,255,255,.3);
  animation: toastIn 220ms cubic-bezier(.34,1.56,.64,1);
}

.toast--success { background: var(--color-success); }
.toast--error   { background: var(--color-danger); }
.toast--warning { background: var(--color-warning); }

@keyframes toastIn {
  from { transform: translateX(110%) scale(.9); opacity: 0; }
  to   { transform: translateX(0) scale(1); opacity: 1; }
}

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44,58,48,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  backdrop-filter: blur(4px);
  animation: fadeIn 150ms ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: 2rem;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: modalIn 200ms cubic-bezier(.34,1.3,.64,1);
  border: 1px solid var(--sand);
}

@keyframes modalIn {
  from { transform: scale(.95) translateY(8px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal__close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: var(--sand-pale);
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  cursor: pointer;
  color: var(--color-text-muted);
  line-height: 1;
  padding: 0.375rem 0.5rem;
  transition: background var(--transition), color var(--transition);
}
.modal__close:hover { background: var(--sand); color: var(--color-text); }

.modal h3 {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--color-text);
  letter-spacing: -.015em;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .hamburger { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.visible { display: block; }

  .main-content { margin-left: 0; }

  #page-container {
    padding: 4.5rem 1.25rem 1.5rem;
  }
}

@media (max-width: 600px) {
  .page-header { flex-direction: column; }
  .modal { padding: 1.5rem; }
}
