/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 15px;
    color: #1a1a2e;
    background: #f4f6fb;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    background: #1a3a6b;
    color: #fff;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 24px;
    height: 52px;
}
.navbar-brand { font-weight: 700; font-size: 16px; color: #fff; text-decoration: none; }
.navbar-brand:hover { color: #c8d8f8; }
.navbar-links { list-style: none; display: flex; gap: 16px; }
.navbar-links a { color: #c8d8f8; text-decoration: none; font-size: 14px; }
.navbar-links a:hover { color: #fff; text-decoration: underline; }

.navbar-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
}
.navbar-user a { color: #c8d8f8; text-decoration: none; }
.navbar-user a:hover { color: #fff; text-decoration: underline; }
.navbar-username { color: #e8f0ff; font-weight: 700; }
.navbar-role {
    background: rgba(255,255,255,.15);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    color: #c8d8f8;
}

/* Container */
.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 28px 20px;
    flex: 1;
}

/* Footer */
footer {
    text-align: center;
    padding: 14px;
    font-size: 12px;
    color: #666;
    background: #e8ecf4;
}

/* Headings */
h1 { font-size: 22px; margin-bottom: 20px; color: #1a3a6b; }
h2 { font-size: 16px; margin-bottom: 14px; color: #1a3a6b; }
h3 { font-size: 14px; margin-bottom: 10px; color: #223; }
h4 { font-size: 13px; margin: 12px 0 6px; color: #334; }

/* Card */
.card {
    background: #fff;
    border: 1px solid #dde3f0;
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

/* Form */
.form-group {
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
label { font-size: 13px; font-weight: 600; color: #334; }
input[type="text"],
input[type="file"],
select {
    padding: 8px 10px;
    border: 1px solid #bcc6df;
    border-radius: 5px;
    font-size: 14px;
    background: #fafcff;
    width: 100%;
}
select:disabled { background: #eef; color: #888; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 9px 20px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    margin-top: 6px;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary   { background: #1a3a6b; color: #fff; }
.btn-primary:hover:not(:disabled)   { background: #24508a; }
.btn-secondary { background: #e4eaf8; color: #1a3a6b; }
.btn-secondary:hover:not(:disabled) { background: #ccd8f2; }
.btn-small  { padding: 4px 12px; font-size: 12px; margin-top: 0; }
.btn-danger { background: #fde8e8; color: #842029; }
.btn-danger:hover:not(:disabled) { background: #f8c8cb; }
.btn-full   { width: 100%; text-align: center; margin-top: 8px; }

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
}
.status-checking { background: #fff3cd; color: #856404; }
.status-ok       { background: #d1e7dd; color: #0a5539; }
.status-error    { background: #f8d7da; color: #842029; }

.hidden { display: none !important; }

/* Flash messages */
.flash {
    padding: 10px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 600;
}
.flash-ok    { background: #d1e7dd; color: #0a5539; border: 1px solid #a3cfbb; }
.flash-error { background: #f8d7da; color: #842029; border: 1px solid #f1aeb5; }
.flash-info  { background: #cfe2ff; color: #084298; border: 1px solid #9ec5fe; }

/* Login page */
.login-wrap { max-width: 380px; margin: 60px auto; }

/* Inline checkbox + label */
.form-group-inline {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}
.form-group-inline input[type="checkbox"] { width: auto; margin: 0; }
.label-inline { font-weight: 400; margin: 0; }

/* Info block */
.info-block { margin-top: 10px; }

/* Tables */
.info-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 8px;
}
.info-table th, .info-table td {
    padding: 6px 10px;
    border: 1px solid #dde3f0;
    text-align: left;
    vertical-align: top;
}
.info-table th {
    width: 180px;
    background: #eef2fb;
    font-weight: 600;
    color: #334;
}
.info-table tr:nth-child(even) td { background: #fafbff; }

code {
    background: #eef2fb;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 12px;
    word-break: break-all;
}

pre {
    background: #1a1a2e;
    color: #c8d8f8;
    padding: 12px 16px;
    border-radius: 5px;
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    margin-top: 8px;
}

/* Result */
.result-ok {
    background: #d1e7dd;
    border: 1px solid #a3cfbb;
    border-radius: 6px;
    padding: 16px 20px;
}
.result-ok p { margin-bottom: 10px; }

/* Hint */
.hint { font-size: 13px; color: #667; margin-bottom: 10px; }

/* Records table wrapper */
.records-table-wrapper { overflow-x: auto; margin-top: 12px; }

/* History page */
.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}
.history-header h1 { margin-bottom: 0; }
.history-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.history-table .history-filename {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.history-table .history-cert {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: #445;
}
.btn-small-pad { padding: 6px 14px; font-size: 13px; }

/* File queue table */
.queue-table { margin-top: 10px; }
.queue-filename {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Queue status pills */
.q-status {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.q-ready    { background: #e8ecf8; color: #334; }
.q-checking { background: #fff3cd; color: #856404; animation: q-pulse .9s ease-in-out infinite alternate; }
.q-ok       { background: #d1e7dd; color: #0a5539; }
.q-error    { background: #f8d7da; color: #842029; cursor: help; }
@keyframes q-pulse { from { opacity: 1; } to { opacity: .55; } }

/* cert-card (legacy, used in verify.html) */
.cert-card {
    background: #f0f4ff;
    border: 1px solid #c0ccee;
    border-radius: 6px;
    padding: 14px 18px;
    margin-top: 12px;
    font-size: 13px;
}

/* =========================================================================
   Certificate selector
   ========================================================================= */

.cert-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.cert-section-header h2 { margin-bottom: 0; }

/* Certificate search box */
.cert-search-wrap {
    margin-bottom: 10px;
}
.cert-search-wrap input {
    padding: 7px 12px;
    border: 1px solid #bcc6df;
    border-radius: 20px;
    font-size: 13px;
    background: #fafcff;
    width: 100%;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.cert-search-wrap input:focus {
    border-color: #1a3a6b;
    box-shadow: 0 0 0 3px rgba(26,58,107,.1);
}

/* Scrollable list of cert cards */
.cert-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 340px;
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 4px;
}
.cert-list::-webkit-scrollbar { width: 6px; }
.cert-list::-webkit-scrollbar-track { background: #f0f2f8; border-radius: 3px; }
.cert-list::-webkit-scrollbar-thumb { background: #b0bcd8; border-radius: 3px; }

/* Individual certificate card */
.cert-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 12px 14px;
    border: 2px solid #dde3f0;
    border-radius: 8px;
    background: #fafcff;
    cursor: pointer;
    transition: border-color .15s, background .15s, box-shadow .15s;
    position: relative;
    user-select: none;
}
.cert-item:hover {
    border-color: #8baade;
    background: #f0f5ff;
    box-shadow: 0 2px 8px rgba(26,58,107,.08);
}
.cert-item.selected {
    border-color: #1a3a6b;
    background: #eef3ff;
    box-shadow: 0 2px 10px rgba(26,58,107,.13);
}
.cert-item.no-key {
    opacity: .55;
    cursor: not-allowed;
}
.cert-item.no-key:hover {
    border-color: #dde3f0;
    background: #fafcff;
    box-shadow: none;
}

/* Avatar / icon circle */
.cert-avatar {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #d4e0f7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background .15s;
}
.cert-item.selected .cert-avatar { background: #1a3a6b; color: #fff; }
.cert-item.no-key    .cert-avatar { background: #e8e8e8; }

/* Text block */
.cert-body { flex: 1; min-width: 0; }

.cert-name {
    font-size: 14px;
    font-weight: 700;
    color: #1a1a2e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}
.cert-item.selected .cert-name { color: #1a3a6b; }

.cert-org {
    font-size: 12px;
    color: #556;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 5px;
}

.cert-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

/* Small pill badges inside cert card */
.cert-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.cert-badge-valid   { background: #d1f0e0; color: #0a5539; }
.cert-badge-expiry  { background: #e8ecf8; color: #334; }
.cert-badge-nokey   { background: #fde8e8; color: #842029; }
.cert-badge-issuer  { background: #eef2fb; color: #446; }
.cert-badge-thumb   {
    background: #eef2fb;
    color: #446;
    font-family: monospace;
    font-size: 10px;
    letter-spacing: .03em;
}

/* Check mark on selected */
.cert-check {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #1a3a6b;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    opacity: 0;
    transform: scale(.6);
    transition: opacity .15s, transform .15s;
}
.cert-item.selected .cert-check {
    opacity: 1;
    transform: scale(1);
}

/* Expanded details panel (shown below selected card) */
.cert-details-panel {
    border: 2px solid #1a3a6b;
    border-top: none;
    border-radius: 0 0 8px 8px;
    background: #f4f7ff;
    padding: 12px 14px 14px;
    margin-top: -6px;
    font-size: 13px;
    animation: slideDown .15s ease;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.cert-details-panel .info-table th { width: 160px; }
