:root {
    --primary: #1a3a6b;
    --primary-light: #2d5ba3;
    --secondary: #c8a843;
    --accent: #e63946;
    --success: #2a9d5c;
    --warning: #f4a017;
    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --text: #1a1a2e;
    --text-muted: #6c757d;
    --border: #dee2e6;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --radius: 10px;
    --sidebar-w: 260px;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--primary) 0%, #0d2248 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    overflow-y: auto;
}

.sidebar-brand {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand .brand-icon {
    width: 48px; height: 48px;
    background: var(--secondary);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    margin-bottom: 10px;
}

.sidebar-brand h5 {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
}

.sidebar-brand small {
    font-size: 11px;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

.nav-section {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    opacity: 0.5;
    padding: 12px 12px 6px;
}

.nav-item { margin-bottom: 2px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
}

.nav-link:hover, .nav-link.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

.nav-link.active {
    background: rgba(200,168,67,0.25);
    color: var(--secondary);
    border-left: 3px solid var(--secondary);
}

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

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

/* ─── Main Content ─── */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.topbar h4 {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
}

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

.admin-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.admin-avatar {
    width: 30px; height: 30px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.page-content { padding: 28px; flex: 1; }

/* ─── Cards ─── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #fafbfc, #f0f2f5);
}

.card-header h5 {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body { padding: 20px; }

/* ─── Stat Cards ─── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

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

.stat-icon.blue   { background: rgba(26,58,107,0.1); color: var(--primary); }
.stat-icon.gold   { background: rgba(200,168,67,0.15); color: #a07820; }
.stat-icon.green  { background: rgba(42,157,92,0.1); color: var(--success); }
.stat-icon.red    { background: rgba(230,57,70,0.1); color: var(--accent); }

.stat-info h3 {
    font-size: 26px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-info p {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover { background: #5a6268; }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #228b4a; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d4890f; }
.btn-danger    { background: var(--accent); color: #fff; }
.btn-danger:hover { background: #c1121f; }
.btn-gold      { background: var(--secondary); color: #5a3800; }
.btn-gold:hover { background: #b8942f; }
.btn-outline   { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }

/* ─── Forms ─── */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-label.required::after {
    content: ' *';
    color: var(--accent);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    font-family: inherit;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,58,107,0.1);
}

.form-control::placeholder { color: #bbb; }

select.form-control { cursor: pointer; }

textarea.form-control { resize: vertical; min-height: 80px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 20px; }

.form-section {
    background: linear-gradient(135deg, #f8f9ff, #eff1f8);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 24px;
    border: 1px solid #dde3f0;
}

.form-section h6 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ─── Tables ─── */
.table-wrapper { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.table th {
    background: linear-gradient(135deg, var(--primary), #1e4d8c);
    color: #fff;
    padding: 11px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.table td {
    padding: 11px 14px;
    border-bottom: 1px solid #f0f2f5;
    vertical-align: middle;
}

.table tr:hover td { background: #f8f9ff; }
.table tr:last-child td { border-bottom: none; }

/* ─── Badges ─── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success  { background: rgba(42,157,92,0.15); color: var(--success); }
.badge-warning  { background: rgba(244,160,23,0.15); color: #a07010; }
.badge-primary  { background: rgba(26,58,107,0.12); color: var(--primary); }
.badge-secondary { background: #e9ecef; color: #6c757d; }

/* ─── Alerts ─── */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-success { background: rgba(42,157,92,0.1); border-left: 4px solid var(--success); color: #1a5c38; }
.alert-danger  { background: rgba(230,57,70,0.1); border-left: 4px solid var(--accent); color: #7a0d13; }
.alert-warning { background: rgba(244,160,23,0.1); border-left: 4px solid var(--warning); color: #7a4e00; }
.alert-info    { background: rgba(26,58,107,0.08); border-left: 4px solid var(--primary); color: #1a3a6b; }

/* ─── Login Page ─── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0d1b2a 0%, #1a3a6b 50%, #0d1b2a 100%);
    position: relative;
}

.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 48px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    position: relative;
    z-index: 1;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .logo-circle {
    width: 72px; height: 72px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 30px;
    margin: 0 auto 12px;
    box-shadow: 0 4px 15px rgba(26,58,107,0.3);
}

.login-logo h4 {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.login-logo p {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ─── Certificate Preview ─── */
.cert-container {
    max-width: 860px;
    margin: 0 auto;
}

.cert-paper {
    background: #fff;
    border: 3px double #1a3a6b;
    border-radius: 4px;
    padding: 0;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.cert-outer-border {
    border: 8px solid #c8a843;
    border-radius: 2px;
    margin: 6px;
}

.cert-inner {
    border: 2px solid #1a3a6b;
    margin: 4px;
    padding: 28px 36px;
    position: relative;
    background: #fffef8;
}

.cert-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    font-size: 80px;
    font-weight: 900;
    color: rgba(26,58,107,0.04);
    white-space: nowrap;
    pointer-events: none;
    letter-spacing: 4px;
    text-transform: uppercase;
    z-index: 0;
    font-family: serif;
}

.cert-content { position: relative; z-index: 1; }

.cert-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 16px;
    border-bottom: 2px solid #c8a843;
    margin-bottom: 20px;
}

.cert-header .govt-logo {
    width: 72px; height: 72px;
    object-fit: contain;
}

.cert-header-center {
    text-align: center;
    flex: 1;
    padding: 0 20px;
}

.cert-header-center .dept-name {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.cert-header-center h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 3px;
}

.cert-header-center h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 2px;
}

.cert-header-center .subtitle {
    font-size: 11px;
    color: var(--text-muted);
}

.cert-title-bar {
    background: linear-gradient(135deg, var(--primary), #2d5ba3);
    color: #fff;
    text-align: center;
    padding: 10px;
    margin: 0 -36px 20px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.cert-reg-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(200,168,67,0.1);
    border: 1px solid rgba(200,168,67,0.4);
    border-radius: 6px;
    padding: 8px 16px;
    margin-bottom: 20px;
    font-size: 13px;
}

.cert-reg-bar strong { color: var(--primary); font-size: 15px; }

.cert-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 20px;
    margin-bottom: 20px;
}

.cert-field {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
    border-bottom: 1px solid #f0e8d0;
}

.cert-field.full { grid-column: 1 / -1; }

.cert-field-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 3px;
    font-weight: 600;
}

.cert-field-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.cert-footer {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    align-items: end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e0d5b8;
}

.cert-footer .qr-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.cert-footer .qr-section img {
    width: 90px; height: 90px;
    border: 1px solid #ddd;
    padding: 4px;
    background: #fff;
}

.cert-footer .qr-section small {
    font-size: 9px;
    text-align: center;
    color: var(--text-muted);
    max-width: 100px;
}

.cert-signature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.cert-signature .sig-line {
    width: 160px;
    border-bottom: 1px solid var(--text);
    margin-bottom: 4px;
}

.cert-signature .sig-label {
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    color: var(--primary);
}

.cert-signature .sig-sublabel {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
}

/* ─── Certificate PDF template ─── */
@media print {
    .no-print { display: none !important; }
    body { background: white; }
}

/* ─── Search & Filter ─── */
.search-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    padding: 16px;
    background: #f8f9ff;
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid #e0e5f0;
}

.search-bar input, .search-bar select {
    flex: 1;
    min-width: 180px;
    max-width: 280px;
}

/* ─── Pagination ─── */
.pagination {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pagination a, .pagination span {
    padding: 6px 12px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.pagination a {
    background: var(--card-bg);
    color: var(--primary);
    border: 1px solid var(--border);
}

.pagination a:hover { background: var(--primary); color: #fff; }
.pagination span { background: var(--primary); color: #fff; }

/* ─── Auto-save indicator ─── */
.autosave-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(42,157,92,0.9);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 6px;
}

.autosave-indicator.show { opacity: 1; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
    .cert-fields { grid-template-columns: 1fr; }
    .cert-footer { grid-template-columns: 1fr; text-align: center; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
    .login-card { padding: 28px 20px; }
}

/* ─── Misc ─── */
.text-muted { color: var(--text-muted) !important; }
.text-center { text-align: center; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 16px; }
.d-flex { display: flex; } .gap-2 { gap: 8px; } .gap-3 { gap: 16px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }
hr.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.activity-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5;
    align-items: flex-start;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--primary);
    margin-top: 5px;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; color: #fff;
}
.activity-dot-success { background: var(--success); }
.activity-dot-primary { background: var(--primary); }
.activity-dot-secondary { background: var(--secondary); }
.activity-dot-muted { background: var(--text-muted); }
.activity-dot i { font-size: 12px; color: #fff; }
.activity-text { font-size: 13px; }
.activity-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state h5 { font-size: 16px; margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* Hamburger button for mobile */
.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--primary);
    padding: 4px;
}

@media (max-width: 768px) {
    .hamburger { display: block; }
}

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

.overlay.show { display: block; }
