:root {
  --primary: #6366f1;
  --primary-light: rgba(99, 102, 241, 0.08);
  --bg: #f8f9fc;
  --card-bg: #ffffff;
  --card-border: rgba(0,0,0,0.06);
  --card-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 20px rgba(0,0,0,0.03);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.06), 0 8px 30px rgba(0,0,0,0.04);
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --green: #10b981;
  --red: #ef4444;
  --orange: #f59e0b;
  --blue: #3b82f6;
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Screens ── */
.screen { display: none; opacity: 0; transition: opacity 0.3s ease; }
.screen.active { display: block; opacity: 1; }
.full-center.active { display: flex !important; align-items: center; justify-content: center; height: 100vh; background: linear-gradient(135deg, #f0f0ff 0%, #f8f9fc 50%, #f0fdf4 100%); }

/* ── Cards ── */
.glass-panel {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius);
  padding: 28px;
  transition: box-shadow var(--transition), transform var(--transition);
}

/* ── Login ── */
.login-panel { width: 100%; max-width: 420px; text-align: center; padding: 40px; }
.login-panel h2 { font-size: 24px; font-weight: 800; margin-bottom: 8px; color: var(--text); }
.login-panel > p { color: var(--text-secondary); font-size: 14px; margin-bottom: 32px; }

.input-group { text-align: left; margin-bottom: 20px; }
.input-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.input-group input {
  width: 100%; padding: 13px 16px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--bg);
  font-size: 14px; font-family: inherit; outline: none; transition: all var(--transition);
}
.input-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); background: #fff; }

.primary-btn {
  width: 100%; padding: 13px 24px; border-radius: var(--radius-sm);
  background: var(--primary); color: white; font-size: 14px; font-weight: 600;
  border: none; cursor: pointer; font-family: inherit;
  transition: all var(--transition); box-shadow: 0 2px 8px rgba(99,102,241,0.25);
}
.primary-btn:hover { background: #4f46e5; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(99,102,241,0.35); }
.primary-btn:active { transform: translateY(0); }
.primary-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.secondary-btn {
  padding: 10px 18px; border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text); font-weight: 600; font-size: 13px;
  border: 1.5px solid var(--border); cursor: pointer; font-family: inherit;
  transition: all var(--transition);
}
.secondary-btn:hover { background: #fff; border-color: var(--primary); color: var(--primary); }

.error-msg { color: var(--red); font-size: 13px; margin-top: 16px; display: none; font-weight: 500; }

/* ── Header ── */
.glass-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 40px; background: rgba(255,255,255,0.85);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--card-border);
  position: sticky; top: 0; z-index: 10;
}
.logo { font-size: 18px; font-weight: 800; letter-spacing: -0.3px; }
.logo span { color: var(--primary); }
.icon-btn {
  padding: 8px 18px; border-radius: var(--radius-sm); background: transparent;
  border: 1.5px solid var(--border); color: var(--text-secondary); font-weight: 600;
  font-size: 13px; cursor: pointer; font-family: inherit; transition: all var(--transition);
}
.icon-btn:hover { border-color: var(--red); color: var(--red); background: rgba(239,68,68,0.04); }

.dashboard-content { padding: 32px 40px; max-width: 1440px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }

/* ── Stats Row ── */
.stats-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
}
@media (max-width: 900px) { .stats-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .stats-row { grid-template-columns: 1fr; } }

.stat-box {
  display: flex; align-items: center; gap: 16px; padding: 22px 24px;
}
.stat-box:hover { transform: translateY(-2px); box-shadow: var(--card-shadow-hover); }

.stat-icon {
  width: 48px; height: 48px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.blue { background: rgba(59,130,246,0.1); }
.stat-icon.green { background: rgba(16,185,129,0.1); }
.stat-icon.orange { background: rgba(245,158,11,0.1); }
.stat-icon.red { background: rgba(239,68,68,0.1); }

.stat-box h3 { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1; letter-spacing: -0.5px; }
.stat-box p { margin-top: 4px; font-size: 12px; color: var(--text-secondary); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }

/* ── Create Form ── */
.create-form-section { padding: 28px 30px; }
.create-form-section h4 { font-size: 16px; font-weight: 700; margin-bottom: 20px; color: var(--text); }

.form-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.form-field { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.4px; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--bg);
  font-size: 14px; font-family: inherit; outline: none; transition: all var(--transition);
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); background: #fff;
}
.form-field textarea { resize: vertical; }
.form-row .primary-btn, .generate-btn { width: auto; padding: 12px 28px; white-space: nowrap; flex-shrink: 0; }

/* ── Table Section ── */
.table-section { padding: 28px 30px; }
.table-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 16px; }
.table-header h3 { font-size: 16px; font-weight: 700; }

.table-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search-box { position: relative; }
.search-box .search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 14px; opacity: 0.4; pointer-events: none; }
.search-box input {
  padding: 10px 14px 10px 38px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--bg);
  font-size: 13px; outline: none; width: 280px; font-family: inherit;
  transition: all var(--transition);
}
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); background: #fff; }

.filter-select {
  padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--bg);
  font-size: 13px; outline: none; font-family: inherit; cursor: pointer;
  transition: all var(--transition);
}
.filter-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.table-wrapper { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; text-align: left; }
thead { background: var(--bg); }
th { padding: 12px 16px; font-size: 11px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; border-bottom: 1.5px solid var(--border); }
td { padding: 14px 16px; font-size: 13px; border-bottom: 1px solid rgba(0,0,0,0.04); vertical-align: middle; transition: background var(--transition); }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: rgba(99,102,241,0.02); }
tbody tr:last-child td { border-bottom: none; }

/* Skeleton Loader */
.skeleton-box {
  height: 18px; border-radius: 6px;
  background: linear-gradient(90deg, #f0f0f0 25%, #fafafa 50%, #f0f0f0 75%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Badges */
.badge { padding: 5px 12px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; letter-spacing: 0.2px; }
.badge.Active { background: rgba(16,185,129,0.1); color: var(--green); }
.badge.Revoked { background: rgba(239,68,68,0.1); color: var(--red); }
.badge.Expired { background: rgba(239,68,68,0.08); color: #dc2626; }

.pkg-badge { padding: 4px 10px; border-radius: 8px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.pkg-badge.Starter { background: #eff6ff; color: #2563eb; }
.pkg-badge.Growth { background: #eef2ff; color: #4f46e5; }
.pkg-badge.Scale { background: #faf5ff; color: #9333ea; }
.pkg-badge.Unlimited { background: #fff7ed; color: #ea580c; }

.text-muted { color: var(--text-secondary); }
.notes-cell { max-width: 160px; font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Action Buttons */
.action-links { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }
.action-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 7px 14px; border-radius: 8px; font-size: 12px; font-weight: 600;
  border: none; cursor: pointer; transition: all var(--transition);
  white-space: nowrap; font-family: inherit;
}
.action-btn svg { width: 13px; height: 13px; flex-shrink: 0; }
.action-btn.revoke-btn { background: rgba(239,68,68,0.08); color: var(--red); }
.action-btn.revoke-btn:hover { background: rgba(239,68,68,0.15); transform: translateY(-1px); }
.action-btn.activate-btn { background: rgba(16,185,129,0.08); color: var(--green); }
.action-btn.activate-btn:hover { background: rgba(16,185,129,0.15); transform: translateY(-1px); }
.action-btn.unbind-btn { background: rgba(245,158,11,0.08); color: #d97706; }
.action-btn.unbind-btn:hover { background: rgba(245,158,11,0.15); transform: translateY(-1px); }
.action-btn.detail-btn { background: var(--primary-light); color: var(--primary); }
.action-btn.detail-btn:hover { background: rgba(99,102,241,0.15); transform: translateY(-1px); }

/* Shop Tags */
.shops-list { font-size: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; max-width: 200px; }
.shop-tag { display: inline-block; background: var(--bg); padding: 3px 8px; border-radius: 6px; border: 1px solid var(--border); font-size: 11px; font-weight: 500; color: var(--text); white-space: nowrap; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.shop-more { display: inline-flex; align-items: center; background: var(--primary-light); color: var(--primary); padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; cursor: pointer; border: 1px solid rgba(99,102,241,0.12); position: relative; transition: background var(--transition); }
.shop-more:hover { background: rgba(99,102,241,0.12); }
.shops-count { display: block; font-size: 11px; color: var(--text-secondary); font-weight: 500; margin-top: 4px; width: 100%; }

.shop-tooltip { display: none; position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); background: var(--text); color: white; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 11px; line-height: 1.8; white-space: nowrap; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,0.2); pointer-events: none; }
.shop-tooltip::after { content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--text); }
.shop-more:hover .shop-tooltip { display: block; }

/* ── Modal ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.35); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  z-index: 1000; align-items: center; justify-content: center; padding: 32px;
}
.modal-overlay.active { display: flex; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

.modal-panel {
  width: 100%; max-width: 640px; max-height: 85vh; overflow-y: auto;
  animation: slideUp 0.25s ease; padding: 32px;
}
.modal-panel::-webkit-scrollbar { width: 5px; }
.modal-panel::-webkit-scrollbar-track { background: transparent; }
.modal-panel::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 3px; }

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close-btn { background: var(--bg); border: none; width: 34px; height: 34px; border-radius: var(--radius-sm); font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); transition: all var(--transition); }
.modal-close-btn:hover { background: rgba(239,68,68,0.08); color: var(--red); }

.modal-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 24px; }
.info-item { background: var(--bg); padding: 12px 16px; border-radius: 12px; }
.info-label { display: block; font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 5px; }
.info-value { font-size: 14px; font-weight: 500; color: var(--text); word-break: break-all; }

.modal-section { margin-bottom: 24px; }
.modal-section h4 { margin: 0 0 14px 0; font-size: 14px; font-weight: 700; color: var(--text); }

/* Change package / Notes / Password */
.change-pkg-area, .notes-edit-area { display: flex; gap: 10px; align-items: flex-start; }
.change-pkg-area select, .change-pkg-area input, .notes-edit-area textarea, .notes-edit-area input {
  flex: 1; padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--bg);
  font-family: inherit; font-size: 13px; outline: none; transition: all var(--transition);
}
.change-pkg-area select:focus, .change-pkg-area input:focus, .notes-edit-area textarea:focus, .notes-edit-area input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); background: #fff; }
.notes-edit-area textarea { resize: vertical; min-height: 56px; }
.change-pkg-area .action-btn, .notes-edit-area .action-btn { padding: 11px 18px; flex-shrink: 0; }

.section-hint { font-size: 11px; color: var(--text-secondary); margin-top: 8px; line-height: 1.5; }
.section-hint a { color: var(--primary); text-decoration: none; font-weight: 600; }
.section-hint a:hover { text-decoration: underline; }

.password-display { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.password-current { font-size: 13px; font-weight: 500; color: var(--text); background: var(--bg); padding: 8px 14px; border-radius: var(--radius-sm); flex: 1; font-family: 'Courier New', monospace; letter-spacing: 0.5px; }
.password-empty { color: var(--text-secondary); font-style: italic; font-family: inherit; letter-spacing: 0; }

/* History form */
.history-add-form { display: flex; gap: 10px; align-items: center; }
.history-add-form select, .history-add-form input {
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--bg);
  font-family: inherit; font-size: 13px; outline: none; transition: all var(--transition);
}
.history-add-form select { width: 150px; flex-shrink: 0; }
.history-add-form input { flex: 1; }
.history-add-form select:focus, .history-add-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.history-add-form .action-btn { padding: 10px 18px; flex-shrink: 0; }

/* ── Timeline ── */
.timeline { position: relative; padding-left: 36px; max-height: 280px; overflow-y: auto; }
.timeline::-webkit-scrollbar { width: 4px; }
.timeline::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.08); border-radius: 2px; }
.timeline::before { content: ''; position: absolute; left: 15px; top: 0; bottom: 0; width: 2px; background: linear-gradient(to bottom, rgba(99,102,241,0.25), rgba(99,102,241,0.03)); border-radius: 1px; }

.timeline-item { position: relative; padding: 8px 0 20px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot { position: absolute; left: -30px; top: 10px; width: 22px; height: 22px; border-radius: 50%; background: white; border: 2px solid var(--primary); display: flex; align-items: center; justify-content: center; font-size: 11px; z-index: 1; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }

.timeline-item.created .timeline-dot { border-color: var(--green); }
.timeline-item.revoked .timeline-dot { border-color: var(--red); }
.timeline-item.activated .timeline-dot { border-color: var(--green); }
.timeline-item.unbind .timeline-dot { border-color: var(--orange); }
.timeline-item.payment .timeline-dot { border-color: #059669; }
.timeline-item.renewed .timeline-dot { border-color: var(--blue); }
.timeline-item.upgraded .timeline-dot { border-color: #7c3aed; }
.timeline-item.downgraded .timeline-dot { border-color: #78716c; }

.timeline-content { background: var(--bg); padding: 12px 16px; border-radius: 12px; transition: background var(--transition); }
.timeline-content:hover { background: rgba(0,0,0,0.04); }
.timeline-action { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.timeline-detail { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
.timeline-date { font-size: 11px; color: var(--text-secondary); margin-top: 5px; font-weight: 500; }
.timeline-empty { text-align: center; color: var(--text-secondary); font-size: 13px; padding: 20px; }

/* Shops Management */
.shops-manage-list { display: flex; flex-direction: column; gap: 8px; }
.shop-item { display: flex; align-items: center; justify-content: space-between; background: var(--bg); padding: 10px 14px; border-radius: var(--radius-sm); transition: background var(--transition); }
.shop-item:hover { background: rgba(0,0,0,0.04); }
.shop-item-name { font-size: 13px; font-weight: 500; }
.shop-unbind-btn { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 6px; font-size: 11px; font-weight: 600; border: none; cursor: pointer; background: rgba(239,68,68,0.06); color: var(--red); transition: all var(--transition); font-family: inherit; }
.shop-unbind-btn svg { width: 12px; height: 12px; }
.shop-unbind-btn:hover { background: rgba(239,68,68,0.14); transform: translateY(-1px); }
.shop-unbind-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.shops-empty { text-align: center; color: var(--text-secondary); font-size: 13px; padding: 16px; background: var(--bg); border-radius: var(--radius-sm); }
.unbind-all-btn { justify-content: center; padding: 10px !important; font-size: 12px !important; }

/* ── Toast ── */
.toast-container { position: fixed; top: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 9999; pointer-events: none; }
.toast {
  background: #fff; border-radius: 12px; padding: 14px 18px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.1), 0 1px 3px rgba(0,0,0,0.06);
  border-left: 4px solid var(--primary);
  transform: translateX(120%); opacity: 0;
  transition: all 0.35s cubic-bezier(0.68, -0.3, 0.265, 1.35);
  pointer-events: auto; min-width: 260px;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast-success { border-left-color: var(--green); }
.toast-error { border-left-color: var(--red); }
.toast-warning { border-left-color: var(--orange); }
.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast-message { font-size: 13px; font-weight: 500; color: var(--text); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .dashboard-content { padding: 20px 16px; }
  .glass-header { padding: 14px 20px; }
  .form-row { flex-direction: column; }
  .form-row .primary-btn { width: 100%; }
  .table-header { flex-direction: column; align-items: stretch; }
  .table-actions { flex-direction: column; }
  .search-box input { width: 100%; }
  .modal-overlay { padding: 16px; }
}
