* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
body.theme-app { background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
button, input, textarea, select { font-family: inherit; font-size: 14px; }
h1, h2, h3, p { margin: 0; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 24px; }
.muted { color: var(--text-3); }
.strong { color: var(--text); font-weight: 600; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}
.topbar__inner {
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; }
.brand__mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}
.brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.brand__name { font-size: 16px; font-weight: 600; }
.topbar--index {
    background: rgba(255, 255, 255, 0.82);
    border-bottom-color: rgba(226, 232, 240, 0.9);
    backdrop-filter: blur(16px);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 1) inset,
        0 6px 24px rgba(15, 23, 42, 0.06),
        0 2px 6px rgba(99, 102, 241, 0.05);
}
.topbar--index::after {
    content: "";
    position: absolute;
    left: 8%;
    right: 8%;
    bottom: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.35) 30%, rgba(168, 85, 247, 0.45) 50%, rgba(99, 102, 241, 0.35) 70%, transparent);
    pointer-events: none;
}
.topbar--index .topbar__inner { min-height: 72px; }
.topbar--index .brand__mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
    font-size: 18px;
}
.topbar--index .brand__name { font-size: 20px; font-weight: 600; color: #0f172a; }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 16px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}
.btn--sm { height: 32px; padding: 0 12px; }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-hover); }
.btn--ghost { border-color: var(--line); background: #fff; color: var(--text); }
.btn--ghost:hover { border-color: #c9cdd4; }
.btn--block { width: 100%; }
a.btn--primary { color: #fff; }

.flash-wrap { padding-top: 16px; }
.flash {
    max-width: var(--max);
    margin: 0 auto;
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
}
.theme-app .flash, .admin-content .flash { max-width: none; }
.flash--ok { background: #e8ffea; color: #009a29; border-color: #aff0b5; }
.flash--err { background: #ffece8; color: #cb2634; border-color: #fdcdc5; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
}
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { color: var(--text-2); }
.hint { color: var(--text-3); font-size: 12px; }
.input, .textarea, .select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    padding: 8px 12px;
    outline: none;
}
.input, .select { height: 36px; }
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .textarea:focus, .select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(22, 93, 255, 0.15);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.file {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 36px;
}
.file input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.file__btn {
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    background: #fff;
}
.file:hover .file__btn { border-color: var(--brand); color: var(--brand); }
.file__name { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--text-2); font-weight: 500; background: #f7f8fa; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafafa; }
.table a.strong { color: var(--text); }
.table a.strong:hover { color: var(--brand); }

.tag { display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: 4px; font-size: 12px; }
.tag--gray { background: #f2f3f5; color: #4e5969; }
.tag--blue { background: #e8f3ff; color: #165dff; }
.tag--green { background: #e8ffea; color: #00b42a; }
.tag--teal { background: #e8fffb; color: #0da5a0; }
.tag--orange { background: #fff7e8; color: #ff7d00; }

.empty { color: var(--text-2); text-align: center; padding: 36px 16px; }
.pager { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.pager a {
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-2);
    background: #fff;
}
.pager a.is-current { color: #fff; background: var(--brand); border-color: var(--brand); }


.is-hidden,
[hidden] { display: none !important; }

@media (max-width: 980px) {
    .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .wrap { padding: 0 16px; }
    .topbar__inner {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px 12px;
        padding-top: 10px;
        padding-bottom: 10px;
    }
    .brand { flex: 1 1 auto; min-width: 0; }
}