* { 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-plain { background: #fff; }
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; }
.brand__sub { font-size: 12px; color: var(--text-3); }
.nav { display: flex; gap: 8px; flex: 1; }
.nav__link {
    color: var(--text-2);
    padding: 6px 10px;
    border-radius: 6px;
}
button.nav__link {
    border: 0;
    background: transparent;
    font: inherit;
    cursor: pointer;
}
.nav__link:hover, .nav__link.is-active { color: var(--text); background: #f2f3f5; }
.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; }
.topbar--index .nav { justify-content: center; gap: 4px; }
.topbar--index .nav__link {
    padding: 8px 16px;
    border-radius: 8px;
    color: #475569;
    font-weight: 500;
}
.topbar--index .nav__link:hover,
.topbar--index .nav__link.is-active {
    background: #eef2ff;
    color: #6366f1;
    font-weight: 500;
}
.topbar--index .nav__link--static,
.topbar--index .nav__link--static:hover {
    background: transparent;
    color: #475569;
    cursor: default;
}
.topbar--index .btn--primary {
    height: 40px;
    padding: 0 20px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
    font-weight: 500;
}
.topbar--index .btn--primary:hover { background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.topbar__actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.user-name { color: var(--text); font-weight: 500; }
.home-user {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 16px;
    border-radius: 999px;
    background: #e8eeff;
    color: #4f6ef2;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}
.home-user:hover { color: #2f6fe4; background: #dfe6ff; }
.role {
    font-size: 12px;
    color: var(--brand);
    background: var(--brand-soft);
    border-radius: 999px;
    padding: 2px 8px;
}

.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; }
.topbar--desk {
    background: #fff;
    border-bottom: 0;
    box-shadow: 0 1px 0 rgba(226, 232, 240, 0.9);
}
.topbar--desk .wrap {
    max-width: none;
    padding-left: 28px;
    padding-right: 28px;
}
.topbar--desk .topbar__inner {
    position: relative;
    min-height: 72px;
}
.topbar--desk .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: 19px;
}
.topbar--desk .brand__name {
    font-size: 20px;
    font-weight: 600;
    color: #172033;
}
.desk-nav {
    position: absolute;
    left: 50%;
    display: flex;
    align-items: center;
    gap: 28px;
    transform: translateX(-50%);
}
.desk-nav__link {
    color: #1c2430;
    font-size: 15px;
    font-weight: 600;
}
.desk-nav__link.is-active,
.desk-nav__link:hover { color: #2f86f5; }
.desk-kefu {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #5c6b80;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.desk-kefu img {
    width: 28px;
    height: 28px;
    display: block;
    object-fit: contain;
}
.desk-kefu:hover { color: #2f86f5; }
.desk-hello {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 16px;
    border-radius: 999px;
    background: #e8eeff;
    color: #4f6ef2;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}
.topbar--desk .desk-logout {
    display: inline-flex;
    align-items: center;
    height: auto;
    padding: 6px 16px;
    border: 1px solid #ff4d4f;
    border-radius: 999px;
    background: #fff;
    box-shadow: none;
    color: #ff4d4f;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.4;
}
.topbar--desk .desk-logout:hover {
    background: #fff1f0;
    color: #ff4d4f;
}
.desk-kefu-qr { display: flex; justify-content: center; }
.desk-kefu-qr img {
    width: 220px;
    height: 220px;
    object-fit: contain;
}
.flash--ok { background: #e8ffea; color: #009a29; border-color: #aff0b5; }
.flash--err { background: #ffece8; color: #cb2634; border-color: #fdcdc5; }

.footer { border-top: 1px solid var(--line); padding: 20px 0 28px; color: var(--text-3); background: #fff; }

.page { padding: 28px 0 64px; min-height: calc(100vh - 120px); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.page-head h1 { font-size: 24px; font-weight: 600; }
.page-head p { margin-top: 6px; color: var(--text-2); }
.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; }
    .brand__sub { display: none; }
    .nav { order: 3; flex: 1 0 100%; }
    .topbar__actions { margin-left: 0; flex: 0 0 auto; }
}