/* ============================================================
   EasyWeb - 轻量前端框架 (替代 mdui)
   纯 CSS，无依赖。data-theme="dark" / "light"
   ============================================================ */

:root {
  --ew-primary: #26a69a;
  --ew-primary-dark: #00897b;
  --ew-accent: #64b5f6;
  --ew-radius: 12px;
  --ew-radius-lg: 16px;
  --ew-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", Helvetica, Arial, sans-serif;
  --ew-transition: .22s cubic-bezier(.4, 0, .2, 1);
}

html[data-theme="dark"] {
  --ew-bg: #14161a;
  --ew-bg-soft: #1b1e24;
  --ew-surface: #21252c;
  --ew-surface-2: #282d35;
  --ew-border: #2f353e;
  --ew-text: #e6e8eb;
  --ew-text-2: #a4abb6;
  --ew-text-3: #737b87;
  --ew-shadow: 0 4px 18px rgba(0, 0, 0, .38);
  --ew-shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
  --ew-header: rgba(20, 22, 26, .86);
  --ew-ok: #26c281;
  --ew-warn: #f0a020;
  --ew-err: #ef5350;
}

html[data-theme="light"] {
  --ew-bg: #f4f6f8;
  --ew-bg-soft: #ffffff;
  --ew-surface: #ffffff;
  --ew-surface-2: #f0f2f5;
  --ew-border: #e2e6eb;
  --ew-text: #262b33;
  --ew-text-2: #5c6674;
  --ew-text-3: #8d97a4;
  --ew-shadow: 0 4px 16px rgba(20, 30, 50, .08);
  --ew-shadow-lg: 0 12px 36px rgba(20, 30, 50, .14);
  --ew-header: rgba(255, 255, 255, .9);
  --ew-ok: #16a34a;
  --ew-warn: #d97706;
  --ew-err: #dc2626;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--ew-font);
  background: var(--ew-bg);
  color: var(--ew-text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background var(--ew-transition), color var(--ew-transition);
}

a { color: var(--ew-primary); text-decoration: none; }
a:hover { color: var(--ew-primary-dark); }

/* ---------------- Appbar ---------------- */
.ew-appbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: 58px;
  background: var(--ew-header);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--ew-border);
  z-index: 900;
}

.ew-appbar-inner {
  height: 58px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ew-brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--ew-text);
  letter-spacing: .5px;
  white-space: nowrap;
}
.ew-brand:hover { color: var(--ew-primary); }

.ew-appbar-sub {
  color: var(--ew-text-2);
  font-size: 13px;
  padding-left: 12px;
  border-left: 1px solid var(--ew-border);
  white-space: nowrap;
}

.ew-appbar-spacer { flex: 1; }

.ew-appbar-nav { display: flex; align-items: center; gap: 4px; }

.ew-appbar-nav a {
  color: var(--ew-text-2);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  transition: var(--ew-transition);
  white-space: nowrap;
}
.ew-appbar-nav a:hover { background: var(--ew-surface-2); color: var(--ew-text); }
.ew-appbar-nav a.is-active { color: var(--ew-primary); background: rgba(38, 166, 154, .12); }

/* ---------------- Buttons ---------------- */
.ew-icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ew-text-2);
  border-radius: 9px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: var(--ew-transition);
  flex: 0 0 auto;
}
.ew-icon-btn:hover { background: var(--ew-surface-2); color: var(--ew-text); }

.ew-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 9px;
  border: 1px solid var(--ew-border);
  background: var(--ew-surface-2);
  color: var(--ew-text);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: var(--ew-transition);
  white-space: nowrap;
}
.ew-btn:hover { border-color: var(--ew-primary); color: var(--ew-primary); }
.ew-btn:active { transform: translateY(1px); }
.ew-btn:disabled { opacity: .5; cursor: not-allowed; }

.ew-btn-primary {
  background: var(--ew-primary);
  border-color: var(--ew-primary);
  color: #fff;
}
.ew-btn-primary:hover { background: var(--ew-primary-dark); border-color: var(--ew-primary-dark); color: #fff; }

.ew-btn-danger { background: transparent; border-color: var(--ew-err); color: var(--ew-err); }
.ew-btn-danger:hover { background: var(--ew-err); color: #fff; }

.ew-btn-sm { padding: 5px 12px; font-size: 12.5px; border-radius: 8px; }
.ew-btn-block { width: 100%; }

/* ---------------- 布局 ---------------- */
.ew-main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 82px 16px 40px;
  min-height: calc(100vh - 130px);
}

.ew-page-title {
  font-size: 21px;
  font-weight: 700;
  margin: 0 0 4px;
}
.ew-page-desc { color: var(--ew-text-2); font-size: 13px; margin: 0 0 20px; }

/* ---------------- 统计条 ---------------- */
.ew-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 6px 0 22px;
}
.ew-stat {
  background: var(--ew-surface);
  border: 1px solid var(--ew-border);
  border-radius: var(--ew-radius);
  padding: 12px 18px;
  min-width: 132px;
  flex: 1 1 132px;
}
.ew-stat-label { color: var(--ew-text-2); font-size: 12px; }
.ew-stat-value { font-size: 20px; font-weight: 700; color: var(--ew-text); letter-spacing: .4px; }

/* ---------------- 卡片 ---------------- */
.ew-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.ew-card {
  background: var(--ew-surface);
  border: 1px solid var(--ew-border);
  border-radius: var(--ew-radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  transition: var(--ew-transition);
}
.ew-card:hover {
  transform: translateY(-3px);
  border-color: rgba(38, 166, 154, .5);
  box-shadow: var(--ew-shadow);
}

.ew-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.ew-card-title {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ew-text);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ew-card-meta {
  font-size: 12px;
  color: var(--ew-text-3);
  margin-bottom: 8px;
}
.ew-card-desc {
  font-size: 13px;
  color: var(--ew-text-2);
  flex: 1;
  margin: 0 0 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ew-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ---------------- 标签 ---------------- */
.ew-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  line-height: 1.7;
  border: 1px solid transparent;
  white-space: nowrap;
}
.ew-tag-ok   { color: var(--ew-ok);   background: rgba(38, 194, 129, .12); border-color: rgba(38, 194, 129, .28); }
.ew-tag-warn { color: var(--ew-warn); background: rgba(240, 160, 32, .12); border-color: rgba(240, 160, 32, .28); }
.ew-tag-err  { color: var(--ew-err);  background: rgba(239, 83, 80, .12);  border-color: rgba(239, 83, 80, .28); }
.ew-tag-info { color: var(--ew-accent); background: rgba(100, 181, 246, .12); border-color: rgba(100, 181, 246, .28); }

/* ---------------- 表单 ---------------- */
.ew-field { margin-bottom: 16px; }
.ew-label {
  display: block;
  font-size: 13px;
  color: var(--ew-text-2);
  margin-bottom: 6px;
}
.ew-input,
.ew-select,
.ew-textarea {
  width: 100%;
  padding: 10px 13px;
  background: var(--ew-bg-soft);
  border: 1px solid var(--ew-border);
  color: var(--ew-text);
  border-radius: 9px;
  font-size: 13.5px;
  font-family: inherit;
  transition: var(--ew-transition);
  outline: none;
}
.ew-input:focus,
.ew-select:focus,
.ew-textarea:focus {
  border-color: var(--ew-primary);
  box-shadow: 0 0 0 3px rgba(38, 166, 154, .16);
}
.ew-textarea { resize: vertical; min-height: 92px; }
.ew-help { font-size: 12px; color: var(--ew-text-3); margin-top: 5px; }

/* ---------------- 面板 ---------------- */
.ew-panel {
  background: var(--ew-surface);
  border: 1px solid var(--ew-border);
  border-radius: var(--ew-radius-lg);
  padding: 20px;
}
.ew-panel + .ew-panel { margin-top: 16px; }
.ew-panel-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* ---------------- 表格 ---------------- */
.ew-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ew-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ew-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--ew-text-2);
  font-weight: 500;
  border-bottom: 1px solid var(--ew-border);
  white-space: nowrap;
}
.ew-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--ew-border);
  color: var(--ew-text);
  vertical-align: middle;
  white-space: nowrap;
}
.ew-table td.ew-td-wrap { white-space: normal; }
.ew-table .ew-actions { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.ew-table tbody tr:hover { background: var(--ew-surface-2); }
.ew-table .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------------- toast ---------------- */
.ew-toast-wrap {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.ew-toast {
  background: var(--ew-surface-2);
  color: var(--ew-text);
  border: 1px solid var(--ew-border);
  border-left: 3px solid var(--ew-primary);
  padding: 9px 18px;
  border-radius: 9px;
  font-size: 13px;
  box-shadow: var(--ew-shadow);
  opacity: 0;
  transform: translateY(-10px);
  transition: var(--ew-transition);
  max-width: 90vw;
}
.ew-toast.is-show { opacity: 1; transform: translateY(0); }
.ew-toast.ok  { border-left-color: var(--ew-ok); }
.ew-toast.err { border-left-color: var(--ew-err); }

/* ---------------- 抽屉 ---------------- */
.ew-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 268px;
  background: var(--ew-surface);
  border-right: 1px solid var(--ew-border);
  z-index: 1200;
  transform: translateX(-100%);
  transition: transform var(--ew-transition);
  display: flex;
  flex-direction: column;
  box-shadow: var(--ew-shadow-lg);
}
.ew-drawer.is-open { transform: translateX(0); }
.ew-drawer-head {
  padding: 20px 18px;
  border-bottom: 1px solid var(--ew-border);
}
.ew-drawer-head strong { display: block; font-size: 16px; margin-bottom: 4px; }
.ew-drawer-head small { color: var(--ew-text-3); font-size: 12px; line-height: 1.5; display: block; }
.ew-drawer-nav { padding: 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.ew-drawer-nav a {
  color: var(--ew-text-2);
  padding: 10px 14px;
  border-radius: 9px;
  font-size: 13.5px;
  transition: var(--ew-transition);
}
.ew-drawer-nav a:hover { background: var(--ew-surface-2); color: var(--ew-primary); }
.ew-drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 1100;
  opacity: 0;
  visibility: hidden;
  transition: var(--ew-transition);
}
.ew-drawer-mask.is-open { opacity: 1; visibility: visible; }

/* ---------------- 分栏切换（用量页左右推拉） ---------------- */
.ew-switch-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.ew-switch-track {
  display: flex;
  background: var(--ew-surface-2);
  border: 1px solid var(--ew-border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.ew-switch-track button {
  border: 0;
  background: transparent;
  color: var(--ew-text-2);
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: var(--ew-transition);
  white-space: nowrap;
}
.ew-switch-track button.is-active {
  background: var(--ew-primary);
  color: #fff;
}

.ew-pusher {
  position: relative;
  overflow: hidden;
  border-radius: var(--ew-radius-lg);
}
.ew-pusher-track {
  display: flex;
  width: 200%;
  transition: transform .32s cubic-bezier(.4, 0, .2, 1);
}
.ew-pusher-track[data-pos="1"] { transform: translateX(-50%); }
.ew-pusher-pane {
  width: 50%;
  flex: 0 0 50%;
  padding: 0;
}
.ew-pane-arrows {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ew-arrow {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--ew-border);
  background: var(--ew-surface);
  color: var(--ew-text-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: var(--ew-transition);
}
.ew-arrow:hover:not(:disabled) { border-color: var(--ew-primary); color: var(--ew-primary); }
.ew-arrow:disabled { opacity: .35; cursor: not-allowed; }

/* ---------------- 图表 ---------------- */
.ew-chart { width: 100%; height: 260px; display: block; }
.ew-bars { display: flex; flex-direction: column; gap: 12px; }
.ew-bar-row { display: flex; align-items: center; gap: 12px; }
.ew-bar-name { width: 110px; font-size: 12.5px; color: var(--ew-text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ew-bar-track { flex: 1; height: 22px; background: var(--ew-surface-2); border-radius: 5px; overflow: hidden; }
.ew-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ew-primary), var(--ew-accent));
  border-radius: 5px;
  transition: width .5s cubic-bezier(.4, 0, .2, 1);
  min-width: 2px;
}
.ew-bar-val { width: 76px; text-align: right; font-size: 12.5px; color: var(--ew-text-3); }

/* ---------------- 空状态 ---------------- */
.ew-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--ew-text-3);
  font-size: 13px;
}

/* ---------------- 页面容器 ---------------- */
.ew-narrow { max-width: 460px; margin: 40px auto; }
.ew-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------------- Footer ---------------- */
.ew-footer {
  border-top: 1px solid var(--ew-border);
  background: var(--ew-bg-soft);
  padding: 22px 16px;
}
.ew-footer-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--ew-text-3);
  font-size: 12.5px;
}
.ew-footer strong { color: var(--ew-text-2); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 860px) {
  .ew-cols { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .ew-appbar-sub { display: none; }
  .ew-grid { grid-template-columns: 1fr; }
  .ew-main { padding: 76px 12px 32px; }
  .ew-stat { min-width: calc(50% - 5px); flex: 1 1 calc(50% - 5px); padding: 10px 14px; }
  .ew-stat-value { font-size: 17px; }
  .ew-pusher-track { }
  .ew-bar-name { width: 74px; font-size: 11.5px; }
  .ew-bar-val { width: 58px; font-size: 11.5px; }
  .ew-page-title { font-size: 18px; }
}

@media (max-width: 400px) {
  .ew-appbar-nav a { padding: 6px 8px; font-size: 12.5px; }
}
