*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== Theme Variables ===== */
:root {
  --bg:        #0d0d0f;
  --bg2:       #1c1c1e;
  --bg3:       #2c2c2e;
  --border:    #3a3a3c;
  --border2:   #636366;
  --text:      #e8e8ed;
  --text2:     #aeaeb2;
  --text3:     #636366;
  --text4:     #48484a;
  --accent:    #0a84ff;
  --green:     #30d158;
  --red:       #ff453a;
  --orange:    #ff9f0a;
  --modal-bg:  rgba(0,0,0,0.75);
  --card-bg:   #1c1c1e;
  --card-bd:   #2a2a2c;
}

body.light {
  --bg:        #f2f2f7;
  --bg2:       #ffffff;
  --bg3:       #e5e5ea;
  --border:    #d1d1d6;
  --border2:   #8e8e93;
  --text:      #1c1c1e;
  --text2:     #3a3a3c;
  --text3:     #8e8e93;
  --text4:     #aeaeb2;
  --accent:    #007aff;
  --green:     #34c759;
  --red:       #ff3b30;
  --orange:    #ff9500;
  --modal-bg:  rgba(0,0,0,0.5);
  --card-bg:   #ffffff;
  --card-bd:   #e5e5ea;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}
body.modal-open { overflow: hidden; }

/* ===== Modal ===== */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
  overflow-y: auto;
}
#modal-overlay.hidden { display: none; }

.modal-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 24px 24px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}

.modal-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--red);
  margin-bottom: 16px;
}

.modal-text {
  font-size: 0.88rem;
  color: var(--text2);
  line-height: 1.7;
  margin-bottom: 12px;
}
.modal-red  { color: var(--red); }
.modal-bold { font-weight: 700; }

.modal-guide {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 14px 0 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-guide-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
}
.guide-icon  { font-size: 1.8rem; flex-shrink: 0; }
.guide-cross { color: var(--red);   font-size: 1.4rem; font-weight: 900; flex-shrink: 0; }
.guide-check { color: var(--green); font-size: 1.4rem; font-weight: 900; flex-shrink: 0; }
.guide-label { line-height: 1.4; }

.modal-confirm-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 50px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}
.modal-confirm-btn:hover { opacity: 0.85; }

/* ===== Layout ===== */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

header {
  text-align: center;
  margin-bottom: 32px;
}

.site-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.home-btn {
  display: inline-block;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  padding: 9px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}
.home-btn:hover { background: var(--bg3); border-color: var(--border2); }

.brand-name {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #5e5ce6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Theme toggle */
.theme-toggle {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--bg3); border-color: var(--border2); }

header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}

.notice, .notice-danger, .tutorial-btn {
  display: block;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  border-radius: 10px;
  box-sizing: border-box;
}

.notice {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--text2);
  line-height: 1.7;
  text-align: left;
  margin-bottom: 16px;
}

.tutorial-btn {
  background: var(--bg2);
  border: 1px solid var(--accent);
  color: var(--accent);
  text-decoration: none;
  padding: 11px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 16px;
  text-align: center;
  transition: background 0.15s, opacity 0.15s;
}
.tutorial-btn:hover { background: var(--bg3); opacity: 0.9; }

.notice-danger {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--red);
  font-weight: 600;
  line-height: 1.7;
  text-align: left;
  margin-bottom: 20px;
}

.meta {
  font-size: 0.85rem;
  color: var(--text3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}

.btn-refresh {
  background: none;
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 3px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.82rem;
  transition: background 0.15s, border-color 0.15s;
}
.btn-refresh:hover { background: var(--bg2); border-color: var(--accent); }
.btn-refresh:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Filter bar ===== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}

.filter-btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 5px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.filter-btn:hover { border-color: var(--border2); color: var(--text); }
.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.loading {
  text-align: center;
  color: var(--text3);
  padding: 60px 0;
  font-size: 0.95rem;
}

.error-msg {
  text-align: center;
  color: var(--red);
  padding: 20px;
  font-size: 0.9rem;
}

/* ===== Cards ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-bd);
  border-radius: 12px;
  padding: 16px;
  transition: border-color 0.2s;
}
.card:hover { border-color: var(--border2); }

.card.status-normal    { border-left: 3px solid var(--green); }
.card.status-abnormal  { border-left: 3px solid var(--red); }
.card.status-pending   { border-left: 3px solid var(--orange); }
.card.status-detecting { border-left: 3px solid var(--accent); }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.source-label {
  font-size: 0.72rem;
  color: var(--text3);
  background: var(--bg3);
  padding: 2px 8px;
  border-radius: 10px;
}

.status-badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}
.status-badge.normal    { background: #0d2e1a; color: #30d158; }
.status-badge.abnormal  { background: #2e0d0d; color: #ff453a; }
.status-badge.pending   { background: #2e1e00; color: #ff9f0a; }
.status-badge.detecting { background: #001a2e; color: #0a84ff; }
.status-badge.unknown   { background: var(--bg3); color: var(--text2); }

body.light .status-badge.normal    { background: #d4f5de; color: #1a7f3c; }
body.light .status-badge.abnormal  { background: #fde8e7; color: #c0392b; }
body.light .status-badge.pending   { background: #fff3d4; color: #a05c00; }
body.light .status-badge.detecting { background: #ddeeff; color: #0055cc; }

.field { margin-bottom: 10px; }

.field-label {
  font-size: 0.7rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-value {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.88rem;
  font-family: "SF Mono", "Menlo", monospace;
  color: var(--text);
  word-break: break-all;
  min-width: 0;
}

.btn-copy {
  flex-shrink: 0;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-copy:hover { background: var(--border); }
.btn-copy.copied { color: var(--green); }

.card-footer {
  margin-top: 12px;
  font-size: 0.72rem;
  color: var(--text4);
  display: flex;
  justify-content: space-between;
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 0;
  color: var(--text4);
}
