:root {
    --bg: #eef2f7;
    --panel: #ffffff;
    --text: #172033;
    --muted: #667085;
    --line: #d9dee8;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --success: #0f766e;
    --danger: #b42318;
    --shadow: 0 18px 45px rgba(24, 36, 64, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(180deg, #f8fafc 0, #eef2f7 320px, #eef2f7 100%);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px clamp(24px, 4vw, 56px);
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.brand {
    font-size: 17px;
    font-weight: 800;
}

.topbar nav a {
    color: var(--accent);
    font-size: 14px;
    font-weight: 700;
}

.app-shell,
.admin-shell {
    width: min(1360px, calc(100% - 48px));
    margin: 0 auto;
    padding: 22px 0 56px;
}

.hero {
    display: grid;
    grid-template-columns: minmax(360px, 1fr) minmax(360px, 520px);
    gap: 28px;
    align-items: center;
    padding: 24px 28px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(24, 36, 64, 0.07);
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

.hero h1,
.admin-title h1 {
    margin-bottom: 8px;
    font-size: 30px;
    line-height: 1.18;
    letter-spacing: 0;
}

.hero p,
.admin-title p {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.7;
}

.search {
    display: flex;
    gap: 10px;
}

input,
textarea,
select,
button {
    font: inherit;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    padding: 10px 12px;
    outline: none;
}

textarea {
    min-height: 220px;
    resize: vertical;
    line-height: 1.7;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

button,
.primary,
.primary-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #ffffff;
    padding: 0 14px;
    cursor: pointer;
    font-weight: 800;
}

button:hover,
.primary:hover,
.primary-link:hover {
    background: var(--accent-dark);
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 18px 0 14px;
    color: var(--muted);
    font-size: 14px;
}

.breadcrumb a {
    color: var(--accent);
    font-weight: 700;
}

.choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 10px;
    margin-bottom: 22px;
}

.choice-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 58px;
    padding: 13px 15px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(24, 36, 64, 0.04);
    font-size: 15px;
    font-weight: 800;
}

.choice-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.choice-card svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
}

.section-title,
.template-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.section-title h2,
.panel h2 {
    margin-bottom: 10px;
    font-size: 18px;
}

.section-title span,
.meta {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.template-card,
.panel,
.empty {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(24, 36, 64, 0.06);
}

.template-card {
    margin-top: 12px;
    padding: 18px;
}

.template-card h3 {
    margin-bottom: 0;
    font-size: 18px;
}

.template-card label,
.form-panel label,
.mini-form label {
    display: block;
    margin: 13px 0 7px;
    color: #344054;
    font-size: 13px;
    font-weight: 800;
}

.copy-line {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

.copy.secondary {
    margin-top: 10px;
    background: #eef4ff;
    color: var(--accent);
}

.copy.secondary:hover {
    background: #dbeafe;
}

.empty {
    padding: 28px;
    color: var(--muted);
}

.empty h3 {
    color: var(--text);
}

.admin-title {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 16px;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 430px;
    gap: 20px;
    align-items: start;
}

.panel {
    padding: 18px;
}

.form-panel {
    display: grid;
}

.admin-grid > aside.panel {
    position: sticky;
    top: 72px;
    max-height: calc(100vh - 92px);
    overflow: auto;
}

.mini-form {
    display: grid;
    gap: 8px;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.path-list {
    display: grid;
    gap: 8px;
    max-height: 420px;
    overflow: auto;
}

.path-item {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    color: var(--text);
    min-height: 38px;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.5;
}

.path-item > span:nth-child(2) {
    flex: 1;
    min-width: 0;
}

.delete-category-form {
    margin-left: auto;
}

.danger-button {
    min-height: 30px;
    border: 1px solid #fecdca;
    background: #fff4f3;
    color: var(--danger);
    padding: 0 10px;
    font-size: 12px;
}

.danger-button:hover {
    background: #fee4e2;
}

.locked-note {
    margin-left: auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.sort-groups {
    display: grid;
    gap: 14px;
    padding-right: 4px;
}

.sort-group {
    display: grid;
    gap: 8px;
}

.sort-group h3 {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.sortable-list {
    display: grid;
    gap: 7px;
}

.sortable-item {
    cursor: grab;
    user-select: none;
}

.sortable-item:active {
    cursor: grabbing;
}

.sortable-item.dragging {
    opacity: 0.45;
    border-color: var(--accent);
}

.drag-handle {
    color: var(--muted);
    font-size: 16px;
    line-height: 1;
}

.field-note {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

.recent {
    margin-top: 20px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

td span {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 13px;
}

.notice {
    margin: 0 0 14px;
    padding: 11px 13px;
    border-radius: 8px;
    font-weight: 700;
}

.success {
    background: #ecfdf3;
    color: var(--success);
}

.error {
    background: #fef3f2;
    color: var(--danger);
}

.setup {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
}

.setup .panel {
    width: min(560px, 100%);
}

.link-row {
    display: flex;
    gap: 16px;
    margin-top: 20px;
}

.link-row a {
    color: var(--accent);
    font-weight: 800;
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    transform: translateY(16px);
    opacity: 0;
    pointer-events: none;
    border-radius: 8px;
    background: #101828;
    color: #ffffff;
    padding: 12px 16px;
    font-weight: 800;
    transition: 0.2s ease;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

@media (max-width: 760px) {
    .hero,
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .hero {
        padding: 24px;
    }

    .search,
    .copy-line,
    .section-title,
    .template-head {
        align-items: stretch;
        flex-direction: column;
    }

    .copy-line {
        display: flex;
    }
}
