*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #ffffff;
  --surface: #f9fafb;
  --surface-2: #f3f4f6;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --primary: #f97316;
  --primary-hover: #ea580c;
  --primary-light: #fff7ed;
  --primary-dark: #c2410c;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1 {
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
  color: var(--text);
}

h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: var(--text);
}

code {
  background: var(--surface-2);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
  word-break: break-all;
  color: #ea580c;
}

small {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.55rem 1.15rem;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.02em;
  position: relative;
  top: 0;
  transition: all 0.12s ease;
}

.btn-primary {
  background: linear-gradient(180deg, #fb923c 0%, #f97316 50%, #ea580c 100%);
  color: white;
  box-shadow: 0 3px 0 var(--primary-dark), 0 4px 8px rgba(234, 88, 12, 0.25);
}

.btn-primary:hover {
  top: 1px;
  box-shadow: 0 2px 0 var(--primary-dark), 0 3px 6px rgba(234, 88, 12, 0.2);
  background: linear-gradient(180deg, #fba363 0%, #f97316 50%, #ea580c 100%);
}

.btn-primary:active {
  top: 3px;
  box-shadow: 0 0 0 var(--primary-dark), 0 1px 3px rgba(234, 88, 12, 0.15);
}

.btn-full {
  width: 100%;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  border-radius: 10px;
  box-shadow: 0 4px 0 var(--primary-dark), 0 6px 14px rgba(234, 88, 12, 0.3);
}

.btn-full:hover {
  top: 2px;
  box-shadow: 0 2px 0 var(--primary-dark), 0 4px 10px rgba(234, 88, 12, 0.22);
}

.btn-full:active {
  top: 4px;
  box-shadow: 0 0 0 var(--primary-dark), 0 2px 5px rgba(234, 88, 12, 0.12);
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
}

.form-group input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group {
  flex: 1;
}

/* Cards */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error {
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.25);
  color: var(--danger);
}

.alert-success {
  background: rgba(22, 163, 74, 0.08);
  border: 1px solid rgba(22, 163, 74, 0.25);
  color: var(--success);
}

/* Badge */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-active {
  background: rgba(22, 163, 74, 0.1);
  color: var(--success);
}

.badge-expired {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th {
  text-align: left;
  padding: 0.75rem;
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.data-table tr:hover td {
  background: var(--primary-light);
}

.data-table .row-expired td {
  opacity: 0.5;
}

.data-table .empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

#create-result pre {
  background: var(--surface-2);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.8;
}

/* Toast */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toast-in 0.25s ease, toast-out 0.25s ease 2.5s forwards;
  max-width: 360px;
}

.toast-success {
  background: linear-gradient(180deg, #22c55e, #16a34a);
}

.toast-error {
  background: linear-gradient(180deg, #ef4444, #dc2626);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; }
  to { opacity: 0; transform: translateX(100%); }
}

.app-version {
  position: fixed;
  bottom: 0.5rem;
  right: 1rem;
  font-size: 0.65rem;
  color: #d1d5db;
  pointer-events: none;
  z-index: 999;
  font-family: monospace;
}
