/* =========================================================
   NusaFlow OS — Modern Design System
   Clean SaaS Aesthetic (Light & Dark Mode + Print Support)
   ========================================================= */

:root {
  --bg-app: #f4f6fb;
  --bg-surface: #ffffff;
  --bg-surface-2: #f8fafc;
  --bg-hover: #f1f5f9;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: rgba(255, 255, 255, 0.08);
  --bg-sidebar-active: rgba(99, 102, 241, 0.22);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-sidebar: #cbd5e1;
  --text-sidebar-muted: #64748b;

  --border-color: #e2e8f0;
  --border-subtle: #f1f5f9;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: rgba(79, 70, 229, 0.1);
  --secondary: #06b6d4;
  --secondary-soft: rgba(6, 182, 212, 0.12);
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.12);

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

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.12);

  --sidebar-width: 272px;
  --topbar-height: 64px;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] {
  --bg-app: #090d16;
  --bg-surface: #111827;
  --bg-surface-2: #161f30;
  --bg-hover: #1e293b;
  --bg-sidebar: #060911;

  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --border-color: #1e293b;
  --border-subtle: #172033;

  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-soft: rgba(99, 102, 241, 0.16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ========================
   APP SHELL
   ======================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 40;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  transition: transform 0.25s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.brand-logo svg {
  width: 20px;
  height: 20px;
}

.brand-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  letter-spacing: -0.02em;
}

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
  border: 1px solid rgba(165, 180, 252, 0.25);
}

.brand-sub {
  display: block;
  font-size: 11px;
  color: var(--text-sidebar-muted);
}

.sidebar-workspace {
  margin: 0 14px 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  gap: 10px;
}

.ws-avatar {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #4f46e5, #ec4899);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.ws-info {
  min-width: 0;
}

.ws-name {
  font-weight: 600;
  font-size: 13px;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ws-meta {
  font-size: 11px;
  color: #94a3b8;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px 16px;
}

.sidebar-nav::-webkit-scrollbar {
  width: 5px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.nav-group-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 14px 10px 6px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  margin-bottom: 2px;
  border: none;
  background: transparent;
  color: var(--text-sidebar);
  border-radius: 9px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
  font-size: 13px;
  font-weight: 500;
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: var(--bg-sidebar-active);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 #818cf8;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-item.active svg {
  opacity: 1;
  color: #a5b4fc;
}

.nav-item-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  font-family: var(--font-mono);
}

.nav-item.active .nav-badge {
  background: rgba(129, 140, 248, 0.25);
  color: #c7d2fe;
}

.nav-item.locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.nav-item.locked:hover {
  background: transparent;
  color: var(--text-sidebar);
}

.step-pill {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.step-pill.done {
  background: #4f46e5;
  color: #fff;
  border-color: #6366f1;
}

.step-pill.current {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border-color: #f59e0b;
}

.step-check {
  font-size: 11px;
  color: #34d399;
  font-weight: 800;
}

.step-lock {
  font-size: 11px;
  opacity: 0.7;
}

/* Horizontal 12-Step Tracker on Dashboard */
.stepper-track {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 4px 10px;
}

.stepper-node {
  min-width: 94px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  cursor: pointer;
  position: relative;
}

.stepper-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  border: 2px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.stepper-node.done .stepper-circle {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.stepper-node.current .stepper-circle {
  border-color: var(--warning);
  color: var(--warning);
  background: var(--warning-soft);
}

.stepper-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.25;
}

.progress-bar-wrap {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--bg-hover);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.3s ease;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.autosave-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: #94a3b8;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

/* ========================
   MAIN WRAPPER & TOPBAR
   ======================== */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 30;
}

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

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
}

.bc-section {
  color: var(--text-muted);
}

.bc-sep {
  color: var(--border-color);
}

.bc-page {
  font-weight: 700;
  color: var(--text-primary);
}

.topbar-center {
  flex: 1;
  max-width: 420px;
}

.search-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 10px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  font-size: 13px;
}

.search-trigger:hover {
  border-color: var(--primary);
  background: var(--bg-surface);
}

.search-trigger svg {
  width: 15px;
  height: 15px;
}

.search-trigger span {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-trigger kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.progress-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px 5px 6px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 600;
}

.progress-ring-sm {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.icon-btn svg {
  width: 17px;
  height: 17px;
}

[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }

/* ========================
   APP CONTENT & LAYOUT
   ======================== */
.app-content {
  padding: 24px 28px 48px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.page-subtitle {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 13.5px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* ========================
   CARDS & BENTO GRID
   ======================== */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  margin: 4px 0 2px;
  letter-spacing: -0.02em;
  font-family: var(--font-mono);
}

.stat-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

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

/* ========================
   BUTTONS & BADGES
   ======================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn svg {
  width: 15px;
  height: 15px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.28);
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-danger-soft {
  background: var(--danger-soft);
  color: var(--danger);
}
.btn-danger-soft:hover {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-ghost-sm {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: var(--text-sidebar);
  font-size: 11.5px;
  cursor: pointer;
}
.btn-ghost-sm:hover {
  background: rgba(255, 255, 255, 0.1);
}
.btn-ghost-sm svg {
  width: 13px;
  height: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-info { background: var(--secondary-soft); color: var(--secondary); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-neutral { background: var(--bg-hover); color: var(--text-secondary); }

/* ========================
   FORMS & TABLES
   ======================== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface-2);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
  border-color: var(--primary);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

table.data-table th {
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

table.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

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

table.data-table tbody tr:hover {
  background: var(--bg-hover);
}

/* ========================
   TABS & TIPS BANNER
   ======================== */
.tabs {
  display: inline-flex;
  padding: 4px;
  border-radius: 11px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  gap: 4px;
  margin-bottom: 18px;
}

.tab-btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.tips-banner {
  background: linear-gradient(135deg, var(--primary-soft), var(--secondary-soft));
  border: 1px solid rgba(79, 70, 229, 0.18);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 13px;
  color: var(--text-primary);
}

.tips-banner svg {
  width: 18px;
  height: 18px;
  color: var(--primary);
  flex-shrink: 0;
  margin-top: 2px;
}

/* ========================
   ORG CHART TREE
   ======================== */
.org-tree-canvas {
  width: 100%;
  overflow-x: auto;
  padding: 28px 16px;
  background: radial-gradient(var(--border-color) 1px, transparent 1px);
  background-size: 20px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface-2);
}

.org-tree {
  display: flex;
  justify-content: center;
  min-width: max-content;
}

.org-tree ul {
  padding-top: 22px;
  position: relative;
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.org-tree li {
  float: left;
  text-align: center;
  list-style-type: none;
  position: relative;
  padding: 22px 6px 0 6px;
}

.org-tree li::before,
.org-tree li::after {
  content: '';
  position: absolute;
  top: 0;
  right: 50%;
  border-top: 2px solid var(--border-color);
  width: 50%;
  height: 22px;
}

.org-tree li::after {
  right: auto;
  left: 50%;
  border-left: 2px solid var(--border-color);
}

.org-tree li:only-child::after,
.org-tree li:only-child::before {
  display: none;
}

.org-tree li:only-child {
  padding-top: 0;
}

.org-tree li:first-child::before,
.org-tree li:last-child::after {
  border: 0 none;
}

.org-tree li:last-child::before {
  border-right: 2px solid var(--border-color);
  border-radius: 0 8px 0 0;
}

.org-tree li:first-child::after {
  border-radius: 8px 0 0 0;
}

.org-tree ul ul::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  border-left: 2px solid var(--border-color);
  width: 0;
  height: 22px;
}

.org-node {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 175px;
  max-width: 210px;
  padding: 12px 14px;
  border-radius: 13px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.org-node:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.org-node.level-direktur {
  border-top: 4px solid #4f46e5;
}
.org-node.level-manager {
  border-top: 4px solid #06b6d4;
}
.org-node.level-supervisor, .org-node.level-koordinator {
  border-top: 4px solid #10b981;
}
.org-node.level-staff {
  border-top: 4px solid #f59e0b;
}

.org-node-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.org-node-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
}

.org-node-emp {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ========================
   RELATIONAL FLOW & SOP FLOWCHART
   ======================== */
.flow-chain {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 2px;
}

.flow-step {
  flex: 1;
  min-width: 135px;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.15s ease;
}

.flow-step:hover {
  border-color: var(--primary);
  background: var(--bg-surface);
}

.flow-step-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--primary);
}

.flow-step-name {
  font-weight: 700;
  font-size: 13px;
  margin: 2px 0;
}

.flow-step-count {
  font-size: 11.5px;
  color: var(--text-muted);
}

.flow-arrow {
  color: var(--text-muted);
  font-weight: 700;
  flex-shrink: 0;
}

.sop-flowchart {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--bg-surface-2);
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.sop-flow-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.sop-flow-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

/* ========================
   MODALS, SEARCH & TOASTS
   ======================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-dialog {
  width: 100%;
  max-width: 780px;
  max-height: 90vh;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.modal-header h3 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 700;
}

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-surface-2);
}

.search-palette {
  width: 100%;
  max-width: 600px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  align-self: flex-start;
  margin-top: 8vh;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.search-input-wrap svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.search-input-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  outline: none;
  font-size: 14.5px;
}

.search-results {
  max-height: 360px;
  overflow-y: auto;
  padding: 8px;
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 9px;
  cursor: pointer;
}

.search-result-item:hover {
  background: var(--bg-hover);
}

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 150;
}

.toast {
  padding: 11px 16px;
  border-radius: 10px;
  background: #0f172a;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideUp 0.2s ease;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--primary); }

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

/* ========================
   UTILITIES & RESPONSIVE
   ======================== */
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 18px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12.5px; }
.font-mono { font-family: var(--font-mono); }

.hidden { display: none !important; }

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top left, rgba(79, 70, 229, 0.14), transparent 45%),
              radial-gradient(circle at bottom right, rgba(6, 182, 212, 0.14), transparent 45%),
              var(--bg-app);
}

.auth-card {
  width: 100%;
  max-width: 430px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 28px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.auth-quick-demo {
  padding-top: 14px;
  border-top: 1px dashed var(--border-color);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 8px;
  border-left: 1px solid var(--border-color);
  font-size: 12.5px;
  font-weight: 600;
}

.mobile-only { display: none; }
.sidebar-backdrop { display: none; }
.print-only { display: none; }

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .mobile-only { display: grid; }
  .hide-sm { display: none; }
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 35;
  }
  .main-wrapper {
    margin-left: 0;
  }
  .grid-2, .grid-3, .grid-4, .form-grid {
    grid-template-columns: 1fr;
  }
  .app-content {
    padding: 18px 16px 40px;
  }
}

@media print {
  .app-shell, .modal-backdrop, .toast-container {
    display: none !important;
  }
  .print-only {
    display: block !important;
    padding: 0;
    color: #0f172a;
    background: #fff;
    font-size: 12px;
  }
  .pdf-page {
    page-break-after: always;
    padding: 28px 32px;
    min-height: 95vh;
  }
  .pdf-page:last-child {
    page-break-after: auto;
  }
  .pdf-cover {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: center;
    border: 1px solid #e2e8f0;
  }
  .pdf-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0 14px;
    font-size: 11.5px;
  }
  .pdf-table th, .pdf-table td {
    border: 1px solid #cbd5e1;
    padding: 6px 8px;
    text-align: left;
  }
  body {
    background: #fff;
  }
}
