:root {
  color-scheme: dark;
  --bg: #070b14;
  --bg-soft: #0d1524;
  --panel: #111b2e;
  --panel-2: #16233a;
  --line: rgba(148, 163, 184, 0.16);
  --text: #e6edf7;
  --muted: #8fa1bb;
  --primary: #3b82f6;
  --primary-2: #2563eb;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(37, 99, 235, 0.22), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(14, 165, 233, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 390px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(22, 35, 58, 0.92), rgba(13, 21, 36, 0.96));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  font-weight: 800; letter-spacing: 0.5px; color: #fff;
}
.brand h1 { margin: 0; font-size: 22px; letter-spacing: 0.2px; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.login-form { display: grid; gap: 16px; }
.login-form label, .reject-box label { display: grid; gap: 8px; }
.login-form span, .reject-box span { color: var(--muted); font-size: 13px; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(7, 11, 20, 0.7);
  color: var(--text);
  padding: 13px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus {
  border-color: rgba(59, 130, 246, 0.8);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}
.primary, .danger, .ghost {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  color: #fff;
  font-weight: 600;
}
.primary { background: linear-gradient(180deg, var(--primary), var(--primary-2)); }
.primary:active { transform: translateY(1px); }
.danger { background: linear-gradient(180deg, #f87171, #dc2626); }
.ghost { background: rgba(148, 163, 184, 0.1); color: var(--text); border: 1px solid var(--line); }
.error { min-height: 18px; margin: 0; color: #fca5a5; font-size: 13px; }

.app-view {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 16px calc(30px + env(safe-area-inset-bottom));
}
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.header-actions .ghost { padding: 9px 12px; font-size: 12px; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 12px; letter-spacing: 1.4px; text-transform: uppercase; }
.app-header h1 { margin: 0; font-size: 26px; letter-spacing: 0.2px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: linear-gradient(180deg, rgba(22, 35, 58, 0.86), rgba(13, 21, 36, 0.9));
}
.stat span { display: block; font-size: 26px; font-weight: 700; letter-spacing: 0.5px; }
.stat small { color: var(--muted); font-size: 12px; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  white-space: nowrap;
  border: 1px solid var(--line);
  background: rgba(148, 163, 184, 0.06);
  color: var(--muted);
  border-radius: 999px;
  padding: 9px 15px;
  font-size: 13px;
}
.tab.active { background: rgba(59, 130, 246, 0.16); border-color: rgba(59, 130, 246, 0.5); color: #bfdbfe; }

.gate-list { display: grid; gap: 12px; }
.gate-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: linear-gradient(180deg, rgba(22, 35, 58, 0.88), rgba(13, 21, 36, 0.92));
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}
.gate-card:active { transform: scale(0.995); }
.gate-card:hover { border-color: rgba(59, 130, 246, 0.45); }
.gate-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.gate-title { margin: 0; font-size: 16px; line-height: 1.35; }
.gate-meta { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; }
.gate-reason { color: #c6d4e8; font-size: 13px; margin: 10px 0 0; line-height: 1.5; }
.gate-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; color: var(--muted); font-size: 12px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 5px 10px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
  border: 1px solid transparent;
}
.badge.high { color: #fecaca; background: rgba(239, 68, 68, 0.16); border-color: rgba(239, 68, 68, 0.35); }
.badge.medium { color: #fde68a; background: rgba(245, 158, 11, 0.14); border-color: rgba(245, 158, 11, 0.32); }
.badge.low { color: #bbf7d0; background: rgba(34, 197, 94, 0.14); border-color: rgba(34, 197, 94, 0.3); }
.badge.pending { color: #bfdbfe; background: rgba(59, 130, 246, 0.14); border-color: rgba(59, 130, 246, 0.32); }
.badge.approved, .badge.auto_approved { color: #bbf7d0; background: rgba(34, 197, 94, 0.14); border-color: rgba(34, 197, 94, 0.3); }
.badge.rejected { color: #fecaca; background: rgba(239, 68, 68, 0.14); border-color: rgba(239, 68, 68, 0.3); }

.empty { text-align: center; color: var(--muted); padding: 48px 0; font-size: 14px; }
.app-footer { display: flex; justify-content: center; gap: 8px; color: #5f718b; font-size: 11px; padding-top: 28px; }

.drawer-mask {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(2, 6, 15, 0.7);
  backdrop-filter: blur(4px);
}
.drawer {
  position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
  max-height: 92dvh; overflow: auto;
  border-radius: 24px 24px 0 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: #0c1422;
  padding: 16px 18px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -30px 80px rgba(0, 0, 0, 0.55);
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.drawer-body { display: grid; gap: 14px; }
.drawer-body h2 { margin: 0; font-size: 20px; line-height: 1.35; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.section-title { margin: 6px 0 0; color: var(--muted); font-size: 12px; letter-spacing: 0.8px; text-transform: uppercase; }
.check-list, .evidence-list { display: grid; gap: 8px; }
.check-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(148, 163, 184, 0.04); font-size: 13px; }
.check-row .ok { color: #86efac; font-weight: 700; }
.check-row .fail { color: #fca5a5; font-weight: 700; }
.evidence-list a { color: #93c5fd; font-size: 13px; text-decoration: none; }
.drawer-actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; margin-top: 18px; }
.reject-box { margin-top: 14px; display: grid; gap: 10px; }
.reject-box textarea { resize: vertical; }

.toast {
  position: fixed; z-index: 80; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 40px);
  padding: 11px 16px; border-radius: 12px;
  background: rgba(15, 23, 42, 0.96); border: 1px solid var(--line);
  color: var(--text); font-size: 13px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

@media (min-width: 720px) {
  .gate-list { grid-template-columns: 1fr 1fr; }
  .drawer { left: 50%; right: auto; bottom: 24px; width: 620px; transform: translateX(-50%); border-radius: 24px; border-bottom: 1px solid var(--line); }
}
