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

:root {
  --primary: #1e40af;
  --primary-dark: #1e3a8a;
  --primary-light: #3b82f6;
  --secondary: #475569;
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --bg: #f1f5f9;
  --sidebar-bg: #0f172a;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.header-logo img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: contain;
}
.header-logo span {
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
}
.header-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}
.header-nav a {
  color: #cbd5e1;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 6px;
  transition: all 0.2s;
}
.header-nav a:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

/* Hero Section */
.hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  text-align: center;
  padding: 48px 24px 32px;
}
.hero-content {
  max-width: 600px;
  margin: 0 auto;
}
.hero-logo {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  object-fit: contain;
  margin-bottom: 16px;
}
.hero h1 {
  color: #fff;
  font-size: 26px;
  font-weight: 700;
}
.hero-subtitle {
  color: #94a3b8;
  font-size: 15px;
  margin-top: 6px;
}
.hero-rc {
  color: #64748b;
  font-size: 13px;
  margin-top: 2px;
}

/* Plans Section */
.plans-section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px;
  text-align: center;
}
.plans-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}
.plans-desc {
  color: var(--text-light);
  font-size: 14px;
  margin-bottom: 28px;
}
.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
}
.plan-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 24px 16px 20px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  display: flex;
  flex-direction: column;
}
.plan-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.plan-name {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
  margin-bottom: 8px;
}
.plan-price {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 2px;
}
.plan-duration {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 16px;
}
.plan-features {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  flex: 1;
}
.plan-features li {
  font-size: 13px;
  color: var(--secondary);
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.plan-features li:last-child { border-bottom: none; }
.plan-btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: background 0.2s;
}
.plan-btn:hover { background: var(--primary-dark); }
.plan-card.plan-free .plan-btn { background: #059669; }
.plan-card.plan-free .plan-btn:hover { background: #047857; }
.plan-card.plan-yearly { border: 2px solid var(--primary-light); }

/* Auth Section (below plans) */
.auth-section {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  padding: 48px 24px 64px;
}
.auth-section .auth-container {
  max-width: 420px;
  margin: 0 auto;
  padding: 0;
}
.auth-section .auth-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
}
.auth-section .auth-header {
  text-align: center;
  margin-bottom: 24px;
}
.auth-section .auth-header h2 {
  font-size: 22px;
  color: var(--text);
}
.auth-section .auth-header p {
  color: var(--text-light);
  font-size: 14px;
  margin-top: 4px;
}

input[readonly] {
  background: #f1f5f9;
  cursor: default;
}
.site-footer {
  background: #0f172a;
  color: #94a3b8;
  text-align: center;
  padding: 28px 24px;
  font-size: 13px;
}
.site-footer p { margin-bottom: 8px; }
.footer-links a {
  color: #94a3b8;
  text-decoration: none;
  font-size: 13px;
}
.footer-links a:hover { color: #fff; }
.footer-links span { color: #475569; margin: 0 8px; }
@media (max-width: 640px) {
  .plans-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Auth Page (legacy login-only pages) */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
}

.auth-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.auth-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-logo {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  object-fit: contain;
  margin-bottom: 16px;
}

.auth-header h1 {
  font-size: 22px;
  color: var(--text);
}

.auth-header p {
  color: var(--text-light);
  font-size: 14px;
  margin-top: 4px;
}
.reg-number {
  font-size: 12px !important;
  color: #94a3b8 !important;
  margin-top: 2px !important;
}

.auth-tabs {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 24px;
  overflow: hidden;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-light);
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--primary);
  color: white;
}

/* Sidebar */
.sidebar {
  width: 240px;
  height: 100vh;
  background: var(--sidebar-bg);
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-header h2 {
  color: white;
  font-size: 16px;
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.nav-link:hover {
  background: rgba(255,255,255,0.05);
  color: white;
}

.nav-link.active {
  background: rgba(59,130,246,0.1);
  color: white;
  border-left-color: var(--primary-light);
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info span {
  color: #94a3b8;
  font-size: 13px;
}

/* Main Content */
.main-content {
  margin-left: 240px;
  min-height: 100vh;
}

.topbar {
  background: var(--card-bg);
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 {
  font-size: 20px;
  font-weight: 600;
}

.topbar-company {
  display: block;
  font-size: 13px;
  color: var(--primary-light);
  font-weight: 600;
  margin-top: 2px;
}

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

#welcomeUser {
  color: var(--text-light);
  font-size: 14px;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #047857;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--bg);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-full {
  width: 100%;
  justify-content: center;
  padding: 10px;
}

/* Form Styles */
.auth-form, #employeeForm, #payrollForm {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-top: 8px;
}

.auth-links {
  text-align: center;
  font-size: 12px;
  margin-top: 4px;
}
.auth-links a {
  color: var(--primary);
  text-decoration: none;
}
.auth-links a:hover {
  text-decoration: underline;
}
.auth-links-sep {
  color: var(--border);
  margin: 0 6px;
}
.checkbox-group {
  margin: 0;
}
.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 6px;
  font-size: 12px !important;
  font-weight: 400 !important;
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  width: auto !important;
  margin: 0;
  cursor: pointer;
}
.checkbox-label a {
  color: var(--primary);
  text-decoration: none;
}
.checkbox-label a:hover {
  text-decoration: underline;
}

.user-info-company {
  color: var(--primary-light);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  text-align: center;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.form-group input,
.form-group select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  background: white;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.password-wrapper {
  position: relative;
}
.password-wrapper input {
  width: 100%;
  padding-right: 40px;
}
.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-light);
  padding: 4px;
  line-height: 1;
}
.password-toggle:hover {
  color: var(--primary);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Alert */
.alert {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-top: 12px;
}

.alert-error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.alert-success {
  background: #f0fdf4;
  color: var(--success);
  border: 1px solid #bbf7d0;
}

/* Dashboard Cards */
.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  padding: 24px 32px;
}

.stat-card {
  background: var(--card-bg);
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.blue {
  background: #eff6ff;
  color: var(--primary-light);
}

.stat-icon.green {
  background: #ecfdf5;
  color: var(--success);
}

.stat-icon.orange {
  background: #fff7ed;
  color: var(--warning);
}

.stat-icon.purple {
  background: #faf5ff;
  color: #9333ea;
}

.stat-info h3 {
  font-size: 22px;
  font-weight: 700;
}

.stat-info p {
  font-size: 13px;
  color: var(--text-light);
}

/* Content Grid */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 0 32px 32px;
}

.content-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.content-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

/* Tables */
.table-container {
  padding: 24px 32px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.page-btn {
  min-width: 36px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.page-btn:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.page-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
}
.page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.page-ellipsis {
  color: var(--text-light);
  font-size: 13px;
  padding: 0 2px;
}
.page-info {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 12px;
  text-align: right;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

table thead {
  background: #f8fafc;
}

table th, table td {
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

table th {
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

table td {
  color: var(--text);
}

table tbody tr:hover {
  background: #f8fafc;
}

.empty-state {
  text-align: center;
  color: var(--text-light);
  padding: 24px !important;
}

.empty-icon {
  font-size: 48px;
  color: var(--text-light);
  margin-bottom: 12px;
}

.empty-report {
  text-align: center;
  padding: 80px 32px;
  color: var(--text-light);
}

.empty-report h3 {
  margin-top: 12px;
  color: var(--text);
}

.empty-report p {
  font-size: 14px;
}

/* Filters */
.filters {
  display: flex;
  gap: 12px;
  padding: 0 32px 16px;
  flex-wrap: wrap;
}

.filter-input {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--card-bg);
  min-width: 250px;
}

.filter-input:focus {
  outline: none;
  border-color: var(--primary-light);
}

.filter-select {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--card-bg);
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary-light);
}

.report-filters {
  display: flex;
  gap: 12px;
  padding: 24px 32px;
  align-items: end;
}

.report-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  padding: 0 32px 24px;
}

.report-cards .stat-card {
  padding: 16px 20px;
}

.report-cards .stat-info h3 {
  font-size: 18px;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--card-bg);
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

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

.modal-header h2 {
  font-size: 18px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

.modal form {
  padding: 24px;
}

/* Payroll Preview */
.payroll-preview {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-top: 8px;
}

.payroll-preview h3 {
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--text);
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.preview-item {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 4px 0;
}

.preview-item span {
  color: var(--text-light);
}

.preview-item strong {
  color: var(--text);
}

.preview-item.deduction strong {
  color: var(--danger);
}

.preview-item.total {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 4px;
}

.preview-item.total strong {
  color: var(--success);
  font-size: 16px;
}

/* Status Badge */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.status-active {
  background: #dcfce7;
  color: #166534;
}

.status-inactive {
  background: #f1f5f9;
  color: #64748b;
}

.status-terminated {
  background: #fef2f2;
  color: #991b1b;
}

.status-pending {
  background: #fefce8;
  color: #854d0e;
}

.status-paid {
  background: #dcfce7;
  color: #166534;
}

.status-cancelled {
  background: #fef2f2;
  color: #991b1b;
}

/* Action Buttons in Table */
.action-btns {
  display: flex;
  gap: 4px;
}

.action-btn {
  padding: 4px 8px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: opacity 0.2s;
}

.action-btn:hover {
  opacity: 0.8;
}

.action-btn.edit {
  background: #eff6ff;
  color: var(--primary-light);
}

.action-btn.delete {
  background: #fef2f2;
  color: var(--danger);
}

.action-btn.download {
  background: #f0fdf4;
  color: var(--success);
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
    overflow: hidden;
  }

  .sidebar-header h2,
  .sidebar-footer .user-info span,
  .sidebar-footer .user-info .btn {
    display: none;
  }

  .sidebar-header {
    justify-content: center;
    padding: 16px;
  }

  .nav-link {
    justify-content: center;
    padding: 12px;
    border-left: none;
  }

  .nav-link span:last-child {
    display: none;
  }

  .main-content {
    margin-left: 60px;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .dashboard-cards {
    grid-template-columns: 1fr 1fr;
    padding: 16px;
  }

  .topbar {
    padding: 12px 16px;
  }

  .table-container {
    padding: 16px;
    overflow-x: auto;
  }

  .filters {
    padding: 0 16px 12px;
  }
}

@media print {
  body * { visibility: hidden; }
  .main-content, .main-content * { visibility: visible; }
  .main-content { position: absolute; left: 0; top: 0; width: 100%; }
  .sidebar, .topbar, .report-filters, .no-print, .pagination { display: none !important; }
  .report-cards { display: grid !important; }
  #reportTableContainer { display: block !important; }
  #emptyReport { display: none !important; }
  .stat-card { break-inside: avoid; }
  table { font-size: 11px; }
  table tr { break-inside: avoid; }
}
