:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e6ec;
  --text: #18202c;
  --muted: #647082;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #15803d;
  --success-bg: #f0fdf4;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

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

.hidden {
  display: none !important;
}

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

.small {
  font-size: 0.9rem;
  margin-top: 0;
}

.center {
  text-align: center;
}

.mt-16 {
  margin-top: 16px;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85em;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 5px;
  word-break: break-all;
}

/* Auth Screen */
.center-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
}

.auth-card h1 {
  margin: 0 0 4px;
  font-size: 1.45rem;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.hint {
  font-size: 0.85rem;
  margin: 12px 0 0;
  min-height: 1.2em;
}

/* Topbar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 1.05rem;
}

.tabs {
  display: flex;
  gap: 6px;
}

.tab {
  border: none;
  background: transparent;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 0.92rem;
  color: var(--muted);
  cursor: pointer;
}

.tab:hover {
  background: var(--bg);
  color: var(--text);
}

.tab.active {
  background: #eff6ff;
  color: var(--primary);
  font-weight: 600;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

/* Layout */
.container {
  max-width: 1100px;
  margin: 20px auto;
  padding: 0 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.card h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

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

.card-head h2 {
  margin: 0;
}

/* Forms */
.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.88rem;
  min-width: 150px;
  flex: 1;
}

.field-action {
  flex: 0 0 auto;
  min-width: auto;
}

input[type="text"],
input[type="password"],
select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 0.92rem;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid rgba(37, 99, 235, 0.2);
  border-color: var(--primary);
}

.checkbox-group {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 7px 0;
  flex-wrap: wrap;
}

.checkbox-group label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-full {
  width: 100%;
}

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

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

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

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

.btn-secondary:hover:not(:disabled) {
  background: #e2e8f0;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #fecaca;
}

.btn-danger:hover:not(:disabled) {
  background: #fee2e2;
}

/* Upload Area */
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 16px;
  align-items: stretch;
}

@media (max-width: 720px) {
  .upload-grid {
    grid-template-columns: 1fr;
  }
}

.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: 9px;
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone.dragover {
  border-color: var(--primary);
  background: #eff6ff;
  color: var(--primary);
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: space-between;
}

.progress-wrap {
  margin-top: 12px;
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--primary);
  transition: width 0.15s ease;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

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

.badge-public {
  background: var(--success-bg);
  color: var(--success);
}

.badge-private {
  background: #eff6ff;
  color: var(--primary);
}

.badge-active {
  background: var(--success-bg);
  color: var(--success);
}

.badge-used,
.badge-expired,
.badge-revoked {
  background: #f1f5f9;
  color: var(--muted);
}

.badge-timed {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-clickable {
  cursor: pointer;
  border: 1px solid transparent;
}

.badge-clickable:hover {
  border-color: currentColor;
}

/* Secret Output Box */
.secret-box {
  margin-top: 14px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.secret-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.86rem;
}

.secret-row code {
  flex: 1;
  min-width: 180px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.modal-dialog {
  position: relative;
  z-index: 41;
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  overflow-y: auto;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 60;
  background: #1e293b;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.22);
}

.toast.error {
  background: var(--danger);
}
