/* sendfile application theme (no framework dependency) */
:root {
    --bg: #f5f5f3;
    --surface: #fff;
    --text: #252525;
    --muted: #707070;
    --border: #deded9;
    --border-strong: #c7c7c1;
    --accent: #e8730c;
    --accent-dark: #bd5700;
    --accent-soft: #fff0e2;
    --success: #2f7d4a;
    --success-bg: #e9f5ed;
    --error: #a43131;
    --error-bg: #fbeaea;
    --warning: #815a12;
    --warning-bg: #fff3d9;
    --info: #315f8e;
    --info-bg: #eaf2fa;
    --radius: 10px;
    --font: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", "Noto Sans JP", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; font-size: 16px; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.6;
    margin: 0;
    min-height: 100vh;
}
a { color: var(--accent-dark); text-underline-offset: .18em; }
a:hover { color: var(--accent); }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.45rem, 3vw, 1.9rem); line-height: 1.3; margin-bottom: 1.25rem; }
h2 { font-size: 1.2rem; line-height: 1.4; }
button, input, select, textarea { font: inherit; }

/* Page frame and application header */
.skip-link {
    background: var(--text);
    color: #fff;
    left: .75rem;
    padding: .55rem .8rem;
    position: fixed;
    top: -5rem;
    z-index: 100;
}
.skip-link:focus { top: .75rem; }
.app-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.app-header__inner {
    align-items: center;
    display: flex;
    gap: 1.5rem;
    justify-content: space-between;
    margin: 0 auto;
    max-width: 1180px;
    min-height: 68px;
    padding: .65rem 1.5rem;
}
.app-brand {
    align-items: center;
    color: var(--text);
    display: inline-flex;
    flex: none;
    gap: .65rem;
    text-decoration: none;
}
.app-brand:hover { color: var(--text); }
.app-brand__mark, .auth-card__mark {
    align-items: center;
    background: var(--accent);
    border-radius: 9px;
    color: #fff;
    display: inline-flex;
    font-weight: 800;
    height: 2.15rem;
    justify-content: center;
    width: 2.15rem;
}
.app-brand__name { font-size: 1.25rem; font-weight: 800; letter-spacing: .025em; }
.app-header__controls { align-items: center; display: flex; gap: 1.3rem; min-width: 0; }
.app-header__user {
    color: var(--muted);
    font-size: .85rem;
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.app-nav { align-items: center; display: flex; gap: .3rem; }
.app-nav__form { display: inline; margin: 0; }
.app-nav__link {
    background: transparent;
    border: 0;
    border-radius: 7px;
    color: var(--muted);
    display: inline-block;
    font-size: .9rem;
    padding: .5rem .7rem;
    text-decoration: none;
    white-space: nowrap;
}
.app-nav__link:hover, .app-nav__link.is-active {
    background: var(--accent-soft);
    color: var(--accent-dark);
}
.app-nav__link.is-active { font-weight: 700; }
.app-nav__button { cursor: pointer; }
.page-shell { margin: 0 auto; max-width: 1180px; padding: 2rem 1.5rem 3rem; width: 100%; }
.page-main { min-width: 0; }

/* Login */
.auth-page .page-shell { max-width: 500px; padding-top: clamp(2rem, 8vh, 5rem); }
.auth-shell { width: 100%; }
.auth-card__heading { align-items: center; display: flex; gap: .9rem; margin-bottom: 1.5rem; }
.auth-card__heading h1 { margin-bottom: 0; }
.auth-card__mark { flex: none; height: 2.75rem; width: 2.75rem; }
.eyebrow {
    color: var(--muted);
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .12em;
    margin-bottom: .1rem;
    text-transform: uppercase;
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(31, 31, 31, .06);
}
.card__header, .card__body, .card__footer { padding: 1.4rem; }
.card__header { border-bottom: 1px solid var(--border); }
.card__footer { border-top: 1px solid var(--border); }
.card__header > :last-child, .card__body > :last-child, .card__footer > :last-child { margin-bottom: 0; }
.narrow-card { margin: 2rem auto; max-width: 620px; }

/* Forms and buttons */
.form-stack { display: grid; gap: 1.15rem; }
.form-grid { display: grid; gap: 1rem 1.25rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-field { min-width: 0; }
.form-field--full { grid-column: 1 / -1; }
.form-label { display: block; font-size: .9rem; font-weight: 700; margin-bottom: .35rem; }
.form-control,
input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="file"],
select, textarea {
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: 7px;
    color: var(--text);
    display: block;
    min-height: 44px;
    padding: .6rem .7rem;
    width: 100%;
}
textarea { min-height: 7rem; resize: vertical; }
input[type="file"] { padding: .5rem; }
input:disabled, select:disabled, textarea:disabled, button:disabled { cursor: not-allowed; opacity: .6; }
.form-control:focus, input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(232, 115, 12, .2);
    outline: 0;
}
.form-help { color: var(--muted); display: block; font-size: .8rem; margin-top: .3rem; }
.check-field { align-items: flex-start; cursor: pointer; display: inline-flex; font-size: .9rem; gap: .55rem; }
.check-field input {
    accent-color: var(--accent);
    height: 1.05rem;
    margin: .22rem 0 0;
    width: 1.05rem;
}
.button {
    align-items: center;
    border: 1px solid transparent;
    border-radius: 7px;
    cursor: pointer;
    display: inline-flex;
    font-weight: 700;
    justify-content: center;
    line-height: 1.35;
    min-height: 44px;
    padding: .65rem 1rem;
    text-decoration: none;
}
.button--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button--primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.button--secondary { background: #fff; border-color: var(--border-strong); color: var(--text); }
.button--secondary:hover { background: #f7f7f4; color: var(--text); }
.button--danger { background: var(--error); color: #fff; }
.button--block { width: 100%; }
.actions { align-items: center; display: flex; flex-wrap: wrap; gap: .65rem; }

/* Alerts */
.alert { border: 1px solid; border-radius: 8px; margin-bottom: 1.2rem; padding: .8rem .95rem; }
.alert--success, .alert-success { background: var(--success-bg); border-color: #c4e3ce; color: var(--success); }
.alert--error, .alert-error, .alert-danger { background: var(--error-bg); border-color: #efc8c8; color: var(--error); }
.alert--warning, .alert-warning { background: var(--warning-bg); border-color: #ecd6a9; color: var(--warning); }
.alert--info, .alert-info { background: var(--info-bg); border-color: #c9dbec; color: var(--info); }

/* Tables and statuses */
.table-wrap { overflow-x: auto; width: 100%; }
table, .table { border-collapse: collapse; font-size: .9rem; width: 100%; }
th, td { border-bottom: 1px solid var(--border); padding: .75rem; text-align: left; vertical-align: middle; }
th {
    background: #f3f3f0;
    color: var(--muted);
    font-size: .78rem;
    letter-spacing: .03em;
    white-space: nowrap;
}
tbody tr:hover { background: #fafaf8; }
.badge {
    border-radius: 999px;
    display: inline-block;
    font-size: .75rem;
    font-weight: 700;
    line-height: 1;
    padding: .38rem .62rem;
    white-space: nowrap;
}
.badge--active, .badge-active { background: var(--success-bg); color: var(--success); }
.badge--expired, .badge-expired { background: #ededeb; color: #60605d; }
.badge--revoked, .badge-revoked { background: var(--error-bg); color: var(--error); }
.badge--purged, .badge-purged { background: #e8edf2; color: #4d5d6c; }

/* Small reusable helpers */
.muted { color: var(--muted); }
.text-right { text-align: right; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.sr-only {
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

@media (max-width: 760px) {
    .app-header__inner {
        align-items: flex-start;
        flex-direction: column;
        gap: .55rem;
        padding: .7rem 1rem;
    }
    .app-header__controls {
        align-items: flex-start;
        flex-direction: column;
        gap: .35rem;
        width: 100%;
    }
    .app-nav { overflow-x: auto; padding-bottom: .15rem; width: 100%; }
    .page-shell { padding: 1.25rem 1rem 2rem; }
    .form-grid { grid-template-columns: 1fr; }
    .form-field--full { grid-column: auto; }
    .card__header, .card__body, .card__footer { padding: 1.1rem; }
    .table-wrap table { min-width: 640px; }
}

@media (max-width: 420px) {
    .app-header__user { max-width: 100%; }
    .app-nav__link { padding-inline: .55rem; }
    .actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
