/* SmartForage Intranet — Design Tokens & Styles */

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

/* ========================================
   DESIGN TOKENS
   ======================================== */
:root {
  /* Brand Colors */
  --color-primary: #8250C4;
  --color-primary-hover: #7040B0;
  --color-primary-light: rgba(130, 80, 196, 0.12);
  --color-accent: #99CC00;
  --color-accent-hover: #88B800;
  --color-accent-light: rgba(153, 204, 0, 0.12);
  --color-accent-muted: rgba(153, 204, 0, 0.7);

  /* Sidebar / Dark surfaces */
  --color-sidebar-bg: #2D2233;
  --color-sidebar-hover: rgba(255, 255, 255, 0.06);
  --color-sidebar-active: rgba(153, 204, 0, 0.12);
  --color-sidebar-text: rgba(255, 255, 255, 0.65);
  --color-sidebar-text-active: #99CC00;
  --color-sidebar-border: rgba(255, 255, 255, 0.08);

  /* Content area — light */
  --color-bg: #F5F4F7;
  --color-surface: #FFFFFF;
  --color-surface-2: #F9F8FB;
  --color-border: rgba(0, 0, 0, 0.08);
  --color-border-strong: rgba(0, 0, 0, 0.14);

  /* Text */
  --color-text: #1A1523;
  --color-text-muted: #6B6480;
  --color-text-faint: #9B95AD;
  --color-text-inverse: #FFFFFF;

  /* Semantic */
  --color-success: #22C55E;
  --color-warning: #F59E0B;
  --color-error: #EF4444;
  --color-info: #3B82F6;

  /* Type Scale */
  --text-xs: clamp(0.6875rem, 0.65rem + 0.1vw, 0.75rem);    /* ~11-12px */
  --text-sm: clamp(0.8125rem, 0.78rem + 0.1vw, 0.875rem);    /* ~13-14px */
  --text-base: clamp(0.875rem, 0.84rem + 0.12vw, 0.9375rem);  /* ~14-15px */
  --text-lg: clamp(1.0625rem, 1rem + 0.2vw, 1.1875rem);       /* ~17-19px */
  --text-xl: clamp(1.25rem, 1.15rem + 0.35vw, 1.5rem);        /* ~20-24px */
  --text-2xl: clamp(1.5rem, 1.35rem + 0.5vw, 1.875rem);       /* ~24-30px */

  /* Spacing (4px grid) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Layout */
  --sidebar-width: 240px;
  --header-height: 56px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 150ms var(--ease-out);
  --transition-normal: 250ms var(--ease-out);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* ========================================
   BASE RESET
   ======================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums lining-nums;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  overflow-x: hidden;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-hover);
}

img { max-width: 100%; display: block; }

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-base); font-weight: 600; }

/* ========================================
   LAYOUT: SIDEBAR + CONTENT
   ======================================== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition-normal);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--color-sidebar-border);
}

.sidebar-logo svg {
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text-inverse);
  letter-spacing: -0.02em;
}

.sidebar-nav {
  padding: var(--space-3) var(--space-3);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-sidebar-text);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.sidebar-nav a:hover {
  background: var(--color-sidebar-hover);
  color: var(--color-text-inverse);
}

.sidebar-nav a.active {
  background: var(--color-sidebar-active);
  color: var(--color-sidebar-text-active);
}

.sidebar-nav a svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-nav a.active svg {
  opacity: 1;
}

.sidebar-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-sidebar-border);
  font-size: var(--text-xs);
  color: var(--color-sidebar-text);
}

.sidebar-footer a {
  color: var(--color-sidebar-text);
  text-decoration: none;
}

.sidebar-footer a:hover {
  color: var(--color-text-inverse);
}

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-4) var(--space-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 50;
}

.content-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.content-header h1 {
  font-size: var(--text-lg);
  font-weight: 600;
}

.content-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.content-body {
  padding: var(--space-6) var(--space-8);
  flex: 1;
}

/* ---- Mobile hamburger ---- */
.mobile-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.mobile-toggle:hover {
  background: var(--color-border);
}

.mobile-toggle svg {
  width: 24px;
  height: 24px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

/* ========================================
   COMPONENT: CARDS
   ======================================== */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-sm);
}

.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.card-link:hover {
  color: inherit;
}

.card-link .card {
  cursor: pointer;
}

.card-link:hover .card {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-3);
}

.card-icon svg {
  width: 20px;
  height: 20px;
}

.card-icon.purple {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.card-icon.green {
  background: var(--color-accent-light);
  color: #6B8F00;
}

.card-icon.blue {
  background: rgba(59, 130, 246, 0.1);
  color: var(--color-info);
}

.card h3 {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.card p {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* ========================================
   COMPONENT: GRID LAYOUTS
   ======================================== */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}

/* ========================================
   COMPONENT: SECTION HEADER
   ======================================== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.section-header h2 {
  font-size: var(--text-lg);
  font-weight: 600;
}

.section-header .badge {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  padding: var(--space-1) var(--space-3);
  border-radius: 100px;
  font-weight: 500;
}

/* ========================================
   COMPONENT: ANNOUNCEMENT ITEMS
   ======================================== */
.announcement-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-4);
}

.announcement-item .date {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-bottom: var(--space-2);
  font-weight: 500;
}

.announcement-item h3 {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.announcement-item p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.65;
  max-width: 72ch;
}

/* ========================================
   COMPONENT: TEAM CARDS
   ======================================== */
.team-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-3);
}

.team-card .avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text-inverse);
  flex-shrink: 0;
}

.team-card .name {
  font-size: var(--text-base);
  font-weight: 600;
}

.team-card .role {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.team-card .contact-placeholder {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-top: var(--space-1);
}

.team-card.placeholder {
  border-style: dashed;
  border-color: var(--color-border-strong);
  background: var(--color-surface-2);
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.team-card.placeholder:hover {
  border-color: var(--color-primary);
}

.team-card.placeholder .avatar {
  background: var(--color-border);
  color: var(--color-text-faint);
}

/* ========================================
   COMPONENT: ACCORDION / SOP SECTIONS
   ======================================== */
.accordion {
  margin-bottom: var(--space-4);
}

.accordion-header {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  width: 100%;
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.accordion-header:hover {
  background: var(--color-surface-2);
}

.accordion-header.open {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: transparent;
}

.accordion-header svg {
  width: 20px;
  height: 20px;
  transition: transform var(--transition-fast);
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.accordion-header.open svg {
  transform: rotate(180deg);
}

.accordion-body {
  border: 1px solid var(--color-border);
  border-top: none;
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
  background: var(--color-surface);
  overflow: hidden;
  max-height: 0;
  transition: max-height var(--transition-normal);
}

.accordion-body.open {
  max-height: 600px;
}

.accordion-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  cursor: default;
  transition: background var(--transition-fast);
}

.accordion-item:last-child {
  border-bottom: none;
}

.accordion-item:hover {
  background: var(--color-surface-2);
}

.accordion-item .item-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.accordion-item .item-title svg {
  width: 16px;
  height: 16px;
  color: var(--color-text-faint);
}

.accordion-item .item-status {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-style: italic;
}

/* ========================================
   COMPONENT: LINK CARDS
   ======================================== */
.link-category {
  margin-bottom: var(--space-8);
}

.link-category h3 {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: var(--space-3);
  color: var(--color-text);
}

.link-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.link-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
  color: inherit;
}

.link-card.disabled {
  opacity: 0.6;
  cursor: default;
  pointer-events: none;
}

.link-card .link-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.link-card .link-icon svg {
  width: 20px;
  height: 20px;
}

.link-card .link-info h4 {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: 2px;
}

.link-card .link-info p {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ========================================
   COMPONENT: IFRAME CONTAINER
   ======================================== */
.iframe-wrapper {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.iframe-wrapper iframe {
  flex: 1;
  width: 100%;
  border: none;
  min-height: calc(100vh - var(--header-height) - 140px);
}

.iframe-note {
  padding: var(--space-3) var(--space-5);
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.iframe-note svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ========================================
   COMPONENT: QUICK STAT
   ======================================== */
.stat-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.stat-row .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-accent);
}

/* ========================================
   COMPONENT: FOOTER
   ======================================== */
.site-footer {
  padding: var(--space-4) var(--space-8);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-align: center;
  margin-top: auto;
}

.site-footer a {
  color: var(--color-text-faint);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--color-text-muted);
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

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

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

  .mobile-toggle {
    display: flex;
  }

  .content-header {
    padding: var(--space-3) var(--space-4);
  }

  .content-body {
    padding: var(--space-4);
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .site-footer {
    padding: var(--space-4);
  }
}

@media (max-width: 480px) {
  .content-header h1 {
    font-size: var(--text-base);
  }
}

/* ========================================
   AUTH: LOGIN PAGE
   ======================================== */
.login-page {
  background: var(--color-sidebar-bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  justify-content: center;
}

.login-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-6);
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  justify-content: center;
  margin-bottom: var(--space-6);
}

.login-logo-text {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.login-title {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: var(--space-6);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.login-error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--color-error);
  font-size: var(--text-xs);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
}

.login-footer {
  margin-top: var(--space-8);
  font-size: var(--text-xs);
}

.login-footer a {
  color: rgba(255, 255, 255, 0.4);
  text-decoration: none;
}

.login-footer a:hover {
  color: rgba(255, 255, 255, 0.7);
}

/* ========================================
   FORMS (shared)
   ======================================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.form-group label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: 0.01em;
}

.form-group input,
.form-group select,
.form-group textarea {
  font-family: inherit;
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-group input::placeholder {
  color: var(--color-text-faint);
}

.form-group select {
  cursor: pointer;
}

.form-error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--color-error);
  font-size: var(--text-xs);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
}

.form-inline {
  flex-direction: row;
  align-items: center;
  gap: var(--space-3);
}

.input-sm {
  font-family: inherit;
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
}

.input-sm:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
}

.btn-ghost:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.btn-danger {
  background: var(--color-error);
  color: var(--color-text-inverse);
}

.btn-danger:hover {
  background: #DC2626;
}

.btn-sm {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-3);
}

.btn-full {
  width: 100%;
  justify-content: center;
  padding: var(--space-3) var(--space-4);
}

.btn-danger-text {
  color: var(--color-error);
}

.btn-danger-text:hover {
  background: rgba(239, 68, 68, 0.08);
  color: var(--color-error);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.btn-icon-danger:hover {
  background: rgba(239, 68, 68, 0.08);
  color: var(--color-error);
}

/* ========================================
   HEADER: USER + LOGOUT
   ======================================== */
.header-user {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
}

/* ========================================
   SIDEBAR: ADMIN SECTION
   ======================================== */
.sidebar-admin-section {
  margin-top: var(--space-2);
}

.sidebar-divider {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-sidebar-text);
  opacity: 0.5;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--space-3) var(--space-3) var(--space-1);
  margin-top: var(--space-2);
  border-top: 1px solid var(--color-sidebar-border);
}

/* ========================================
   ADMIN: TABLES
   ======================================== */
.admin-table-wrapper {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.admin-table thead {
  background: var(--color-surface-2);
}

.admin-table th {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table tbody tr:hover {
  background: var(--color-surface-2);
}

.admin-table .actions-cell {
  text-align: right;
  display: flex;
  gap: var(--space-1);
  justify-content: flex-end;
}

.table-input {
  font-family: inherit;
  font-size: var(--text-sm);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%;
  outline: none;
  transition: border-color var(--transition-fast);
}

.table-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-light);
}

/* ========================================
   ROLE BADGES
   ======================================== */
.role-badge {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 2px var(--space-2);
  border-radius: 100px;
  white-space: nowrap;
}

.role-admin {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.role-staff {
  background: var(--color-accent-light);
  color: #5B8A00;
}

.role-viewer {
  background: var(--color-surface-2);
  color: var(--color-text-faint);
}

/* ========================================
   MODALS
   ======================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  transition: opacity 200ms ease;
}

.modal-overlay.modal-open {
  opacity: 1;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(8px);
  transition: transform 200ms var(--ease-out);
}

.modal-open .modal {
  transform: translateY(0);
}

.modal-sm {
  max-width: 400px;
}

.modal-lg {
  max-width: 640px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.modal-header h3 {
  font-size: var(--text-base);
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: var(--text-xl);
  color: var(--color-text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.modal-close:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.modal-body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.modal-body p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding-top: var(--space-3);
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */
.sf-toast {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  background: var(--color-text);
  color: var(--color-text-inverse);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  transform: translateY(16px);
  opacity: 0;
  transition: transform 300ms var(--ease-out), opacity 300ms ease;
  max-width: 400px;
}

.sf-toast-show {
  transform: translateY(0);
  opacity: 1;
}

.sf-toast-success {
  background: #1A1523;
}

.sf-toast-error {
  background: var(--color-error);
}

/* ========================================
   ADMIN: SOP EDITOR
   ======================================== */
.sop-admin-category {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
  overflow: hidden;
}

.sop-admin-cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.sop-admin-cat-header h3 {
  font-size: var(--text-base);
  font-weight: 600;
}

.sop-admin-cat-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.sop-admin-doc-list {
  /* container for docs */
}

.sop-admin-doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition-fast);
}

.sop-admin-doc-item:last-child {
  border-bottom: none;
}

.sop-admin-doc-item:hover {
  background: var(--color-surface-2);
}

.sop-admin-doc-info {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  min-width: 0;
  flex: 1;
}

.sop-admin-doc-info svg {
  flex-shrink: 0;
  color: var(--color-text-faint);
}

.sop-admin-doc-actions {
  display: flex;
  gap: var(--space-1);
  flex-shrink: 0;
}

.sop-admin-doc-empty {
  padding: var(--space-4) var(--space-5);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-style: italic;
}

.sop-status-badge {
  font-size: var(--text-xs);
  padding: 1px var(--space-2);
  border-radius: 100px;
  font-weight: 500;
  flex-shrink: 0;
  margin-left: var(--space-2);
}

.sop-status-written {
  background: var(--color-accent-light);
  color: #5B8A00;
}

.sop-status-empty {
  background: var(--color-surface-2);
  color: var(--color-text-faint);
}

/* Editor */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border-strong);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.editor-btn {
  background: none;
  border: none;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  transition: background var(--transition-fast);
}

.editor-btn:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.editor-sep {
  width: 1px;
  height: 20px;
  background: var(--color-border-strong);
  margin: 0 var(--space-1);
}

.editor-content {
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--color-border-strong);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-family: inherit;
  font-size: var(--text-sm);
  line-height: 1.65;
  color: var(--color-text);
  outline: none;
}

.editor-content:focus {
  border-color: var(--color-primary);
}

.editor-content h2 {
  font-size: var(--text-lg);
  margin: var(--space-3) 0 var(--space-2);
}

.editor-content ul, .editor-content ol {
  padding-left: var(--space-5);
  margin: var(--space-2) 0;
}

/* ========================================
   ADMIN: CONFIG SECTIONS
   ======================================== */
.admin-section {
  margin-bottom: var(--space-8);
}

.admin-section-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.admin-note {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-style: italic;
}

.config-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.config-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.config-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot-green {
  background: var(--color-success);
}

.status-dot-red {
  background: var(--color-error);
}

/* ========================================
   EMPTY STATE
   ======================================== */
.empty-state {
  background: var(--color-surface);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-10) var(--space-6);
  text-align: center;
}

.empty-state p {
  color: var(--color-text-faint);
  font-size: var(--text-sm);
}

/* ========================================
   SOP VIEWER OVERLAY
   ======================================== */
.sop-viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  transition: opacity 200ms ease;
}

.sop-viewer-overlay.sop-viewer-open {
  opacity: 1;
}

.sop-viewer {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  overflow-y: auto;
  transform: translateY(8px);
  transition: transform 200ms var(--ease-out);
}

.sop-viewer-overlay.sop-viewer-open .sop-viewer {
  transform: translateY(0);
}

.sop-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.sop-viewer-header h3 {
  font-size: var(--text-lg);
  font-weight: 600;
}

.sop-viewer-body {
  padding: var(--space-5) var(--space-6);
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--color-text);
}

.sop-viewer-body h2 {
  font-size: var(--text-lg);
  margin: var(--space-4) 0 var(--space-2);
}

.sop-viewer-body ul, .sop-viewer-body ol {
  padding-left: var(--space-5);
  margin: var(--space-2) 0;
}

.sop-viewer-body p {
  margin: var(--space-2) 0;
}

/* ========================================
   RESPONSIVE: ADMIN
   ======================================== */
@media (max-width: 768px) {
  .admin-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .admin-table {
    min-width: 500px;
  }

  .sop-admin-cat-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .admin-section-meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal {
    margin: var(--space-4);
  }

  .modal-lg {
    max-width: 100%;
  }

  .sf-toast {
    left: var(--space-4);
    right: var(--space-4);
    bottom: var(--space-4);
    max-width: none;
  }
}
