:root {
    --ink: #1c2f28;
    --muted: #758179;
    --green: #214b3b;
    --green-dark: #17392d;
    --lime: #c8f263;
    --paper: #fff;
    --bg: #f4f5ef;
    --line: #e5e9e2;
    --orange: #ff986f;
    --purple: #dcd6fb;
    --yellow: #ffe48b;
    --shadow: 0 20px 50px rgba(29,61,45,.08);
    --ease: cubic-bezier(.22,1,.36,1);
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: Inter, ui-rounded, "SF Pro Rounded", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }

.admin-body { min-height: 100vh; padding-left: 244px; }
.sidebar { position: fixed; z-index: 10; inset: 0 auto 0 0; width: 244px; padding: 30px 22px 23px; display: flex; flex-direction: column; color: #ebf4ee; background: linear-gradient(180deg, #183e30, #112f25); }
.admin-brand { display: inline-flex; align-items: center; gap: 11px; padding: 0 8px; font-size: 18px; font-weight: 750; letter-spacing: -.4px; }
.admin-brand strong { color: #aeca9e; }
.admin-brand-mark { width: 37px; height: 37px; display: grid; place-items: center; border-radius: 12px; color: var(--green-dark); background: var(--lime); font-family: Georgia, serif; font-size: 21px; font-weight: 700; box-shadow: 0 8px 22px rgba(4,20,14,.2); transform: rotate(-3deg); }
.sidebar nav { display: grid; gap: 6px; margin-top: 49px; }
.sidebar nav a { padding: 13px 12px; display: flex; align-items: center; gap: 11px; border-radius: 11px; color: rgba(255,255,255,.6); font-size: 14px; font-weight: 700; transition: .2s ease; }
.sidebar nav a span { width: 20px; font-size: 16px; text-align: center; }
.sidebar nav a:hover { color: white; background: rgba(255,255,255,.07); }
.sidebar nav a.is-active { color: white; background: rgba(200,242,99,.13); }
.sidebar nav a.is-active span { color: var(--lime); }
.sidebar-bottom { margin-top: auto; padding-top: 18px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid rgba(255,255,255,.1); }
.admin-user { display: flex; align-items: center; gap: 9px; }
.admin-user > span { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; color: var(--green-dark); background: #d9d2fa; font-size: 13px; font-weight: 900; }
.admin-user div { display: grid; }
.admin-user strong { font-size: 13px; }
.admin-user small { color: rgba(255,255,255,.52); font-size: 10px; }
.sidebar-bottom form button { border: 0; color: rgba(255,255,255,.48); background: transparent; cursor: pointer; font-size: 16px; }

.admin-main { width: 100%; max-width: none; margin: 0; padding: 36px clamp(24px, 2.2vw, 48px) 64px; }
.admin-header { display: flex; align-items: center; justify-content: space-between; gap: 25px; margin-bottom: 28px; }
.page-kicker, .login-kicker { color: #829188; font-size: 10px; font-weight: 900; letter-spacing: 1.8px; }
.admin-header h1 { margin: 7px 0 4px; font-family: Georgia, "Songti SC", serif; font-size: clamp(34px, 2.2vw, 42px); font-weight: 500; letter-spacing: -1px; }
.admin-header p { margin: 0; color: var(--muted); font-size: 14px; }
.add-button { min-height: 52px; padding: 0 21px 0 9px; display: inline-flex; align-items: center; gap: 11px; border: 0; border-radius: 14px; color: white; background: var(--green); font-size: 13px; font-weight: 800; cursor: pointer; box-shadow: 0 12px 24px rgba(33,75,59,.18); transition: .25s var(--ease); }
.add-button span { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 9px; color: var(--green); background: var(--lime); font-size: 17px; }
.add-button:hover { transform: translateY(-2px); background: var(--green-dark); }
.alert { margin-bottom: 20px; padding: 14px 17px; border-radius: 12px; font-size: 13px; font-weight: 700; animation: alertIn .4s var(--ease) both; }
.alert-success { color: #37613e; background: #def1dc; border: 1px solid #c2e1be; }
.alert-error { color: #914b3c; background: #ffe1d8; border: 1px solid #f5c6b8; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 20px; }
.stat-grid article { min-height: 124px; padding: 21px; display: flex; align-items: center; gap: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: 0 7px 25px rgba(31,60,45,.035); }
.stat-icon { width: 50px; height: 50px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 14px; font-family: Georgia, serif; font-size: 18px; font-weight: 800; }
.stat-icon.green { color: #355f42; background: #ddf0d1; }
.stat-icon.orange { color: #8e533d; background: #ffe1d5; }
.stat-icon.purple { color: #655a9d; background: var(--purple); }
.stat-icon.yellow { color: #816719; background: #fff0b9; }
.stat-grid article div { min-width: 0; display: grid; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 7px; }
.stat-grid small { grid-column: 1 / -1; color: var(--muted); font-size: 11px; font-weight: 750; }
.stat-grid strong { margin-top: 5px; font-family: Georgia, serif; font-size: 32px; font-weight: 500; }
.stat-grid em { color: #8f9a94; font-size: 11px; font-style: normal; }

.admin-grid { display: grid; grid-template-columns: minmax(760px, 1fr) minmax(300px, 350px); gap: 20px; align-items: start; }
.content-panel, .mix-panel, .activity-panel { border: 1px solid var(--line); border-radius: 19px; background: var(--paper); box-shadow: 0 7px 25px rgba(31,60,45,.03); }
.panel-heading { min-height: 78px; padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; gap: 17px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font-size: 17px; }
.panel-heading > div > span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.filters { display: flex; gap: 8px; }
.filters select, .filters > button, .search-box { height: 40px; border: 1px solid var(--line); border-radius: 10px; background: #f8f9f6; color: #5d6962; font-size: 12px; }
.filters select { padding: 0 11px; outline: none; }
.filters > button { padding: 0 14px; cursor: pointer; }
.search-box { width: clamp(180px, 14vw, 260px); display: flex; align-items: center; padding: 0 11px; gap: 7px; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 12px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 16px; color: #89958e; background: #fafbf8; border-bottom: 1px solid var(--line); text-align: left; font-size: 10px; font-weight: 850; letter-spacing: .55px; text-transform: uppercase; white-space: nowrap; }
td { padding: 15px 16px; border-bottom: 1px solid #eef0ec; vertical-align: middle; font-size: 13px; }
tbody tr { transition: .18s ease; }
tbody tr:hover { background: #fbfcf9; }
.item-content { max-width: 520px; }
.item-content strong, .item-content span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-content strong { margin-bottom: 5px; font-size: 14px; }
.item-content span { color: var(--muted); font-size: 12px; }
.type-tag { display: inline-block; padding: 6px 10px; border-radius: 8px; font-size: 10px; font-weight: 800; }
.type-word { color: #42684a; background: #e4f2dc; }
.type-phrase { color: #905b42; background: #ffe4d8; }
.type-sentence { color: #665b99; background: #e8e3ff; }
.type-dialogue { color: #7e661c; background: #fff1bb; }
.date-cell, .tags-cell { color: var(--muted); white-space: nowrap; }
.tags-cell { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.difficulty { color: #80ae43; font-size: 8px; letter-spacing: 2px; white-space: nowrap; }
.difficulty i { color: #dfe4df; font-style: normal; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-actions form { display: inline-flex; }
.row-actions button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 9px; background: white; color: #6f7d75; cursor: pointer; font-size: 14px; }
.row-actions button:hover { border-color: #9fc466; color: var(--green); }
.empty-cell { height: 230px; text-align: center; color: var(--muted); }
.empty-cell span, .empty-cell strong { display: block; }
.empty-cell span { font-size: 26px; }
.empty-cell strong { margin: 8px; color: var(--ink); }
.empty-cell button { border: 0; background: transparent; color: #598145; text-decoration: underline; cursor: pointer; font-size: 13px; }
.pagination { padding: 12px; display: flex; justify-content: center; gap: 5px; }
.pagination a { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; }
.pagination a.is-current { color: white; border-color: var(--green); background: var(--green); }

.side-panels { display: grid; gap: 17px; }
.mix-bars { padding: 20px; display: grid; gap: 17px; }
.mix-bars > div > span { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 700; }
.mix-bars > div > span i { color: var(--ink); font-style: normal; }
.mix-bars b { height: 8px; display: block; margin-top: 8px; overflow: hidden; border-radius: 999px; background: #eef1ed; }
.mix-bars b i { height: 100%; display: block; border-radius: inherit; }
.mix-bars .green { background: #82b753; }.mix-bars .orange { background: var(--orange); }.mix-bars .purple { background: #9c90d8; }.mix-bars .yellow { background: #e3bf49; }
.activity-list { padding: 8px 19px 14px; }
.activity-list article { padding: 13px 0; display: flex; gap: 10px; border-bottom: 1px solid #eef0ec; }
.activity-list article:last-child { border: 0; }
.activity-dot { width: 8px; height: 8px; flex: 0 0 auto; margin-top: 3px; border: 2px solid #cbd4ce; border-radius: 50%; }
.activity-dot.correct { border-color: #82b753; background: #dff2ce; }
.activity-dot.almost { border-color: #e1ae4f; background: #fff0b2; }
.activity-dot.incorrect { border-color: #e1826c; background: #ffe0d7; }
.activity-list strong { display: block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.activity-list p, .empty-small { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.empty-small { padding: 16px 0; line-height: 1.6; text-align: center; }

/* Dialog */
.item-dialog { width: min(760px, calc(100vw - 28px)); max-height: calc(100vh - 32px); padding: 0; overflow: hidden; border: 0; border-radius: 22px; color: var(--ink); background: white; box-shadow: 0 35px 100px rgba(14,42,29,.28); }
.item-dialog::backdrop { background: rgba(18,45,34,.45); backdrop-filter: blur(5px); }
.item-dialog[open] { animation: dialogIn .35s var(--ease) both; }
.item-dialog form { max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.dialog-head { padding: 23px 26px 18px; display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 5px 0 0; font-size: 23px; }
.dialog-head > button { width: 37px; height: 37px; border: 1px solid var(--line); border-radius: 10px; background: white; color: #7a8780; cursor: pointer; font-size: 22px; }
.dialog-body { padding: 19px 26px; overflow-y: auto; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row.four-types { grid-template-columns: repeat(4, 1fr); margin-bottom: 13px; }
.four-types input { position: absolute; opacity: 0; }
.four-types span { height: 42px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: #fafbf8; font-size: 12px; font-weight: 750; cursor: pointer; }
.four-types input:checked + span { color: #315f47; border-color: #9dc582; background: #e6f3dc; box-shadow: inset 0 0 0 1px white; }
.field { margin: 12px 0 0; display: block; }
.field > span { display: block; margin-bottom: 6px; color: #52635a; font-size: 13px; font-weight: 800; }
.field em { color: #dd7055; font-style: normal; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--line); border-radius: 10px; outline: 0; background: #fafbf8; color: var(--ink); font-size: 14px; transition: .2s ease; }
.field input, .field select { height: 44px; padding: 0 12px; }
.field textarea { padding: 11px 12px; resize: vertical; line-height: 1.55; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: #87af72; background: white; box-shadow: 0 0 0 3px rgba(153,197,126,.13); }
.field small { display: block; margin-top: 5px; color: #8e9993; font-size: 11px; line-height: 1.45; }
.active-check { margin-top: 16px; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.active-check input { accent-color: var(--green); }
.dialog-footer { padding: 15px 26px 20px; display: flex; justify-content: flex-end; gap: 9px; border-top: 1px solid var(--line); }
.dialog-footer button { height: 44px; padding: 0 19px; border-radius: 11px; font-size: 13px; font-weight: 800; cursor: pointer; }
.cancel-button { border: 1px solid var(--line); background: white; color: var(--muted); }
.save-button { border: 0; color: white; background: var(--green); }
.save-button span { margin-left: 10px; color: var(--lime); }

/* Login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: #edf0e9; }
.login-shell { width: min(940px, 100%); min-height: 575px; display: grid; grid-template-columns: 1.05fr .95fr; overflow: hidden; border: 1px solid rgba(255,255,255,.8); border-radius: 28px; background: white; box-shadow: 0 35px 90px rgba(27,62,44,.15); }
.login-visual { position: relative; overflow: hidden; padding: 34px; color: white; background: radial-gradient(circle at 80% 5%, rgba(200,242,99,.18), transparent 30%), linear-gradient(145deg, #234f3d, #133327); }
.admin-brand.light { color: white; padding: 0; }
.login-quote { position: relative; z-index: 2; margin-top: 99px; }
.login-kicker { color: #a5beae; }
.login-quote h1 { margin: 14px 0; font-family: Georgia, "Songti SC", serif; font-size: 37px; font-weight: 500; line-height: 1.35; letter-spacing: -1px; }
.login-quote p { color: rgba(255,255,255,.58); font-size: 11px; }
.login-art { position: absolute; right: -32px; bottom: -48px; width: 270px; height: 270px; border: 1px solid rgba(200,242,99,.13); border-radius: 50%; }
.login-art::before, .login-art::after { content: ""; position: absolute; border: 1px solid rgba(200,242,99,.11); border-radius: 50%; }
.login-art::before { inset: 42px; }.login-art::after { inset: 83px; }
.login-art i { position: absolute; z-index: 2; width: 55px; height: 29px; background: #7da85c; }
.login-art i:nth-child(1) { left: 71px; top: 43px; border-radius: 30px 3px 30px 3px; transform: rotate(28deg); }
.login-art i:nth-child(2) { left: 133px; top: 82px; border-radius: 3px 30px 3px 30px; transform: rotate(-22deg); }
.login-art i:nth-child(3) { left: 62px; top: 125px; border-radius: 30px 3px 30px 3px; transform: rotate(20deg); }
.login-art b { position: absolute; z-index: 1; left: 115px; top: 68px; width: 5px; height: 145px; border-radius: 5px; background: #a6d46d; transform: rotate(-5deg); }
.login-art span { position: absolute; right: 22px; top: 27px; color: var(--lime); font-size: 25px; }
.login-panel { display: grid; place-items: center; padding: 45px; }
.login-form { width: min(320px, 100%); }
.login-form h2 { margin: 8px 0 5px; font-family: Georgia, "Songti SC", serif; font-size: 27px; font-weight: 500; }
.login-form > p { margin: 0 0 28px; color: var(--muted); font-size: 9px; }
.login-form label { display: block; margin-top: 14px; }
.login-form label span { display: block; margin-bottom: 6px; color: #56675e; font-size: 9px; font-weight: 800; }
.login-form input { width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 11px; outline: 0; background: #fafbf8; font-size: 11px; }
.login-form input:focus { border-color: #8fb776; box-shadow: 0 0 0 3px rgba(143,183,118,.13); }
.login-button { width: 100%; height: 49px; margin-top: 22px; padding: 0 8px 0 17px; display: flex; align-items: center; justify-content: space-between; border: 0; border-radius: 13px; color: white; background: var(--green); font-size: 10px; font-weight: 850; cursor: pointer; }
.login-button i { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; color: var(--green); background: var(--lime); font-size: 16px; font-style: normal; }
.back-link { display: block; margin-top: 17px; color: var(--muted); font-size: 8px; text-align: center; }

@keyframes dialogIn { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes alertIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

@media (max-width: 1400px) {
    .admin-grid { grid-template-columns: 1fr; }
    .side-panels { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1120px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 780px) {
    .admin-body { padding-left: 0; padding-bottom: 70px; }
    .sidebar { inset: auto 0 0; width: auto; height: 62px; padding: 8px 15px; flex-direction: row; align-items: center; }
    .sidebar .admin-brand { display: none; }
    .sidebar nav { flex: 1; width: auto; margin: 0; display: grid; grid-template-columns: 1fr 1fr; }
    .sidebar nav a { justify-content: center; }
    .sidebar-bottom { margin: 0 0 0 5px; padding: 0; display: flex; border: 0; }
    .sidebar-bottom .admin-user { display: none; }
    .sidebar-bottom form button { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: rgba(255,255,255,.07); }
    .admin-main { padding: 27px 16px; }
    .admin-header { align-items: flex-end; }
    .admin-header h1 { font-size: 27px; }
    .add-button { font-size: 0; padding: 7px; }
    .add-button span { font-size: 17px; }
    .panel-heading { align-items: flex-start; flex-direction: column; }
    .filters { width: 100%; flex-wrap: wrap; }
    .search-box { flex: 1 1 160px; }
    .login-shell { grid-template-columns: 1fr; }
    .login-visual { min-height: 240px; }
    .login-quote { margin-top: 52px; }
    .login-quote h1 { font-size: 28px; }
    .login-art { opacity: .55; }
}
@media (max-width: 520px) {
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-grid article { min-height: 90px; padding: 12px; }
    .stat-icon { width: 35px; height: 35px; }
    .stat-grid strong { font-size: 21px; }
    .side-panels { grid-template-columns: 1fr; }
    .field-row { grid-template-columns: 1fr; }
    .field-row.four-types { grid-template-columns: repeat(2, 1fr); }
    .login-body { padding: 12px; }
    .login-panel { padding: 38px 25px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
