:root {
  --h5-bg: #0d1828;
  --h5-surface: #152238;
  --h5-surface2: #1c2d48;
  --h5-border: rgba(255, 255, 255, 0.08);
  --h5-text: #eef3fb;
  --h5-muted: #8fa3bf;
  --h5-primary: #3b82f6;
  --h5-primary-dark: #2563eb;
  --h5-accent: #10b981;
  --h5-warn: #f59e0b;
  --h5-danger: #ef4444;
  --h5-radius: 12px;
  --h5-tab-h: 56px;
  --h5-safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--h5-bg);
  color: var(--h5-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--h5-primary); text-decoration: none; }

.h5-body { min-height: 100dvh; }

.h5-app {
  min-height: 100dvh;
  padding-bottom: calc(var(--h5-tab-h) + var(--h5-safe-b) + 12px);
}

.h5-app:has(.h5-login) { padding-bottom: 0; }

/* Header */
.h5-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 16px 12px;
  background: linear-gradient(180deg, #1a3050 0%, var(--h5-bg) 100%);
}

.h5-header-simple { display: block; }

.h5-header-eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--h5-muted);
  letter-spacing: 0.05em;
}

.h5-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.h5-header p {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--h5-muted);
}

.h5-header-link {
  font-size: 13px;
  color: var(--h5-muted);
  padding: 6px 10px;
  border: 1px solid var(--h5-border);
  border-radius: 8px;
}

.h5-back {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--h5-muted);
}

/* Stats */
.h5-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 0 12px 16px;
}

.h5-stat {
  background: var(--h5-surface);
  border: 1px solid var(--h5-border);
  border-radius: var(--h5-radius);
  padding: 12px 8px;
  text-align: center;
}

.h5-stat strong {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.h5-stat span {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--h5-muted);
}

/* Section */
.h5-section { padding: 0 12px 16px; }

.h5-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.h5-section-head h2,
.h5-section-title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
}

.h5-section-head a { font-size: 13px; }

/* Cards */
.h5-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 12px 16px;
}

.h5-card {
  display: block;
  background: var(--h5-surface);
  border: 1px solid var(--h5-border);
  border-radius: var(--h5-radius);
  padding: 14px;
  color: inherit;
}

.h5-card-action { padding-bottom: 12px; }

.h5-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.h5-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
}

.h5-card-sub {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--h5-muted);
}

.h5-card-meta {
  margin: 0;
  font-size: 12px;
  color: var(--h5-muted);
}

.h5-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.h5-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

.h5-badge-warn {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
}

/* Detail */
.h5-detail {
  margin: 0 12px 16px;
  background: var(--h5-surface);
  border: 1px solid var(--h5-border);
  border-radius: var(--h5-radius);
  overflow: hidden;
}

.h5-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--h5-border);
  font-size: 14px;
}

.h5-detail-row:last-child { border-bottom: none; }

.h5-detail-row span { color: var(--h5-muted); flex-shrink: 0; }

.h5-detail-row strong,
.h5-detail-row a {
  text-align: right;
  word-break: break-all;
}

/* Quick actions */
.h5-quick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 12px 20px;
}

.h5-quick-btn {
  display: block;
  text-align: center;
  padding: 14px;
  background: var(--h5-surface2);
  border: 1px solid var(--h5-border);
  border-radius: var(--h5-radius);
  color: var(--h5-text);
  font-weight: 500;
}

/* Piece list */
.h5-piece-list {
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.h5-piece-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: var(--h5-surface);
  border: 1px solid var(--h5-border);
  border-radius: var(--h5-radius);
}

.h5-piece-item strong {
  display: block;
  font-size: 15px;
}

.h5-piece-item span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--h5-muted);
}

.h5-piece-item em {
  font-style: normal;
  font-size: 17px;
  font-weight: 700;
  color: var(--h5-accent);
}

/* Form */
.h5-form { display: flex; flex-direction: column; gap: 12px; }

.h5-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.h5-field span {
  font-size: 13px;
  color: var(--h5-muted);
}

.h5-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--h5-border);
  border-radius: 10px;
  background: var(--h5-surface2);
  color: var(--h5-text);
  font-size: 15px;
  outline: none;
}

.h5-input:focus {
  border-color: var(--h5-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.h5-textarea { min-height: 72px; resize: vertical; }

.h5-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.h5-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.h5-btn-block { width: 100%; margin-top: 4px; }

.h5-btn-primary {
  background: var(--h5-primary);
  color: #fff;
}

.h5-btn-primary:active { background: var(--h5-primary-dark); }

.h5-btn-accent {
  background: var(--h5-accent);
  color: #fff;
}

/* Login */
.h5-login {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 24px;
}

.h5-login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.h5-login-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.h5-login-brand h1 {
  margin: 0 0 6px;
  font-size: 26px;
}

.h5-login-brand p {
  margin: 0;
  color: var(--h5-muted);
  font-size: 14px;
}

.h5-hint {
  margin: 12px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--h5-muted);
}

.h5-hint-err { color: var(--h5-danger); }

.h5-empty {
  text-align: center;
  padding: 40px 24px;
  color: var(--h5-muted);
  font-size: 14px;
}

/* Tab bar */
.h5-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--h5-tab-h) + var(--h5-safe-b));
  padding-bottom: var(--h5-safe-b);
  background: rgba(13, 24, 40, 0.96);
  border-top: 1px solid var(--h5-border);
  backdrop-filter: blur(12px);
}

.h5-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--h5-muted);
  font-size: 11px;
  padding: 6px 0;
}

.h5-tab-icon { font-size: 20px; line-height: 1; }

.h5-tab.is-active { color: var(--h5-primary); }

.h5-menu { padding: 0 12px 20px; display: flex; flex-direction: column; gap: 8px; }
.h5-menu-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--h5-surface); border: 1px solid var(--h5-border);
  border-radius: var(--h5-radius); color: var(--h5-text); font-size: 15px;
}
.h5-menu-item em { font-style: normal; background: var(--h5-danger); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.h5-menu-danger { color: var(--h5-danger); }
.h5-msg.is-unread { border-color: rgba(59, 130, 246, 0.4); }

.h5-toast {
  position: fixed; left: 50%; bottom: calc(var(--h5-tab-h) + 24px); transform: translateX(-50%);
  background: rgba(0,0,0,0.85); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; z-index: 200; opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.h5-toast.show { opacity: 1; }
