/* ============ 设计变量 ============ */
:root {
  --bg: #f4f6fb;
  --bg-grad-1: #eef2ff;
  --bg-grad-2: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-hover: #f1f5fd;
  --border: #e5e9f2;
  --border-strong: #d3dbe9;
  --text: #0f172a;
  --text-soft: #475569;
  --text-muted: #7c8798;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --accent-line: #c7d2fe;
  --green: #0f9d58;
  --amber: #d97706;
  --red: #dc2626;
  --radius-lg: 18px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.03);
  --shadow: 0 4px 16px -6px rgba(15, 23, 42, 0.1), 0 2px 6px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 20px 50px -20px rgba(15, 23, 42, 0.28);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 12% -10%, var(--bg-grad-1) 0%, transparent 60%),
    radial-gradient(900px 420px at 92% 0%, #ecfeff 0%, transparent 55%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}

.app {
  max-width: 1320px;
  margin: 0 auto;
  padding: 22px 24px 40px;
}

/* ============ 顶栏 ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  font-size: 21px;
  border-radius: 13px;
  background: linear-gradient(145deg, #ffffff, #eef2ff);
  border: 1px solid var(--accent-line);
  box-shadow: var(--shadow-sm);
}

.brand-text h1 { margin: 0; font-size: 18px; letter-spacing: -0.2px; }
.brand-text p { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }

.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 10px;
  height: 40px;
  min-width: 280px;
  box-shadow: var(--shadow-sm);
  transition: border-color .18s, box-shadow .18s;
}
.search:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px rgba(79, 70, 229, .1); }
.search svg { width: 16px; height: 16px; fill: none; stroke: var(--text-muted); stroke-width: 2; stroke-linecap: round; }
.search input {
  border: 0; outline: 0; background: transparent; flex: 1;
  font-family: inherit; font-size: 13px; color: var(--text);
}
.search input::placeholder { color: var(--text-muted); }
.search kbd {
  font-family: var(--mono); font-size: 11px; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; background: var(--surface-soft);
}

.btn {
  height: 40px; padding: 0 15px;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit; font-size: 13px; font-weight: 550;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .12s, box-shadow .18s, border-color .18s, background .18s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, #5b52ea, #4f46e5);
  border-color: #4338ca; color: #fff;
  box-shadow: 0 4px 12px -3px rgba(79, 70, 229, .45);
}
.btn-primary:hover { background: linear-gradient(180deg, #665df0, #4b42df); border-color: #4338ca; }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12px; border-radius: var(--radius-sm); }
.btn span { font-size: 15px; line-height: 1; margin-top: -1px; }

/* ============ 三栏工具条 ============ */
.toolbar {
  display: grid;
  grid-template-columns: 1.05fr 1fr 1.15fr;
  gap: 16px;
  margin-bottom: 22px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 16px 18px 18px;
  display: flex; flex-direction: column;
  min-height: 232px;
  position: relative;
  overflow: hidden;
}
.panel::after {
  content: ""; position: absolute; inset: 0 0 auto; height: 3px;
  background: linear-gradient(90deg, var(--accent), #22d3ee);
  opacity: .85;
}
#fxPanel::after { background: linear-gradient(90deg, #0f9d58, #34d399); }
#weatherPanel::after { background: linear-gradient(90deg, #f59e0b, #38bdf8); }

.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 14px;
}
.panel-title { display: flex; align-items: center; gap: 8px; }
.panel-icon { font-size: 15px; }
.panel-title h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--text-soft); letter-spacing: .01em; }
.panel-tag {
  font-size: 11px; color: var(--text-muted);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 8px;
  white-space: nowrap;
}
.panel-tag.live { color: var(--green); border-color: #bbf7d0; background: #f0fdf4; }
.panel-tag.warn { color: var(--amber); border-color: #fde68a; background: #fffbeb; }
.panel-body { flex: 1; display: flex; flex-direction: column; }

/* ---- 时钟 ---- */
.clock-primary { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.clock-time {
  font-family: var(--mono);
  font-size: 34px; font-weight: 600; letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.clock-sec { color: var(--accent); font-size: 22px; }
.clock-city { font-size: 12px; color: var(--text-muted); }
.clock-date {
  margin-top: 6px; display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-soft); flex-wrap: wrap;
}
.clock-badge {
  font-family: var(--mono); font-size: 10px; letter-spacing: .04em;
  background: var(--accent-soft); color: #4338ca;
  border: 1px solid var(--accent-line); border-radius: 5px; padding: 1px 5px;
}
.clock-zones {
  margin-top: auto; padding-top: 12px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.clock-stats {
  margin-top: 14px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.stat {
  background: var(--surface-soft); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 9px;
  display: flex; flex-direction: column; gap: 1px;
}
.stat-label { font-size: 10px; color: var(--text-muted); }
.stat-value { font-size: 12.5px; font-weight: 620; font-family: var(--mono); }

.day-progress { margin-top: 12px; }
.dp-label {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--text-muted); margin-bottom: 5px;
}
.dp-label span:last-child { font-family: var(--mono); color: var(--text-soft); }
.dp-track {
  height: 5px; border-radius: 999px; background: #eef2f8; overflow: hidden;
  border: 1px solid var(--border);
}
.dp-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #6366f1, #22d3ee);
  transition: width .6s ease;
}
.zone {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
}
.zone-name { font-size: 10.5px; color: var(--text-muted); display: block; }
.zone-time { font-family: var(--mono); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- 汇率 ---- */
.fx-input-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.fx-input-wrap {
  flex: 1; display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-soft); padding: 0 10px; height: 36px;
}
.fx-input-wrap:focus-within { border-color: var(--accent-line); background: #fff; box-shadow: 0 0 0 3px rgba(79,70,229,.08); }
.fx-input-wrap span { font-size: 12px; color: var(--text-muted); font-family: var(--mono); }
.fx-input-wrap input {
  border: 0; outline: 0; background: transparent; width: 100%;
  font-family: var(--mono); font-size: 15px; font-weight: 600; color: var(--text);
}
.fx-list { display: flex; flex-direction: column; gap: 5px; }
.fx-row {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 8px; border-radius: var(--radius-sm);
  transition: background .15s;
}
.fx-row:hover { background: var(--surface-soft); }
.fx-code {
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  color: var(--text-soft); background: #eef2f8; border-radius: 4px;
  padding: 1px 5px; min-width: 38px; text-align: center;
}
.fx-name { font-size: 12px; color: var(--text-muted); flex: 1; }
.fx-value { font-family: var(--mono); font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fx-rate { font-size: 10.5px; color: var(--text-muted); font-family: var(--mono); min-width: 96px; text-align: right; }

/* ---- 天气 ---- */
.weather-now { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.weather-icon { font-size: 34px; line-height: 1; }
.weather-temp { font-size: 30px; font-weight: 650; letter-spacing: -1px; line-height: 1; }
.weather-temp small { font-size: 14px; font-weight: 500; color: var(--text-muted); }
.weather-desc { display: flex; flex-direction: column; gap: 2px; }
.weather-desc strong { font-size: 12.5px; font-weight: 600; }
.weather-desc span { font-size: 11px; color: var(--text-muted); }
.weather-days { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: auto; }
.weather-extra {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.weather-extra span {
  font-size: 10.5px; color: var(--text-muted);
  background: var(--surface-soft); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 8px;
}
.day {
  background: var(--surface-soft); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 6px; text-align: center;
}
.day-label { font-size: 11px; color: var(--text-soft); font-weight: 550; }
.day-date { font-size: 10px; color: var(--text-muted); font-family: var(--mono); }
.day-icon { font-size: 19px; display: block; margin: 4px 0 2px; }
.day-temp { font-family: var(--mono); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.day-temp i { font-style: normal; color: var(--text-muted); }
.day-rain { font-size: 10px; color: #0284c7; }

/* ============ 导航区 ============ */
.nav-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-bottom: 14px; flex-wrap: wrap;
}
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  font-family: inherit; font-size: 12.5px; font-weight: 550;
  cursor: pointer;
  transition: all .16s;
  box-shadow: var(--shadow-sm);
}
.tab:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.tab.active {
  background: linear-gradient(180deg, #5b52ea, #4f46e5);
  border-color: #4338ca; color: #fff;
  box-shadow: 0 4px 12px -4px rgba(79, 70, 229, .5);
}
.tab .count {
  font-family: var(--mono); font-size: 10px;
  background: rgba(15, 23, 42, .06); border-radius: 999px; padding: 0 5px;
}
.tab.active .count { background: rgba(255, 255, 255, .24); }
.nav-meta { font-size: 12px; color: var(--text-muted); }

.section { margin-bottom: 26px; }
.section-head { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.section-head h3 { margin: 0; font-size: 14px; font-weight: 650; }
.section-head .section-icon { font-size: 15px; }
.section-head .section-desc { font-size: 11.5px; color: var(--text-muted); }
.section-head .section-actions { margin-left: auto; display: flex; gap: 6px; opacity: 0; transition: opacity .18s; }
.section:hover .section-actions { opacity: 1; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 11px;
}

.card {
  position: relative;
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 13px;
  box-shadow: var(--shadow-sm);
  transition: transform .16s, box-shadow .2s, border-color .2s;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--accent-line);
}
.card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.card-mark {
  width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  background: var(--accent-soft); color: #4338ca;
  border: 1px solid var(--accent-line);
  flex: none;
  font-family: var(--mono);
}
.card-name { font-size: 13px; font-weight: 620; letter-spacing: -.1px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-badge {
  font-size: 9.5px; color: var(--text-muted);
  border: 1px solid var(--border); background: var(--surface-soft);
  border-radius: 4px; padding: 0 4px; white-space: nowrap;
}
.card-desc {
  font-size: 11.5px; color: var(--text-muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 30px;
}
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 7px; }
.card-host { font-size: 10.5px; color: #94a3b8; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-hits { font-size: 10px; color: #94a3b8; font-family: var(--mono); }
.card-tools {
  position: absolute; top: 8px; right: 8px;
  display: flex; gap: 4px;
  opacity: 0; transform: translateY(-2px);
  transition: opacity .16s, transform .16s;
}
.card:hover .card-tools { opacity: 1; transform: none; }
.icon-btn {
  width: 22px; height: 22px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); cursor: pointer;
  display: grid; place-items: center;
  font-size: 11px; line-height: 1;
  box-shadow: var(--shadow-sm);
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.icon-btn.danger:hover { color: var(--red); border-color: #fecaca; background: #fef2f2; }

.empty {
  text-align: center; padding: 46px 20px;
  color: var(--text-muted); font-size: 13px;
  background: var(--surface); border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}
.empty strong { display: block; color: var(--text-soft); margin-bottom: 4px; font-size: 14px; }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 23, 42, .38);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 20px;
  animation: fade .16s ease;
}
.modal {
  width: 100%; max-width: 430px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  padding: 20px 22px 18px;
  animation: pop .18s cubic-bezier(.2, .9, .3, 1.2);
}
.modal h3 { margin: 0 0 4px; font-size: 15px; }
.modal .modal-sub { margin: 0 0 16px; font-size: 12px; color: var(--text-muted); }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 11.5px; color: var(--text-soft); margin-bottom: 5px; font-weight: 550; }
.field input, .field select, .field textarea {
  width: 100%; height: 36px; padding: 0 10px;
  font-family: inherit; font-size: 13px; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-soft); outline: 0;
  transition: border-color .16s, box-shadow .16s, background .16s;
}
.field textarea { height: 68px; padding: 8px 10px; resize: vertical; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent-line); background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .1);
}
.field .hint { font-size: 10.5px; color: var(--text-muted); margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 88px 1fr; gap: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal-error {
  font-size: 12px; color: var(--red); background: #fef2f2;
  border: 1px solid #fecaca; border-radius: var(--radius-sm);
  padding: 7px 10px; margin-bottom: 12px;
}

/* ============ Toast / 横幅 ============ */
.toasts {
  position: fixed; right: 20px; bottom: 20px; z-index: 80;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  min-width: 220px; max-width: 340px;
  background: #0f172a; color: #f8fafc;
  border-radius: var(--radius); padding: 10px 14px;
  font-size: 12.5px; box-shadow: var(--shadow-lg);
  animation: slideIn .2s ease;
  display: flex; align-items: center; gap: 8px;
}
.toast.ok { background: #064e3b; }
.toast.err { background: #7f1d1d; }
.toast.out { animation: fadeOut .2s forwards; }

.banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 70;
  background: #fff7ed; border-bottom: 1px solid #fed7aa;
  color: #9a3412; font-size: 12.5px;
  padding: 7px 16px; text-align: center;
}

/* ============ 骨架屏 ============ */
.skeleton {
  background: linear-gradient(90deg, #eef2f8 25%, #f6f8fc 37%, #eef2f8 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  border-radius: var(--radius-sm);
}
.skeleton-lg { height: 120px; width: 100%; }
.skeleton-card { height: 96px; }

/* ============ 页脚 ============ */
.footer {
  margin-top: 34px; padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: 11px; color: var(--text-muted);
}
.footer-status.ok { color: var(--green); }
.footer-status.err { color: var(--red); }

@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(6px); } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

/* ============ 响应式 ============ */
@media (max-width: 1080px) {
  .toolbar { grid-template-columns: 1fr 1fr; }
  #weatherPanel { grid-column: span 2; min-height: auto; }
}
@media (max-width: 720px) {
  .app { padding: 16px 14px 32px; }
  .toolbar { grid-template-columns: 1fr; }
  #weatherPanel { grid-column: auto; }
  .search { min-width: 0; flex: 1; }
  .topbar { gap: 12px; }
  .topbar-actions { width: 100%; }
  .clock-time { font-size: 30px; }
  .fx-rate { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .tabs {
    flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; }
  .nav-head { gap: 8px; }
  .section-head .section-actions { opacity: 1; }
}
