:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #dfe4ec;
  --text: #1c2430;
  --muted: #5f6c80;
  --primary: #0f766e;
  --primary-hover: #0d5f59;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #15803d;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.86rem;
}

.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.brand-header {
  margin-bottom: 20px;
}

.brand-header h1 {
  margin: 8px 0 6px;
  font-size: 1.45rem;
}

.brand-badge {
  display: inline-block;
  background: #ccfbf1;
  color: #115e59;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 3px 9px;
  border-radius: 999px;
}

.brand-badge.warn {
  background: #fef3c7;
  color: #92400e;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tabbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.main-content {
  max-width: 1220px;
  margin: 20px auto;
  padding: 0 20px 48px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}

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

.card-header h2 {
  margin: 0;
  font-size: 1.08rem;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-card .label {
  font-size: 0.84rem;
  color: var(--muted);
}

.stat-card .value {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 6px 0 4px;
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.grid-three {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}

.grid-four {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.stat-pill {
  flex: 1;
  min-width: 90px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
}

.stat-pill strong {
  display: block;
  font-size: 1.35rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.form-group.align-end {
  justify-content: flex-end;
}

label {
  font-size: 0.88rem;
  font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  font-size: 0.94rem;
  background: #fff;
}

.checkbox-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 10px;
}

.inline-form select,
.inline-form input {
  flex: 1;
  min-width: 180px;
}

.btn {
  padding: 8px 15px;
  border-radius: 7px;
  border: 1px solid transparent;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.82rem;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-outline {
  background: #fff;
  border-color: #cbd5e1;
  color: var(--text);
}

.btn-ghost {
  background: #f1f5f9;
  color: var(--text);
}

.btn-warn {
  background: var(--warn);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: #f8fafc;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-ok { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-err { background: #fee2e2; color: #991b1b; }
.badge-neutral { background: #e2e8f0; color: #334155; }

.alert-critical {
  background: #fef2f2;
  border: 2px solid var(--danger);
  color: #7f1d1d;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.error-banner {
  background: #fee2e2;
  color: #991b1b;
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 0.88rem;
}

.info-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin: 10px 0;
}

.secret-once-box {
  background: #fffbeb;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
  word-break: break-all;
}

.secret-once-box code {
  display: block;
  margin-top: 6px;
  font-size: 0.95rem;
  font-weight: 700;
}

.code-block {
  background: #0f172a;
  color: #f8fafc;
  padding: 12px 14px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.88rem;
}

.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #1e293b;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.toast.err {
  background: #b91c1c;
}

.avatar-setting-row {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.avatar-preview-box {
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  border-radius: 16px;
  background: #0f172a;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.avatar-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-setting-controls {
  flex: 1;
  min-width: 240px;
}

.avatar-setting-controls p {
  margin: 0 0 8px;
}
