/* SOP SYSTEM: Shared Styles */
/* Same component system as Business OS, purple accent so the two read as sister products. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --bg: #f8fafc;
  --sidebar: #1e1b2e;
  --sidebar-hover: #2d2a42;
  --sidebar-active: #7c3aed;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --card: #ffffff;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --amber: #d97706;
  --amber-bg: #fef3c7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --blue: #7c3aed;
  --blue-bg: #ede9fe;
  --grey: #64748b;
  --grey-bg: #f1f5f9;
  --orange: #ea580c;
  --orange-bg: #ffedd5;
}

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  height: 100%;
}

/* ── LAYOUT ── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid #2d2a42;
}
.sidebar-logo .logo-mark {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.sidebar-logo .org-name {
  font-size: 11px;
  color: #a78bfa;
  margin-top: 2px;
  line-height: 1.4;
}

.sidebar-section { padding: 16px 0 8px; }
.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #6d6889;
  padding: 0 16px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: #a8a3c4;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s;
  cursor: pointer;
}
.nav-item:hover { background: var(--sidebar-hover); color: #ede9fe; }
.nav-item.active { background: var(--sidebar-hover); color: #fff; border-left-color: var(--sidebar-active); }
.nav-item .nav-icon { width: 16px; text-align: center; flex-shrink: 0; }

/* ── MAIN ── */
.main-area { flex: 1; display: flex; flex-direction: column; overflow-y: auto; }

.topbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.page-title { font-size: 15px; font-weight: 600; }
.period-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--blue-bg);
  color: var(--blue);
}

.org-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 4px;
  background: #1e1b2e;
  color: #fff;
  letter-spacing: .03em;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

.role-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
}
.role-switcher label { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.role-switcher select {
  font-size: 12px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  outline: none;
  font-family: inherit;
}

.notif-btn {
  position: relative;
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  color: var(--text-muted);
}
.notif-badge {
  position: absolute;
  top: -4px; right: -4px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.page-content,
#page-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px 56px;
}

/* ── CARDS ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.card-title { font-size: 14px; font-weight: 700; color: var(--text); }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ── STAT CARDS ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.stat-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 10px;
}
.stat-value { font-size: 32px; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.stat-sub   { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

.stat-card.green { border-top: 3px solid var(--green); background: #f0fdf4; }
.stat-card.green .stat-label { color: #15803d; }

.stat-card.amber { border-top: 3px solid var(--amber); background: #fffbeb; }
.stat-card.amber .stat-label { color: #b45309; }

.stat-card.red   { border-top: 3px solid var(--red); background: #fef2f2; }
.stat-card.red   .stat-label { color: #b91c1c; }

.stat-card.blue  { border-top: 3px solid var(--blue); background: #f5f3ff; }
.stat-card.blue  .stat-label { color: #6d28d9; }

/* ── STATUS BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.badge::before { content: '●'; font-size: 8px; }
.badge.green   { background: var(--green-bg);  color: var(--green);  }
.badge.amber   { background: var(--amber-bg);  color: var(--amber);  }
.badge.red     { background: var(--red-bg);    color: var(--red);    }
.badge.grey    { background: var(--grey-bg);   color: var(--grey);   }
.badge.missing { background: var(--grey-bg);   color: var(--grey);   }
.badge.late    { background: var(--orange-bg); color: var(--orange); }
.badge.submitted{ background: var(--blue-bg);  color: var(--blue);   }
.badge.approved { background: var(--green-bg); color: var(--green);  }
.badge.locked   { background: #f1f5f9; color: #475569; }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  text-align: left;
  padding: 9px 14px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  color: var(--text);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
  text-decoration: none;
  transition: all .15s;
}
.btn-primary   { background: var(--blue);  color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: #6d28d9; }
.btn-secondary { background: var(--card); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger    { background: var(--red);   color: #fff; border-color: var(--red); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── GRID HELPERS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.flex  { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: 12px; }
.text-xs    { font-size: 11px; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

/* ── PROGRESS BAR ── */
.progress-bar { height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width .4s ease; }
.progress-fill.green { background: var(--green); }
.progress-fill.amber { background: var(--amber); }
.progress-fill.red   { background: var(--red);   }

/* ── DATA ROWS ── */
.data-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  background: var(--bg);
  border-radius: 7px;
  border: 1px solid var(--border);
  gap: 12px;
}
.data-row + .data-row { margin-top: 6px; }
.data-row.red   { border-left: 3px solid var(--red);   background: #fef2f2; }
.data-row.amber { border-left: 3px solid var(--amber); background: #fffbeb; }
.data-row.green { border-left: 3px solid var(--green); background: #f0fdf4; }
.data-row-title { font-size: 13px; font-weight: 600; color: var(--text); }
.data-row-sub   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── SECTION HEADER ── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.section-title { font-size: 13px; font-weight: 600; }

/* ── ALERT BOX ── */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  border-left: 3px solid;
  margin-bottom: 12px;
}
.alert.red   { background: var(--red-bg);   border-color: var(--red);   color: #7f1d1d; }
.alert.amber { background: var(--amber-bg); border-color: var(--amber); color: #78350f; }
.alert.green { background: var(--green-bg); border-color: var(--green); color: #14532d; }
.alert.blue  { background: var(--blue-bg);  border-color: var(--blue);  color: #4c1d95; }

/* ── FORM ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
  outline: none;
  transition: border-color .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--blue); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── LOGIN / LANDING CARD ── */
.landing-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #1e1b2e 0%, #2d2a42 100%);
  padding: 24px;
}
.landing-card {
  background: var(--card);
  border-radius: 14px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.landing-logo { font-size: 20px; font-weight: 800; letter-spacing: -.01em; margin-bottom: 4px; }
.landing-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 28px; }
.landing-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.landing-tab {
  flex: 1;
  text-align: center;
  padding: 9px 0;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.landing-tab.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.role-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  margin-bottom: 8px;
  transition: all .15s;
}
.role-btn:hover { border-color: var(--blue); background: var(--blue-bg); }
.role-btn .role-btn-sub { display: block; font-size: 11px; font-weight: 400; color: var(--text-muted); margin-top: 2px; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* DEMO ADDITIONS */
.sidebar-nav { flex: 1; }
.demo-banner { background: #1e1b2e; color: #ddd6fe; font-size: 12px; font-weight: 500; text-align: center; padding: 7px 16px; flex-shrink: 0; }
.demo-credit { padding: 16px; font-size: 11px; color: #6d6889; border-top: 1px solid #2d2a42; line-height: 1.7; }
.demo-credit a { color: #c4b5fd; text-decoration: none; }
.demo-credit a:hover { text-decoration: underline; }
.demo-login-note { font-size: 12px; color: var(--text-muted); background: #f5f3ff; border-radius: 8px; padding: 10px 12px; margin-bottom: 16px; text-align: center; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.grid-2 > *, .card, .stat-grid > * { min-width: 0; }

/* Phones and small tablets: sidebar becomes a top bar */
@media (max-width: 800px) {
  .app-shell { flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }
  .sidebar { width: 100%; overflow: visible; }
  .sidebar-logo { padding: 14px 16px; }
  .sidebar-nav { display: flex; overflow-x: auto; padding: 6px 8px; }
  .sidebar-section { display: flex; padding: 0; }
  .sidebar-section-label { display: none; }
  .nav-item { white-space: nowrap; padding: 8px 10px; border-left: 0; border-bottom: 3px solid transparent; }
  .nav-item.active { border-bottom-color: var(--sidebar-active); }
  .demo-credit { display: none; }
  .main-area { overflow: visible; }
  .topbar { height: auto; padding: 10px 16px; flex-wrap: wrap; gap: 8px; }
  .role-switcher select { max-width: 100%; }
  .page-content { padding: 20px 16px 48px !important; }
  .flex-between { flex-wrap: wrap; gap: 10px; }
  .grid-2 { grid-template-columns: 1fr !important; }
  .stat-grid { grid-template-columns: 1fr 1fr !important; }
  #sop-search, #status-filter, #dept-filter { max-width: none !important; }
  .page-content > div[style*="display:flex;gap:10px"] { flex-wrap: wrap; }
}