/* ──────────────────────────────────────────────────────────────────────────
 * Kiro 账号登记台 — 共享设计系统
 * 绑定 Open Design「Neutral Modern」令牌，所有界面共用。
 * ─────────────────────────────────────────────────────────────────────── */

:root {
  /* Surface */
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-warm: var(--surface);

  /* Foreground */
  --fg: #111111;
  --fg-2: var(--fg);
  --muted: #6b6b6b;
  --meta: var(--muted);

  /* Border */
  --border: #e5e5e5;
  --border-soft: var(--border);

  /* Accent — cobalt */
  --accent: #2f6feb;
  --accent-on: #ffffff;
  --accent-hover: color-mix(in oklab, var(--accent), black 8%);
  --accent-active: color-mix(in oklab, var(--accent), black 14%);
  --accent-soft: color-mix(in oklab, var(--accent), transparent 90%);

  /* Semantic */
  --success: #17a34a;
  --warn: #eab308;
  --danger: #dc2626;
  --success-soft: color-mix(in oklab, var(--success), transparent 88%);
  --warn-soft: color-mix(in oklab, var(--warn), transparent 86%);
  --danger-soft: color-mix(in oklab, var(--danger), transparent 90%);

  /* Type */
  --font-display: "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;

  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 20px;
  --text-xl: 24px;
  --text-2xl: 32px;
  --text-3xl: 48px;

  --leading-body: 1.5;
  --leading-tight: 1.2;
  --tracking-display: -0.01em;

  /* Spacing — 4px base */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-20: 80px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 9999px;

  /* Elevation */
  --elev-flat: none;
  --elev-ring: 0 0 0 1px var(--border);
  --elev-raised: 0 2px 8px color-mix(in oklab, var(--fg), transparent 92%);
  --elev-pop: 0 8px 28px color-mix(in oklab, var(--fg), transparent 86%);

  --focus-ring: 0 0 0 3px color-mix(in oklab, var(--accent), transparent 70%);

  --motion-fast: 150ms;
  --motion-base: 200ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);

  --sidebar-w: 248px;
  --header-h: 60px;
}

/* ─── reset & base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0; line-height: var(--leading-tight); }
p { margin: 0; text-wrap: pretty; }
::selection { background: var(--accent-soft); }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* ─── buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--motion-fast) var(--ease-standard),
              border-color var(--motion-fast) var(--ease-standard),
              color var(--motion-fast) var(--ease-standard);
}
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn-primary { background: var(--accent); color: var(--accent-on); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; }
.btn-primary:active { background: var(--accent-active); }
.btn-secondary { background: var(--surface); color: var(--fg); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--fg); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--fg); background: color-mix(in oklab, var(--fg), transparent 95%); text-decoration: none; }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger-ghost:hover { border-color: var(--danger); text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: var(--text-xs); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; }
.icon-lg { width: 20px; height: 20px; }

/* ─── card ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
}
.card-pad-lg { padding: var(--space-8); }

/* ─── form fields ──────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: var(--text-sm); color: var(--fg); font-weight: 500; }
.field .hint { font-size: var(--text-xs); color: var(--muted); }
.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--text-sm);
}
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 1; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
.input:hover:not(:focus), .select:hover:not(:focus), .textarea:hover:not(:focus) { border-color: color-mix(in oklab, var(--border), var(--fg) 30%); }
/* 自定义下拉箭头，跨浏览器一致 */
.select {
  appearance: none; -webkit-appearance: none;
  padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6b6b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.5; font-family: var(--font-mono); font-size: var(--text-sm); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }

/* ─── badges / status ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: 500;
  border: 1px solid transparent;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-pending { color: var(--warn); background: var(--warn-soft); }
.badge-assigned { color: var(--accent); background: var(--accent-soft); }
.badge-active { color: var(--success); background: var(--success-soft); }
.badge-neutral { color: var(--muted); background: color-mix(in oklab, var(--muted), transparent 90%); }

/* ─── table ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.ds-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); min-width: 720px; }
.ds-table th, .ds-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.ds-table thead th {
  color: var(--muted); font-weight: 500; font-size: var(--text-xs);
  letter-spacing: .03em; text-transform: uppercase;
  background: color-mix(in oklab, var(--bg), var(--surface) 40%);
  position: sticky; top: 0;
}
.ds-table tbody tr:last-child td { border-bottom: 0; }
.ds-table tbody tr:hover { background: color-mix(in oklab, var(--accent), transparent 96%); }
.ds-table .col-email { font-family: var(--font-mono); font-size: var(--text-xs); }
.cell-name { font-weight: 500; }
.cell-sub { color: var(--muted); font-size: var(--text-xs); margin-top: 2px; }

/* ─── tabs ─────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 12px 16px; border: 0; background: transparent;
  font-size: var(--text-sm); font-weight: 500; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--fg); }
.tab:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; padding-top: var(--space-6); }
.tab-panel.is-active { display: block; }

/* ─── app shell ────────────────────────────────────────────────────────── */
.app { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-w) 1fr; }
.sidebar {
  border-right: 1px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; padding: var(--space-5);
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: var(--space-3); padding: 6px 8px var(--space-5); }
.brand-mark {
  width: 34px; height: 34px; border-radius: var(--radius-sm); flex: none;
  background: var(--accent); color: var(--accent-on);
  display: grid; place-items: center; font-weight: 700; font-size: 17px;
}
.brand-name { font-weight: 600; font-size: var(--text-base); line-height: 1.1; }
.brand-sub { font-size: 11px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: var(--space-4) 8px 6px; }
.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--fg); font-size: var(--text-sm); font-weight: 500;
}
.nav-item:hover { background: color-mix(in oklab, var(--fg), transparent 95%); text-decoration: none; }
.nav-item:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); }
.nav-item .icon { color: var(--muted); }
.nav-item.is-active .icon { color: var(--accent); }
.sidebar-foot { margin-top: auto; padding-top: var(--space-4); border-top: 1px solid var(--border); }
.userchip { display: flex; align-items: center; gap: var(--space-3); padding: 8px; border-radius: var(--radius-sm); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: color-mix(in oklab, var(--accent), transparent 82%); color: var(--accent);
  display: grid; place-items: center; font-size: var(--text-xs); font-weight: 600;
}
.userchip-name { font-size: var(--text-sm); font-weight: 500; line-height: 1.2; }
.userchip-role { font-size: 11px; color: var(--muted); }

.scrim { display: none; }
.main { min-width: 0; }
.topbar {
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: 0 var(--space-8);
  border-bottom: 1px solid var(--border); background: color-mix(in oklab, var(--bg), transparent 8%);
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: var(--text-lg); }
.menu-btn { display: none; }
.content { padding: var(--space-8); max-width: 1120px; }
.page-head { margin-bottom: var(--space-6); }
.page-head .eyebrow { font-size: var(--text-xs); color: var(--accent); font-weight: 600; letter-spacing: .04em; margin-bottom: 6px; }
.page-head h2 { font-size: var(--text-2xl); letter-spacing: var(--tracking-display); }
.page-head p { color: var(--muted); margin-top: 8px; max-width: 60ch; }

/* ─── stat row ─────────────────────────────────────────────────────────── */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-5); }
.stat .num { font-size: var(--text-2xl); font-weight: 600; letter-spacing: var(--tracking-display); font-family: var(--font-mono); }
.stat .label { font-size: var(--text-sm); color: var(--muted); margin-top: 4px; }
.stat .label .accent { color: var(--accent); }
@media (max-width: 880px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }

/* ─── toolbar (search + filters) ───────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-5); }
.search { position: relative; flex: 1; min-width: 220px; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 38px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.seg button { padding: 8px 14px; border: 0; background: transparent; font-size: var(--text-sm); color: var(--muted); border-right: 1px solid var(--border); transition: background var(--motion-fast) var(--ease-standard), color var(--motion-fast) var(--ease-standard); }
.seg button:last-child { border-right: 0; }
.seg button:hover:not(.is-active) { color: var(--fg); background: color-mix(in oklab, var(--fg), transparent 96%); }
.seg button:focus-visible { outline: none; box-shadow: inset var(--focus-ring); }
.seg button.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

/* ─── toast ────────────────────────────────────────────────────────────── */
.toast-host { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: var(--radius-pill);
  font-size: var(--text-sm); box-shadow: var(--elev-pop);
  display: flex; align-items: center; gap: 8px;
  animation: toast-in var(--motion-base) var(--ease-standard);
}
.toast .icon { color: var(--success); stroke: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ─── empty state ──────────────────────────────────────────────────────── */
.empty { text-align: center; padding: var(--space-20) var(--space-6); color: var(--muted); }
.empty .icon { width: 28px; height: 28px; margin: 0 auto var(--space-3); color: var(--border); stroke: var(--muted); }

/* ─── responsive shell ─────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 40; width: 280px; height: 100vh;
    transform: translateX(-100%); transition: transform var(--motion-base) var(--ease-standard);
    box-shadow: var(--elev-pop);
  }
  .app.nav-open .sidebar { transform: translateX(0); }
  .scrim { display: none; position: fixed; inset: 0; background: color-mix(in oklab, var(--fg), transparent 55%); z-index: 30; }
  .app.nav-open .scrim { display: block; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 var(--space-5); }
  .content { padding: var(--space-5); }
}
@media (max-width: 520px) {
  .page-head h2 { font-size: var(--text-xl); }
  .topbar h1 { font-size: var(--text-base); }
}

/* ─── reduced motion ───────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
