:root {
  --blue-50:  #EFF6FF;
  --blue-100: #DBEAFE;
  --blue-600: #2563EB;
  --blue-700: #1D4ED8;
  --red-600:  #DC2626;
  --red-700:  #B91C1C;
  --green-50: #F0FDF4;
  --green-600:#16A34A;
  --yellow-50:#FEFCE8;
  --yellow-600:#CA8A04;
  --orange-600:#EA580C;
  --purple-600:#7C3AED;
  --gray-50:  #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-900: #111827;
  --white:    #FFFFFF;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --radius:    8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --sidebar-w: 230px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--gray-900);
  background: var(--gray-50);
  line-height: 1.5;
}

/* ─── Auth pages ──────────────────────────────────────────────────────────── */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--gray-100); }
.auth-wrapper { width: 100%; max-width: 400px; padding: 24px; }
.auth-logo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 32px; }
.logo-text { font-size: 20px; font-weight: 700; color: var(--gray-900); }
.auth-card { background: var(--white); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow-md); }
.auth-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.auth-subtitle { color: var(--gray-500); margin-bottom: 24px; }
.auth-footer { text-align: center; margin-top: 20px; color: var(--gray-500); }
.auth-footer a { color: var(--blue-600); text-decoration: none; }
.auth-legal { text-align: center; margin-top: 16px; font-size: 12px; color: var(--gray-500); }

/* ─── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 13px; }
.form-group input, .select, .search-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
  background: var(--white);
}
.form-group input:focus, .select:focus, .search-input:focus { border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
textarea.form-control {
  width: 100%; padding: 9px 12px; border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); font-size: 14px; resize: vertical;
  font-family: inherit; outline: none;
}
textarea.form-control:focus { border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm); font-size: 14px;
  font-weight: 500; cursor: pointer; border: none; transition: all .15s;
  text-decoration: none; white-space: nowrap;
}
.btn-primary   { background: var(--blue-600); color: var(--white); }
.btn-primary:hover { background: var(--blue-700); }
.btn-secondary { background: var(--white); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-50); }
.btn-ghost     { background: transparent; color: var(--gray-700); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-danger    { background: var(--red-600); color: var(--white); padding: 4px 10px; font-size: 12px; }
.btn-danger:hover { background: var(--red-700); }
.btn-success   { background: var(--green-600); color: var(--white); }
.btn-full      { width: 100%; }
.btn-sm        { padding: 4px 10px; font-size: 12px; }

/* ─── Alerts ──────────────────────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; }
.alert-error   { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.alert-success { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }
.alert-warning { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }
.alert-info    { background: var(--blue-50); color: #1E40AF; border: 1px solid var(--blue-100); }

/* ─── App shell (sidebar layout) ─────────────────────────────────────────── */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 20px;
  height: 54px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.topbar-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; text-decoration: none; color: var(--gray-900); min-width: var(--sidebar-w); }
.topbar-brand:hover { color: var(--blue-600); }
.topbar-spacer { flex: 1; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-username { font-weight: 600; font-size: 13px; }
.topbar-admin-warning { background: #FEF2F2; color: var(--red-600); font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; text-transform: uppercase; letter-spacing: .5px; }

.body-layout { display: flex; padding-top: 54px; min-height: calc(100vh - 54px); }

/* ─── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  position: fixed;
  top: 54px;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  padding: 16px 0 32px;
  z-index: 90;
}

.sidebar-section { padding: 0 12px; margin-bottom: 8px; }
.sidebar-label { font-size: 10px; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: .8px; padding: 8px 8px 4px; }
.sidebar-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500;
  color: var(--gray-700); text-decoration: none;
  cursor: pointer; transition: background .1s, color .1s;
  border: none; background: none; width: 100%; text-align: left;
}
.sidebar-item:hover { background: var(--gray-100); color: var(--gray-900); }
.sidebar-item.active { background: var(--blue-50); color: var(--blue-600); }
.sidebar-item svg { flex-shrink: 0; opacity: .7; }
.sidebar-item.active svg { opacity: 1; }
.sidebar-item .sidebar-badge {
  margin-left: auto; font-size: 10px; font-weight: 700;
  background: var(--red-600); color: white; border-radius: 10px;
  padding: 1px 6px; min-width: 18px; text-align: center;
}
.sidebar-divider { height: 1px; background: var(--gray-100); margin: 8px 12px; }
.sidebar-restricted { color: var(--gray-400) !important; }
.sidebar-lock { font-size: 11px; margin-left: auto; opacity: .5; }

/* ─── Main content ────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px 32px;
  max-width: calc(100% - var(--sidebar-w));
}

/* ─── Navbar (legacy — keep for compatibility) ────────────────────────────── */
.navbar {
  background: var(--white); border-bottom: 1px solid var(--gray-200);
  padding: 0 24px; height: 56px;
  display: flex; align-items: center; gap: 24px;
  position: sticky; top: 0; z-index: 100;
}
.navbar-admin { border-bottom-color: #FECACA; }
.nav-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-links a, .admin-tab {
  padding: 6px 12px; border-radius: var(--radius-sm); color: var(--gray-700);
  text-decoration: none; font-weight: 500; cursor: pointer;
}
.nav-links a:hover, .admin-tab:hover { background: var(--gray-100); }
.nav-links a.active, .admin-tab.active { background: var(--blue-600); color: var(--white); }
.nav-user { display: flex; align-items: center; gap: 10px; margin-left: auto; }

/* ─── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; text-transform: uppercase; letter-spacing: .5px;
  display: inline-block;
}
.badge-user    { background: var(--gray-100); color: var(--gray-700); }
.badge-manager { background: #EEF2FF; color: #3730A3; }
.badge-admin   { background: #FEF2F2; color: var(--red-600); }
.badge-open        { background: var(--blue-50); color: var(--blue-600); }
.badge-in_progress { background: #FFF7ED; color: var(--orange-600); }
.badge-pending     { background: var(--yellow-50); color: var(--yellow-600); }
.badge-resolved    { background: var(--green-50); color: var(--green-600); }
.badge-closed      { background: var(--gray-100); color: var(--gray-500); }
.badge-critical    { background: #FEF2F2; color: var(--red-600); }
.badge-high        { background: #FFF7ED; color: var(--orange-600); }
.badge-medium      { background: var(--yellow-50); color: var(--yellow-600); }
.badge-low         { background: var(--green-50); color: var(--green-600); }
.badge-restricted  { background: #FEF2F2; color: var(--red-600); }
.badge-confidential{ background: #FFF7ED; color: var(--orange-600); }
.badge-internal    { background: var(--yellow-50); color: var(--yellow-600); }
.badge-public      { background: var(--green-50); color: var(--green-600); }
.badge-green  { background: var(--green-50); color: var(--green-600); }
.badge-yellow { background: var(--yellow-50); color: var(--yellow-600); }
.badge-red    { background: #FEF2F2; color: var(--red-600); }
.badge-active    { background: var(--blue-50); color: var(--blue-600); }
.badge-completed { background: var(--green-50); color: var(--green-600); }
.badge-on_hold   { background: var(--yellow-50); color: var(--yellow-600); }
.badge-planning  { background: var(--gray-100); color: var(--gray-600); }
.badge-cancelled { background: var(--gray-100); color: var(--gray-500); }

/* ─── Container ───────────────────────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; }
.page-header-sub { color: var(--gray-500); font-size: 13px; margin-top: 2px; }

/* ─── Search bar ──────────────────────────────────────────────────────────── */
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-input { flex: 1; }
.select { width: auto; min-width: 160px; }

/* ─── Card ────────────────────────────────────────────────────────────────── */
.card { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); overflow: hidden; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* ─── Table ───────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th { padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 700; color: var(--gray-500); text-transform: uppercase; letter-spacing: .5px; background: var(--gray-50); border-bottom: 1px solid var(--gray-200); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--gray-50); }
.table-compact td, .table-compact th { padding: 8px 12px; }

/* ─── Modal ───────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.modal-content { position: relative; background: var(--white); border-radius: var(--radius); width: 640px; max-width: 90vw; max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-content-sm { width: 420px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--gray-200); }
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--gray-500); line-height: 1; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-200); display: flex; gap: 8px; justify-content: flex-end; }

/* ─── Stats ───────────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 20px 24px; }
.stat-card.stat-card-blue   { border-top: 3px solid var(--blue-600); }
.stat-card.stat-card-green  { border-top: 3px solid var(--green-600); }
.stat-card.stat-card-orange { border-top: 3px solid var(--orange-600); }
.stat-card.stat-card-red    { border-top: 3px solid var(--red-600); }
.stat-value { font-size: 32px; font-weight: 800; color: var(--gray-900); }
.stat-value.blue   { color: var(--blue-600); }
.stat-value.green  { color: var(--green-600); }
.stat-value.orange { color: var(--orange-600); }
.stat-value.red    { color: var(--red-600); }
.stat-label { color: var(--gray-500); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; margin-top: 4px; }
.stat-detail { font-size: 12px; color: var(--gray-400); margin-top: 8px; word-break: break-all; }

/* ─── Dashboard widgets ───────────────────────────────────────────────────── */
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.widget { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); overflow: hidden; }
.widget-header { padding: 14px 20px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; }
.widget-title { font-size: 13px; font-weight: 700; color: var(--gray-700); text-transform: uppercase; letter-spacing: .4px; }
.widget-body { padding: 0; }
.widget-item { padding: 12px 20px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: flex-start; gap: 12px; }
.widget-item:last-child { border-bottom: none; }
.widget-item-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 14px; }
.widget-item-main { flex: 1; min-width: 0; }
.widget-item-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.widget-item-sub { font-size: 12px; color: var(--gray-500); margin-top: 1px; }
.widget-empty { padding: 32px 20px; text-align: center; color: var(--gray-400); font-size: 13px; }

/* ─── Announcement card ───────────────────────────────────────────────────── */
.announcement {
  padding: 14px 20px; border-bottom: 1px solid var(--gray-100);
}
.announcement:last-child { border-bottom: none; }
.announcement-title { font-weight: 600; font-size: 13.5px; margin-bottom: 4px; }
.announcement-title .pinned-tag { font-size: 10px; background: #DBEAFE; color: #1D4ED8; padding: 1px 6px; border-radius: 4px; font-weight: 700; margin-right: 6px; vertical-align: middle; }
.announcement-content { font-size: 13px; color: var(--gray-600); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.announcement-meta { font-size: 11px; color: var(--gray-400); margin-top: 6px; }
.announcement-restricted { background: #FFF7ED; border-left: 3px solid var(--orange-600); }

/* ─── Avatar ──────────────────────────────────────────────────────────────── */
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; background: var(--blue-100); color: var(--blue-600);
  flex-shrink: 0;
}
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }

/* ─── Employee card (HR) ──────────────────────────────────────────────────── */
.employee-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.employee-card { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 20px; display: flex; gap: 14px; align-items: flex-start; transition: box-shadow .15s; }
.employee-card:hover { box-shadow: var(--shadow-md); }
.employee-info { flex: 1; min-width: 0; }
.employee-name { font-weight: 600; font-size: 14px; }
.employee-title { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.employee-dept { font-size: 11px; color: var(--gray-400); margin-top: 4px; }
.employee-contact { font-size: 12px; color: var(--gray-600); margin-top: 6px; }
.employee-contact a { color: var(--blue-600); text-decoration: none; }

/* ─── Ticket / issue ──────────────────────────────────────────────────────── */
.ticket-ref { font-family: monospace; font-size: 12px; color: var(--gray-500); }
.priority-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.priority-dot.critical { background: var(--red-600); }
.priority-dot.high     { background: var(--orange-600); }
.priority-dot.medium   { background: var(--yellow-600); }
.priority-dot.low      { background: var(--green-600); }

/* ─── Project card ────────────────────────────────────────────────────────── */
.project-card { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 20px; }
.project-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.project-code { font-family: monospace; font-size: 11px; color: var(--gray-400); }
.project-name { font-weight: 700; font-size: 15px; margin-top: 2px; }
.progress-bar-wrap { background: var(--gray-100); border-radius: 4px; height: 6px; margin: 10px 0 6px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 4px; background: var(--blue-600); transition: width .3s; }
.progress-bar.red    { background: var(--red-600); }
.progress-bar.yellow { background: var(--yellow-600); }
.progress-bar.green  { background: var(--green-600); }
.progress-label { font-size: 11px; color: var(--gray-500); display: flex; justify-content: space-between; }

/* ─── Finance ─────────────────────────────────────────────────────────────── */
.finance-restricted-banner { background: #FFF7ED; border: 1px solid #FDE68A; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--yellow-600); }

/* ─── Vault ───────────────────────────────────────────────────────────────── */
.vault-locked { text-align: center; padding: 60px 20px; }
.vault-icon { font-size: 64px; margin-bottom: 16px; }
.vault-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.vault-subtitle { color: var(--gray-500); margin-bottom: 32px; }
.pin-input { text-align: center; letter-spacing: 12px; font-size: 24px; font-weight: 700; width: 200px; padding: 12px 16px; }

/* ─── Profile ─────────────────────────────────────────────────────────────── */
.profile-header { display: flex; align-items: center; gap: 20px; margin-bottom: 28px; }
.profile-avatar-lg { width: 72px; height: 72px; border-radius: 50%; font-size: 24px; font-weight: 700; background: var(--blue-100); color: var(--blue-600); display: flex; align-items: center; justify-content: center; }
.profile-meta h2 { font-size: 20px; font-weight: 700; }
.profile-meta p { color: var(--gray-500); margin-top: 2px; }

/* ─── Misc ────────────────────────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted  { color: var(--gray-500); }
.text-small  { font-size: 12px; }
.text-mono   { font-family: monospace; }
.file-input  { display: block; margin-bottom: 16px; }
.tab-content { }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.flex-1 { flex: 1; }

.category-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 600;
  background: var(--gray-100); color: var(--gray-700);
}
.link-btn { background: none; border: none; color: var(--blue-600); cursor: pointer; font-size: 14px; text-decoration: underline; }

/* ─── Breadcrumb ──────────────────────────────────────────────────────────── */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--gray-400); margin-bottom: 20px; }
.breadcrumb a { color: var(--gray-500); text-decoration: none; }
.breadcrumb a:hover { color: var(--blue-600); }
.breadcrumb-sep { font-size: 10px; }

/* ─── Empty state ─────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--gray-400); }
.empty-state-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }
.empty-state-text { font-size: 13px; }

/* ─── Skeleton ────────────────────────────────────────────────────────────── */
.skeleton { background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-50) 50%, var(--gray-100) 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} }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; max-width: 100%; padding: 16px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .employee-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
