:root {
  --bg: #f4eee8;
  --bg-deep: #e9ddd2;
  --panel: #fffaf6;
  --panel-solid: #ffffff;
  --panel-soft: #f8efe7;
  --ink: #2b211d;
  --ink-soft: #4b3d35;
  --muted: #7b6d64;
  --line: #eadcd0;
  --line-strong: #d9c4b4;
  --nav: #2d2420;
  --nav-2: #171210;
  --nav-text: #eadfd7;
  --accent: #c96d3f;
  --accent-dark: #8f4022;
  --accent-deep: #6f2f19;
  --accent-soft: #f7e3d5;
  --champagne: #d6a879;
  --champagne-soft: #f5eadf;
  --ok: #4d876c;
  --warn: #bd7b33;
  --danger: #b65450;
  --shadow: 0 16px 40px rgba(78, 51, 34, .09);
  --shadow-soft: 0 8px 24px rgba(78, 51, 34, .065);
  --shadow-lift: 0 22px 55px rgba(75, 44, 28, .14);
  --radius: 15px;
  --radius-sm: 10px;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
html, body { margin: 0; min-height: 100%; color: var(--ink); }
body {
  font-size: 14px;
  background:
    radial-gradient(circle at 84% 4%, rgba(214,168,121,.17), transparent 28%),
    radial-gradient(circle at 18% 96%, rgba(201,109,63,.08), transparent 30%),
    linear-gradient(145deg, #f7f2ed 0%, var(--bg) 46%, #efe5dc 100%);
}
body::selection { background: rgba(201,109,63,.22); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar {
  background:
    linear-gradient(180deg, rgba(255,255,255,.018), transparent 24%),
    linear-gradient(180deg, var(--nav) 0%, #211915 52%, var(--nav-2) 100%);
  color: var(--nav-text);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(222,183,149,.17);
  box-shadow: 12px 0 36px rgba(39, 25, 18, .11);
  overflow: hidden;
}
.sidebar::after {
  content: "";
  position: absolute;
  inset: auto -76px -66px auto;
  width: 280px;
  height: 260px;
  opacity: .24;
  background:
    repeating-linear-gradient(145deg, rgba(222,178,139,.14) 0 1px, transparent 1px 20px),
    radial-gradient(circle at 70% 70%, rgba(210,132,82,.22), transparent 62%);
  transform: rotate(-5deg);
  pointer-events: none;
}
.brand {
  padding: 23px 18px 21px;
  border-bottom: 1px solid rgba(230,199,174,.14);
  display: flex;
  gap: 12px;
  align-items: center;
  position: relative;
  z-index: 1;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-size: 27px;
  font-weight: 900;
  color: #2c1f19;
  border: 1px solid rgba(255,226,197,.52);
  border-radius: 12px 3px 12px 3px;
  background: linear-gradient(145deg, #f2c08d 0%, #cd7547 56%, #8c3d22 100%);
  box-shadow: 0 8px 24px rgba(183,90,45,.28), inset 0 1px 0 rgba(255,255,255,.4);
}
.brand strong { display: block; color: #fffaf5; font-size: 17px; letter-spacing: .35px; line-height: 1.25; }
.brand small { display: block; color: #a99a91; font-size: 10px; line-height: 1.45; margin-top: 3px; }
.sidebar nav { padding: 15px 0; position: relative; z-index: 1; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  margin: 3px 10px;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #d2c7bf;
  transition: .2s ease;
}
.nav-link:hover { background: rgba(255,255,255,.055); border-color: rgba(226,190,157,.09); color: #fff; transform: translateX(2px); }
.nav-link.active {
  background: linear-gradient(90deg, rgba(201,109,63,.24), rgba(201,109,63,.075));
  color: #ffd7b8;
  border-color: rgba(222,146,95,.28);
  box-shadow: inset 3px 0 0 var(--accent), 0 8px 20px rgba(0,0,0,.08);
}
.nav-icon { width: 22px; text-align: center; color: #bcaea4; font-weight: 900; font-size: 16px; }
.nav-link.active .nav-icon { color: #f0a46f; }
.sidebar-spacer { flex: 1; }
.sidebar-note {
  margin: 18px;
  padding: 18px 2px 8px;
  border-top: 1px solid rgba(230,199,174,.14);
  color: #978980;
  line-height: 1.85;
  font-size: 11px;
  position: relative;
  z-index: 1;
}
.sidebar-note::before { content: ""; display: block; width: 34px; height: 3px; background: linear-gradient(90deg,var(--accent),var(--champagne)); margin-bottom: 12px; border-radius: 99px; }

.main-shell { min-width: 0; display: flex; min-height: 100vh; flex-direction: column; }
.topbar {
  min-height: 66px;
  background: rgba(255,250,246,.88);
  border-bottom: 1px solid rgba(215,193,176,.72);
  display: flex;
  align-items: center;
  padding: 0 26px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(15px) saturate(120%);
  box-shadow: 0 5px 24px rgba(91,61,42,.045);
}
.topbar > strong { color: var(--ink-soft); font-size: 15px; letter-spacing: .2px; }
.topbar .search { margin-left: auto; width: min(380px, 35vw); }
.search input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 15px;
  background: rgba(255,255,255,.82);
  box-shadow: inset 0 1px 2px rgba(75,45,28,.025);
}
.top-actions { display: flex; align-items: center; gap: 9px; }
.top-button {
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,.84);
  color: #4b3b33;
  padding: 9px 13px;
  border-radius: 9px;
  text-decoration: none;
  font-weight: 750;
  transition: .18s ease;
}
.top-button:hover { transform: translateY(-1px); border-color: #c89b7b; box-shadow: var(--shadow-soft); }
.top-button.accent { border-color: rgba(201,109,63,.42); color: var(--accent-dark); background: linear-gradient(180deg,#fff8f2,#f6e6da); }
.user-badge { display: flex; align-items: center; gap: 9px; padding-left: 7px; }
.avatar {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  background: linear-gradient(145deg,#765b4c,#3e3029);
  color: #fffaf6;
  display: grid;
  place-items: center;
  font-weight: 850;
  box-shadow: 0 6px 16px rgba(65,43,31,.18);
}
.user-badge small { display: block; color: var(--muted); font-size: 11px; }

.content { padding: 25px; max-width: 1680px; width: 100%; margin: 0 auto; flex: 1; }
.hero {
  background:
    linear-gradient(110deg, rgba(255,252,248,.98) 0%, rgba(248,237,228,.96) 58%, rgba(224,194,169,.90) 100%);
  border: 1px solid rgba(214,185,163,.82);
  min-height: 158px;
  padding: 30px 32px;
  position: relative;
  overflow: hidden;
  margin-bottom: 17px;
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0 0 0 48%;
  background:
    linear-gradient(120deg, transparent 0 24%, rgba(110,73,51,.08) 24.2% 24.8%, transparent 25% 42%, rgba(110,73,51,.09) 42.2% 42.7%, transparent 43%),
    repeating-linear-gradient(90deg, rgba(103,67,45,.065) 0 1px, transparent 1px 62px);
  transform: skewX(-11deg) scale(1.08);
  transform-origin: center;
}
.hero::after {
  content: "";
  position: absolute;
  width: 320px;
  height: 320px;
  right: -80px;
  top: -130px;
  border-radius: 50%;
  border: 58px solid rgba(255,255,255,.19);
  box-shadow: 0 0 0 25px rgba(145,82,48,.045);
}
.hero > * { position: relative; z-index: 1; }
.hero h1 { margin: 0 0 8px; font-size: clamp(30px, 4vw, 46px); letter-spacing: .4px; color: #2b201b; }
.hero p { margin: 0 0 18px; color: #604f45; font-size: 17px; }
.hero-tag { display: inline-flex; align-items: center; gap: 10px; color: #776459; font-weight: 700; }
.hero-tag::before { content: ""; width: 35px; height: 4px; background: linear-gradient(90deg,var(--accent),var(--champagne)); border-radius: 99px; }

.page-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin: 7px 0 18px; }
.page-head h1 { margin: 0; font-size: 31px; color: #2c211d; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.kpi-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 13px; margin-bottom: 16px; }
.kpi {
  background: linear-gradient(145deg,rgba(255,255,255,.98),rgba(255,248,242,.96));
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  padding: 17px;
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 13px;
  align-items: center;
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  transition: .2s ease;
}
.kpi::after { content: ""; position: absolute; top: 0; right: 0; width: 86px; height: 3px; background: linear-gradient(90deg, transparent, rgba(201,109,63,.75)); }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: #dec2ad; }
.kpi-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg,#fff3e8,#efd1bc);
  color: var(--accent-dark);
  border-radius: 13px;
  font-size: 21px;
  font-weight: 900;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}
.kpi-label { color: #5a4940; font-weight: 760; }
.kpi-value { font-size: 27px; font-weight: 900; margin-top: 4px; font-variant-numeric: tabular-nums; color: #271d19; }
.kpi-sub { color: var(--muted); margin-top: 4px; font-size: 11px; }

.module-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 11px; margin: 16px 0; }
.module-card {
  min-height: 184px;
  padding: 22px;
  background:
    linear-gradient(145deg, rgba(69,53,46,.98), rgba(34,26,22,.99));
  color: white;
  border: 1px solid rgba(218,178,145,.20);
  border-radius: 15px;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(46,30,23,.14);
  transition: .22s ease;
}
.module-card::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .23;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.055) 0 1px, transparent 1px 44px),
    linear-gradient(135deg, transparent 0 63%, rgba(211,160,106,.22) 63.3% 64%, transparent 64.3%);
}
.module-card::after { content: ""; position: absolute; width: 150px; height: 150px; right: -54px; bottom: -58px; border: 28px solid rgba(255,255,255,.045); border-radius: 50%; }
.module-card > * { position: relative; z-index: 1; }
.module-card:hover { border-color: rgba(233,182,140,.55); transform: translateY(-3px); box-shadow: 0 20px 44px rgba(47,29,20,.20); }
.module-card.highlight {
  background: linear-gradient(145deg,#51352a 0%,#2b1f1a 64%,#1d1714 100%);
  border-color: rgba(222,143,91,.78);
  box-shadow: inset 0 0 0 1px rgba(239,164,111,.22), 0 17px 38px rgba(84,42,22,.20);
}
.module-card h3 { margin: 15px 0 8px; font-size: 20px; color: #fff8f1; }
.module-card p { color: #c6b8ae; line-height: 1.7; margin: 0; }
.module-card .module-icon { font-size: 27px; color: #f3c198; font-weight: 900; }
.module-card .go { position: absolute; bottom: 18px; left: 22px; width: 34px; height: 34px; border: 1px solid rgba(240,205,177,.55); border-radius: 50%; display: grid; place-items: center; color: #f5cfb0; }
.module-card.ai-hub { grid-column: span 1; display: flex; flex-direction: column; }
.module-card.ai-hub .module-actions { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.module-card.ai-hub .btn { padding: 9px 12px; }
.module-card.ai-hub .btn.ghost-dark { background: rgba(255,255,255,.035); }

.grid-2 { display: grid; grid-template-columns: minmax(0,.78fr) minmax(0,1.7fr); gap: 15px; }
.grid-equal { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px; }
.panel {
  background: linear-gradient(150deg,rgba(255,255,255,.98),rgba(255,249,244,.96));
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg,rgba(255,255,255,.9),rgba(249,240,233,.58)); }
.panel-head h2, .panel-head h3 { margin: 0; font-size: 18px; color: #32251f; }
.panel-head a { color: var(--accent-dark); text-decoration: none; font-weight: 700; }
.panel-body { padding: 18px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg,#fff,#fbf4ee);
  color: #49382f;
  padding: 10px 15px;
  border-radius: 9px;
  text-decoration: none;
  font-weight: 750;
  transition: .18s ease;
  box-shadow: 0 3px 10px rgba(74,45,28,.035);
}
.btn:hover { border-color: #bd8d6c; transform: translateY(-1px); box-shadow: var(--shadow-soft); }
.btn.primary { background: linear-gradient(180deg,#d97f4d,#ad4f2a); color: white; border-color: #a94827; box-shadow: 0 8px 18px rgba(156,70,35,.19); }
.btn.primary:hover { background: linear-gradient(180deg,#e28b58,#b85630); }
.btn.danger { color: #9e3737; border-color: #dfb4ad; background: #fff6f4; }
.btn.small { padding: 6px 9px; font-size: 12px; border-radius: 7px; }
.btn.ghost-dark { background: transparent; color: #fff4eb; border-color: rgba(237,201,174,.42); box-shadow: none; }

.filters {
  background: rgba(255,250,246,.96);
  border: 1px solid var(--line);
  padding: 15px;
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 15px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}
.field { min-width: 150px; flex: 1; }
.field.compact { flex: 0 0 auto; }
label { display: block; margin-bottom: 6px; font-weight: 750; color: #55463d; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,.92);
  padding: 10px 11px;
  border-radius: 8px;
  color: var(--ink);
  box-shadow: inset 0 1px 2px rgba(92,54,31,.025);
}
input::placeholder, textarea::placeholder { color: #aa9c92; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(201,109,63,.12); border-color: var(--accent); background: #fff; }
textarea { min-height: 90px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 15px; }
.form-grid.two { grid-template-columns: repeat(2,minmax(0,1fr)); }
.form-section { margin: 20px 0 10px; padding-top: 18px; border-top: 1px solid var(--line); }
.form-section h3 { margin: 0 0 14px; color: #3f3029; }
.help { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.6; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: #f5ede6; color: #65544a; font-weight: 800; text-align: left; white-space: nowrap; letter-spacing: .05px; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 11px; vertical-align: middle; }
tbody tr { transition: background .16s ease; }
tbody tr:hover { background: #fff5ed; }
tbody tr:last-child td { border-bottom: 0; }
td a { color: var(--accent-dark); font-weight: 750; text-decoration: none; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 999px; font-weight: 750; font-size: 12px; white-space: nowrap; background: #f0ece8; color: #655b55; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #958980; box-shadow: 0 0 0 3px rgba(149,137,128,.12); }
.status.ok { background: #eaf4ef; color: #32715a; }
.status.ok::before { background: var(--ok); box-shadow: 0 0 0 3px rgba(77,135,108,.12); }
.status.warn { background: #fbefdf; color: #955f20; }
.status.warn::before { background: var(--warn); box-shadow: 0 0 0 3px rgba(189,123,51,.13); }
.status.danger { background: #fae9e7; color: #994442; }
.status.danger::before { background: var(--danger); box-shadow: 0 0 0 3px rgba(182,84,80,.12); }

.flash-stack { margin-bottom: 14px; }
.flash { padding: 11px 13px; border-left: 4px solid #8d796c; background: #fffaf6; border: 1px solid var(--line); border-left-width: 4px; margin-bottom: 8px; border-radius: 9px; box-shadow: var(--shadow-soft); }
.flash.success { border-left-color: var(--ok); }
.flash.error { border-left-color: var(--danger); }

.detail-layout { display: grid; grid-template-columns: minmax(0,1fr) 390px; gap: 15px; }
.detail-list { display: grid; grid-template-columns: 160px 1fr; border-top: 1px solid var(--line); }
.detail-list dt, .detail-list dd { margin: 0; padding: 11px 0; border-bottom: 1px solid var(--line); }
.detail-list dt { color: var(--muted); font-weight: 750; }
.detail-list dd { font-weight: 750; color: #3d2e27; }
.detail-list .accent-value { color: var(--accent-dark); font-size: 17px; }

.work-list { list-style: none; padding: 0; margin: 0; }
.work-list li { display: grid; grid-template-columns: 42px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.work-list li:last-child { border-bottom: 0; }
.work-count { color: var(--accent); font-size: 22px; font-weight: 900; }
.muted { color: var(--muted); }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #5f4d43; }
.amount-positive { color: var(--ok); }
.amount-negative { color: var(--danger); }

.login-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 16%, rgba(221,147,96,.18), transparent 32%),
    linear-gradient(120deg,#1a1411,#3b2c25 62%,#6a4535);
  display: grid;
  grid-template-columns: minmax(320px,1fr) 470px;
}
.login-visual { padding: 60px; color: white; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(135deg,rgba(255,255,255,.045) 0 1px,transparent 1px 34px),
    linear-gradient(110deg,transparent 45%,rgba(229,172,129,.09) 45.2% 45.7%,transparent 46%);
}
.login-visual::after { content: ""; position: absolute; width: 420px; height: 420px; border: 70px solid rgba(255,255,255,.035); border-radius: 50%; right: -130px; bottom: -160px; }
.login-visual > * { position: relative; z-index: 1; }
.login-visual .brand-mark { width: 52px; height: 52px; font-size: 32px; margin-bottom: 22px; }
.login-visual h1 { font-size: 44px; margin: 0 0 14px; }
.login-visual p { color: #d1c2b7; font-size: 17px; line-height: 1.8; }
.login-card { background: linear-gradient(145deg,#fffdfb,#f7eee7); display: grid; place-items: center; padding: 38px; border-left: 1px solid rgba(238,207,182,.34); }
.login-box { width: min(360px,100%); background: rgba(255,255,255,.72); padding: 30px; border: 1px solid rgba(221,197,179,.72); border-radius: 18px; box-shadow: var(--shadow-lift); backdrop-filter: blur(10px); }
.login-box h2 { font-size: 28px; margin: 0 0 8px; color: #2e211b; }
.login-box .field { margin: 18px 0; }
.login-box .btn { width: 100%; }

.empty { padding: 50px 20px; text-align: center; color: var(--muted); }
.footer { padding: 20px 26px; color: #94847a; font-size: 12px; display: flex; justify-content: space-between; }

.portal-source .sidebar {
  background: linear-gradient(180deg,#33251f,#18110f);
}
.portal-source .nav-link.active { color: #ffe1c8; }
.portal-source .topbar > strong { color: var(--accent-dark); }

@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .module-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .detail-layout { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; box-shadow: none; }
  .sidebar nav { display: flex; overflow-x: auto; padding: 8px; }
  .nav-link { min-width: max-content; margin: 0 3px; }
  .nav-link.active { box-shadow: inset 0 -3px 0 var(--accent); }
  .sidebar-spacer, .sidebar-note { display: none; }
  .topbar { position: static; padding: 0 14px; }
  .topbar .search { display: none; }
  .content { padding: 14px; }
  .hero { padding: 24px 21px; border-radius: 14px; }
  .kpi-grid, .module-grid, .grid-2, .grid-equal, .form-grid, .form-grid.two { grid-template-columns: 1fr; }
  .login-page { grid-template-columns: 1fr; }
  .login-visual { min-height: 260px; padding: 34px; }
  .login-card { padding: 30px 20px; }
  .login-box { padding: 24px; }
}
