/* shadcn/ui inspired admin styles · neutral palette */
:root {
  --bg: hsl(0 0% 100%);
  --fg: hsl(240 10% 3.9%);
  --muted: hsl(240 4.8% 95.9%);
  --muted-fg: hsl(240 3.8% 46.1%);
  --card: hsl(0 0% 100%);
  --card-fg: hsl(240 10% 3.9%);
  --border: hsl(240 5.9% 90%);
  --border-strong: hsl(240 5% 80%);
  --input: hsl(240 5.9% 90%);
  --ring: hsl(240 5% 64.9%);
  --primary: hsl(221 83% 53%);
  --primary-fg: hsl(0 0% 98%);
  --secondary: hsl(240 4.8% 95.9%);
  --secondary-fg: hsl(240 5.9% 10%);
  --destructive: hsl(0 84% 60%);
  --destructive-fg: hsl(0 0% 98%);
  --success: hsl(142 76% 36%);
  --warning: hsl(38 92% 50%);
  --accent: hsl(240 4.8% 95.9%);
  --accent-fg: hsl(240 5.9% 10%);
  --radius: 0.5rem;
  --sidebar-bg: hsl(240 5% 96%);
  --sidebar-border: hsl(240 5.9% 90%);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Geist", "Noto Sans TC", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

[data-icon] { display: inline-flex; align-items: center; justify-content: center; line-height: 1; flex-shrink: 0; }
[data-icon] > svg { display: block; }
.sidebar__item [data-icon] { opacity: 0.75; }
.sidebar__item.active [data-icon] { opacity: 1; }

/* ===== Layout shell ===== */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

/* sidebar */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column;
}
.sidebar__brand {
  padding: 20px 20px 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar__brand-mark {
  width: 32px; height: 32px; background: var(--fg); color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); font-weight: 800; font-size: 13px;
  font-family: "Fraunces", serif;
}
.sidebar__brand-name { font-weight: 600; font-size: 14px; line-height: 1.2; }
.sidebar__brand-name small { display: block; font-size: 11px; color: var(--muted-fg); font-weight: 400; }

.sidebar__org {
  padding: 12px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar__org-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px); font-size: 13px;
}
.sidebar__org-pill svg, .sidebar__org-pill .dot { width: 8px; height: 8px; background: hsl(142 76% 36%); border-radius: 50%; flex-shrink: 0; }
.sidebar__org-pill strong { font-weight: 500; }
.sidebar__org-pill small { color: var(--muted-fg); margin-left: auto; font-size: 11px; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 12px 8px; }
.sidebar__group { margin-bottom: 16px; }
.sidebar__group-label {
  padding: 4px 12px; font-size: 11px; color: var(--muted-fg);
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500;
}
.sidebar__item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: calc(var(--radius) - 2px);
  font-size: 13.5px; color: var(--fg);
  cursor: pointer; margin-bottom: 1px;
}
.sidebar__item:hover { background: var(--accent); }
.sidebar__item.active { background: var(--fg); color: var(--bg); font-weight: 500; }
.sidebar__item .icon { width: 16px; height: 16px; opacity: 0.7; flex-shrink: 0; }
.sidebar__item .badge {
  margin-left: auto; font-size: 11px; padding: 1px 6px;
  background: var(--muted); color: var(--muted-fg); border-radius: 999px; font-weight: 500;
}
.sidebar__item.active .badge { background: rgba(255,255,255,0.2); color: var(--bg); }

.sidebar__user {
  border-top: 1px solid var(--sidebar-border);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
}
.sidebar__avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: hsl(221 83% 53%); color: var(--primary-fg);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px; flex-shrink: 0;
}
.sidebar__user-info { font-size: 13px; line-height: 1.3; min-width: 0; }
.sidebar__user-info strong { display: block; font-weight: 500; }
.sidebar__user-info small { color: var(--muted-fg); font-size: 11px; }

/* ===== Main ===== */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px;
  gap: 16px; background: var(--bg);
  position: sticky; top: 0; z-index: 20;
}
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted-fg); }
.breadcrumb a:hover { color: var(--fg); }
.breadcrumb .sep { opacity: 0.4; }
.breadcrumb .current { color: var(--fg); font-weight: 500; }
.topbar__search {
  margin-left: auto; min-width: 280px; position: relative;
}
.topbar__search input {
  width: 100%; padding: 6px 12px 6px 32px;
  background: var(--muted); border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px); font-size: 13px;
}
.topbar__search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--muted-fg);
}
.topbar__kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); padding: 1px 6px; font-size: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; color: var(--muted-fg); font-family: monospace; }

.topbar__icon-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: calc(var(--radius) - 2px); cursor: pointer;
  background: transparent; border: 1px solid transparent;
  color: var(--muted-fg);
}
.topbar__icon-btn:hover { background: var(--accent); color: var(--fg); }
.topbar__icon-btn .dot { position: relative; }
.topbar__icon-btn .dot::after { content: ""; position: absolute; top: -2px; right: -4px; width: 6px; height: 6px; background: var(--destructive); border-radius: 50%; border: 1px solid var(--bg); }

/* page header */
.content { padding: 24px 32px 64px; flex: 1; min-width: 0; }
.page-head {
  display: flex; justify-content: space-between; align-items: end;
  padding-bottom: 16px; margin-bottom: 24px; border-bottom: 1px solid var(--border);
}
.page-head__title h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.page-head__title p { color: var(--muted-fg); font-size: 13px; margin-top: 4px; }
.page-head__actions { display: flex; gap: 8px; align-items: center; }

/* ===== Components ===== */

/* Button */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 0 14px; height: 36px;
  border-radius: calc(var(--radius) - 2px); font-size: 13px; font-weight: 500;
  background: var(--fg); color: var(--bg); border: 1px solid var(--fg);
  cursor: pointer; transition: opacity 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.9; }
.btn--sm { height: 30px; font-size: 12px; padding: 0 10px; }
.btn--lg { height: 40px; padding: 0 18px; }
.btn--outline { background: var(--bg); color: var(--fg); border-color: var(--border-strong); }
.btn--outline:hover { background: var(--accent); }
.btn--ghost { background: transparent; color: var(--fg); border-color: transparent; }
.btn--ghost:hover { background: var(--accent); }
.btn--secondary { background: var(--secondary); color: var(--secondary-fg); border-color: var(--secondary); }
.btn--destructive { background: var(--destructive); color: var(--destructive-fg); border-color: var(--destructive); }
.btn--primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; font-size: 11.5px; font-weight: 500;
  border-radius: 999px; line-height: 1.4; white-space: nowrap;
}
.badge--default { background: var(--fg); color: var(--bg); }
.badge--secondary { background: var(--secondary); color: var(--secondary-fg); }
.badge--outline { border: 1px solid var(--border-strong); color: var(--fg); background: transparent; }
.badge--success { background: hsl(142 76% 95%); color: hsl(142 76% 25%); }
.badge--warning { background: hsl(38 92% 95%); color: hsl(38 92% 30%); }
.badge--destructive { background: hsl(0 84% 95%); color: hsl(0 84% 40%); }
.badge--info { background: hsl(221 83% 95%); color: hsl(221 83% 40%); }
.badge::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.badge--outline::before { display: none; }

/* Card */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.card__head { padding: 16px 20px 0; }
.card__head h3 { font-size: 15px; font-weight: 600; }
.card__head p { color: var(--muted-fg); font-size: 13px; margin-top: 2px; }
.card__body { padding: 20px; }
.card__foot { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--muted); display: flex; justify-content: space-between; align-items: center; font-size: 13px; }

/* Stats card */
.stat-card { padding: 16px 20px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.stat-card__label { font-size: 12px; color: var(--muted-fg); display: flex; justify-content: space-between; align-items: center; }
.stat-card__val { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; line-height: 1.2; }
.stat-card__delta { font-size: 11.5px; color: var(--muted-fg); margin-top: 4px; }
.stat-card__delta.up { color: hsl(142 76% 36%); }
.stat-card__delta.down { color: var(--destructive); }

/* Inputs */
.input, .select, .textarea {
  display: block; width: 100%; height: 36px; padding: 0 12px;
  background: var(--bg); border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px); font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { height: auto; min-height: 80px; padding: 8px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px hsl(240 5% 64.9% / 0.2);
}
.label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.help { font-size: 11.5px; color: var(--muted-fg); margin-top: 4px; }
.req { color: var(--destructive); }

/* Table */
.table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 500; color: var(--muted-fg);
  padding: 10px 16px; background: var(--muted);
  border-bottom: 1px solid var(--border);
  font-size: 12px; white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: var(--accent); }
.table tbody tr:last-child td { border-bottom: none; }
.table__num { font-family: "Geist Mono", "JetBrains Mono", monospace; font-size: 12.5px; }
.table__row-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.table tr:hover .table__row-actions { opacity: 1; }

/* Tabs */
.tabs {
  display: flex; gap: 4px; padding: 4px; background: var(--muted);
  border-radius: calc(var(--radius) - 2px); width: fit-content;
}
.tabs__item {
  padding: 6px 12px; font-size: 13px; font-weight: 500;
  border-radius: calc(var(--radius) - 4px); color: var(--muted-fg); cursor: pointer;
}
.tabs__item.active { background: var(--bg); color: var(--fg); box-shadow: 0 1px 2px hsl(240 5% 0% / 0.06); }

/* Filter bar */
.filter-bar {
  display: flex; gap: 8px; align-items: center;
  padding: 12px 16px; background: var(--muted);
  border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px;
}
.filter-bar .input, .filter-bar .select { height: 32px; font-size: 12.5px; background: var(--bg); }

/* Checkbox */
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; border: 1px solid var(--border-strong); border-radius: 3px; }

/* Avatar group */
.avatars { display: flex; }
.avatars > * {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--bg);
  margin-left: -8px; font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 600;
}
.avatars > *:first-child { margin-left: 0; }

/* Placeholder image */
.ph {
  background:
    linear-gradient(135deg, transparent 49.5%, var(--border) 49.5%, var(--border) 50.5%, transparent 50.5%),
    linear-gradient(45deg, transparent 49.5%, var(--border) 49.5%, var(--border) 50.5%, transparent 50.5%),
    var(--muted);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted-fg); font-family: monospace; font-size: 11px;
  border-radius: calc(var(--radius) - 2px);
}

/* Section header inside content */
.section-head { display: flex; justify-content: space-between; align-items: end; margin: 24px 0 12px; }
.section-head h2 { font-size: 16px; font-weight: 600; }
.section-head p { color: var(--muted-fg); font-size: 12.5px; margin-top: 2px; }

/* Pagination */
.pagination { display: flex; gap: 4px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted-fg); justify-content: space-between; }
.pagination__pages { display: flex; gap: 4px; }
.pagination__pages a {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: calc(var(--radius) - 4px);
}
.pagination__pages a.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.pagination__pages a:hover:not(.active) { background: var(--accent); }

/* Empty state pill (used inline) */
.kbd { font-family: monospace; font-size: 11px; padding: 1px 5px; background: var(--muted); border: 1px solid var(--border); border-radius: 4px; }

/* Dividers */
.hr { height: 1px; background: var(--border); margin: 16px 0; }

/* Audit log style */
.audit { font-family: "Geist Mono", "JetBrains Mono", monospace; font-size: 12px; }
.audit__row { display: grid; grid-template-columns: 140px 110px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.audit__row:last-child { border-bottom: none; }
.audit__time { color: var(--muted-fg); }
.audit__actor { color: var(--primary); }
