@font-face {
    font-family: "Aptos";
    src: url("/assets/aptos.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Aptos";
    src: url("/assets/aptos-bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #f7f8fa;
    --panel: #ffffff;
    --text: #000000;
    --muted: #5a5a5a;
    --line: #e7e7e7;
    --brand: #5fc4e1;
    --brand-strong: #3eb0d0;
    --ink: #000000;
    --danger: #b42318;
    --ok-bg: #e8f7fb;
    --err-bg: #fdecec;
    --warn-bg: #fff8e8;
    --font: "Aptos", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.45;
    font-size: 16px;
}
a { color: var(--brand); }
a:hover { color: var(--ink); }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    background: #ffffff;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
}
.brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}
.brand a {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--ink);
    text-decoration: none;
}
.brand-logo {
    display: block;
    height: 36px;
    width: auto;
}
.brand-title {
    font-weight: 700;
    letter-spacing: 0.01em;
    font-size: 0.95rem;
    color: var(--ink);
    border-left: 1px solid var(--line);
    padding-left: 0.75rem;
}
.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.95rem;
    align-items: center;
}
.nav a {
    color: var(--ink);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.92rem;
}
.nav a:hover { color: var(--brand-strong); }
.inline { display: inline; margin: 0; }
.linkish {
    background: none;
    border: 0;
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    padding: 0;
}
.linkish:hover { color: var(--brand-strong); }

.container {
    max-width: 1100px;
    margin: 1.5rem auto;
    padding: 0 1rem 2rem;
}
.page-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}
.page-head h1,
.auth-card h1,
.panel h2,
.import-dialog h2 {
    margin: 0 0 0.35rem;
    font-weight: 700;
    line-height: 1.2;
}
.muted { color: var(--muted); }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.button, button {
    display: inline-block;
    background: var(--ink);
    color: #fff;
    border: 1px solid var(--ink);
    border-radius: 4px;
    padding: 0.55rem 0.95rem;
    text-decoration: none;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}
.button:hover, button:hover {
    background: #222;
    border-color: #222;
}
.button.secondary, button.secondary {
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--ink);
}
.button.secondary:hover, button.secondary:hover {
    border-color: var(--brand);
    color: var(--brand-strong);
    background: #fff;
}
button.danger {
    background: #fff;
    color: var(--danger);
    border-color: var(--danger);
}
button.danger:hover {
    background: var(--danger);
    color: #fff;
}

.panel, .auth-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 1rem 1.1rem;
}
.auth-card {
    max-width: 400px;
    margin: 3rem auto;
}
.stack { display: grid; gap: 0.75rem; }
.narrow { max-width: 520px; }
label {
    display: grid;
    gap: 0.3rem;
    font-weight: 700;
    font-size: 0.92rem;
}
input, select, textarea {
    font: inherit;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: 4px;
    width: 100%;
    background: #fff;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(95, 196, 225, 0.25);
}

.filters {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: end;
    margin-bottom: 1rem;
}
.table-wrap {
    overflow-x: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
}
.table-wrap.admin-table {
    /* Allow action menus to escape the scroll box */
    overflow: visible;
}
td.wrap {
    max-width: 18rem;
    word-break: break-all;
}
.compact-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}
.compact-actions form {
    margin: 0;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}
th, td {
    text-align: left;
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
th {
    background: #f3f5f7;
    font-weight: 700;
}
.badge {
    display: inline-block;
    background: rgba(95, 196, 225, 0.18);
    color: #0b5f74;
    border-radius: 999px;
    padding: 0.1rem 0.55rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 700;
}
.status { font-weight: 700; text-transform: capitalize; }
.status-active { color: #0b7a95; }
.status-revoked { color: var(--danger); }
.status-expired { color: #8a5a00; }

.flash {
    padding: 0.75rem 0.9rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}
.flash-success { background: var(--ok-bg); border: 1px solid #b7e6f3; }
.flash-error { background: var(--err-bg); border: 1px solid #f2c4c4; }
.flash-info { background: var(--warn-bg); border: 1px solid #f0d9a0; }
.notice {
    background: var(--ok-bg);
    border: 1px solid #b7e6f3;
    padding: 0.75rem 0.9rem;
    border-radius: 6px;
}
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.customer-edit {
    border-top: 1px solid var(--line);
    padding-top: 0.85rem;
    margin-top: 0.85rem;
}
.row-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}
code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85em;
}
.sort-link {
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}
.sort-link:hover { color: var(--brand-strong); text-decoration: underline; }
.holder-edit {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    min-width: 12rem;
}
.holder-edit input[type="text"] {
    margin: 0;
    padding: 0.35rem 0.45rem;
}
button.compact, .button.compact {
    padding: 0.35rem 0.55rem;
    font-size: 0.85rem;
    white-space: nowrap;
}
.import-dialog {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1.1rem 1.2rem;
    max-width: 560px;
    width: calc(100% - 2rem);
}
.import-dialog::backdrop {
    background: rgba(0, 0, 0, 0.35);
}
.kv {
    display: grid;
    grid-template-columns: 9rem 1fr;
    gap: 0.35rem 0.75rem;
    background: #f3f5f7;
    border-radius: 6px;
    padding: 0.75rem 0.85rem;
    margin: 0.25rem 0 0.5rem;
}
.kv dt {
    margin: 0;
    color: var(--muted);
    font-weight: 700;
    font-size: 0.85rem;
}
.kv dd {
    margin: 0;
    font-size: 0.92rem;
}
details.panel > summary {
    cursor: pointer;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.nav-dropdown,
.action-menu {
    position: relative;
}
.nav-dropdown > summary,
.action-menu > summary {
    list-style: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--ink);
    user-select: none;
}
.nav-dropdown > summary::-webkit-details-marker,
.action-menu > summary::-webkit-details-marker {
    display: none;
}
.nav-dropdown > summary::after,
.action-menu > summary::after {
    content: " ▾";
    font-size: 0.75em;
    color: var(--muted);
}
.nav-dropdown > summary:hover,
.action-menu > summary:hover {
    color: var(--brand-strong);
}
.nav-dropdown-panel,
.action-menu-panel {
    position: absolute;
    right: 0;
    top: auto;
    bottom: calc(100% + 0.35rem);
    min-width: 11rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    padding: 0.35rem;
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.nav-dropdown-panel {
    left: 0;
    right: auto;
    top: calc(100% + 0.35rem);
    bottom: auto;
}
.nav-dropdown-panel a,
.action-menu-panel a,
.action-menu-panel button.linkish {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.45rem 0.65rem;
    border-radius: 4px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    background: none;
    border: 0;
    cursor: pointer;
    font-family: inherit;
}
.nav-dropdown-panel a:hover,
.action-menu-panel a:hover,
.action-menu-panel button.linkish:hover {
    background: #f3f5f7;
    color: var(--brand-strong);
}
.action-menu-panel form {
    margin: 0;
}
.danger-text {
    color: var(--danger) !important;
}
.admin-table .admin-actions-cell {
    width: 6.5rem;
    text-align: right;
    vertical-align: middle;
    overflow: visible;
}
.panel:has(.admin-table) {
    overflow: visible;
}
.admin-table .row-inactive td {
    opacity: 0.72;
}
.password-row td {
    background: #f8fafb;
}
.password-reset-form {
    margin: 0.25rem 0;
}
.badge + .muted,
.status + .badge {
    margin-left: 0.35rem;
}

@media (max-width: 800px) {
    .grid-2 { grid-template-columns: 1fr; }
    .page-head { flex-direction: column; }
    .holder-edit { flex-direction: column; align-items: stretch; }
    .kv { grid-template-columns: 1fr; }
    .brand-title { display: none; }
}
