:root {
  --bg: #f8fafc;
  --surface: rgba(255,255,255,.9);
  --surface-strong: #fff;
  --text: #0f172a;
  --muted: #64748b;
  --line: rgba(15,23,42,.1);
  --brand: #0ea5e9;
  --brand-dark: #0284c7;
  --danger: #ef4444;
  --warn: #f59e0b;
  --ok: #16a34a;
  --shadow: 0 18px 55px rgba(15,23,42,.12);
  --radius: 26px;
}

* { box-sizing: border-box; }
html {
  min-height: 100%;
  background:
    radial-gradient(circle at 12% 4%, rgba(14,165,233,.18), transparent 34%),
    radial-gradient(circle at 88% 0%, rgba(34,197,94,.1), transparent 30%),
    linear-gradient(180deg,#fff 0%,#f8fafc 56%,#edf7fb 100%);
}
body {
  margin: 0;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.5;
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 0 48px;
}
.hero {
  position: relative;
  overflow: hidden;
  min-height: 320px;
  padding: 26px;
  border-radius: 34px;
  color: white;
  background:
    linear-gradient(140deg, rgba(15,23,42,.97), rgba(30,41,59,.9)),
    radial-gradient(circle at top right, rgba(14,165,233,.52), transparent 34%);
  box-shadow: var(--shadow);
}
.hero::after {
  content: "";
  position: absolute;
  right: -80px;
  bottom: -90px;
  width: 280px;
  height: 280px;
  border-radius: 999px;
  background: rgba(14,165,233,.25);
}
.hero-top, .hero-body { position: relative; z-index: 1; }
.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 20px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.16);
  overflow: hidden;
  font-size: 26px;
  font-weight: 900;
}
.brand-mark img { width: 72%; height: 72%; object-fit: contain; }
.eyebrow {
  margin: 0 0 6px;
  color: #38bdf8;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .12em;
}
h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 5vw, 48px);
  letter-spacing: -.04em;
}
h2 { margin-bottom: 0; font-size: 22px; letter-spacing: -.02em; }
.hero-body { width: min(740px,100%); margin-top: 72px; }
.hero-body p { color: rgba(255,255,255,.84); font-size: 17px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.primary-btn, .secondary-btn, .ghost-btn {
  border: 0;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 900;
}
.primary-btn { color: #082f49; background: white; }
.secondary-btn {
  color: white;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
}
.ghost-btn {
  color: var(--text);
  background: #f1f5f9;
}
.status-stack { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.status-pill {
  padding: 9px 13px;
  border-radius: 999px;
  color: rgba(255,255,255,.9);
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}
.status-pill.is-ok { background: rgba(22,163,74,.22); }
.status-pill.is-error { background: rgba(239,68,68,.22); }

.grid-section {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 14px;
  margin-top: -48px;
  padding: 0 20px;
}
.metric-card, .panel {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.metric-card { padding: 22px; border-radius: var(--radius); }
.metric-card span { color: var(--muted); font-size: 13px; font-weight: 900; }
.metric-card strong { display: block; margin: 8px 0; font-size: 34px; letter-spacing: -.04em; }
.metric-card p { margin-bottom: 0; color: var(--muted); font-size: 14px; }

.panel { margin-top: 18px; padding: 22px; border-radius: var(--radius); }
.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.panel-title small { color: var(--muted); }
.binding-panel {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg,rgba(255,255,255,.96),rgba(248,250,252,.92));
}
.bind-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
.bind-badge.is-ok { background: rgba(22,163,74,.12); color: #166534; }
.bind-badge.is-warn { background: rgba(245,158,11,.14); color: #92400e; }
.bind-badge.is-error { background: rgba(239,68,68,.13); color: #991b1b; }
.bind-summary {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
  padding: 16px;
  border-radius: 22px;
  background: linear-gradient(135deg,#0f172a,#1e293b);
  color: white;
}
.bind-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 20px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.16);
  font-size: 25px;
}
.bind-summary strong, .bind-summary span { display: block; }
.bind-summary span { margin-top: 4px; color: rgba(255,255,255,.78); font-size: 13px; }
.binding-detail {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 12px;
}
.binding-detail > div {
  min-width: 0;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
}
.binding-detail span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
.binding-detail strong {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.permission-mini { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.permission-mini span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
}
.helper-text {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 16px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 14px;
}
.module-grid {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 12px;
}
.module-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff;
  text-align: left;
  color: inherit;
}
.module-card.is-locked {
  opacity: .48;
  background: #f8fafc;
}
.module-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 17px;
  background: #e0f2fe;
  font-size: 22px;
}
.module-card strong { display: block; font-size: 15px; }
.module-card small { display: block; margin-top: 4px; color: var(--muted); line-height: 1.45; }
.empty-state {
  padding: 22px;
  border: 1px dashed rgba(15,23,42,.18);
  border-radius: 20px;
  background: rgba(248,250,252,.8);
  color: var(--muted);
}
.notice-list { display: grid; gap: 12px; }
.notice-card {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 14px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  text-align: left;
}
.notice-dot { width: 12px; height: 12px; margin-top: 7px; border-radius: 50%; background: var(--brand); }
.notice-card.is-read .notice-dot { background: #cbd5e1; }
.notice-card h3 { margin: 0 0 4px; font-size: 16px; }
.notice-card p { margin: 0; color: var(--muted); font-size: 14px; }
.notice-card time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.notice-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.notice-tag, .notice-action {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
  font-weight: 900;
}
.notice-action { color: #0284c7; }
.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 80;
  transform: translateX(-50%) translateY(20px);
  max-width: min(520px, calc(100% - 32px));
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(15,23,42,.92);
  color: white;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 18px 55px rgba(15,23,42,.22);
  transition: opacity .18s ease, transform .18s ease;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.mobile-bottom-bar { display: none; }

@media (max-width: 900px) {
  .grid-section, .module-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  body { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
  .app-shell {
    width: min(100% - 18px,1180px);
    padding-top: max(12px, env(safe-area-inset-top));
  }
  .hero { min-height: auto; padding: 18px; border-radius: 26px; }
  .hero-top { flex-direction: column; gap: 14px; }
  .status-stack { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .status-pill { text-align: center; padding: 8px 10px; }
  .brand-mark { width: 52px; height: 52px; border-radius: 18px; }
  .hero-body { margin-top: 34px; }
  .hero-body p { font-size: 15px; line-height: 1.7; }
  .hero-actions { display: grid; grid-template-columns: 1fr; gap: 9px; }
  .hero-actions .primary-btn, .hero-actions .secondary-btn { border-radius: 15px; }

  .grid-section { grid-template-columns: 1fr; gap: 10px; margin-top: 12px; padding: 0; }
  .metric-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    align-items: center;
    padding: 16px;
  }
  .metric-card strong { grid-column: 2; grid-row: 1 / span 2; margin: 0; font-size: 30px; }
  .metric-card p { font-size: 13px; }

  .panel { margin-top: 12px; padding: 16px; border-radius: 22px; }
  .panel-title { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 14px; }
  .bind-summary { padding: 14px; border-radius: 20px; }
  .binding-detail { grid-template-columns: 1fr; gap: 9px; }
  .binding-detail > div { padding: 12px; border-radius: 16px; }
  .binding-detail strong { font-size: 12px; }
  .permission-mini span { max-width: 100%; overflow-wrap: anywhere; }
  .module-grid { grid-template-columns: 1fr; }
  .module-card { min-height: 92px; padding: 14px; border-radius: 18px; }
  .notice-card { grid-template-columns: 10px 1fr; gap: 12px; padding: 14px; border-radius: 18px; }
  .notice-card time { grid-column: 2; justify-self: start; }
  .notice-card h3 { font-size: 15px; }
  .notice-card p { font-size: 13px; line-height: 1.65; }
  .mobile-bottom-bar {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 60;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(18px);
    box-shadow: 0 18px 55px rgba(15,23,42,.18);
  }
  .mobile-bottom-bar button {
    display: grid;
    place-items: center;
    min-height: 42px;
    border: 0;
    border-radius: 16px;
    background: #f1f5f9;
    color: #0f172a;
    font-size: 13px;
    font-weight: 900;
  }
  .mobile-bottom-bar button:first-child { background: #0f172a; color: white; }
}
