:root {
    --bg: #f3f4f6;
    --ink: #111;
    --muted: #6b7280;
    --panel: rgba(255,255,255,.92);
    --line: rgba(17,17,17,.12);
    --soft: rgba(255,255,255,.62);
    --primary: #111;
    --blue: #3f3f46;
    --red: #111;
    --amber: #52525b;
    --green: #111;
    --shadow: 0 24px 70px rgba(0,0,0,.10);
    --radius: 18px;
}
* { box-sizing: border-box; }
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(14px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, "Microsoft YaHei", sans-serif;
    color: var(--ink);
    background: linear-gradient(180deg, #fff 0%, var(--bg) 54%, #fafafa 100%);
}
a { color: inherit; text-decoration: none; }
.topbar {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 0 34px;
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255,255,255,.82);
    border-bottom: 1px solid rgba(17,17,17,.08);
    backdrop-filter: blur(18px);
    box-shadow: 0 10px 34px rgba(0,0,0,.06);
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 900;
    letter-spacing: 0;
}
.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: linear-gradient(135deg, #111, #444);
    box-shadow: 0 12px 22px rgba(0,0,0,.18);
    color: #fff;
    font-size: 13px;
    font-weight: 900;
}
.topbar nav { display: flex; gap: 8px; flex-wrap: wrap; }
.topbar nav a {
    padding: 9px 13px;
    border-radius: 999px;
    color: #3f3f46;
    font-weight: 700;
}
.topbar nav a:hover { background: rgba(17,17,17,.06); color: var(--ink); }
.topbar nav a.active { background: #111; color: #fff; }
.shell { max-width: 1340px; margin: 34px auto 60px; padding: 0 24px; }
.flash {
    margin-bottom: 18px;
    padding: 13px 15px;
    border-radius: 14px;
    background: #f5f5f5;
    color: #111;
    border: 1px solid rgba(17,17,17,.12);
    box-shadow: 0 12px 34px rgba(0,0,0,.06);
}
.flash.bad { background: #111; color: #fff; border-color: #111; }
.hero, .page-head {
    display: grid;
    grid-template-columns: minmax(0,1fr) auto;
    align-items: end;
    gap: 22px;
    margin-bottom: 18px;
}
.hero {
    padding: 32px;
    border-radius: 24px;
    color: #fff;
    background: linear-gradient(135deg, #111, #3f3f46);
    box-shadow: 0 30px 78px rgba(0,0,0,.18);
    overflow: hidden;
    position: relative;
    animation: fadeUp .28s ease both;
    transition: transform .18s ease, box-shadow .18s ease;
}
.hero:hover { transform: translateY(-2px); box-shadow: 0 34px 86px rgba(0,0,0,.22); }
.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.12) 100%);
    pointer-events: none;
}
.hero > *, .page-head > * { position: relative; z-index: 1; }
.eyebrow {
    display: inline-block;
    margin-bottom: 8px;
    color: currentColor;
    opacity: .72;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}
h1 { margin: 0; font-size: 38px; line-height: 1.15; letter-spacing: 0; }
h2 { margin: 0; font-size: 24px; line-height: 1.2; letter-spacing: 0; }
h3 { margin: 10px 0 4px; }
p { color: var(--muted); }
.hero p { color: rgba(255,255,255,.78); max-width: 760px; margin: 10px 0 0; }
.hero-actions, .head-actions, .form-actions, .row-actions, .cycle-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.head-actions { justify-content: flex-end; }
.form-actions.end { justify-content: flex-end; }
.btn {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 10px 15px;
    background: rgba(255,255,255,.9);
    color: var(--ink);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(0,0,0,.12); }
.btn.fit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    justify-self: start;
    align-self: start;
    width: auto;
    min-height: 42px;
}
.btn.primary, .btn.light {
    border-color: transparent;
    color: #fff;
    background: linear-gradient(135deg, #111, #3f3f46);
    box-shadow: 0 15px 30px rgba(0,0,0,.16);
}
.btn.light { background: #fff; color: #111; }
.btn.ghost, .btn.ghost-light { background: rgba(255,255,255,.72); }
.btn.ghost-light { color: #fff; border-color: rgba(255,255,255,.5); background: rgba(255,255,255,.16); }
.btn.danger { color: #fff; border-color: transparent; background: linear-gradient(135deg, #111, #3f3f46); }
.btn.mini, .mini { padding: 7px 10px; font-size: 13px; }
button.mini {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255,255,255,.92);
    color: var(--ink);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}
button.mini.primary {
    border-color: transparent;
    color: #fff;
    background: linear-gradient(135deg, #111, #3f3f46);
}
.btn.danger-text, .danger-text {
    color: #111;
    border-color: rgba(17,17,17,.18);
    background: #f4f4f5;
}
.btn.soft-danger {
    color: #111;
    border-color: rgba(17,17,17,.18);
    background: #f4f4f5;
    box-shadow: none;
}
.panel, .login-card {
    background: var(--panel);
    border: 1px solid rgba(17,17,17,.08);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    padding: 22px;
    animation: fadeUp .28s ease both;
}
.login-card { max-width: 440px; margin: 90px auto; text-align: center; }
.login-mark {
    width: 58px; height: 58px; border-radius: 16px; margin: 0 auto 16px;
    background: linear-gradient(135deg, #111, #444);
}
.form-stack, .form-grid { display: grid; gap: 16px; }
.form-stack { align-content: start; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.wide { grid-column: 1 / -1; }
label { display: grid; gap: 7px; color: #3f3f46; font-weight: 800; }
input, textarea, select {
    width: 100%;
    padding: 11px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,.94);
    color: var(--ink);
    font: inherit;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus {
    outline: 0;
    border-color: rgba(17,17,17,.68);
    box-shadow: 0 0 0 4px rgba(17,17,17,.10);
}
.field-hint {
    display: none;
    color: #111;
    font-size: 12px;
    font-weight: 900;
    line-height: 1.45;
}
.field-hint.show { display: block; }
.form-note {
    margin: -4px 0 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    line-height: 1.6;
}
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.stat-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.stat {
    min-height: 112px;
    padding: 20px;
    border-radius: 18px;
    background: rgba(255,255,255,.84);
    border: 1px solid rgba(17,17,17,.08);
    box-shadow: 0 14px 38px rgba(0,0,0,.07);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.stat:hover { transform: translateY(-3px); border-color: rgba(17,17,17,.18); box-shadow: 0 20px 48px rgba(0,0,0,.11); }
.stat span { display: block; color: var(--muted); font-weight: 900; }
.stat b { display: block; margin-top: 12px; font-size: 38px; line-height: 1; }
.compact-stats .stat { min-height: 86px; padding: 16px 18px; }
.compact-stats .stat b { margin-top: 8px; font-size: 30px; }
.stat.warn b { color: var(--red); }
.stat.ok b { color: var(--green); }
.stat.card-left b { color: var(--primary); }
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}
.tool-head { align-items: center; }
.detail-head {
    align-items: center;
    margin-bottom: 12px;
}
.detail-head h1 { font-size: 30px; }
.customer-strip {
    padding: 14px 18px;
    margin-bottom: 16px;
}
.customer-facts {
    display: flex;
    align-items: center;
    gap: 10px 14px;
    min-width: 0;
    flex-wrap: wrap;
}
.customer-facts strong {
    font-size: 17px;
    color: var(--ink);
}
.customer-facts span:not(.badge) {
    color: var(--muted);
    font-weight: 800;
    white-space: nowrap;
}
.wide-modal { width: min(920px, 100%); }
.tabs {
    display: inline-flex;
    gap: 5px;
    padding: 5px;
    border-radius: 999px;
    background: rgba(255,255,255,.78);
    border: 1px solid rgba(255,255,255,.86);
    box-shadow: 0 12px 34px rgba(20,32,51,.08);
}
.tabs a { padding: 9px 14px; border-radius: 999px; color: var(--muted); font-weight: 900; }
.tabs a.active { color: #fff; background: linear-gradient(135deg, #111, #3f3f46); }
.search { display: flex; gap: 8px; }
.search input { min-width: 260px; }
.table-panel { overflow-x: auto; }
table { width: 100%; min-width: 1080px; border-collapse: separate; border-spacing: 0; }
th, td { padding: 14px 13px; text-align: left; border-bottom: 1px solid rgba(111,128,153,.15); vertical-align: middle; }
th { color: #52525b; font-size: 13px; font-weight: 900; background: rgba(244,244,245,.82); }
td small { display: block; margin-top: 3px; color: var(--muted); }
tbody td { transition: background .16s ease, transform .16s ease; }
tbody tr:hover td { background: rgba(244,244,245,.92); }
.mono { font-family: Consolas, Monaco, monospace; }
.empty { text-align: center; color: var(--muted); padding: 32px; }
.nowrap { flex-wrap: nowrap; }
.row-actions form { margin: 0; }
.muted-text { color: var(--muted); font-weight: 900; }
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 16px;
    margin-top: 4px;
    color: var(--muted);
    font-weight: 900;
    flex-wrap: wrap;
}
.per-page, .page-buttons {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.per-page select {
    width: auto;
    min-width: 86px;
    padding: 8px 10px;
}
.page-buttons span { color: var(--ink); }
.btn.disabled {
    pointer-events: none;
    opacity: .42;
    box-shadow: none;
}
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
    color: #3f3f46;
    background: #f4f4f5;
    border: 1px solid transparent;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.available { color: #fff; background: #111; }
.badge.used { color: #3f3f46; background: #e4e4e7; border-color: #d4d4d8; }
.badge.completed, .badge.manual { color: #111; background: #f4f4f5; border-color: #d4d4d8; }
.badge.failed { color: #fff; background: #111; }
.badge.processing, .badge.submitted, .badge.reserved, .badge.active { color: #111; background: #fafafa; border-color: #c7c7c7; }
.badge.deleted, .badge.disabled { color: var(--muted); background: #f2f4f7; }
.modal-open { overflow: hidden; }
.modal[hidden] { display: none; }
.modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 22px;
    background: rgba(17,17,17,.44);
    backdrop-filter: blur(10px);
}
.modal-card {
    width: min(680px, 100%);
    max-height: calc(100vh - 44px);
    overflow: auto;
    padding: 22px;
    border-radius: 20px;
    background: rgba(255,255,255,.96);
    border: 1px solid rgba(17,17,17,.08);
    box-shadow: 0 30px 80px rgba(0,0,0,.24);
    animation: modalIn .22s ease both;
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
.modal-head h2 { margin: 0; }
.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--muted);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}
.cycle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 18px;
}
.cycle-card {
    padding: 18px;
    border-radius: 18px;
    background: rgba(255,255,255,.86);
    border: 1px solid rgba(17,17,17,.08);
    box-shadow: 0 14px 38px rgba(0,0,0,.07);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.cycle-card:hover { transform: translateY(-3px); border-color: rgba(17,17,17,.18); box-shadow: 0 22px 50px rgba(0,0,0,.11); }
.cycle-card.completed, .cycle-card.manual { border-color: rgba(17,17,17,.16); }
.cycle-card.failed { border-color: rgba(17,17,17,.28); background: rgba(244,244,245,.92); }
.cycle-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cycle-top span { color: var(--muted); font-weight: 900; }
.cycle-top b { color: var(--primary); }
.cycle-card dl { display: grid; grid-template-columns: 72px 1fr; gap: 7px 10px; margin: 14px 0; }
.cycle-card dt { color: var(--muted); font-weight: 800; }
.cycle-card dd { margin: 0; word-break: break-all; }
.error-text { color: #111; background: rgba(17,17,17,.08); padding: 9px; border-radius: 10px; }
.two-col { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(300px,.6fr); gap: 18px; margin-bottom: 18px; }
.secure-card-tools { display: grid; gap: 14px; }
.secure-box, .danger-box {
    display: grid;
    gap: 10px;
    padding: 18px;
    border-radius: 16px;
    background: rgba(248,250,252,.78);
    border: 1px solid rgba(111,128,153,.18);
}
.secure-box h3, .danger-box h3 { margin: 0; }
.secure-box p, .danger-box p { margin: 0; }
.danger-box { background: rgba(244,244,245,.92); border: 1px solid rgba(17,17,17,.12); }
.full-key {
    user-select: all;
    word-break: break-all;
    font-weight: 900;
    color: var(--primary);
}
.security-panel { margin-bottom: 18px; }
.section-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}
.section-title p { margin: 7px 0 0; }
.twofa-box {
    display: grid;
    gap: 14px;
    padding: 18px;
    border-radius: 16px;
    background: rgba(248,250,252,.72);
    border: 1px solid rgba(111,128,153,.18);
}
.secret-box {
    display: grid;
    gap: 8px;
    padding: 14px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(17,17,17,.07), rgba(255,255,255,.88));
    border: 1px dashed rgba(17,17,17,.26);
}
.secret-box span {
    color: var(--muted);
    font-weight: 900;
    font-size: 13px;
}
.secret-box code {
    font-family: Consolas, Monaco, monospace;
    font-size: 17px;
    font-weight: 900;
    word-break: break-all;
    color: var(--primary);
}
@media (max-width: 900px) {
    .hero, .page-head, .toolbar, .two-col { grid-template-columns: 1fr; display: grid; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .form-grid, .form-grid.compact { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .topbar { align-items: flex-start; flex-direction: column; padding: 16px; }
    .shell { padding: 0 16px; margin-top: 24px; }
    h1 { font-size: 30px; }
    .stat-grid { grid-template-columns: 1fr; }
    .search { width: 100%; flex-direction: column; }
    .tabs { width: 100%; overflow-x: auto; }
}
