@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

:root {
  --bg: #f5f6fa;
  --bg2: #ffffff;
  --bg3: #f0f2f7;
  --border: #e2e6f0;
  --border2: #cbd2e0;
  --text: #1a2035;
  --text2: #5a6478;
  --text3: #9aa3b5;
  --primary: #3b82f6;
  --primary-dim: #eff6ff;
  --primary-hover: #2563eb;
  --green: #16a34a;
  --green-dim: #f0fdf4;
  --red: #dc2626;
  --red-dim: #fef2f2;
  --yellow: #d97706;
  --yellow-dim: #fffbeb;
  --purple: #7c3aed;
  --purple-dim: #f5f3ff;
  --sidebar-w: 240px;
  --sidebar-collapsed: 64px;
  --topbar-h: 56px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
  --transition: 0.2s ease;
  --font: 'DM Sans', sans-serif;
  --mono: 'DM Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

.app { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar { width: var(--sidebar-w); background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; transition: width var(--transition); overflow: hidden; position: relative; z-index: 100; box-shadow: 2px 0 8px rgba(0,0,0,.04); }
.sidebar.collapsed { overflow: visible; } /* allow tooltips to show outside sidebar */
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar-header { height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.sidebar-logo { width: 32px; height: 32px; background: var(--primary); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar-logo svg { width: 18px; height: 18px; color: #fff; }
.sidebar-brand { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; opacity: 1; transition: opacity var(--transition); color: var(--text); }
.sidebar.collapsed .sidebar-brand { opacity: 0; width: 0; }
.sidebar-toggle { margin-left: auto; width: 28px; height: 28px; border: none; background: transparent; color: var(--text3); cursor: pointer; display: flex; align-items: center; justify-content: center; border-radius: 6px; flex-shrink: 0; transition: background var(--transition), color var(--transition); }
.sidebar-toggle:hover { background: var(--bg3); color: var(--text); }
.sidebar.collapsed .sidebar-toggle svg { transform: rotate(180deg); }
.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: visible; padding: 8px; }
.nav-section { margin-bottom: 4px; }
.nav-section-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text3); padding: 10px 8px 4px; white-space: nowrap; overflow: hidden; transition: opacity var(--transition); }
.sidebar.collapsed .nav-section-label { opacity: 0; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--radius); color: var(--text2); text-decoration: none; cursor: pointer; transition: background var(--transition), color var(--transition); white-space: nowrap; overflow: hidden; }
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--primary-dim); color: var(--primary); font-weight: 600; }
.nav-icon { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; border-radius: 8px; }
.nav-item.active .nav-icon { background: rgba(59,130,246,.12); }
.nav-icon svg { width: 17px; height: 17px; }
.nav-label { font-size: 13.5px; }
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .nav-icon { width: 100%; margin: 0; }
.sidebar-footer { border-top: 1px solid var(--border); padding: 10px 8px; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius); cursor: pointer; transition: background var(--transition); }
.user-card:hover { background: var(--bg3); }
.user-avatar { width: 32px; height: 32px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text3); text-transform: capitalize; }
.sidebar.collapsed .user-info { display: none; }

/* Main */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: var(--topbar-h); background: var(--bg2); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 24px; flex-shrink: 0; }
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.page-content { flex: 1; overflow-y: auto; padding: 24px; }

/* Page header */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 16px; }
.page-title { font-size: 20px; font-weight: 700; }
.page-subtitle { color: var(--text2); font-size: 13px; margin-top: 2px; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius); font-family: var(--font); font-size: 13px; font-weight: 500; cursor: pointer; border: 1px solid transparent; transition: all var(--transition); white-space: nowrap; text-decoration: none; }
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-secondary { background: var(--bg2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--border2); background: var(--bg3); }
.btn-danger { background: var(--red-dim); color: var(--red); border-color: rgba(220,38,38,.2); }
.btn-danger:hover { background: #fee2e2; }
.btn-ghost { background: transparent; color: var(--text2); border-color: transparent; }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Cards */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 14px; font-weight: 600; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow); }
.stat-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.stat-icon { width: 38px; height: 38px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; }
.stat-icon svg { width: 18px; height: 18px; }
.stat-icon.blue { background: #eff6ff; color: #3b82f6; }
.stat-icon.green { background: #f0fdf4; color: #16a34a; }
.stat-icon.yellow { background: #fffbeb; color: #d97706; }
.stat-icon.red { background: #fef2f2; color: #dc2626; }
.stat-icon.purple { background: #f5f3ff; color: #7c3aed; }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text2); margin-top: 4px; font-weight: 500; }

/* Table */
.table-wrap { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
.table-toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--bg2); }
.table-search { position: relative; flex: 1; max-width: 280px; }
.table-search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--text3); width: 14px; height: 14px; pointer-events: none; }
.table-search input { width: 100%; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 10px 7px 30px; color: var(--text); font-family: var(--font); font-size: 13px; outline: none; }
.table-search input:focus { border-color: var(--primary); background: var(--bg2); }
.table-search input::placeholder { color: var(--text3); }
.table-count { color: var(--text3); font-size: 12px; margin-left: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { background: var(--bg3); padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text3); border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg3); }
.td-mono { font-family: var(--mono); font-size: 12px; color: var(--text2); }
.td-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* Badge */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-yellow { background: #fef3c7; color: #b45309; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-purple { background: #ede9fe; color: #6d28d9; }
.badge-gray { background: #f1f5f9; color: #64748b; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,17,30,.45); backdrop-filter: blur(3px); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; pointer-events: none; transition: opacity var(--transition); }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; transform: translateY(16px) scale(.98); transition: transform var(--transition); box-shadow: var(--shadow-lg); }
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-lg { max-width: 720px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg2); z-index: 1; }
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close { width: 28px; height: 28px; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; color: var(--text2); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--transition); }
.modal-close:hover { background: var(--red-dim); color: var(--red); border-color: rgba(220,38,38,.2); }
.modal-body { padding: 20px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--bg3); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* Form */
.form-row { margin-bottom: 14px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; margin-bottom: 14px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 5px; }
.required::after { content: ' *'; color: var(--red); }
input, select, textarea { width: 100%; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; color: var(--text); font-family: var(--font); font-size: 13px; outline: none; transition: border-color var(--transition), background var(--transition); }
input:focus, select:focus, textarea:focus { border-color: var(--primary); background: var(--bg2); box-shadow: 0 0 0 3px rgba(59,130,246,.08); }
input::placeholder, textarea::placeholder { color: var(--text3); }
select { cursor: pointer; }
textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11px; color: var(--text3); margin-top: 3px; }
input.error, select.error { border-color: var(--red); }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 4px; padding: 12px 16px; border-top: 1px solid var(--border); justify-content: flex-end; background: var(--bg3); }
.page-btn { width: 30px; height: 30px; background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; color: var(--text2); cursor: pointer; font-family: var(--font); font-size: 12px; display: flex; align-items: center; justify-content: center; transition: all var(--transition); }
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-info { font-size: 12px; color: var(--text2); margin: 0 8px; }

/* Toast */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.toast { display: flex; align-items: flex-start; gap: 10px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 14px; box-shadow: var(--shadow-lg); animation: slideIn .2s ease; border-left: 3px solid; }
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.info { border-left-color: var(--primary); }
.toast.warning { border-left-color: var(--yellow); }
.toast-icon svg { width: 16px; height: 16px; }
.toast.success .toast-icon { color: var(--green); }
.toast.error .toast-icon { color: var(--red); }
.toast.info .toast-icon { color: var(--primary); }
.toast.warning .toast-icon { color: var(--yellow); }
.toast-title { font-size: 13px; font-weight: 600; }
.toast-msg { font-size: 12px; color: var(--text2); margin-top: 2px; }
.toast-close { background: none; border: none; color: var(--text3); cursor: pointer; flex-shrink: 0; padding: 0; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* Confirm */
.confirm-dialog { max-width: 420px; }
.confirm-icon { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.confirm-icon.danger { background: var(--red-dim); color: var(--red); }
.confirm-icon svg { width: 24px; height: 24px; }
.confirm-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.confirm-msg { font-size: 13px; color: var(--text2); line-height: 1.6; }

/* Empty state */
.empty-state { display: flex; flex-direction: column; align-items: center; padding: 60px 20px; text-align: center; }
.empty-icon { margin-bottom: 12px; color: var(--border2); }
.empty-icon svg { width: 48px; height: 48px; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.empty-msg { font-size: 13px; color: var(--text3); max-width: 320px; }

/* Error state */
.error-state { display: flex; flex-direction: column; align-items: center; padding: 48px 20px; text-align: center; }
.error-icon { width: 56px; height: 56px; background: var(--red-dim); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; color: var(--red); }
.error-icon svg { width: 24px; height: 24px; }
.error-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.error-msg { font-size: 13px; color: var(--text2); max-width: 360px; line-height: 1.6; margin-bottom: 16px; }

/* Loading */
.loading-overlay { display: flex; align-items: center; justify-content: center; padding: 60px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
.skeleton { background: linear-gradient(90deg, var(--bg3) 25%, var(--border) 50%, var(--bg3) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 4px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Dropdown */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 4px); background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 4px; min-width: 160px; z-index: 200; box-shadow: var(--shadow-lg); display: none; }
.dropdown-menu.open { display: block; }
.dropdown-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius); font-size: 13px; color: var(--text2); cursor: pointer; transition: background var(--transition), color var(--transition); border: none; background: none; width: 100%; text-align: left; font-family: var(--font); }
.dropdown-item svg { width: 14px; height: 14px; }
.dropdown-item:hover { background: var(--bg3); color: var(--text); }
.dropdown-item.danger:hover { background: var(--red-dim); color: var(--red); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Filter */
.filter-select { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 10px; color: var(--text); font-family: var(--font); font-size: 13px; outline: none; cursor: pointer; width: auto; transition: border-color var(--transition); }
.filter-select:focus { border-color: var(--primary); }

/* Detail grid */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text3); margin-bottom: 3px; }
.detail-value { font-size: 14px; color: var(--text); }

/* Login page */
.login-page { min-height: 100vh; display: flex; }
.login-left { flex: 1; background: linear-gradient(145deg, #1e3a8a 0%, #1d4ed8 50%, #2563eb 100%); display: flex; flex-direction: column; padding: 48px; position: relative; overflow: hidden; }
.login-left::before { content: ''; position: absolute; top: -100px; right: -100px; width: 350px; height: 350px; background: rgba(255,255,255,.06); border-radius: 50%; pointer-events: none; }
.login-left::after { content: ''; position: absolute; bottom: -80px; left: -60px; width: 280px; height: 280px; background: rgba(255,255,255,.04); border-radius: 50%; pointer-events: none; }
.left-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 64px; }
.left-logo .logo-box { width: 40px; height: 40px; background: rgba(255,255,255,.2); backdrop-filter: blur(10px); border-radius: 10px; display: flex; align-items: center; justify-content: center; border: 1px solid rgba(255,255,255,.3); }
.left-logo .logo-box svg { width: 22px; height: 22px; color: #fff; }
.left-logo .brand { font-size: 20px; font-weight: 700; color: #fff; letter-spacing: -.3px; }
.left-logo .version { font-size: 11px; color: rgba(255,255,255,.6); background: rgba(255,255,255,.15); border-radius: 20px; padding: 2px 8px; }
.left-headline { font-size: 38px; font-weight: 800; line-height: 1.15; letter-spacing: -.5px; color: #fff; margin-bottom: 16px; }
.left-headline span { color: #bfdbfe; }
.left-sub { font-size: 15px; color: rgba(255,255,255,.75); line-height: 1.7; max-width: 380px; margin-bottom: 48px; }
.left-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 48px; }
.left-stat { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15); border-radius: var(--radius-lg); padding: 16px; backdrop-filter: blur(10px); }
.left-stat-val { font-size: 28px; font-weight: 800; color: #fff; line-height: 1; }
.left-stat-label { font-size: 12px; color: rgba(255,255,255,.65); margin-top: 4px; }
.left-features { display: flex; flex-direction: column; gap: 12px; }
.left-feature { display: flex; align-items: center; gap: 10px; font-size: 13px; color: rgba(255,255,255,.8); }
.left-feature-icon { width: 28px; height: 28px; background: rgba(255,255,255,.15); border-radius: 6px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.left-feature-icon svg { width: 14px; height: 14px; color: #fff; }
.left-footer { margin-top: auto; font-size: 12px; color: rgba(255,255,255,.45); }
.login-right { width: 460px; flex-shrink: 0; background: #fff; display: flex; align-items: center; justify-content: center; padding: 48px 40px; }
.login-form-wrap { width: 100%; max-width: 360px; }
.login-welcome { font-size: 26px; font-weight: 800; margin-bottom: 6px; color: var(--text); }
.login-tagline { font-size: 13px; color: var(--text2); margin-bottom: 32px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .05em; }
.form-group input { width: 100%; background: #f8fafc; border: 1.5px solid #e2e8f0; border-radius: var(--radius); padding: 11px 14px; color: var(--text); font-family: var(--font); font-size: 14px; outline: none; transition: all .2s; }
.form-group input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.form-group input::placeholder { color: #94a3b8; }
.login-btn { width: 100%; background: var(--primary); color: #fff; border: none; border-radius: var(--radius); padding: 12px; font-family: var(--font); font-size: 14px; font-weight: 600; cursor: pointer; transition: all .2s; margin-top: 8px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.login-btn:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(59,130,246,.35); }
.login-btn:active { transform: none; }
.login-btn:disabled { opacity: .6; cursor: not-allowed; transform: none; box-shadow: none; }
.login-error { background: #fef2f2; border: 1px solid #fecaca; border-radius: var(--radius); padding: 10px 14px; font-size: 13px; color: #b91c1c; margin-bottom: 16px; display: none; line-height: 1.5; }
.login-error.show { display: block; }
.config-toggle { text-align: center; margin-top: 20px; }
.config-toggle a { font-size: 12px; color: var(--text3); text-decoration: none; cursor: pointer; }
.config-toggle a:hover { color: var(--text2); }
.config-panel { background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-top: 16px; display: none; }
.config-panel.open { display: block; }
.config-panel label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; margin-bottom: 4px; margin-top: 10px; display: block; }
.config-panel label:first-child { margin-top: 0; }
.config-panel input { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; color: var(--text); font-size: 12px; font-family: monospace; width: 100%; outline: none; }
.config-panel input:focus { border-color: var(--primary); }
.config-save-btn { margin-top: 10px; padding: 7px 14px; font-size: 12px; background: var(--primary); border: none; border-radius: 6px; color: #fff; cursor: pointer; font-family: var(--font); font-weight: 500; }

@media (max-width: 900px) { .login-left { display: none; } .login-right { width: 100%; } }
@media (max-width: 768px) { .form-row-2, .form-row-3 { grid-template-columns: 1fr; } .stats-grid { grid-template-columns: 1fr 1fr; } .detail-grid { grid-template-columns: 1fr; } }

/* ── Sidebar tooltip on collapsed ── */
.sidebar.collapsed .nav-item { position: relative; }
.sidebar.collapsed .nav-item[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--text);
  color: var(--bg2);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 999;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
}
.sidebar.collapsed .nav-item[data-tip]:hover::before {
  content: '';
  position: absolute;
  left: calc(100% + 3px);
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: var(--text);
  z-index: 999;
}

/* ── Topbar search ── */
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text3); width: 14px; height: 14px; }
.search-input { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 10px 7px 32px; color: var(--text); font-family: var(--font); font-size: 13px; width: 240px; outline: none; transition: all .2s; }
.search-input:focus { border-color: var(--primary); background: var(--bg2); box-shadow: 0 0 0 3px rgba(59,130,246,.08); width: 300px; }
.search-input::placeholder { color: var(--text3); }



/* ── Role badges ── */
.role-super_admin { background:#f5f3ff;color:#6d28d9; }
.role-admin       { background:#eff6ff;color:#1d4ed8; }
.role-manager     { background:#ecfdf5;color:#065f46; }
.role-inventory_staff { background:#fff7ed;color:#9a3412; }
.role-finance     { background:#fefce8;color:#854d0e; }
.role-viewer      { background:#f8fafc;color:#475569; }

/* ── Log table ── */
.log-action { font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.04em;padding:2px 7px;border-radius:4px; }
.log-create { background:#dcfce7;color:#15803d; }
.log-update { background:#dbeafe;color:#1d4ed8; }
.log-delete { background:#fee2e2;color:#b91c1c; }
.log-login  { background:#f5f3ff;color:#6d28d9; }
.log-export { background:#fef3c7;color:#b45309; }
.log-api_call { background:#f0f9ff;color:#0369a1; }
.log-stock_adjust { background:#ecfdf5;color:#065f46; }

/* ── API Explorer ── */
.api-method { font-size:11px;font-weight:800;padding:2px 8px;border-radius:4px;font-family:var(--mono);letter-spacing:.03em; }
.method-GET    { background:#dcfce7;color:#15803d; }
.method-POST   { background:#dbeafe;color:#1d4ed8; }
.method-PATCH  { background:#fef3c7;color:#b45309; }
.method-PUT    { background:#fef3c7;color:#b45309; }
.method-DELETE { background:#fee2e2;color:#b91c1c; }

.api-response { background:#1e2534;color:#e2e8f0;border-radius:var(--radius);padding:16px;font-family:var(--mono);font-size:12px;line-height:1.6;overflow-x:auto;white-space:pre;max-height:400px;overflow-y:auto; }

/* ── Webhook status ── */
.wh-status-dot { width:8px;height:8px;border-radius:50%;display:inline-block;margin-right:6px; }
.wh-active { background:var(--green); }
.wh-inactive { background:var(--text3); }
.wh-error { background:var(--red); }

/* ═══════════════════════════════════════════════════════
   TOPBAR — Profile menu top-right
   ═══════════════════════════════════════════════════════ */
.topbar { justify-content: space-between; padding: 0 20px; }
.topbar-left  { display: flex; flex-direction: column; justify-content: center; }
.topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.topbar-clock { font-size: 12px; color: var(--text2); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Search in topbar */
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text3); width: 14px; height: 14px; pointer-events: none; }
.search-input { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 12px 7px 32px; color: var(--text); font-family: var(--font); font-size: 13px; width: 220px; outline: none; transition: all .2s; }
.search-input:focus { border-color: var(--primary); background: var(--bg2); box-shadow: 0 0 0 3px rgba(59,130,246,.08); width: 280px; }
.search-input::placeholder { color: var(--text3); }

/* Profile button */
.profile-menu { position: relative; }
.profile-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px 5px 5px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-family: var(--font);
  transition: all .2s;
  min-width: 160px;
}
.profile-btn:hover { border-color: var(--border2); background: var(--bg2); }
.profile-avatar {
  width: 30px; height: 30px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.profile-info { flex: 1; text-align: left; min-width: 0; }
.profile-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-role { font-size: 11px; color: var(--text3); text-transform: capitalize; }

/* Profile dropdown */
.profile-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  z-index: 500;
  overflow: hidden;
  display: none;
  animation: ddFade .15s ease;
}
.profile-dropdown.open { display: block; }
@keyframes ddFade { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:none; } }

.profile-dropdown-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 12px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}
.profile-avatar-lg {
  width: 38px; height: 38px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.profile-dropdown-divider { height: 1px; background: var(--border); margin: 3px 0; }
.profile-dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  font-size: 13px; color: var(--text2);
  text-decoration: none;
  cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
  font-family: var(--font);
  transition: background .15s, color .15s;
}
.profile-dropdown-item:hover { background: var(--bg3); color: var(--text); }
.profile-dropdown-item.danger { color: var(--red); }
.profile-dropdown-item.danger:hover { background: var(--red-dim); color: var(--red); }

/* ═══════════════════════════════════════════════════════
   SIDEBAR — Collapsed state & tooltips
   ═══════════════════════════════════════════════════════ */
/* Toggle arrows */
.sidebar-toggle .icon-expand { display: none; }
.sidebar.collapsed .sidebar-toggle .icon-collapse { display: none; }
.sidebar.collapsed .sidebar-toggle .icon-expand   { display: block; }

/* Collapsed nav items — equal spacing */
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 9px 0;
  height: 42px;
}
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section-label { display: none; }
.sidebar.collapsed .nav-icon {
  width: 36px; height: 36px;
  margin: 0 auto;
}

/* Sidebar footer collapsed */
.sidebar.collapsed .sidebar-footer .user-info { display: none; }
.sidebar.collapsed .sidebar-footer .user-card { justify-content: center; padding: 8px 0; }

/* Tooltips on collapsed icons - handled by JS for proper positioning */
.sidebar.collapsed .nav-item { position: relative; }
/* JS tooltip element */
#sidebar-tooltip {
  position: fixed;
  background: #1e2534;
  color: #f1f5f9;
  font-size: 12px; font-weight: 500;
  padding: 5px 11px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 99999;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  pointer-events: none;
  border: 1px solid #334155;
  display: none;
}
#sidebar-tooltip::before {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%; transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: #1e2534;
}

/* ═══════════════════════════════════════════════════════
   ACTION ICON BUTTONS (3-icon: View / Edit / Delete)
   ═══════════════════════════════════════════════════════ */
.td-actions { display: flex; align-items: center; gap: 3px; justify-content: flex-end; flex-wrap: nowrap; }

.action-icon {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer; background: none;
  transition: background .15s, border-color .15s;
  flex-shrink: 0; padding: 0;
}
.action-icon svg { width: 14px; height: 14px; pointer-events: none; display: block; }

.action-icon.view   { color: #2563eb; }
.action-icon.view:hover   { background: #dbeafe; border-color: #93c5fd; }
.action-icon.edit   { color: #b45309; }
.action-icon.edit:hover   { background: #fef3c7; border-color: #fcd34d; }
.action-icon.delete { color: #dc2626; }
.action-icon.delete:hover { background: #fee2e2; border-color: #fca5a5; }

/* ── Sidebar bottom expand/collapse button ── */
.sidebar-toggle-bottom {
  width: 100%; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer; color: var(--text2);
  transition: all .2s;
}
.sidebar-toggle-bottom:hover { background: var(--border); color: var(--text); }
/* Only show when collapsed */
.sidebar:not(.collapsed) .sidebar-toggle-bottom { display: none; }
/* Hide top toggle when collapsed (bottom one takes over) */
.sidebar.collapsed .sidebar-toggle { display: none; }

/* tooltip overflow handled via JS */

/* ── Page title with count on right ── */
.page-record-count {
  font-size: 13px; color: var(--text2);
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 20px; padding: 2px 10px;
  font-weight: 500;
}

/* ── Autocomplete dropdown ── */
.ac-dropdown {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  display: none;
  max-height: 200px;
  overflow-y: auto;
}
.ac-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover { background: var(--bg3); }

/* ── Per-page in pagination ── */
.page-per-page {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 4px 8px;
  color: var(--text); font-family: var(--font); font-size: 12px;
  cursor: pointer; outline: none;
}
.page-per-page:focus { border-color: var(--primary); }

/* ── Record count badge beside title ── */
.record-count-badge {
  font-size: 13px; color: var(--text2);
  font-weight: 400;
}

/* ── Pagination always shows ── */
.pagination { min-height: 44px; }

/* ── Invoice line items ── */
.li-row input, .li-row select { font-size:12px; padding:6px 8px; }

/* ── Autocomplete dropdown ── */
.ac-dropdown {
  position: absolute; top:100%; left:0; right:0;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  z-index: 600; display: none; max-height: 180px; overflow-y: auto;
}
.ac-item { padding: 8px 12px; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--border); transition: background .1s; }
.ac-item:last-child { border-bottom: none; }
.ac-item:hover { background: var(--bg3); }
