:root {
  --ink: #160f10;
  --wine: #3a1016;
  --wine-soft: #5b1a22;
  --gold: #bd8d42;
  --gold-light: #e3c481;
  --paper: #f7f4ee;
  --paper-deep: #eee8dc;
  --white: #fffdf8;
  --muted: #80736f;
  --line: rgba(71, 40, 36, .12);
  --success: #527b5b;
  --danger: #a34848;
  --shadow: 0 24px 70px rgba(52, 22, 20, .14);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; color: var(--ink); background: var(--paper); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 6px; color: var(--gold); font-family: Georgia, serif; font-size: 11px; font-weight: 700; letter-spacing: .22em; }

.login-view { min-height: 100vh; display: grid; place-items: center; overflow: hidden; position: relative; padding: 32px 18px; background: radial-gradient(circle at 20% 20%, #58202a 0, #2a0e13 35%, #10090a 100%); }
.login-view::before { content: ""; position: absolute; inset: 0; opacity: .23; background-image: linear-gradient(120deg, transparent 48%, rgba(211, 169, 91, .22) 49%, transparent 50%), linear-gradient(60deg, transparent 48%, rgba(211, 169, 91, .12) 49%, transparent 50%); background-size: 52px 90px; }
.login-aura { position: absolute; border: 1px solid rgba(219, 178, 98, .18); border-radius: 50%; }
.aura-one { width: 520px; height: 520px; left: -180px; top: -220px; }
.aura-two { width: 760px; height: 760px; right: -300px; bottom: -420px; }
.login-card { position: relative; z-index: 1; width: min(440px, 100%); padding: 44px; border: 1px solid rgba(227, 196, 129, .35); background: rgba(255, 253, 248, .96); box-shadow: 0 40px 100px rgba(0, 0, 0, .34); }
.login-card::before { content: ""; position: absolute; inset: 9px; pointer-events: none; border: 1px solid rgba(189, 141, 66, .19); }
.seal, .brand-seal { display: grid; place-items: center; color: #f2d99a; background: var(--wine); border: 1px solid var(--gold); font-family: STKaiti, KaiTi, serif; }
.seal { width: 58px; height: 58px; margin-bottom: 24px; font-size: 30px; }
.login-card h1 { margin: 0; font-family: STSong, SimSun, serif; font-size: clamp(26px, 7vw, 34px); letter-spacing: .08em; }
.login-intro { margin: 14px 0 26px; color: var(--muted); line-height: 1.8; }
.stack-form { display: grid; gap: 16px; }
label { display: grid; gap: 8px; color: #574a47; font-size: 13px; font-weight: 600; }
input, textarea, select { width: 100%; border: 1px solid rgba(67, 37, 34, .17); border-radius: 4px; outline: 0; background: #fff; color: var(--ink); padding: 12px 13px; transition: .2s; }
textarea { resize: vertical; min-height: 92px; line-height: 1.6; }
input:focus, textarea:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(189, 141, 66, .12); }
.primary-button, .secondary-button, .ghost-button, .danger-button { border: 0; border-radius: 4px; padding: 11px 16px; font-weight: 700; }
.primary-button { color: #fff7e5; background: linear-gradient(135deg, #5b1720, #300c11); box-shadow: 0 8px 24px rgba(58, 16, 22, .22); }
.secondary-button { color: var(--wine); background: rgba(189, 141, 66, .16); border: 1px solid rgba(189, 141, 66, .35); }
.ghost-button { color: inherit; background: transparent; border: 1px solid currentColor; }
.danger-button { color: white; background: var(--danger); }
.login-note { margin: 20px 0 0; color: #9d8f88; font-size: 12px; text-align: center; }

.app-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; z-index: 30; top: 0; height: 100vh; display: flex; flex-direction: column; color: #f7ead3; background: radial-gradient(circle at 0 0, #5b2028, transparent 42%), linear-gradient(180deg, #2c0d12, #16090b); box-shadow: 14px 0 50px rgba(47, 19, 17, .15); }
.brand { display: flex; align-items: center; gap: 12px; min-height: 98px; padding: 22px; border-bottom: 1px solid rgba(227, 196, 129, .15); }
.brand-seal { width: 42px; height: 42px; font-size: 22px; }
.brand strong { display: block; font-family: STSong, SimSun, serif; font-size: 20px; letter-spacing: .18em; }
.brand span { display: block; margin-top: 4px; color: rgba(247, 234, 211, .55); font-size: 10px; letter-spacing: .12em; }
.nav-list { display: grid; gap: 4px; padding: 24px 14px; }
.nav-list button { display: flex; align-items: center; gap: 12px; border: 0; border-radius: 4px; padding: 13px 14px; color: rgba(247, 234, 211, .68); background: transparent; text-align: left; }
.nav-list button span { display: grid; place-items: center; width: 25px; height: 25px; border: 1px solid rgba(227, 196, 129, .28); color: var(--gold-light); font-family: STKaiti, KaiTi, serif; font-size: 12px; }
.nav-list button:hover, .nav-list button.active { color: #fff6df; background: linear-gradient(90deg, rgba(189, 141, 66, .2), rgba(189, 141, 66, .04)); }
.sidebar-foot { margin-top: auto; padding: 18px 20px 24px; border-top: 1px solid rgba(227, 196, 129, .15); }
.sidebar-foot strong, .sidebar-foot span { display: block; }
.sidebar-foot span { margin: 4px 0 12px; color: rgba(247, 234, 211, .55); font-size: 12px; }
.sidebar-foot button { width: 100%; color: rgba(247, 234, 211, .7); border-color: rgba(247, 234, 211, .22); }

.main-area { min-width: 0; }
.topbar { min-height: 98px; display: flex; align-items: center; gap: 18px; padding: 18px clamp(20px, 4vw, 48px); border-bottom: 1px solid var(--line); background: rgba(247, 244, 238, .93); backdrop-filter: blur(12px); }
.topbar h2 { margin: 0; font-family: STSong, SimSun, serif; font-size: 25px; letter-spacing: .06em; }
.topbar-status { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.topbar-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px rgba(82, 123, 91, .13); }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 4px; color: var(--wine); background: rgba(255,255,255,.55); font-size: 21px; }
#menuButton { display: none; }
.content { min-width: 0; padding: clamp(22px, 4vw, 48px); }

.section-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.section-head h3 { margin: 0; font-family: STSong, SimSun, serif; font-size: 23px; }
.section-head p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat-card, .panel { min-width: 0; border: 1px solid var(--line); background: rgba(255, 253, 248, .84); box-shadow: 0 12px 40px rgba(57, 24, 21, .06); }
.stat-card { position: relative; overflow: hidden; min-height: 138px; padding: 24px; }
.stat-card::after { content: attr(data-mark); position: absolute; right: 14px; bottom: -28px; color: rgba(189, 141, 66, .08); font-family: STKaiti, KaiTi, serif; font-size: 92px; }
.stat-card span { color: var(--muted); font-size: 12px; letter-spacing: .08em; }
.stat-card strong { display: block; margin: 14px 0 6px; color: var(--wine); font-family: Georgia, serif; font-size: 34px; }
.stat-card small { color: #9a8e88; }
.dashboard-grid { min-width: 0; display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .8fr); gap: 18px; margin-top: 18px; }
.panel { padding: 22px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-title h4 { margin: 0; font-family: STSong, SimSun, serif; font-size: 18px; }
.panel-title span { color: var(--muted); font-size: 12px; }
.status-list { display: grid; gap: 13px; }
.status-row { display: grid; grid-template-columns: 88px minmax(0, 1fr) 26px; align-items: center; gap: 10px; font-size: 12px; }
.status-bar { height: 7px; overflow: hidden; border-radius: 8px; background: #e9e2d8; }
.status-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--wine-soft), var(--gold)); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input { flex: 1 1 240px; }
.toolbar select { flex: 0 1 180px; }
.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; border: 1px solid var(--line); background: rgba(255, 253, 248, .88); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: #8d7e78; background: #f1ece3; font-size: 11px; font-weight: 700; letter-spacing: .08em; }
td { font-size: 13px; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(189, 141, 66, .05); }
.link-button { border: 0; padding: 0; color: var(--wine-soft); background: transparent; font-weight: 700; text-align: left; }
.subtext { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 400; }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 5px 9px; color: var(--wine); background: rgba(189, 141, 66, .14); font-size: 11px; white-space: nowrap; }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--gold); }
.badge.cancelled { color: #7a6868; background: #ece7e4; }
.badge.completed { color: #3d6849; background: #e4eee6; }
.empty { padding: 56px 20px; color: var(--muted); text-align: center; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 14px; color: var(--muted); font-size: 12px; }
.pager button { border: 1px solid var(--line); border-radius: 4px; padding: 7px 11px; background: #fff; }

.drawer-mask { position: fixed; z-index: 60; inset: 0; background: rgba(20, 8, 9, .45); backdrop-filter: blur(3px); }
.drawer { position: fixed; z-index: 61; top: 0; right: 0; width: min(620px, 94vw); height: 100vh; transform: translateX(105%); transition: transform .25s ease; background: var(--paper); box-shadow: -30px 0 80px rgba(24, 7, 9, .25); }
.drawer.open { transform: translateX(0); }
.drawer > header { min-height: 90px; display: flex; align-items: center; justify-content: space-between; padding: 20px 26px; border-bottom: 1px solid var(--line); background: var(--white); }
.drawer h3 { margin: 0; font-family: STSong, SimSun, serif; font-size: 24px; }
.drawer-body { height: calc(100vh - 90px); overflow-y: auto; padding: 26px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-item { padding: 13px; border: 1px solid var(--line); background: rgba(255,255,255,.55); }
.detail-item span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; }
.detail-item strong { font-size: 14px; }
.detail-section { margin-top: 24px; }
.detail-section h4 { margin: 0 0 12px; font-family: STSong, SimSun, serif; font-size: 17px; }
.product-line, .timeline-item { padding: 13px 15px; border-left: 2px solid var(--gold); background: rgba(255,255,255,.64); }
.product-line + .product-line, .timeline-item + .timeline-item { margin-top: 8px; }
.timeline-item p { margin: 0 0 7px; line-height: 1.6; }
.timeline-item small { color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.toast { position: fixed; z-index: 100; right: 24px; bottom: 24px; max-width: min(390px, calc(100vw - 48px)); border-left: 4px solid var(--gold); padding: 14px 18px; color: #fff8e7; background: #2d1115; box-shadow: var(--shadow); }
.toast.error { border-color: #d66f6f; }
.role-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.role-card { padding: 18px; border: 1px solid var(--line); background: var(--white); }
.role-card strong { display: block; margin-bottom: 6px; }
.role-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.sidebar-mask { display: none; }

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

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); width: min(290px, 84vw); transition: transform .23s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-mask { position: fixed; z-index: 29; inset: 0; display: block; visibility: hidden; opacity: 0; background: rgba(20, 8, 9, .4); transition: .2s; }
  .sidebar-mask.open { visibility: visible; opacity: 1; }
  #menuButton { display: grid; }
  .topbar { min-height: 82px; padding: 14px 16px; }
  .topbar h2 { font-size: 20px; }
  .topbar-status span { display: none; }
  .content { padding: 20px 14px 36px; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .section-head .head-actions, .section-head button { width: 100%; }
  .stat-grid { gap: 10px; }
  .stat-card { min-height: 118px; padding: 18px; }
  .stat-card strong { font-size: 29px; }
  .panel { padding: 16px; }
  .detail-grid, .form-grid, .role-card-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .login-card { padding: 36px 26px; }
  .drawer-body { padding: 20px 16px; }
}

@media (max-width: 430px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-card small { display: none; }
  .toolbar select { flex: 1 1 100%; }
}
