:root {
    --bg: #f3f1ec;
    --ink: #1c2430;
    --muted: #6b7280;
    --card: #fffdf8;
    --line: #d9d2c5;
    --accent: #0f6a5a;
    --accent-2: #134e4a;
    --warn: #b45309;
    --danger: #b91c1c;
    --ok: #047857;
    --shadow: 0 10px 30px rgba(28, 36, 48, 0.08);
    --radius: 14px;
    font-family: "IBM Plex Sans", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(1200px 500px at 10% -10%, #d9efe8 0%, transparent 55%),
        radial-gradient(900px 400px at 100% 0%, #f3e7d3 0%, transparent 50%),
        var(--bg);
    min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    background: #eef6f3;
    padding: 0.1rem 0.35rem;
    border-radius: 6px;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.9rem 1.5rem;
    background: rgba(255,253,248,0.9);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 10;
}
.brand { font-weight: 700; letter-spacing: 0.02em; }
.topbar nav { display: flex; gap: 1rem; flex: 1; }
.user { display: flex; gap: 0.75rem; align-items: center; color: var(--muted); }

.container { width: min(1100px, calc(100% - 2rem)); margin: 1.5rem auto 3rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.page-head h1, .block h2, .login-card h1 { margin: 0 0 0.25rem; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}
.toolbar { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.toolbar input, .form input, .form select, .form textarea, .login-card input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.7rem 0.85rem;
    font: inherit;
    background: #fff;
}
.toolbar input { max-width: 360px; }
label { display: grid; gap: 0.35rem; margin-bottom: 0.9rem; font-size: 0.92rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.form { max-width: 640px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 999px;
    padding: 0.45rem 0.95rem;
    cursor: pointer;
    font: inherit;
    text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(0.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.warn { background: #fff7ed; border-color: #fdba74; color: var(--warn); }
.btn.danger { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 0.25rem 0.65rem; font-size: 0.85rem; }

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.75rem 0.9rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 0.85rem; color: var(--muted); background: #faf7f1; }
tr:last-child td { border-bottom: 0; }
.empty { text-align: center; color: var(--muted); }

.tag {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.82rem;
    background: #eef2ff;
}
.status-active { background: #ecfdf5; color: var(--ok); }
.status-suspended { background: #fff7ed; color: var(--warn); }
.status-revoked, .status-expired { background: #fef2f2; color: var(--danger); }

.detail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem 1.25rem; margin-bottom: 1.5rem; }
.kv { display: grid; gap: 0.2rem; }
.kv span { color: var(--muted); font-size: 0.85rem; }
.block { margin-top: 1.5rem; }
.block h2 { margin-bottom: 0.75rem; }

.login-wrap { min-height: 80vh; display: grid; place-items: center; }
.login-card { width: min(380px, 100%); }
.login-card .muted { color: var(--muted); margin-top: 0; }
.alert {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 0.65rem 0.8rem;
    margin-bottom: 0.9rem;
}

.row-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.muted { color: var(--muted); }
.detail-actions { margin-bottom: 1rem; }

.modal {
    border: none;
    padding: 0;
    background: transparent;
    max-width: calc(100vw - 2rem);
}
.modal::backdrop {
    background: rgba(20, 28, 36, 0.45);
    backdrop-filter: blur(2px);
}
.modal-card {
    width: min(560px, 100%);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.modal-wide { width: min(920px, 100%); }
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-close {
    border: none;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--muted);
    padding: 0 0.25rem;
}
.modal-body {
    padding: 1.1rem 1.15rem;
    max-height: min(70vh, 640px);
    overflow: auto;
}
.modal-body.form { max-width: none; }
.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.9rem 1.15rem 1.1rem;
    border-top: 1px solid var(--line);
}

@media (max-width: 720px) {
    .detail, .grid-2 { grid-template-columns: 1fr; }
    .page-head { flex-direction: column; align-items: flex-start; }
    .topbar { flex-wrap: wrap; }
}
