/* ISP-ERP Design System Styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #3B82F6; --primary-dark: #1E40AF; --primary-light: #DBEAFE; --primary-hover: #2563EB;
  --secondary: #8B5CF6; --secondary-light: #EDE9FE;
  --success: #22C55E; --success-light: #DCFCE7;
  --warning: #F59E0B; --warning-light: #FEF3C7;
  --danger: #EF4444; --danger-light: #FEE2E2;
  --info: #06B6D4; --info-light: #CFFAFE;
  --bg: #F8FAFC; --surface: #FFFFFF; --border: #E2E8F0;
  --text-primary: #0F172A; --text-secondary: #64748B; --text-muted: #94A3B8;
  --sidebar-bg: #1E293B; --sidebar-text: #CBD5E1; --sidebar-hover: #334155;
  --topbar-h: 56px; --sidebar-w: 240px; --preview-nav-h: 40px;
  --r-sm: 4px; --r-md: 6px; --r-lg: 8px; --r-xl: 12px;
  --sh-sm: 0 1px 2px rgba(0,0,0,0.05);
  --sh-md: 0 4px 6px -1px rgba(0,0,0,0.1);
  --sh-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
  --sh-xl: 0 20px 25px -5px rgba(0,0,0,0.1);
}

body { font-family: 'Inter', -apple-system, sans-serif; font-size: 14px; color: var(--text-primary); background: var(--bg); line-height: 1.5; }

/* PREVIEW NAV */
#preview-nav { position: fixed; top: 0; left: 0; right: 0; z-index: 9999; background: #0F172A; color: white; padding: 0 16px; display: flex; align-items: center; gap: 4px; height: var(--preview-nav-h); overflow-x: auto; overflow-y: visible; font-size: 12px; }
#preview-nav .pn-label { color: var(--text-muted); font-weight: 600; white-space: nowrap; padding: 0 8px; border-right: 1px solid #334155; height: 24px; display: flex; align-items: center; }
#preview-nav .pn-group { position: relative; }
#preview-nav .pn-group > button { background: transparent; border: none; color: #CBD5E1; padding: 6px 12px; cursor: pointer; font-size: 12px; font-family: inherit; white-space: nowrap; height: 28px; border-radius: 4px; }
#preview-nav .pn-group > button:hover { background: #334155; color: white; }
#preview-nav .pn-group > button.has-active { background: var(--primary); color: white; }

/* Dropdown rendered as fixed overlay so it escapes nav's overflow clipping */
.pn-dropdown { display: none; position: fixed; top: var(--preview-nav-h); left: 0; background: white; min-width: 200px; border-radius: 6px; box-shadow: var(--sh-lg); z-index: 10000; padding: 4px 0; max-height: calc(100vh - var(--preview-nav-h) - 20px); overflow-y: auto; }
.pn-dropdown.open { display: block; }
.pn-dropdown a { display: block; padding: 8px 14px; color: var(--text-primary); text-decoration: none; font-size: 13px; cursor: pointer; }
.pn-dropdown a:hover { background: var(--primary-light); color: var(--primary); }
.pn-dropdown a.active { background: var(--primary); color: white; }

/* AUTH VIEWS (login, forgot, reset) - shared full-screen layout */
.auth-view { display: none; position: fixed; top: var(--preview-nav-h); left: 0; right: 0; bottom: 0; background: linear-gradient(135deg, #1E3A8A 0%, #1E40AF 35%, #3B82F6 100%); z-index: 100; overflow: auto; }
.auth-view.active { display: flex; }
.auth-view .auth-bg-decoration { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.auth-view .auth-bg-decoration::before, .auth-view .auth-bg-decoration::after { content: ''; position: absolute; border-radius: 50%; opacity: 0.15; }
.auth-view .auth-bg-decoration::before { top: -120px; left: -120px; width: 320px; height: 320px; background: radial-gradient(circle, #FFFFFF 0%, transparent 70%); }
.auth-view .auth-bg-decoration::after { bottom: -100px; right: -100px; width: 380px; height: 380px; background: radial-gradient(circle, #60A5FA 0%, transparent 70%); }

/* Auth pattern: split screen with brand panel + form card */
.auth-layout { display: flex; width: 100%; min-height: 100%; position: relative; z-index: 1; }
.auth-brand-panel { flex: 1; display: flex; flex-direction: column; justify-content: space-between; padding: 48px 56px; color: white; max-width: 560px; }
.auth-brand-top { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; }
.auth-brand-top .brand-mark { width: 40px; height: 40px; background: rgba(255,255,255,0.15); border-radius: 10px; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(8px); }
.auth-brand-top .brand-mark [data-lucide] { width: 22px; height: 22px; color: white; }
.auth-brand-middle h2 { font-size: 38px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 16px; }
.auth-brand-middle p { font-size: 15px; line-height: 1.6; opacity: 0.85; max-width: 440px; }
.auth-brand-features { display: flex; flex-direction: column; gap: 16px; margin-top: 32px; }
.auth-brand-feature { display: flex; align-items: center; gap: 12px; font-size: 14px; opacity: 0.92; }
.auth-brand-feature .feat-icon { width: 32px; height: 32px; border-radius: 8px; background: rgba(255,255,255,0.12); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.auth-brand-feature .feat-icon [data-lucide] { width: 16px; height: 16px; color: white; }
.auth-brand-footer { font-size: 12px; opacity: 0.6; }

.auth-form-panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { background: white; border-radius: var(--r-xl); box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); width: 100%; max-width: 440px; padding: 40px; animation: scaleIn 0.3s ease; }
.auth-header { margin-bottom: 28px; }
.auth-header-icon { width: 52px; height: 52px; background: linear-gradient(135deg, var(--primary-light) 0%, #BFDBFE 100%); border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; color: var(--primary); margin-bottom: 16px; }
.auth-header-icon [data-lucide] { width: 26px; height: 26px; }
.auth-header h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 6px; }
.auth-header p { color: var(--text-secondary); font-size: 13px; line-height: 1.5; }
.auth-footer { margin-top: 24px; text-align: center; font-size: 13px; color: var(--text-secondary); }
.auth-footer a { color: var(--primary); text-decoration: none; font-weight: 500; cursor: pointer; }
.auth-footer a:hover { text-decoration: underline; }
.auth-version { margin-top: 28px; text-align: center; font-size: 11px; color: var(--text-muted); }

/* Input with leading icon */
.input-icon-wrap { position: relative; }
.input-icon-wrap .input-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.input-icon-wrap .input-icon-trailing { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); cursor: pointer; background: none; border: none; padding: 0; }
.input-icon-wrap .input-icon-trailing:hover { color: var(--primary); }
.input-icon-wrap .form-input { padding-left: 40px; }
.input-icon-wrap .form-input.has-trailing { padding-right: 40px; }

/* Password strength meter */
.pw-strength { margin-top: 8px; }
.pw-strength-bars { display: flex; gap: 4px; margin-bottom: 6px; }
.pw-strength-bar { flex: 1; height: 4px; background: var(--border); border-radius: 2px; transition: background 0.2s; }
.pw-strength-bar.s1 { background: var(--danger); }
.pw-strength-bar.s2 { background: var(--warning); }
.pw-strength-bar.s3 { background: #EAB308; }
.pw-strength-bar.s4 { background: var(--success); }
.pw-strength-label { font-size: 11px; color: var(--text-muted); }
.pw-requirements { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.pw-req { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-muted); }
.pw-req [data-lucide] { width: 12px; height: 12px; }
.pw-req.ok { color: var(--success); }

/* Auth success state */
.auth-success-icon { width: 72px; height: 72px; background: var(--success-light); color: var(--success); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; }
.auth-success-icon [data-lucide] { width: 36px; height: 36px; }

/* Mobile: hide brand panel */
@media (max-width: 960px) {
  .auth-brand-panel { display: none; }
  .auth-form-panel { padding: 20px; }
}

/* APP SHELL */
#app-shell { display: none; }
#app-shell.active { display: block; }

/* SIDEBAR */
#sidebar { position: fixed; top: var(--preview-nav-h); left: 0; bottom: 0; width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-text); overflow-y: auto; z-index: 100; }
.sidebar-logo { height: var(--topbar-h); display: flex; align-items: center; padding: 0 16px; gap: 10px; border-bottom: 1px solid #334155; }
.sidebar-logo .logo-sm { width: 32px; height: 32px; background: var(--primary); border-radius: 6px; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.sidebar-logo .logo-text { font-size: 15px; font-weight: 700; color: white; }
.sidebar-logo .logo-sub { font-size: 10px; color: var(--text-muted); display: block; }
.menu-group { padding: 2px 0; }
.menu-group-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: #64748B; padding: 12px 16px 4px; }
.menu-item { display: flex; align-items: center; height: 34px; padding: 0 16px; gap: 10px; color: var(--sidebar-text); text-decoration: none; font-size: 13px; cursor: pointer; border-left: 3px solid transparent; }
.menu-item:hover { background: var(--sidebar-hover); color: white; }
.menu-item.active { background: rgba(59,130,246,0.15); color: white; border-left-color: var(--primary); }
.menu-item .icon { width: 18px; text-align: center; flex-shrink: 0; opacity: 0.7; font-size: 13px; }
.menu-item.active .icon { opacity: 1; }
.menu-badge { margin-left: auto; background: var(--danger); color: white; font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 10px; }

/* TOPBAR */
#topbar { position: fixed; top: var(--preview-nav-h); left: var(--sidebar-w); right: 0; height: var(--topbar-h); background: white; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; gap: 16px; z-index: 99; box-shadow: var(--sh-sm); }
.topbar-toggle { background: none; border: none; color: var(--text-secondary); font-size: 18px; cursor: pointer; }
.topbar-search { flex: 1; max-width: 400px; position: relative; }
.topbar-search input { width: 100%; height: 36px; border: 1px solid var(--border); border-radius: 8px; padding: 0 12px 0 36px; font-size: 13px; font-family: inherit; background: #F8FAFC; outline: none; }
.topbar-search input:focus { border-color: var(--primary); background: white; }
.topbar-search .si { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.topbar-branch { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; color: var(--text-secondary); cursor: pointer; background: white; }
.topbar-branch:hover { border-color: var(--primary); color: var(--primary); }
.notif-btn { position: relative; width: 36px; height: 36px; border: none; background: transparent; border-radius: 8px; cursor: pointer; font-size: 16px; color: var(--text-secondary); }
.notif-btn:hover { background: #F1F5F9; }
.notif-badge { position: absolute; top: 4px; right: 4px; width: 16px; height: 16px; background: var(--danger); color: white; font-size: 10px; font-weight: 600; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.user-menu { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 8px; cursor: pointer; }
.user-menu:hover { background: #F1F5F9; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; }
.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--text-muted); }

/* CONTENT */
#content-area { margin-left: var(--sidebar-w); margin-top: calc(var(--preview-nav-h) + var(--topbar-h)); padding: 24px; min-height: calc(100vh - var(--preview-nav-h) - var(--topbar-h)); }
.content-page { display: none; }
.content-page.active { display: block; }

/* FORM */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: #334155; margin-bottom: 6px; }
.form-label .req { color: var(--danger); }
.form-input { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--r-md); font-size: 14px; font-family: inherit; color: var(--text-primary); background: white; outline: none; transition: border-color 0.15s, box-shadow 0.15s; }
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-input::placeholder { color: var(--text-muted); }
.form-input.error { border-color: var(--danger); }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
textarea.form-input { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
.form-select { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--r-md); font-size: 14px; font-family: inherit; color: var(--text-primary); background: white; appearance: none; cursor: pointer; outline: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748B' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-checkbox, .form-radio { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-secondary); cursor: pointer; }
.form-checkbox input, .form-radio input { width: 16px; height: 16px; accent-color: var(--primary); }
.form-section { border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; margin-bottom: 20px; background: white; }
.form-section-title { font-size: 14px; font-weight: 600; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.input-group { display: flex; }
.input-group .form-input { border-radius: var(--r-md) 0 0 var(--r-md); }
.input-group-addon { display: inline-flex; align-items: center; padding: 0 12px; border: 1px solid var(--border); border-left: none; border-radius: 0 var(--r-md) var(--r-md) 0; background: #F8FAFC; font-size: 13px; color: var(--text-secondary); }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border: none; border-radius: var(--r-md); font-size: 14px; font-weight: 500; font-family: inherit; cursor: pointer; transition: all 0.15s; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: white; color: var(--primary); border: 1px solid var(--primary); }
.btn-secondary:hover { background: var(--primary-light); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #16A34A; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; }
.btn-warning { background: var(--warning); color: white; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: #F1F5F9; }
.btn-outline { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-outline:hover { background: #F8FAFC; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 11px; }
.btn-lg { height: 44px; padding: 0 24px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }

/* BADGES */
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--r-sm); font-size: 11px; font-weight: 500; white-space: nowrap; }
.badge-new, .badge-info { background: #CFFAFE; color: #0891B2; }
.badge-contacted, .badge-sent { background: #E0E7FF; color: #4338CA; }
.badge-qualified, .badge-pending, .badge-partial { background: #FEF3C7; color: #B45309; }
.badge-assigned, .badge-in-progress, .badge-deployed, .badge-installing { background: #DBEAFE; color: #1D4ED8; }
.badge-active, .badge-completed, .badge-paid, .badge-won, .badge-feasible, .badge-in-stock, .badge-approved { background: #DCFCE7; color: #15803D; }
.badge-overdue, .badge-suspended, .badge-lost, .badge-rejected, .badge-faulty, .badge-terminated { background: #FEE2E2; color: #B91C1C; }
.badge-cancelled, .badge-draft, .badge-disconnected { background: #F1F5F9; color: #64748B; }
.badge-purple { background: var(--secondary-light); color: var(--secondary); }

/* CARDS */
.card { background: white; border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-sm); }
.card-header { padding: 14px 20px; border-bottom: 1px solid var(--border); font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }

/* STATS */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: white; border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--sh-sm); }
.stat-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.stat-icon { width: 40px; height: 40px; border-radius: var(--r-lg); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.amber { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-icon.cyan { background: var(--info-light); color: var(--info); }
.stat-icon.purple { background: var(--secondary-light); color: var(--secondary); }
.stat-trend { font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 2px; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }
.stat-value { font-size: 26px; font-weight: 700; font-family: 'JetBrains Mono', monospace; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 12px; color: var(--text-secondary); }

/* DATA TABLE */
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th { text-align: left; padding: 10px 16px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); background: #F8FAFC; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table tbody td { padding: 12px 16px; border-bottom: 1px solid #F1F5F9; font-size: 13px; vertical-align: middle; }
.data-table tbody tr:hover { background: #F8FAFC; cursor: pointer; }
.data-table tbody tr.selected { background: var(--primary-light); }
.data-table .row-actions { display: flex; gap: 4px; opacity: 0.7; }
.data-table tr:hover .row-actions { opacity: 1; }
.table-pagination { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; font-size: 13px; color: var(--text-secondary); border-top: 1px solid var(--border); }
.pg-btns { display: flex; gap: 4px; }
.pg-btns button { width: 32px; height: 32px; border: 1px solid var(--border); background: white; border-radius: 6px; cursor: pointer; font-size: 13px; font-family: inherit; }
.pg-btns button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pg-btns button:hover:not(.active) { background: #F8FAFC; }

/* FILTER */
.filter-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 2px solid var(--border); }
.filter-tab { padding: 8px 14px; font-size: 13px; font-weight: 500; color: var(--text-secondary); border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; font-family: inherit; }
.filter-tab:hover { color: var(--primary); }
.filter-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.filter-tab .count { background: #F1F5F9; color: var(--text-secondary); font-size: 11px; padding: 1px 6px; border-radius: 10px; margin-left: 4px; }
.filter-tab.active .count { background: var(--primary-light); color: var(--primary); }
.filter-bar { display: flex; gap: 12px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.filter-bar .form-input, .filter-bar .form-select { height: 36px; font-size: 13px; }

/* PAGE HEADER */
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.breadcrumb a { color: var(--primary); text-decoration: none; cursor: pointer; }
.breadcrumb a:hover { text-decoration: underline; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 16px; }
.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; }
.back-btn { background: none; border: none; cursor: pointer; color: var(--text-secondary); font-size: 14px; padding: 4px 8px; border-radius: 4px; display: inline-flex; align-items: center; gap: 4px; }
.back-btn:hover { background: #F1F5F9; color: var(--primary); }

/* DETAIL HEADER */
.detail-header { background: white; border: 1px solid var(--border); border-radius: var(--r-lg); padding: 22px; margin-bottom: 20px; box-shadow: var(--sh-sm); }
.detail-title-row { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 8px; gap: 20px; }
.detail-name { font-size: 20px; font-weight: 700; }
.detail-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.detail-meta { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.detail-meta-item { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.detail-meta-item .lbl { color: var(--text-muted); font-weight: 500; }

/* PROGRESS STEPS */
.progress-steps { display: flex; align-items: center; padding: 0 20px; }
.progress-step { display: flex; flex-direction: column; align-items: center; flex: 1; position: relative; }
.progress-step::before { content: ''; position: absolute; top: 12px; left: -50%; right: 50%; height: 3px; background: var(--border); }
.progress-step:first-child::before { display: none; }
.progress-step.done::before, .progress-step.now::before { background: var(--primary); }
.step-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--border); border: 3px solid white; box-shadow: 0 0 0 2px var(--border); z-index: 1; margin-bottom: 6px; }
.progress-step.done .step-dot { background: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.progress-step.now .step-dot { background: white; box-shadow: 0 0 0 3px var(--primary); border-color: var(--primary); }
.step-label { font-size: 11px; color: var(--text-muted); text-align: center; }
.progress-step.done .step-label, .progress-step.now .step-label { color: var(--primary); }
.progress-step.now .step-label { font-weight: 600; }

/* TABS */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab { padding: 10px 20px; font-size: 14px; font-weight: 500; color: var(--text-secondary); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; background: none; border-top: none; border-left: none; border-right: none; font-family: inherit; }
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* TIMELINE */
.timeline { padding: 16px 0; }
.timeline-item { display: flex; gap: 16px; padding-bottom: 20px; position: relative; }
.timeline-item:not(:last-child)::after { content: ''; position: absolute; left: 15px; top: 32px; bottom: 0; width: 2px; background: var(--border); }
.timeline-dot { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; z-index: 1; }
.timeline-dot.note { background: var(--primary-light); color: var(--primary); }
.timeline-dot.call { background: var(--success-light); color: var(--success); }
.timeline-dot.email { background: var(--info-light); color: var(--info); }
.timeline-dot.status { background: var(--warning-light); color: var(--warning); }
.timeline-dot.meeting { background: var(--secondary-light); color: var(--secondary); }
.timeline-dot.create { background: #F1F5F9; color: var(--text-secondary); }
.timeline-content { flex: 1; }
.timeline-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.timeline-title { font-size: 14px; font-weight: 500; }
.timeline-time { font-size: 12px; color: var(--text-muted); }
.timeline-body { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.timeline-user { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ITEMS TABLE */
.items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.items-table th { text-align: left; padding: 8px 12px; font-weight: 600; color: var(--text-secondary); background: #F8FAFC; border-bottom: 1px solid var(--border); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.items-table td { padding: 10px 12px; border-bottom: 1px solid #F1F5F9; }
.items-table tfoot td { font-weight: 600; border-top: 2px solid var(--border); background: #F8FAFC; }

/* PROPOSAL */
.proposal-preview { background: white; border: 1px solid var(--border); border-radius: var(--r-lg); max-width: 800px; margin: 0 auto; box-shadow: var(--sh-md); }
.proposal-hdr-bar { background: var(--primary-dark); color: white; padding: 24px 32px; border-radius: var(--r-lg) var(--r-lg) 0 0; }
.proposal-hdr-bar h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.proposal-hdr-bar p { font-size: 13px; opacity: 0.8; }
.proposal-body { padding: 28px; }
.proposal-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 28px; }
.proposal-info-box h4 { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.proposal-info-box p { font-size: 14px; line-height: 1.6; }
.cost-summary { background: #F8FAFC; border-radius: var(--r-lg); padding: 18px; margin-top: 20px; }
.cost-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.cost-row.total { border-top: 2px solid var(--border); margin-top: 8px; padding-top: 12px; font-weight: 700; font-size: 16px; }
.cost-row.monthly { color: var(--primary); font-weight: 600; }

/* STOCK BAR */
.stock-bar { height: 6px; background: #E2E8F0; border-radius: 3px; overflow: hidden; width: 70px; }
.stock-bar-fill { height: 100%; border-radius: 3px; }
.stock-high .stock-bar-fill { background: var(--success); }
.stock-mid .stock-bar-fill { background: var(--warning); }
.stock-low .stock-bar-fill { background: var(--danger); }

/* PHOTO UPLOAD */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 12px; }
.photo-item { aspect-ratio: 1; border: 2px dashed var(--border); border-radius: var(--r-lg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--text-muted); font-size: 11px; text-align: center; cursor: pointer; padding: 4px; }
.photo-item:hover { border-color: var(--primary); color: var(--primary); }
.photo-item .ico { font-size: 22px; }
.photo-item.filled { border-style: solid; }

/* MODAL / DIALOG */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15,23,42,0.6); z-index: 1000; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.active { display: flex; }
.modal { background: white; border-radius: var(--r-xl); box-shadow: var(--sh-xl); max-width: 500px; width: 100%; max-height: 90vh; overflow-y: auto; }
.modal.modal-lg { max-width: 720px; }
.modal-hdr { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); padding: 4px; }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ALERT */
.alert { padding: 12px 16px; border-radius: var(--r-md); display: flex; gap: 10px; align-items: flex-start; font-size: 13px; margin-bottom: 16px; border: 1px solid; line-height: 1.4; }
.alert [data-lucide] { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-info { background: var(--info-light); color: #0E7490; border-color: #A5F3FC; }
.alert-warning { background: var(--warning-light); color: #92400E; border-color: #FDE68A; }
.alert-danger { background: var(--danger-light); color: #991B1B; border-color: #FECACA; }
.alert-success { background: var(--success-light); color: #166534; border-color: #BBF7D0; }
.detail-meta-item [data-lucide] { width: 14px; height: 14px; opacity: 0.6; }
.menu-badge { line-height: 1.2; }

/* Empty state polish */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state .empty-icon { width: 56px; height: 56px; margin: 0 auto 16px; color: var(--text-muted); display: flex; align-items: center; justify-content: center; background: #F1F5F9; border-radius: 50%; }
.empty-state .empty-icon [data-lucide] { width: 28px; height: 28px; }
.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.empty-state p { color: var(--text-secondary); font-size: 13px; max-width: 320px; margin: 0 auto 16px; }

/* DROPDOWN */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { display: none; position: absolute; top: 100%; right: 0; min-width: 180px; background: white; border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--sh-lg); z-index: 100; padding: 4px 0; margin-top: 4px; }
.dropdown.open .dropdown-menu, .dropdown:hover .dropdown-menu { display: block; }
.dropdown-item { display: flex; align-items: center; gap: 8px; padding: 8px 14px; cursor: pointer; font-size: 13px; color: var(--text-primary); }
.dropdown-item:hover { background: var(--primary-light); color: var(--primary); }
.dropdown-item.danger:hover { background: var(--danger-light); color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* NOTIFICATION DROPDOWN */
.notif-dropdown { display: none; position: absolute; top: 44px; right: 0; width: 360px; max-height: 480px; background: white; border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-lg); z-index: 200; overflow: hidden; }
.notif-dropdown.open { display: block; }
.notif-hdr { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 14px; }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid #F1F5F9; cursor: pointer; display: flex; gap: 10px; }
.notif-item:hover { background: #F8FAFC; }
.notif-item.unread { background: var(--primary-light); }
.notif-icon { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.notif-content { flex: 1; }
.notif-title { font-size: 13px; font-weight: 500; margin-bottom: 2px; }
.notif-time { font-size: 11px; color: var(--text-muted); }
.notif-footer { padding: 10px 16px; border-top: 1px solid var(--border); text-align: center; font-size: 13px; color: var(--primary); cursor: pointer; }

/* USER DROPDOWN */
.user-dropdown { display: none; position: absolute; top: 44px; right: 0; min-width: 220px; background: white; border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-lg); z-index: 200; }
.user-dropdown.open { display: block; }
.user-dropdown-header { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.user-dropdown-header .name { font-weight: 600; font-size: 14px; }
.user-dropdown-header .email { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* WIZARD */
.wizard-steps { display: flex; align-items: center; padding: 20px 24px; background: white; border: 1px solid var(--border); border-radius: var(--r-lg); margin-bottom: 20px; }
.wizard-step { display: flex; align-items: center; gap: 10px; flex: 1; }
.wizard-step:not(:last-child)::after { content: ''; flex: 1; height: 2px; background: var(--border); margin: 0 12px; }
.wizard-step.done:not(:last-child)::after, .wizard-step.now:not(:last-child)::after { background: var(--primary); }
.wizard-num { width: 28px; height: 28px; border-radius: 50%; background: var(--border); color: white; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.wizard-step.done .wizard-num, .wizard-step.now .wizard-num { background: var(--primary); }
.wizard-label { font-size: 13px; color: var(--text-muted); }
.wizard-step.done .wizard-label, .wizard-step.now .wizard-label { color: var(--text-primary); font-weight: 500; }

/* TREE */
.tree { font-size: 13px; }
.tree-node { padding: 6px 0; }
.tree-toggle { display: inline-block; width: 14px; cursor: pointer; color: var(--text-muted); }
.tree-children { padding-left: 22px; border-left: 1px dashed var(--border); margin-left: 6px; }
.tree-item { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 4px; cursor: pointer; }
.tree-item:hover { background: #F1F5F9; }
.tree-item.active { background: var(--primary-light); color: var(--primary); }

/* KANBAN */
.kanban { display: grid; grid-template-columns: repeat(7, 280px); gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.kanban-col { background: #F1F5F9; border-radius: var(--r-lg); padding: 12px; }
.kanban-col-hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-weight: 600; font-size: 13px; }
.kanban-col-count { background: white; padding: 2px 8px; border-radius: 10px; font-size: 11px; }
.kanban-card { background: white; border-radius: var(--r-md); padding: 12px; margin-bottom: 8px; box-shadow: var(--sh-sm); cursor: pointer; }
.kanban-card:hover { box-shadow: var(--sh-md); }
.kanban-card-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.kanban-card-meta { font-size: 11px; color: var(--text-muted); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

/* AVATAR */
.avatar-sm { width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: white; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; }
.avatar-group { display: inline-flex; }
.avatar-group .avatar-sm { margin-left: -6px; border: 2px solid white; }
.avatar-group .avatar-sm:first-child { margin-left: 0; }

/* PERMISSIONS GRID */
.perms-grid { display: grid; grid-template-columns: 200px 1fr; gap: 0; }
.perms-list { border-right: 1px solid var(--border); }
.perms-list-item { padding: 10px 16px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.perms-list-item:hover { background: #F8FAFC; }
.perms-list-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.perms-detail { padding: 16px 20px; }
.perms-module { margin-bottom: 16px; }
.perms-module-title { font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.perms-checkbox-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }

/* UTILS */
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-mono { font-family: 'JetBrains Mono', monospace; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.ml-auto { margin-left: auto; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* Loading state */
.loading { display: flex; justify-content: center; align-items: center; padding: 60px; color: var(--text-muted); font-size: 14px; gap: 10px; }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Lucide icon sizing */
.icon, [data-lucide] { width: 18px; height: 18px; flex-shrink: 0; }
.menu-item [data-lucide] { width: 18px; height: 18px; opacity: 0.7; }
.menu-item.active [data-lucide] { opacity: 1; }
.btn [data-lucide] { width: 16px; height: 16px; }
.btn-sm [data-lucide], .btn-xs [data-lucide] { width: 14px; height: 14px; }
.stat-icon [data-lucide] { width: 22px; height: 22px; }
.notif-icon [data-lucide] { width: 16px; height: 16px; }
.timeline-dot [data-lucide] { width: 16px; height: 16px; }
.detail-meta-item [data-lucide] { width: 14px; height: 14px; opacity: 0.6; }
.topbar-toggle [data-lucide] { width: 22px; height: 22px; }
.notif-btn [data-lucide] { width: 18px; height: 18px; }
.topbar-search .si [data-lucide] { width: 14px; height: 14px; }
.dropdown-item [data-lucide] { width: 16px; height: 16px; opacity: 0.7; }
.row-actions [data-lucide] { width: 14px; height: 14px; }
.tree-item [data-lucide] { width: 14px; height: 14px; opacity: 0.6; }
.kanban-card [data-lucide] { width: 12px; height: 12px; }
.modal-close [data-lucide] { width: 16px; height: 16px; }
.back-btn [data-lucide] { width: 14px; height: 14px; }
.breadcrumb [data-lucide] { width: 12px; height: 12px; }

/* Better focus states */
*:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:focus-visible { outline-offset: 3px; }
.form-input:focus-visible, .form-select:focus-visible { outline: none; }

/* Transitions */
.btn, .menu-item, .form-input, .form-select, .badge, .card, .stat-card, .tab, .filter-tab, .data-table tr, .dropdown-item, .notif-item { transition: all 0.15s ease; }
.card:hover { box-shadow: var(--sh-md); }
.stat-card:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }

/* Modal animations */
.modal-overlay { animation: fadeIn 0.15s ease; }
.modal-overlay.active .modal { animation: scaleIn 0.2s ease; }
.notif-dropdown.open, .user-dropdown.open, .pn-dropdown.open, .dropdown-menu { animation: fadeIn 0.15s ease; }

/* TOAST NOTIFICATIONS */
#toast-container { position: fixed; top: calc(var(--preview-nav-h) + 12px); right: 16px; z-index: 10001; display: flex; flex-direction: column; gap: 8px; pointer-events: none; max-width: 380px; }
.toast { background: white; border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--r-md); box-shadow: var(--sh-lg); padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; pointer-events: auto; min-width: 280px; animation: slideInRight 0.25s ease; }
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-info { border-left-color: var(--info); }
.toast-icon { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 12px; }
.toast-success .toast-icon { background: var(--success-light); color: var(--success); }
.toast-error .toast-icon { background: var(--danger-light); color: var(--danger); }
.toast-warning .toast-icon { background: var(--warning-light); color: var(--warning); }
.toast-info .toast-icon { background: var(--info-light); color: var(--info); }
.toast-content { flex: 1; min-width: 0; }
.toast-title { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.toast-msg { font-size: 12px; color: var(--text-secondary); }
.toast-close { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 0; font-size: 14px; line-height: 1; flex-shrink: 0; }
.toast-close:hover { color: var(--text-primary); }

/* MOBILE RESPONSIVE */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  #sidebar { transform: translateX(-100%); width: 260px; transition: transform 0.25s ease; box-shadow: var(--sh-xl); }
  #sidebar.open { transform: translateX(0); }
  #sidebar.open + #topbar::before { content: ''; position: fixed; inset: var(--preview-nav-h) 0 0 0; background: rgba(0,0,0,0.4); z-index: 50; }
  #topbar { left: 0; padding: 0 12px; gap: 8px; }
  .topbar-toggle { display: flex; }
  .topbar-search { max-width: none; }
  .topbar-branch { display: none; }
  .user-info { display: none; }
  #content-area { margin-left: 0; padding: 16px; width: 100%; }
  .grid-2, .grid-3, .grid-4, .stats-grid { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-actions { flex-wrap: wrap; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .form-input, .filter-bar .form-select { width: 100% !important; }
  .filter-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .data-table { display: block; overflow-x: auto; }
  .modal { margin: 0 12px; }
  .modal-lg { margin: 0 12px; }
  .perms-grid { grid-template-columns: 1fr; }
  .perms-list { border-right: none; border-bottom: 1px solid var(--border); }
  .kanban { grid-template-columns: repeat(7, 240px); }
}
@media (min-width: 769px) {
  .topbar-toggle { display: none; }
}

/* SKELETON */
.skeleton { background: linear-gradient(90deg, #F1F5F9 0%, #E2E8F0 50%, #F1F5F9 100%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 4px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 22px; width: 40%; margin-bottom: 12px; }
.skeleton-card { height: 80px; margin-bottom: 12px; }

/* BETTER NOTIF ICONS (smaller, no overflow) */
.notif-icon { width: 36px; height: 36px; min-width: 36px; }

/* Cleaner table on hover */
.data-table tbody tr { cursor: default; }
.data-table tbody tr[onclick] { cursor: pointer; }

/* Sticky table headers */
.card .data-table thead th { position: sticky; top: 0; z-index: 1; }

/* Improved card hover for clickable cards */
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--primary); }

/* Print styles */
@media print {
  #preview-nav, #sidebar, #topbar, .page-actions, .filter-bar, .filter-tabs, .pg-btns, .row-actions { display: none !important; }
  #content-area { margin: 0; padding: 0; }
  #app-shell { display: block !important; }
}
