/* ============================================================
   零时科技独立后台 - 全局样式
   品牌绿 #0F6E56 · 管理后台风格 · 浅色内容区
   ============================================================ */
:root {
  --brand: #0F6E56;
  --brand-dark: #0A5341;
  --brand-light: #E7F3EF;
  --accent: #F5A623;
  --red: #E03131;
  --green: #2F9E44;
  --bg: #F4F6F8;
  --panel: #FFFFFF;
  --border: #E3E8ED;
  --text: #1F2937;
  --text-2: #6B7280;
  --text-3: #9CA3AF;
  --sidebar-w: 220px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, .12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 13px; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 登录页 ============ */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0A5341 0%, #0F6E56 55%, #159A7A 100%);
  position: relative; overflow: hidden;
}
.login-wrap::before {
  content: ""; position: absolute; width: 640px; height: 640px; border-radius: 50%;
  background: rgba(255,255,255,.05); top: -220px; right: -160px;
}
.login-wrap::after {
  content: ""; position: absolute; width: 420px; height: 420px; border-radius: 50%;
  background: rgba(255,255,255,.04); bottom: -140px; left: -100px;
}
.login-card {
  position: relative; z-index: 2; width: 400px; background: #fff; border-radius: 16px;
  padding: 40px 38px 32px; box-shadow: 0 24px 64px rgba(0,0,0,.25);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand .logo {
  width: 60px; height: 60px; border-radius: 14px; background: var(--brand);
  color: #fff; font-size: 26px; font-weight: 800; display: inline-flex;
  align-items: center; justify-content: center; letter-spacing: 1px;
}
.login-brand h1 { font-size: 22px; margin-top: 14px; color: var(--text); }
.login-brand p { color: var(--text-3); font-size: 12px; margin-top: 4px; letter-spacing: 2px; }
.login-form label { display: block; font-size: 13px; color: var(--text-2); margin: 16px 0 6px; }
.login-form input {
  width: 100%; height: 42px; border: 1px solid var(--border); border-radius: 8px;
  padding: 0 12px; outline: none; transition: border .2s;
}
.login-form input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,110,86,.12); }
.login-btn {
  width: 100%; height: 44px; margin-top: 24px; border: none; border-radius: 8px;
  background: var(--brand); color: #fff; font-size: 15px; font-weight: 600;
  transition: background .2s, transform .1s;
}
.login-btn:hover { background: var(--brand-dark); }
.login-btn:active { transform: scale(.98); }
.login-err { color: var(--red); font-size: 12px; margin-top: 12px; text-align: center; min-height: 16px; }
.login-foot { text-align: center; color: var(--text-3); font-size: 11px; margin-top: 22px; }

/* ============ 主框架 ============ */
.admin-layout { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: var(--sidebar-w); background: #0B2A23; color: #C8DCD6; flex-shrink: 0;
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 100;
  transition: margin-left .25s;
}
.sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-w)); }
.sidebar-head {
  padding: 20px 18px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-head .logo {
  width: 40px; height: 40px; border-radius: 10px; background: var(--brand);
  color: #fff; font-weight: 800; font-size: 18px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}
.sidebar-head .name { font-size: 15px; font-weight: 700; color: #fff; }
.sidebar-head .sub { font-size: 11px; color: #7FA398; margin-top: 2px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.nav-group-title {
  font-size: 11px; color: #5D7F74; padding: 14px 20px 6px; letter-spacing: 1px;
  text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px; cursor: pointer;
  color: #C8DCD6; font-size: 13.5px; transition: background .15s, color .15s; border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(15,110,86,.28); color: #fff; border-left-color: #2FBFA3; font-weight: 600; }
.nav-item .ic { width: 20px; text-align: center; font-size: 15px; }
.nav-item .badge {
  margin-left: auto; font-size: 10px; background: var(--accent); color: #fff;
  padding: 1px 6px; border-radius: 8px; font-weight: 600;
}
.sidebar-foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-foot .user-line { display: flex; align-items: center; gap: 10px; color: #C8DCD6; font-size: 13px; }
.sidebar-foot .avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.sidebar-foot .logout { margin-left: auto; background: none; border: none; color: #7FA398; font-size: 16px; cursor: pointer; }
.sidebar-foot .logout:hover { color: #fff; }

/* 主区域 */
.main-area { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; transition: margin-left .25s; }
.main-area.expanded { margin-left: 0; }

/* 顶栏 */
.topbar {
  height: 58px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; gap: 16px; position: sticky; top: 0; z-index: 90;
}
.topbar .menu-toggle { background: none; border: 1px solid var(--border); border-radius: 8px; width: 34px; height: 34px; font-size: 16px; color: var(--text-2); }
.topbar .breadcrumb { font-size: 14px; font-weight: 600; }
.topbar .breadcrumb .sep { color: var(--text-3); margin: 0 6px; font-weight: 400; }
.topbar .spacer { flex: 1; }
.global-search {
  display: flex; align-items: center; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 0 10px; height: 34px; width: 300px;
}
.global-search input { border: none; background: none; outline: none; flex: 1; padding: 0 6px; }
.global-search .hint { color: var(--text-3); font-size: 12px; }
.top-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.green { background: #37B24D; box-shadow: 0 0 0 3px rgba(55,178,77,.15); }
.dot.gray { background: #ADB5BD; }

/* 内容区 */
.content { padding: 20px; flex: 1; overflow-y: auto; }
.page { display: none; animation: fadeIn .25s; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============ 通用组件 ============ */
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.panel-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px;
}
.panel-head h3 { font-size: 15px; font-weight: 600; }
.panel-head .desc { color: var(--text-3); font-size: 12px; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 16px 18px; }
.panel-body.flush { padding: 0; }

/* 卡片 */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat-card .label { color: var(--text-2); font-size: 12.5px; }
.stat-card .value { font-size: 26px; font-weight: 700; margin-top: 8px; font-variant-numeric: tabular-nums; }
.stat-card .value small { font-size: 13px; color: var(--text-2); font-weight: 400; margin-left: 4px; }
.stat-card .sub { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.stat-card .icon {
  position: absolute; right: 14px; top: 14px; width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.stat-card .icon.green { background: var(--brand-light); }
.stat-card .icon.amber { background: #FDF3E0; }
.stat-card .icon.blue { background: #E8F1FD; }
.stat-card .icon.purple { background: #F1EAFD; }
.stat-card .icon.red { background: #FDE8E8; }

.up { color: var(--red); }
.down { color: var(--green); }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; padding: 10px 12px; background: #F8FAFB; color: var(--text-2);
  font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 12.5px;
}
.table td { padding: 10px 12px; border-bottom: 1px solid #F1F4F7; white-space: nowrap; }
.table tr:hover td { background: #FAFCFB; }
.table .num { font-variant-numeric: tabular-nums; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border);
  background: #fff; color: var(--text); border-radius: 8px; padding: 7px 14px; font-size: 13px;
  transition: all .15s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-danger { color: var(--red); border-color: #F3C1C1; }
.btn-danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-lg { padding: 10px 22px; font-size: 14px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* 表单 */
.form-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.form-row label { color: var(--text-2); font-size: 13px; min-width: 70px; }
.input, .select {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; outline: none;
  background: #fff; transition: border .15s; height: 36px;
}
.input:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,110,86,.1); }
.input.wide { width: 240px; }
.input.mid { width: 160px; }

/* 标签 */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600;
}
.tag.green { background: var(--brand-light); color: var(--brand); }
.tag.red { background: #FDE8E8; color: var(--red); }
.tag.amber { background: #FDF3E0; color: #B45309; }
.tag.blue { background: #E8F1FD; color: #1D4ED8; }
.tag.gray { background: #F1F3F5; color: var(--text-2); }

/* 空状态 / 加载 */
.empty { text-align: center; color: var(--text-3); padding: 48px 20px; font-size: 13px; }
.loading { text-align: center; color: var(--text-3); padding: 40px; font-size: 13px; }
.loading::before {
  content: ""; display: inline-block; width: 18px; height: 18px; border: 2px solid var(--border);
  border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite;
  vertical-align: -4px; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 200;
  display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-mask.show { opacity: 1; pointer-events: auto; }
.modal {
  background: #fff; border-radius: 14px; width: 520px; max-width: 92vw; max-height: 86vh;
  overflow-y: auto; box-shadow: var(--shadow-lg); transform: translateY(12px); transition: transform .2s;
}
.modal-mask.show .modal { transform: none; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-head h3 { font-size: 15px; flex: 1; }
.modal-head .close { background: none; border: none; font-size: 18px; color: var(--text-3); cursor: pointer; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* 提示 toast */
.toast {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%) translateY(-16px);
  background: #1F2937; color: #fff; padding: 10px 22px; border-radius: 10px; font-size: 13px;
  z-index: 300; opacity: 0; pointer-events: none; transition: all .25s; box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: var(--brand); }
.toast.err { background: var(--red); }

/* 分页 */
.pager { display: flex; align-items: center; gap: 8px; padding: 12px 16px; justify-content: flex-end; font-size: 12.5px; color: var(--text-2); }
.pager button { border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 4px 10px; font-size: 12px; }
.pager button:hover:not([disabled]) { border-color: var(--brand); color: var(--brand); }
.pager button[disabled] { opacity: .4; }

/* 指标徽章 */
.metric-row { display: flex; gap: 14px; flex-wrap: wrap; }
.metric-box {
  flex: 1; min-width: 140px; background: #F8FAFB; border: 1px solid var(--border);
  border-radius: 10px; padding: 14px;
}
.metric-box .k { font-size: 12px; color: var(--text-2); }
.metric-box .v { font-size: 22px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }

/* 行业财务画像 */
.fin-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.fin-metric { background: linear-gradient(135deg, #F0F7F5, #FAFCFB); border: 1px solid #DCEBE6; border-radius: 10px; padding: 14px; text-align: center; }
.fin-metric .k { font-size: 12px; color: var(--text-2); }
.fin-metric .v { font-size: 20px; font-weight: 700; margin-top: 6px; color: var(--brand); }

/* K线容器 */
.kline-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.kline-toolbar .stock-info { font-size: 15px; font-weight: 700; margin-right: 8px; }
.kline-toolbar .price { font-size: 18px; font-weight: 700; }
.kline-toolbar .chg { font-size: 13px; }
.kline-box { position: relative; }
.kline-box canvas { display: block; width: 100%; }
.kline-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--text-3); background: rgba(255,255,255,.7); font-size: 13px; }

/* 索引卡片 */
.index-card {
  display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.index-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.index-card .name { font-weight: 600; font-size: 14px; }
.index-card .code { font-size: 11px; color: var(--text-3); }
.index-card .val { font-size: 18px; font-weight: 700; margin-left: auto; font-variant-numeric: tabular-nums; }
.index-card .chg { font-size: 12px; text-align: right; }

/* 持仓/委托行 */
.pos-row { display: flex; align-items: center; gap: 16px; padding: 12px 4px; border-bottom: 1px solid #F1F4F7; flex-wrap: wrap; }
.pos-row:last-child { border-bottom: none; }
.pos-row .stock { font-weight: 600; min-width: 120px; }
.pos-row .stock small { display: block; color: var(--text-3); font-weight: 400; font-size: 11px; }
.pos-row .field { flex: 1; min-width: 90px; }
.pos-row .field .k { font-size: 11px; color: var(--text-3); }
.pos-row .field .v { font-weight: 600; font-variant-numeric: tabular-nums; }

/* 净值曲线 */
.equity-canvas { width: 100%; height: 260px; }

/* 搜索下拉 */
.search-drop {
  position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--border);
  border-radius: 0 0 10px 10px; box-shadow: var(--shadow-lg); max-height: 300px; overflow-y: auto; z-index: 50;
}
.search-drop .item { padding: 9px 14px; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.search-drop .item:hover { background: var(--brand-light); }
.search-drop .item .code { color: var(--text-2); font-size: 12px; }
.search-drop .item .name { font-weight: 600; }
.search-drop .item .market { margin-left: auto; font-size: 11px; color: var(--text-3); }
.search-drop .item .mkt { font-size: 11px; color: var(--text-3); background: var(--bg); padding: 1px 6px; border-radius: 4px; }

/* ============ 富易式交易终端 ============ */
.trade-terminal {
  display: grid; grid-template-columns: 340px 1fr 300px; gap: 16px; align-items: start; margin-bottom: 16px;
}
.trade-order { margin-bottom: 0; }
.trade-right { display: flex; flex-direction: column; gap: 16px; }
.trade-right .panel { margin: 0; }

/* 买卖大 Tab */
.trade-tabs { display: flex; gap: 6px; }
.trade-tab {
  flex: 1; text-align: center; padding: 6px 0; border-radius: 8px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border); background: #fff; color: var(--text-2); transition: all .15s;
}
.trade-tab.buy.active { background: var(--red); border-color: var(--red); color: #fff; }
.trade-tab.sell.active { background: var(--green); border-color: var(--green); color: #fff; }

/* 大号下单按钮（富易式） */
.btn-trade {
  flex: 1; height: 46px; border: none; border-radius: 10px; color: #fff; font-size: 16px; font-weight: 700;
  letter-spacing: 2px; transition: filter .15s, transform .1s;
}
.btn-trade:hover { filter: brightness(1.06); }
.btn-trade:active { transform: scale(.98); }
.btn-trade.btn-buy { background: var(--red); }
.btn-trade.btn-sell { background: var(--green); }

/* 费用预估明细 */
.cost-detail {
  margin-top: 12px; border: 1px dashed var(--border); border-radius: 8px; padding: 10px 12px;
  background: #FBFDFC; font-size: 12.5px;
}
.cost-detail .row { display: flex; justify-content: space-between; padding: 3px 0; color: var(--text-2); }
.cost-detail .row span:last-child { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.cost-detail .row.total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 7px; }
.cost-detail .row.total span { color: var(--brand); font-size: 13.5px; }

/* 五档盘口 */
.trade-depth .panel-body { padding: 8px 10px; }
.depth-row { display: flex; align-items: center; gap: 10px; padding: 4px 6px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.depth-row .dl { color: var(--text-2); width: 34px; }
.depth-row .dp { flex: 1; text-align: right; font-weight: 700; }
.depth-row .dv { width: 64px; text-align: right; color: var(--text-3); font-size: 11.5px; }
.depth-row.sell { background: rgba(47,158,68,.05); }
.depth-row.buy { background: rgba(224,49,49,.05); }
.depth-now {
  display: flex; align-items: center; gap: 10px; justify-content: center; padding: 8px 0; margin: 4px 0;
  border-top: 1px dashed var(--border); border-bottom: 1px dashed var(--border); font-size: 17px; font-weight: 800;
}
.depth-now small { font-size: 12px; }
.depth-now em { font-style: normal; font-size: 11px; color: var(--text-3); background: var(--bg); padding: 1px 7px; border-radius: 4px; }

@media (max-width: 1100px) { .trade-terminal { grid-template-columns: 1fr; } }

/* 信号图例 */
.sig-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); padding: 8px 16px 0; }
.sig-legend .buy::before { content: "▲"; color: var(--red); margin-right: 4px; }
.sig-legend .sell::before { content: "▼"; color: var(--green); margin-right: 4px; }

/* 响应式 */
@media (max-width: 900px) {
  .global-search { width: 140px; }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
}
