:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --border: #e2e5ea;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #059669;
    --danger: #dc2626;
    --code-bg: #0f172a;
    --code-text: #e2e8f0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top bar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner {
    max-width: 1100px; margin: 0 auto; padding: 0 20px;
    display: flex; align-items: center; justify-content: space-between;
    height: 58px;
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { margin-right: 4px; }
.topnav { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.topnav a { color: var(--muted); }
.topnav a:hover { color: var(--text); text-decoration: none; }
.topnav a.active { color: var(--primary); font-weight: 600; }
.user-chip {
    background: #eef2ff; color: var(--primary-dark); border-radius: 999px;
    padding: 3px 12px; font-weight: 500; max-width: 180px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.inline-form { display: inline; }
.btn-link { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0; }
.btn-link:hover { color: var(--danger); }

/* ---------- Layout ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }
.footer {
    text-align: center; color: var(--muted); font-size: 13px;
    padding: 18px; border-top: 1px solid var(--border); background: var(--surface);
}
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; margin: 0; }
.page-head .sub { color: var(--muted); margin-top: 2px; font-size: 14px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 16px; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 14px; max-width: 460px; }
.form-row label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 5px; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"] {
    width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 14px; background: #fff; color: var(--text);
}
input:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
.form-inline { display: flex; gap: 8px; flex-wrap: wrap; }
.form-inline input[type="text"] { flex: 1 1 240px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block; padding: 9px 16px; border-radius: 6px; border: 1px solid transparent;
    font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px; font-size: 14px; border: 1px solid; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-list { margin: 0; padding-left: 18px; }

/* ---------- Stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .value { font-size: 26px; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 13px; }

/* ---------- Tables & lists ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; padding: 10px 18px; border-bottom: 1px solid var(--border); color: var(--muted); font-weight: 600; font-size: 13px; }
.table td { padding: 10px 18px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tr.rowlink { cursor: pointer; }
.table tr.rowlink:hover td { background: #f8fafc; }

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

.method { display: inline-block; font-family: ui-monospace, monospace; font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 4px; }
.method-get { background: #ecfdf5; color: #065f46; }
.method-post { background: #eff6ff; color: #1e40af; }
.method-put, .method-patch { background: #fffbeb; color: #92400e; }
.method-delete { background: #fef2f2; color: #991b1b; }
.method-other { background: #f3f4f6; color: #374151; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; background: #f3f4f6; color: #374151; }
.badge-live { background: #ecfdf5; color: #065f46; font-weight: 600; }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }

/* ---------- Code blocks ---------- */
.code-block {
    background: var(--code-bg); color: var(--code-text); border-radius: 6px;
    padding: 14px 16px; overflow: auto; font-family: ui-monospace, monospace;
    font-size: 13px; line-height: 1.5; margin: 8px 0; white-space: pre-wrap; word-break: break-word;
}

/* ---------- Credential box ---------- */
.cred-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.cred .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cred .v { font-size: 15px; font-weight: 600; word-break: break-all; }
.copy-btn { cursor: pointer; font-size: 12px; margin-left: 6px; color: var(--primary); background: none; border: 1px solid var(--border); border-radius: 4px; padding: 1px 8px; }

.url-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.url-line code { background: #f3f4f6; padding: 6px 10px; border-radius: 6px; font-size: 13px; word-break: break-all; flex: 1; }

/* ---------- Message detail ---------- */
.email-meta { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 14px; padding: 14px 18px; }
.email-meta dt { color: var(--muted); margin: 0; }
.email-meta dd { margin: 0; word-break: break-word; }
.section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 22px 0 8px; }

/* ---------- Auth pages ---------- */
.auth-wrap { max-width: 400px; margin: 60px auto 0; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-card .tagline { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.auth-alt { text-align: center; margin-top: 16px; font-size: 14px; color: var(--muted); }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 6px; padding: 14px 18px; flex-wrap: wrap; align-items: center; }
.pagination .page-link { padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 13px; }
.pagination .page-link:hover { border-color: var(--primary); text-decoration: none; }
.pagination .disabled span { padding: 4px 10px; color: #d1d5db; }
.pagination .active span { padding: 4px 10px; background: var(--primary); color: #fff; border-radius: 6px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }


/* ---------- Overflow safety: long values must wrap, never stretch the layout ---------- */
.page-head,
.page-head h1,
.card-head,
.card-head h2,
.card-body,
.url-line,
.email-meta {
    min-width: 0;
}

.page-head h1,
.card-head h2,
.url-line code,
.email-meta dd {
    overflow-wrap: anywhere;
}

.mono {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Short values (dates, counters) must never break in the middle of a word. */
.nowrap {
    white-space: nowrap;
}

.cred .v {
    overflow-wrap: anywhere;
}

/* ---------- Bulk selection lists ---------- */
.list-toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    flex-wrap: wrap;
}

.bulk-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}

.bulk-delete-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.col-check {
    width: 34px;
    text-align: center;
}

.col-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

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

/* ---------- Brand / logo ---------- */
.brand { display: inline-flex; align-items: center; gap: 9px; }
.brand-logo { display: block; border-radius: 8px; }
.brand-text { font-weight: 700; font-size: 18px; color: var(--text); letter-spacing: -.01em; }
.brand-accent { color: var(--primary); }

.version-badge {
    display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px;
    background: #eef2ff; color: var(--primary-dark); font-size: 11px; font-weight: 600;
    vertical-align: middle;
}

/* ---------- Shared (read-only) banner ---------- */
.shared-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    background: #eef2ff; border: 1px solid #c7d2fe; color: #1e3a8a;
    border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; font-size: 14px;
}
.shared-banner .muted { color: #3b4a86; }

/* ---------- Sharing ---------- */
.share-list { margin: 0; padding: 0; list-style: none; }
.share-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 18px; border-top: 1px solid var(--border); flex-wrap: wrap;
}
.share-row:first-child { border-top: none; }
.share-row .share-url { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.share-row code { background: #f3f4f6; padding: 4px 8px; border-radius: 6px; font-size: 12px; word-break: break-all; }
.share-meta { color: var(--muted); font-size: 12px; }
.status-pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-active { background: #ecfdf5; color: #065f46; }
.status-expired { background: #fffbeb; color: #92400e; }
.status-revoked { background: #fef2f2; color: #991b1b; }
.share-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.share-form .field { display: flex; flex-direction: column; gap: 4px; }
.share-form label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.share-form select,
.share-form input[type="datetime-local"] {
    padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; background: #fff; color: var(--text);
}

/* ---------- Admin ---------- */
.admin-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.badge-admin { background: #eef2ff; color: var(--primary-dark); font-weight: 600; }

