:root {
  color-scheme: light;
  --ink: #241c2c;
  --muted: #766d7b;
  --paper: #f8f4ef;
  --panel: #fffdf9;
  --line: #e8e0d8;
  --plum: #41243f;
  --plum-2: #684160;
  --rose: #bd7c82;
  --sage: #658477;
  --gold: #b08a51;
  --danger: #a34e5b;
  --shadow: 0 18px 50px rgba(53, 32, 50, 0.08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif; font-size: 14px; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
code { padding: 2px 6px; border-radius: 5px; background: #f0e9e3; color: var(--plum); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 32px 20px; background: radial-gradient(circle at 20% 10%, #f3dfe0, transparent 35%), radial-gradient(circle at 90% 90%, #e7dced, transparent 36%), var(--paper); }
.login-card { width: min(430px, 100%); padding: 40px; border: 1px solid rgba(255,255,255,.8); border-radius: 26px; background: rgba(255,253,249,.9); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.brand-mark { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 17px; background: var(--plum); color: #f4d6d7; }
.brand-mark svg { width: 38px; height: 38px; }
.login-eyebrow, .page-eyebrow, .panel-kicker { margin: 22px 0 7px; color: var(--rose); font-size: 10px; font-weight: 800; letter-spacing: .2em; }
.login-card h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 38px; font-weight: 500; }
.login-copy { margin: 10px 0 28px; color: var(--muted); line-height: 1.7; }
.login-form { display: grid; gap: 10px; }
.login-form label { margin-top: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
input, select { width: 100%; min-height: 43px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; outline: none; background: #fff; color: var(--ink); transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus { border-color: var(--rose); box-shadow: 0 0 0 3px rgba(189,124,130,.14); }
.primary-button, .secondary-button, .text-button, .icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 9px 15px; border-radius: 10px; border: 1px solid transparent; font-weight: 700; font-size: 12px; white-space: nowrap; }
.primary-button { background: var(--plum); color: #fff; }
.primary-button:hover { background: var(--plum-2); }
.primary-button:disabled { cursor: wait; opacity: .65; }
.secondary-button { border-color: var(--line); background: #fff; color: var(--plum); }
.secondary-button:hover { border-color: #cdbdc5; background: #fbf6f3; }
.secondary-button:disabled { cursor: default; opacity: .4; }
.text-button { padding-inline: 0; background: transparent; color: var(--muted); }
.text-button:hover { color: var(--plum); }
.icon-button { width: 36px; min-height: 36px; padding: 0; background: #f5efe9; color: var(--ink); font-size: 22px; }
.login-form .primary-button { margin-top: 14px; min-height: 46px; }
.login-note { min-height: 20px; margin: 14px 0 0; color: var(--danger); font-size: 12px; line-height: 1.6; }
.back-link { display: inline-block; margin-top: 12px; color: var(--muted); font-size: 12px; }
.back-link:hover { color: var(--plum); }
.login-language { display: flex; justify-content: flex-end; margin: -20px 0 24px; }
.language-toggle { display: flex; flex: 0 0 auto; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.65); }
.language-toggle button { padding: 6px 11px; border: 0; border-radius: 999px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 750; }
.language-toggle button.active { background: var(--ink); color: #fff; }
.language-toggle button:focus-visible { outline: 2px solid var(--rose); outline-offset: 2px; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 28px 20px; background: var(--plum); color: #f9eef0; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 30px; font-size: 13px; font-weight: 800; letter-spacing: .12em; }
.sidebar-brand small { display: block; margin-top: 4px; color: #c8aebb; font-size: 10px; font-weight: 500; letter-spacing: .08em; }
.mini-mark { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.24); border-radius: 12px; background: rgba(255,255,255,.08); font-family: Georgia, serif; font-size: 22px; }
.sidebar-nav { display: grid; gap: 7px; }
.nav-item { padding: 12px 14px; border: 0; border-radius: 10px; background: transparent; color: #cdbbc6; text-align: left; font-weight: 600; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { box-shadow: inset 3px 0 #e1adb1; }
.sidebar-footer { display: grid; gap: 8px; margin-top: auto; padding: 20px 8px 0; border-top: 1px solid rgba(255,255,255,.12); font-size: 12px; }
.sidebar-footer a { color: #cdbbc6; }
.sidebar-footer .text-button { color: #e7c7cc; }
.admin-main { min-width: 0; padding: 36px clamp(20px, 4vw, 52px) 60px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.page-header-actions { display: flex; align-items: center; gap: 18px; }
.page-eyebrow { margin: 0 0 6px; }
.page-header h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(28px, 3vw, 38px); font-weight: 500; }
.page-description { margin: 8px 0 0; color: var(--muted); }
.admin-profile { display: flex; align-items: center; gap: 10px; }
.profile-avatar { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: #eadadd; color: var(--plum); font-weight: 800; }
.admin-profile strong, .admin-profile small { display: block; max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-profile strong { font-size: 12px; }
.admin-profile small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.view { display: grid; gap: 20px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.metric-card { padding: 22px; border: 1px solid var(--line); border-radius: 17px; background: var(--panel); box-shadow: 0 8px 24px rgba(53,32,50,.035); }
.metric-card p { margin: 0; color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; margin: 12px 0 7px; font-family: Georgia, serif; font-size: 32px; font-weight: 500; }
.metric-card small { color: var(--sage); font-size: 11px; }
.overview-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 20px; }
.panel { padding: 22px; border: 1px solid var(--line); border-radius: 17px; background: var(--panel); box-shadow: 0 8px 24px rgba(53,32,50,.035); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-kicker { margin: 0 0 5px; }
.panel h2 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 20px; font-weight: 500; }
.plan-bar { display: flex; height: 18px; overflow: hidden; border-radius: 999px; background: #eee7e1; }
.plan-bar span { min-width: 0; transition: width .3s; }
.plan-bar .free { background: #d8c9d2; }
.plan-bar .pro { background: var(--plum-2); }
.plan-summary { display: flex; justify-content: space-between; gap: 16px; margin-top: 14px; color: var(--muted); font-size: 12px; }
.plan-summary strong { color: var(--ink); }
.legend { display: flex; gap: 18px; margin-top: 18px; color: var(--muted); font-size: 11px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; background: #d8c9d2; }
.legend .pro-dot { background: var(--plum-2); }
.service-list { display: grid; gap: 10px; }
.service-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.service-row:last-child { border-bottom: 0; }
.service-row strong { display: block; font-size: 12px; }
.service-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 999px; background: #edf3ef; color: var(--sage); font-size: 10px; font-weight: 800; white-space: nowrap; }
.status-pill.off { background: #f8e9e9; color: var(--danger); }
.status-pill.neutral { background: #f0ece8; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 11px 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .06em; white-space: nowrap; }
td { max-width: 260px; padding: 13px 10px; border-bottom: 1px solid #f0e9e3; color: #4b414e; font-size: 12px; vertical-align: top; overflow-wrap: anywhere; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fcf8f4; }
.table-empty { padding: 28px 10px !important; color: var(--muted); text-align: center; }
.row-action { padding: 5px 9px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--plum); font-size: 11px; font-weight: 700; }
.row-action.danger { color: var(--danger); }
.toolbar { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.toolbar label { display: grid; gap: 6px; min-width: 140px; color: var(--muted); font-size: 11px; font-weight: 700; }
.toolbar .search-field { flex: 1; min-width: 220px; }
.toolbar input, .toolbar select { background: #fff; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; color: var(--muted); font-size: 11px; }
.pagination > div { display: flex; gap: 8px; }
.config-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.config-card { padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.config-card h3 { margin: 0 0 6px; font-size: 13px; }
.config-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.config-card .status-pill { margin-top: 13px; }
.secure-note { color: var(--muted); font-size: 11px; }
.setup-list { display: grid; gap: 12px; }
.setup-row { display: flex; align-items: flex-start; gap: 12px; padding: 14px; border-radius: 11px; background: #f9f4ef; }
.setup-icon { width: 24px; height: 24px; flex: 0 0 24px; display: grid; place-items: center; border-radius: 50%; background: #e4eee8; color: var(--sage); font-weight: 800; }
.setup-icon.off { background: #f6e3e4; color: var(--danger); }
.setup-row strong { display: block; font-size: 12px; }
.setup-row p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.danger-panel { border-color: #ead6d7; }
.danger-panel p { margin: 0; color: var(--muted); line-height: 1.8; }
.dialog-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(35, 22, 34, .48); backdrop-filter: blur(5px); }
.detail-dialog { width: min(760px, 100%); max-height: min(850px, 92vh); overflow-y: auto; padding: 26px; border-radius: 20px; background: var(--panel); box-shadow: 0 30px 90px rgba(25,12,24,.3); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.detail-item { padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.detail-item span { display: block; color: var(--muted); font-size: 10px; }
.detail-item strong { display: block; margin-top: 5px; overflow-wrap: anywhere; font-size: 12px; }
.detail-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.detail-form label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.dialog-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; }
.dialog-actions > div { display: flex; gap: 8px; }
.user-journal { margin-top: 22px; }
.user-journal h3 { margin: 0 0 12px; font-size: 14px; }
.refund-dialog { width: min(560px, 100%); }
.refund-form { display: grid; gap: 12px; margin-top: 20px; }
.refund-form label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
.form-note, .form-error { margin: 0; font-size: 11px; line-height: 1.6; }
.form-note { color: var(--muted); }
.form-error { min-height: 18px; color: var(--danger); }
.refund-form .dialog-actions { margin-top: 4px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 80; max-width: min(380px, calc(100vw - 48px)); padding: 13px 17px; border-radius: 11px; background: var(--plum); color: #fff; box-shadow: var(--shadow); font-size: 12px; line-height: 1.5; }
.toast.error { background: var(--danger); }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid { grid-template-columns: 1fr; }
  .config-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 16px; }
  .sidebar-brand { padding-bottom: 16px; }
  .sidebar-nav { grid-template-columns: repeat(6, minmax(0, 1fr)); overflow-x: auto; }
  .nav-item { padding: 10px 8px; text-align: center; font-size: 11px; white-space: nowrap; }
  .sidebar-footer { display: none; }
  .admin-main { padding: 24px 16px 44px; }
  .page-header { align-items: flex-start; flex-wrap: wrap; }
  .page-header-actions { width: 100%; justify-content: flex-end; }
  .language-toggle button { padding: 6px 9px; }
  .admin-profile { display: none; }
  .metric-grid { gap: 10px; }
  .metric-card { padding: 17px; }
  .metric-card strong { font-size: 27px; }
  .panel { padding: 16px; }
  .config-grid, .detail-grid, .detail-form { grid-template-columns: 1fr; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions > div { width: 100%; }
  .dialog-actions button { flex: 1; }
  .panel-head { align-items: flex-start; }
  .secure-note { display: none; }
  th, td { padding-inline: 8px; }
}

@media (max-width: 420px) {
  .login-card { padding: 28px 22px; }
  .metric-grid { grid-template-columns: 1fr; }
  .page-header h1 { font-size: 29px; }
  .page-header-actions { justify-content: flex-start; }
  .toolbar label, .toolbar .search-field { min-width: 100%; }
  .toolbar .primary-button, .toolbar .secondary-button { flex: 1; }
}
