/* ==================== RESET & BASE ==================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --sidebar-bg: #0f172a;
  --sidebar-width: 240px;
  --topbar-h: 64px;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --gold: #c8960c;
  --gold-light: #f5d020;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 6px rgba(0,0,0,0.1), 0 10px 25px rgba(0,0,0,0.1);
}

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

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

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.brand-icon { font-size: 24px; }
.brand-name { display: block; font-weight: 700; font-size: 15px; color: #f1f5f9; }
.brand-sub { display: block; font-size: 10px; color: #64748b; text-transform: uppercase; letter-spacing: 1px; }

.sidebar-nav { flex: 1; padding: 12px 10px; }
.nav-section { margin-bottom: 16px; }
.nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #475569;
  padding: 0 8px;
  margin-bottom: 4px;
  display: block;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 7px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 13.5px;
  transition: all 0.15s ease;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,0.07); color: #e2e8f0; }
.nav-item.active { background: rgba(37,99,235,0.2); color: #60a5fa; font-weight: 500; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,0.07);
  gap: 8px;
}
.user-info { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: white;
  flex-shrink: 0;
}
.user-name { display: block; font-size: 12px; font-weight: 600; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: 10px; color: #64748b; }
.logout-btn {
  background: none; border: none; cursor: pointer;
  color: #64748b; font-size: 18px; padding: 4px;
  border-radius: 5px; transition: color 0.15s;
}
.logout-btn:hover { color: #ef4444; }

/* ==================== MAIN CONTENT ==================== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.page-title { font-size: 18px; font-weight: 700; color: var(--text); }
.breadcrumb { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.breadcrumb a { color: var(--primary); text-decoration: none; }
.topbar-right { display: flex; gap: 8px; align-items: center; }
.action-group { display: flex; gap: 8px; }

.content-area { padding: 24px; flex: 1; }

/* ==================== ALERTS ==================== */
.alert {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13.5px;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ==================== CARDS ==================== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 20px;
}
.card:last-child { margin-bottom: 0; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
.card-header h3 { font-size: 15px; font-weight: 600; color: var(--text); }
.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }
.mb-4 { margin-bottom: 16px; }
.mt-2 { margin-top: 8px; }

/* ==================== STATS ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.stat-icon { font-size: 28px; }
.stat-number { font-size: 26px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-blue .stat-number { color: var(--primary); }
.stat-green .stat-number { color: var(--success); }
.stat-yellow .stat-number { color: var(--warning); }
.stat-red .stat-number { color: var(--danger); }

/* ==================== TABLES ==================== */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  background: #f8fafc; padding: 10px 14px;
  text-align: left; font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }

.serial-badge {
  background: #eff6ff; color: var(--primary);
  border: 1px solid #bfdbfe;
  padding: 3px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
  font-family: monospace;
  white-space: nowrap;
}

.status-badge {
  padding: 3px 10px; border-radius: 20px;
  font-size: 11.5px; font-weight: 500;
  white-space: nowrap;
}
.status-active { background: #dcfce7; color: #166534; }
.status-expired { background: #fee2e2; color: #991b1b; }
.status-expiring { background: #fef3c7; color: #92400e; }
.status-unknown { background: #f1f5f9; color: #64748b; }

.badge {
  background: var(--primary-light); color: var(--primary);
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}

.action-btns { display: flex; align-items: center; gap: 4px; }
.btn-icon {
  background: none; border: none; cursor: pointer;
  padding: 5px 6px; border-radius: 6px; font-size: 14px;
  text-decoration: none; display: inline-flex; align-items: center;
  transition: background 0.15s;
}
.btn-icon:hover { background: #f1f5f9; }
.btn-icon.btn-danger:hover { background: #fee2e2; }

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px;
  font-size: 13.5px; font-weight: 500;
  cursor: pointer; text-decoration: none;
  border: none; transition: all 0.15s ease;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #f1f5f9; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-full { width: 100%; justify-content: center; }

/* ==================== FORMS ==================== */
.form-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
  background: #fafbfc;
}
.section-title {
  font-size: 14px; font-weight: 600; margin-bottom: 14px;
  color: var(--text); padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.form-group { margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-muted); margin-bottom: 5px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  background: white;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-group textarea { resize: vertical; }
.file-input { padding: 6px 8px; cursor: pointer; }
.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; display: block; }
.error-msg { font-size: 12px; color: var(--danger); margin-top: 4px; display: block; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.form-notice {
  background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: 7px; padding: 10px 14px;
  font-size: 13px; color: #1d4ed8; margin-bottom: 16px;
  display: flex; align-items: center; gap: 6px;
}
.current-signature { margin-bottom: 8px; display: flex; align-items: center; gap: 10px; }
.current-file-preview { margin-bottom: 10px; }
.preview-caption { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.checkbox-group { margin-bottom: 8px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.checkbox-label input { width: auto; }

/* ==================== FILTERS ==================== */
.filter-form { }
.filter-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.filter-actions { display: flex; gap: 8px; }

/* ==================== PAGINATION ==================== */
.pagination-wrapper { padding: 14px 16px; border-top: 1px solid var(--border); }
.pagination-wrapper .pagination { display: flex; gap: 4px; list-style: none; flex-wrap: wrap; }
.pagination-wrapper .page-item .page-link {
  padding: 6px 12px; border: 1px solid var(--border);
  border-radius: 6px; text-decoration: none; color: var(--text);
  font-size: 13px; display: block;
}
.pagination-wrapper .page-item.active .page-link { background: var(--primary); color: white; border-color: var(--primary); }
.pagination-wrapper .page-item.disabled .page-link { color: var(--text-muted); pointer-events: none; }

/* ==================== EMPTY STATE ==================== */
.empty-state { text-align: center; padding: 50px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 18px; color: var(--text); margin-bottom: 6px; }
.empty-state p { color: var(--text-muted); margin-bottom: 16px; }

/* ==================== DETAILS PAGE ==================== */
.details-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.details-column { display: flex; flex-direction: column; gap: 0; }
.detail-row { display: flex; padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
.detail-row:last-child { border-bottom: none; }
.detail-label { width: 160px; flex-shrink: 0; font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.detail-value { flex: 1; font-size: 13.5px; color: var(--text); }

/* ==================== CERTIFICATE PREVIEW ==================== */
.cert-display { }
.cert-bg {
  background: linear-gradient(135deg, #0a1628 0%, #1a2a4a 30%, #0d1f3c 70%, #0a1628 100%);
  border-radius: 8px;
  color: white;
  padding: 16px;
  font-family: Arial, sans-serif;
  position: relative;
  border: 3px solid var(--gold);
  margin-bottom: 12px;
}
.cert-header-section { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.cert-logo { width: 50px; height: 50px; object-fit: contain; }
.cert-logo-placeholder { width: 50px; height: 50px; background: rgba(200,150,12,0.2); border: 2px solid var(--gold); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.cert-title-block { flex: 1; text-align: center; }
.cert-main-title { font-size: 13px; font-weight: 800; letter-spacing: 2px; color: var(--gold-light); text-transform: uppercase; }
.cert-subtitle { font-size: 9px; color: #c8c8c8; margin-top: 2px; }
.cert-company { text-align: center; font-size: 15px; font-weight: 700; color: white; margin: 6px 0; text-transform: uppercase; letter-spacing: 1px; }
.cert-scope-section { text-align: center; margin: 4px 0; }
.cert-scope-label { font-size: 8px; color: var(--gold); text-transform: uppercase; letter-spacing: 1px; }
.cert-scope-text { font-size: 9px; color: #e0e0e0; font-style: italic; line-height: 1.4; }
.cert-standard { text-align: center; margin: 6px 0; }
.cert-standard strong { display: inline-block; background: rgba(200,150,12,0.2); border: 1.5px solid var(--gold); padding: 3px 14px; border-radius: 4px; font-size: 11px; color: var(--gold-light); letter-spacing: 1px; }
.cert-dates-row { display: flex; gap: 6px; margin: 8px 0; }
.cert-date-item { flex: 1; text-align: center; background: rgba(255,255,255,0.05); border: 1px solid rgba(200,150,12,0.3); border-radius: 4px; padding: 5px; }
.cert-date-label { font-size: 7px; color: var(--gold); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
.cert-date-value { font-size: 9px; font-weight: bold; }
.cert-reg-block { margin: 6px 0; }
.cert-reg-label { font-size: 8px; color: var(--gold); text-transform: uppercase; }
.cert-reg-number { font-size: 10px; font-weight: bold; }
.cert-footer-row { display: flex; align-items: flex-end; justify-content: space-between; margin-top: 8px; }
.cert-signature-block { text-align: center; }
.cert-signature { max-height: 40px; max-width: 100px; }
.cert-sig-placeholder { height: 40px; }
.cert-sig-line { font-size: 8px; color: #c8c8c8; border-top: 1px solid rgba(200,150,12,0.4); padding-top: 3px; margin-top: 3px; width: 100px; }
.cert-serial-block { text-align: right; }
.cert-serial { font-size: 8px; color: var(--gold); font-family: monospace; }
.cert-actions { margin-top: 8px; }

/* ==================== PUBLIC URL ==================== */
.public-url-box { display: flex; gap: 8px; }
.url-input { flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 12px; background: #f8fafc; font-family: monospace; }

/* ==================== LOGIN ==================== */
.login-body {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
}
.login-wrapper { width: 100%; max-width: 400px; padding: 20px; }
.login-card {
  background: white; border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
}
.login-header {
  background: linear-gradient(135deg, #0f172a, #1e3a5f);
  padding: 32px 28px 24px;
  text-align: center; color: white;
}
.login-logo { font-size: 48px; margin-bottom: 8px; display: block; }
.login-header h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-header p { font-size: 13px; color: #94a3b8; }
.login-form { padding: 28px; }
.login-footer { padding: 12px 28px 20px; text-align: center; font-size: 12px; color: var(--text-muted); }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-grid { grid-template-columns: repeat(2, 1fr); }
  .details-grid { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .filter-grid { grid-template-columns: 1fr; }
}
