:root {
  --primary: #5e5ce6;
  --bg-color: #f2f2f7;
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.4);
  --text-main: #1c1c1e;
  --text-muted: #8e8e93;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --blue: #007aff;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-color);
  background-image: 
    radial-gradient(at 0% 0%, rgba(94, 92, 230, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(52, 199, 89, 0.1) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
}

* { box-sizing: border-box; }

.screen { display: none; }
.screen.active { display: block; }

.full-center.active {
  display: flex !important;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
  border-radius: 24px;
  padding: 30px;
}

/* Login Panel */
.login-panel { width: 100%; max-width: 400px; text-align: center; }
.login-panel h2 { margin: 0 0 10px 0; font-weight: 800; }
.login-panel p { color: var(--text-muted); font-size: 14px; margin-bottom: 30px; }

.input-group { text-align: left; margin-bottom: 20px; }
.input-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px;}
.input-group input { width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid rgba(0,0,0,0.1); background: rgba(255,255,255,0.8); font-size: 15px; outline: none; transition: 0.2s; }
.input-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(94, 92, 230, 0.1); }

.primary-btn { width: 100%; padding: 14px; border-radius: 12px; background: var(--text-main); color: white; font-size: 15px; font-weight: 600; border: none; cursor: pointer; transition: 0.2s; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.15); }
.secondary-btn { padding: 10px 16px; border-radius: 10px; background: rgba(0,0,0,0.05); color: var(--text-main); font-weight: 600; border: none; cursor: pointer; transition: 0.2s; }
.secondary-btn:hover { background: rgba(0,0,0,0.1); }

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

/* Dashboard Header */
.glass-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 40px; background: var(--glass-bg); backdrop-filter: blur(20px); border-bottom: 1px solid var(--glass-border); position: sticky; top: 0; z-index: 10; }
.logo { font-size: 20px; font-weight: 800; }
.logo span { color: var(--primary); }

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

/* Action Bar */
.action-bar { display: flex; gap: 40px; align-items: flex-start; padding: 20px 30px; }
.stat-box { text-align: center; }
.stat-box h3 { margin: 0; font-size: 36px; font-weight: 800; color: var(--primary); }
.stat-box p { margin: 5px 0 0 0; font-size: 13px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }

.create-form { flex: 1; border-left: 1px solid rgba(0,0,0,0.1); padding-left: 40px; }
.create-form h4 { margin: 0 0 15px 0; font-size: 16px; }

/* Form field groups with labels */
.form-row { display: flex; gap: 15px; align-items: flex-end; }
.form-field { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.form-field input,
.form-field select { 
  width: 100%; 
  padding: 12px; 
  border-radius: 10px; 
  border: 1px solid rgba(0,0,0,0.1); 
  background: rgba(255,255,255,0.8); 
  outline: none; 
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-field input:focus,
.form-field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(94, 92, 230, 0.1);
}
.form-row .primary-btn { width: auto; padding: 12px 24px; white-space: nowrap; }

/* Table */
.table-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.table-header h3 { margin: 0; }

.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 15px 16px; font-size: 13px; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid rgba(0,0,0,0.1); text-transform: uppercase; white-space: nowrap; }
td { padding: 16px; font-size: 14px; border-bottom: 1px solid rgba(0,0,0,0.05); vertical-align: middle; }

.badge { padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.Active { background: rgba(52, 199, 89, 0.15); color: var(--green); }
.badge.Revoked { background: rgba(255, 59, 48, 0.15); color: var(--red); }
.badge.Expired { background: rgba(255, 59, 48, 0.12); color: #d32f2f; }

.pkg-badge { padding: 4px 10px; border-radius: 8px; font-size: 12px; font-weight: 600; background: rgba(0,0,0,0.05); color: #555; white-space: nowrap; }
.pkg-badge.Starter { background: #e3f2fd; color: #1976d2; }
.pkg-badge.Growth { background: #e8eaf6; color: #3f51b5; }
.pkg-badge.Scale { background: #f3e5f5; color: #9c27b0; }
.pkg-badge.Unlimited { background: #fff3e0; color: #e65100; }

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

/* Notes cell */
.notes-cell { 
  max-width: 180px; 
  font-size: 13px; 
  color: #555; 
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
}

/* Action buttons — icon style */
.action-links { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
}
.action-btn svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}
.action-btn.revoke-btn {
  background: rgba(255, 59, 48, 0.1);
  color: var(--red);
}
.action-btn.revoke-btn:hover {
  background: rgba(255, 59, 48, 0.2);
  transform: translateY(-1px);
}
.action-btn.activate-btn {
  background: rgba(52, 199, 89, 0.1);
  color: var(--green);
}
.action-btn.activate-btn:hover {
  background: rgba(52, 199, 89, 0.2);
  transform: translateY(-1px);
}
.action-btn.unbind-btn {
  background: rgba(255, 149, 0, 0.1);
  color: #e68a00;
}
.action-btn.unbind-btn:hover {
  background: rgba(255, 149, 0, 0.2);
  transform: translateY(-1px);
}
.action-btn.detail-btn {
  background: rgba(0, 122, 255, 0.1);
  color: var(--blue);
}
.action-btn.detail-btn:hover {
  background: rgba(0, 122, 255, 0.2);
  transform: translateY(-1px);
}

/* Shop tags — collapsible with tooltip */
.shops-list {
  font-size: 12px; 
  color: #555; 
  line-height: 1.6;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  max-width: 220px;
}
.shops-list .shop-tag { 
  display: inline-block; 
  background: white; 
  padding: 3px 8px; 
  border-radius: 6px; 
  border: 1px solid #e0e0e0; 
  font-size: 11px;
  font-weight: 500;
  color: #444;
  white-space: nowrap;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.shops-list .shop-more {
  display: inline-flex;
  align-items: center;
  background: rgba(94, 92, 230, 0.08);
  color: var(--primary);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid rgba(94, 92, 230, 0.15);
  position: relative;
  transition: background 0.2s;
}
.shops-list .shop-more:hover {
  background: rgba(94, 92, 230, 0.15);
}
.shops-count {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 4px;
  width: 100%;
}

/* Tooltip for showing all shops */
.shop-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-main);
  color: white;
  padding: 10px 14px;
  border-radius: 10px;
  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-main);
}
.shop-more:hover .shop-tooltip {
  display: block;
}

/* ============================================================
   DETAIL MODAL — Glassmorphism + Timeline
   ============================================================ */

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 40px;
  animation: modalFadeIn 0.25s ease;
}

.modal-overlay.active {
  display: flex;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-panel {
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
  animation: modalSlideUp 0.3s ease;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.modal-panel::-webkit-scrollbar {
  width: 6px;
}
.modal-panel::-webkit-scrollbar-track {
  background: transparent;
}
.modal-panel::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 3px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.modal-close-btn {
  background: rgba(0,0,0,0.05);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.2s;
}
.modal-close-btn:hover {
  background: rgba(255, 59, 48, 0.1);
  color: var(--red);
}

/* Modal Info Grid */
.modal-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.info-item {
  background: rgba(0,0,0,0.03);
  padding: 12px 16px;
  border-radius: 12px;
}

.info-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.info-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  word-break: break-all;
}

/* Modal Sections */
.modal-section {
  margin-bottom: 24px;
}

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

/* Notes edit area */
.notes-edit-area {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.notes-edit-area textarea {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(255,255,255,0.8);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 60px;
}

.notes-edit-area textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(94, 92, 230, 0.1);
}

.notes-edit-area .action-btn {
  padding: 10px 18px;
  flex-shrink: 0;
}

/* History add form */
.history-add-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.history-add-form select,
.history-add-form input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(255,255,255,0.8);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.history-add-form select { width: 160px; 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 rgba(94, 92, 230, 0.1);
}

.history-add-form .action-btn {
  padding: 10px 18px;
  flex-shrink: 0;
}

/* ============================================================
   TIMELINE — Vertical dot & line
   ============================================================ */

.timeline {
  position: relative;
  padding-left: 36px;
  max-height: 300px;
  overflow-y: auto;
}

.timeline::-webkit-scrollbar {
  width: 4px;
}
.timeline::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.1);
  border-radius: 2px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, rgba(94, 92, 230, 0.3), rgba(94, 92, 230, 0.05));
  border-radius: 1px;
}

.timeline-item {
  position: relative;
  padding: 10px 0 20px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -30px;
  top: 12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  z-index: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Color-code timeline dots by action type */
.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: #4caf50; }
.timeline-item.renewed .timeline-dot { border-color: var(--blue); }
.timeline-item.upgraded .timeline-dot { border-color: #9c27b0; }
.timeline-item.downgraded .timeline-dot { border-color: #795548; }

.timeline-content {
  background: rgba(0,0,0,0.03);
  padding: 12px 16px;
  border-radius: 12px;
  transition: background 0.2s;
}

.timeline-content:hover {
  background: rgba(0,0,0,0.05);
}

.timeline-action {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.timeline-detail {
  font-size: 12px;
  color: #555;
  line-height: 1.5;
}

.timeline-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 500;
}

.timeline-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 20px;
}

/* ============================================================
   SHOPS MANAGEMENT — Selective Unbind
   ============================================================ */

.shops-manage-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0,0,0,0.03);
  padding: 10px 14px;
  border-radius: 10px;
  transition: background 0.2s;
}

.shop-item:hover {
  background: rgba(0,0,0,0.06);
}

.shop-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
}

.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(255, 59, 48, 0.08);
  color: var(--red);
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
}

.shop-unbind-btn svg {
  width: 12px;
  height: 12px;
}

.shop-unbind-btn:hover {
  background: rgba(255, 59, 48, 0.18);
  transform: translateY(-1px);
}

.shop-unbind-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.shops-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 16px;
  background: rgba(0,0,0,0.02);
  border-radius: 10px;
}

.unbind-all-btn {
  justify-content: center;
  padding: 10px !important;
  font-size: 12px !important;
}
