:root {
  --green: #2f9e44;
  --green-dark: #247a37;
  --green-soft: #e9f7ee;
  --green-menu: #16833a;
  --green-menu-dark: #106a31;
  --text: #1f2a37;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f5f7fb;
  --card: #ffffff;
  --danger: #e5484d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: var(--bg); }
body { font-size: 14px; line-height: 1.5715; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 236px 1fr; }
.sidebar {
  min-height: 100vh;
  color: #fff;
  background:
    linear-gradient(145deg, rgba(255,255,255,.08), transparent 32%),
    linear-gradient(180deg, #27a84b 0%, var(--green-menu) 48%, var(--green-menu-dark) 100%);
  padding: 14px 10px;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
}
.brand { height: 48px; display: flex; align-items: center; gap: 10px; padding: 0 10px 12px; font-weight: 800; font-size: 20px; letter-spacing: 0; }
.brand-icon { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; background: #fff; color: var(--green); font-size: 14px; }
.nav { display: grid; gap: 2px; }
.nav-item {
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: rgba(255,255,255,.92);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 11px;
  text-align: left;
}
.nav-item:hover, .nav-item.active, .nav-parent.expanded { background: rgba(8, 84, 39, .54); box-shadow: inset 3px 0 0 rgba(255,255,255,.72); }
.nav-icon { width: 22px; display: inline-grid; place-items: center; font-size: 15px; }
.nav-parent em { margin-left: auto; font-style: normal; opacity: .72; }
.nav-group { display: grid; gap: 3px; }
.subnav { display: none; padding: 2px 0 4px 38px; }
.nav-group.open .subnav, .subnav.show { display: grid; gap: 2px; }
.subnav-item {
  min-height: 28px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: rgba(255,255,255,.78);
  text-align: left;
  padding: 0 10px;
  font-size: 13px;
}
.subnav-item:hover, .subnav-item.active { background: rgba(255,255,255,.18); color: #fff; box-shadow: inset 2px 0 0 #fff; }
.sidebar-footer { display: flex; gap: 14px; padding: 18px 12px; }
.sidebar-footer a { color: #fff; text-decoration: none; }
.main-wrap { min-width: 0; }
.topbar {
  height: 58px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.crumb { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.crumb b { color: var(--text); font-size: 14px; }
.tools { display: flex; align-items: center; gap: 10px; }
.page-tabs {
  height: 42px;
  display: flex;
  align-items: end;
  gap: 6px;
  padding: 6px 26px 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  white-space: nowrap;
}
.page-tab {
  min-width: 112px;
  height: 34px;
  border: 1px solid var(--line);
  border-bottom-color: #dfe3ea;
  border-radius: 8px 8px 0 0;
  background: #f8fafc;
  color: #5b6472;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  font-size: 14px;
  position: relative;
}
.page-tab.active {
  background: #fff;
  color: var(--green);
  font-weight: 700;
  border-bottom-color: #fff;
}
.page-tab i {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  color: #9ca3af;
  font-style: normal;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 16px;
}
.page-tab:hover i, .page-tab.active i { display: inline-flex; }
.page-tab i:hover { background: #eef2f7; color: #374151; }
.main { padding: 16px 20px 22px; display: grid; gap: 12px; }
.hero-panel {
  min-height: 108px;
  background:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,.24), transparent 25%),
    linear-gradient(120deg, #62be63, #2d9f44);
  color: #fff;
  border-radius: 4px;
  display: grid;
  grid-template-columns: auto 1fr minmax(360px, .8fr) auto;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
}
.avatar { width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.88); color: var(--green); display: grid; place-items: center; font-size: 20px; font-weight: 800; }
.hero-user { display: grid; gap: 5px; }
.hero-user strong { font-size: 18px; }
.hero-user span { opacity: .86; }
.port-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.port-card { min-height: 56px; border-left: 1px solid rgba(255,255,255,.25); padding-left: 14px; display: grid; gap: 4px; }
.port-card span { opacity: .86; }
.port-card b { font-size: 22px; }
.mini-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.mini-card { min-height: 74px; background: #fff; display: flex; gap: 10px; align-items: center; padding: 13px; border: 1px solid var(--line); border-radius: 4px; }
.mini-icon { width: 38px; height: 38px; border-radius: 8px; background: var(--green-soft); color: var(--green); display: grid; place-items: center; }
.mini-card p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.dashboard-grid { display: grid; grid-template-columns: 1.1fr 1fr .9fr; gap: 16px; }
.panel, .filter-panel, .table-panel, .page-head, .tabs-bar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 14px;
}
.panel-title { font-weight: 700; font-size: 16px; margin-bottom: 12px; }
.split { display: flex; align-items: center; justify-content: space-between; }
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.quick { border: 0; background: #f1fbf4; min-height: 58px; border-radius: 6px; color: #245b32; display: grid; gap: 4px; place-items: center; font-size: 13px; }
.notice { display: grid; grid-template-columns: 54px 1fr; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.notice span { color: var(--green); }
.notice time { grid-column: 2; color: var(--muted); font-size: 12px; }
.rank { display: grid; grid-template-columns: 32px 1fr 32px; align-items: center; padding: 9px 0; }
.rank span { color: #c99400; font-size: 20px; }
.rank em { color: var(--green); font-style: normal; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 16px; display: grid; gap: 6px; }
.stat-card small { color: var(--muted); }
.stat-card strong { font-size: 28px; }
.tabs-bar { display: flex; gap: 18px; padding: 0 14px; min-height: 42px; align-items: center; }
.tabs-bar.compact { border: 0; padding: 0; min-height: 40px; margin-bottom: 8px; }
.tab-btn { min-height: 42px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: #4b5563; padding: 0 4px; font-size: 14px; }
.compact .tab-btn { min-height: 38px; }
.tab-btn.active, .tab-btn:hover { color: var(--green); border-bottom-color: var(--green); font-weight: 700; }
.module-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.module-strip div { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; display: grid; gap: 3px; }
.module-strip span { color: var(--muted); font-size: 12px; }
.module-strip b { font-size: 16px; overflow-wrap: anywhere; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.page-head h1 { margin: 0; font-size: 20px; font-weight: 700; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.action-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-panel { display: grid; grid-template-columns: repeat(3, minmax(170px, 1fr)) auto auto; gap: 12px; align-items: end; }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.field.full { width: 100%; }
input, textarea {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 10px;
  outline: none;
  background: #fff;
  color: var(--text);
}
textarea { min-height: 120px; width: 100%; resize: vertical; }
input:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(47,158,68,.1); }
.table-panel { overflow-x: auto; }
table { width: 100%; min-width: 1080px; border-collapse: collapse; table-layout: fixed; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
th { color: #4b5563; background: #f7f8fa; font-weight: 700; }
tbody tr:hover { background: #fbfdfc; }
.empty { text-align: center; color: var(--muted); height: 90px; }
.ops { display: flex; gap: 8px; flex-wrap: nowrap; }
.pager { padding-top: 14px; color: var(--muted); text-align: right; }
.primary-btn, .secondary-btn, .ghost-btn, .icon-btn, .user-btn, .link-btn, .danger-btn {
  border-radius: 4px;
  min-height: 32px;
  border: 1px solid transparent;
  padding: 0 12px;
  font-size: 14px;
}
.primary-btn { background: var(--green); color: #fff; }
.secondary-btn { background: #f3f4f6; color: #1f2937; border-color: var(--line); }
.ghost-btn, .icon-btn, .user-btn { background: #fff; border-color: transparent; color: #374151; }
.icon-btn { width: 34px; padding: 0; font-size: 16px; }
.user-btn { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { background: transparent; color: var(--green); padding: 0 2px; min-height: 24px; }
.danger-btn { background: transparent; color: var(--danger); padding: 0 2px; min-height: 24px; }
.status { display: inline-flex; min-width: 46px; justify-content: center; padding: 3px 8px; border-radius: 3px; font-size: 12px; background: #eef2ff; color: #334155; }
.status.ok { background: #e7f8ed; color: #1f7a3b; }
.status.warn { background: #fff4de; color: #9a5b00; }
.status.muted { background: #f1f5f9; color: #64748b; }
.api-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.api-key { display: block; background: #0f172a; color: #d1fae5; border-radius: 4px; padding: 14px; margin-bottom: 12px; overflow-wrap: anywhere; }
pre { background: #111827; color: #e5e7eb; border-radius: 4px; padding: 14px; overflow: auto; }
.packages { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.package-card { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 18px; display: grid; gap: 10px; }
.package-card h3 { margin: 0; }
.package-card strong { font-size: 22px; color: var(--green); }
.package-card ul { margin: 0; padding-left: 18px; color: var(--muted); }
.placeholder-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.chart-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.chart-card { min-height: 160px; background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 14px; display: grid; grid-template-rows: auto 1fr; gap: 12px; }
.chart-head { display: flex; justify-content: space-between; align-items: center; }
.chart-head span { color: var(--muted); font-size: 12px; }
.chart-bars { height: 96px; display: flex; align-items: end; gap: 8px; border-bottom: 1px solid var(--line); padding: 0 6px; }
.chart-bars i { flex: 1; min-width: 8px; border-radius: 3px 3px 0 0; background: linear-gradient(180deg, #6fcf83, #2f9e44); }
.about-hero {
  min-height: 150px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 24px;
}
.brand-icon.large { width: 50px; height: 50px; font-size: 24px; }
.about-hero h1 { margin: 0 0 6px; font-size: 24px; }
.about-hero p { margin: 0; color: var(--muted); }
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 4px;
  z-index: 30;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .38);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 20;
}
.modal {
  width: min(760px, 100%);
  max-height: 86vh;
  overflow: auto;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 24px 64px rgba(15,23,42,.2);
}
.modal-head, .modal-foot { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-foot { border-top: 1px solid var(--line); border-bottom: 0; justify-content: flex-end; gap: 10px; }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-stack { display: grid; gap: 10px; }
.hint { margin: 0; color: var(--muted); font-size: 13px; }
.detail-list { display: grid; gap: 10px; }
.detail-list div { display: grid; grid-template-columns: 160px 1fr; gap: 12px; padding: 10px; background: #f9fafb; border-radius: 4px; }
.detail-list span { color: var(--muted); }
.check-list { display: grid; gap: 12px; }
.check-list label { display: flex; align-items: center; gap: 8px; }
.loading { padding: 40px; color: var(--muted); }
.notice-list { max-height: 360px; overflow: auto; }
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(145deg, rgba(47,158,68,.14), transparent 42%),
    linear-gradient(180deg, #f6fbf7, #eef7f0);
}
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 28px;
  display: grid;
  gap: 14px;
  box-shadow: 0 20px 70px rgba(31,42,55,.12);
}
.login-card h1 { margin: 4px 0 0; font-size: 22px; }
.login-card p { margin: 0; color: var(--muted); }
.login-brand { color: var(--text); padding: 0; height: auto; }

body.dark {
  --bg: #111827;
  --card: #172033;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --line: #2a3447;
}
body.dark .topbar, body.dark .page-tabs, body.dark .panel, body.dark .filter-panel, body.dark .table-panel, body.dark .page-head,
body.dark .mini-card, body.dark .stat-card, body.dark .package-card, body.dark .modal { background: var(--card); }
body.dark .page-tab { background: #111827; border-color: var(--line); color: var(--muted); }
body.dark .page-tab.active { background: var(--card); color: #6ee083; border-bottom-color: var(--card); }
body.dark th { background: #1f2937; }
body.dark input, body.dark textarea { background: #0f172a; color: var(--text); border-color: var(--line); }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 78px 1fr; }
  .brand-text, .nav-item span:last-child, .nav-parent em, .sidebar-footer, .subnav { display: none; }
  .nav-item { justify-content: center; }
  .hero-panel { grid-template-columns: auto 1fr; }
  .port-grid { grid-column: 1 / -1; }
  .mini-grid, .stats-grid, .module-strip { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid, .api-grid, .packages, .placeholder-grid, .chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; min-height: auto; }
  .nav { grid-template-columns: repeat(2, 1fr); }
  .brand-text, .nav-item span:last-child, .nav-parent em { display: inline; }
  .nav-group.open .subnav { display: grid; grid-column: 1 / -1; padding-left: 18px; }
  .main { padding: 14px; }
  .topbar { padding: 0 12px; }
  .page-tabs { padding-left: 12px; padding-right: 12px; }
  .page-tab { min-width: 104px; }
  .hero-panel, .page-head, .filter-panel { grid-template-columns: 1fr; }
  .mini-grid, .stats-grid, .module-strip, .quick-grid, .about-hero, .chart-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .tools .ghost-btn, .tools .icon-btn { display: none; }
}
