@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap');

* { box-sizing: border-box; }

:root {
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-bg-strong: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.35);
  --text-primary: #1c1c1e;
  --text-secondary: #6e6e73;
  --accent: #0a84ff;
  --accent-2: #5e5ce6;
  --success: #30d158;
  --danger: #ff453a;
  --warning: #ff9f0a;
  --radius: 22px;
}

html, body {
  margin: 0;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
  font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
  direction: rtl;
  color: var(--text-primary);
  background:
    radial-gradient(circle at 15% 20%, #a9c9ff 0%, transparent 45%),
    radial-gradient(circle at 85% 15%, #ffd6e8 0%, transparent 40%),
    radial-gradient(circle at 50% 90%, #b9fbc0 0%, transparent 45%),
    linear-gradient(135deg, #eef2ff 0%, #f7f7fb 50%, #fdf2f8 100%);
  background-attachment: fixed;
}

.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}
.bg-orbs span {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.5;
  animation: float 18s ease-in-out infinite;
}
.bg-orbs span:nth-child(1) { width: 380px; height: 380px; background: #93c5fd; top: -100px; left: -80px; }
.bg-orbs span:nth-child(2) { width: 320px; height: 320px; background: #f9a8d4; bottom: -80px; right: -60px; animation-delay: -6s; }
.bg-orbs span:nth-child(3) { width: 260px; height: 260px; background: #86efac; top: 40%; right: 20%; animation-delay: -12s; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, -40px) scale(1.08); }
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.12), inset 0 1px 0 rgba(255,255,255,0.5);
}

.glass-strong {
  background: var(--glass-bg-strong);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.14), inset 0 1px 0 rgba(255,255,255,0.6);
}

.app-shell {
  max-width: 1180px;
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 20px;
}
.brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px rgba(10,132,255,0.6);
}

.welcome-line { color: var(--text-secondary); font-size: 14px; margin-top: 2px; }

.btn {
  border: none;
  border-radius: 14px;
  padding: 11px 20px;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  box-shadow: 0 6px 18px rgba(10,132,255,0.35);
}
.btn-primary:hover { box-shadow: 0 8px 22px rgba(10,132,255,0.45); }
.btn-ghost {
  background: rgba(120,120,128,0.12);
  color: var(--text-primary);
}
.btn-ghost:hover { background: rgba(120,120,128,0.2); }
.btn-danger {
  background: rgba(255,69,58,0.12);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(255,69,58,0.2); }
.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  padding: 22px 24px;
}
.stat-card .label { color: var(--text-secondary); font-size: 13px; margin-bottom: 6px; }
.stat-card .value { font-size: 28px; font-weight: 800; }
.stat-card .value.accent { color: var(--accent); }
.stat-card .value.success { color: var(--success); }
.stat-card .value.warning { color: var(--warning); }

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 8px;
  background: rgba(120,120,128,0.15);
  overflow: hidden;
  margin-top: 10px;
}
.progress-fill {
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.4s ease;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 6px;
  margin-bottom: 20px;
  width: fit-content;
}
.tab-btn {
  border: none;
  background: transparent;
  padding: 10px 20px;
  border-radius: 14px;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}
.tab-btn.active {
  background: white;
  color: var(--text-primary);
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}

.panel-section { padding: 26px; margin-bottom: 20px; }
.panel-section h2 { margin: 0 0 18px; font-size: 18px; }

table { width: 100%; border-collapse: collapse; min-width: 560px; }
th, td { text-align: right; padding: 12px 10px; font-size: 14px; }
thead th { color: var(--text-secondary); font-weight: 600; font-size: 13px; border-bottom: 1px solid rgba(120,120,128,0.18); white-space: nowrap; }
tbody tr { border-bottom: 1px solid rgba(120,120,128,0.1); }
tbody tr:hover { background: rgba(120,120,128,0.05); }
td { white-space: nowrap; }
td:first-child, th:first-child { white-space: normal; }

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}
.badge-online { background: rgba(48,209,88,0.15); color: #22a446; }

.online-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #d0d0d5;
  margin-inline-end: 6px;
  vertical-align: middle;
}
.online-dot.is-online {
  background: #30d158;
  box-shadow: 0 0 0 0 rgba(48,209,88,0.6);
  animation: onlinePulse 1.6s ease-out infinite;
}
@keyframes onlinePulse {
  0% { box-shadow: 0 0 0 0 rgba(48,209,88,0.55); }
  70% { box-shadow: 0 0 0 8px rgba(48,209,88,0); }
  100% { box-shadow: 0 0 0 0 rgba(48,209,88,0); }
}

.badge-expired-time { background: rgba(255,69,58,0.15); color: var(--danger); }
.badge-expired-volume { background: rgba(255,69,58,0.15); color: var(--danger); }
.badge-offline { background: rgba(255,69,58,0.15); color: var(--danger); }
.badge-unknown { background: rgba(120,120,128,0.15); color: var(--text-secondary); }
.badge-pending { background: rgba(255,159,10,0.15); color: #b06d00; }
.badge-approved { background: rgba(48,209,88,0.15); color: #22a446; }
.badge-rejected { background: rgba(255,69,58,0.15); color: var(--danger); }

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.25);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  width: 92%; max-width: 460px;
  padding: 28px;
  max-height: 88vh;
  overflow-y: auto;
  animation: popIn 0.25s cubic-bezier(0.2, 0.8, 0.3, 1.2);
}
@keyframes popIn { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-box h3 { margin: 0 0 18px; font-size: 18px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(120,120,128,0.2);
  background: rgba(255,255,255,0.6);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: border 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(10,132,255,0.12);
}
.field .hint { font-size: 12px; color: var(--text-secondary); margin-top: 5px; }

.checkbox-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(120,120,128,0.1);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  border: 1.5px solid transparent;
  transition: all 0.15s ease;
}
.chip.selected {
  background: rgba(10,132,255,0.14);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.toast-container {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 2000;
  display: flex; flex-direction: column; gap: 10px;
  align-items: center;
}
.toast {
  padding: 12px 22px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  color: white;
  animation: slideUp 0.25s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.toast.success { background: linear-gradient(135deg, #30d158, #22a446); }
.toast.error { background: linear-gradient(135deg, #ff453a, #d92c22); }
.toast.info { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-secondary); }

.icon-btn {
  border: none; background: rgba(120,120,128,0.1);
  width: 34px; height: 34px; border-radius: 10px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; margin-inline-start: 6px;
  transition: background 0.15s ease;
}
.icon-btn:hover { background: rgba(120,120,128,0.2); }

/* Login page */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  padding: 40px 32px;
  text-align: center;
}
.login-card .logo {
  width: 64px; height: 64px; border-radius: 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  margin: 0 auto 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: white; font-weight: 800;
  box-shadow: 0 10px 28px rgba(10,132,255,0.35);
}
.login-card h1 { font-size: 22px; margin: 0 0 6px; }
.login-card p.subtitle { color: var(--text-secondary); font-size: 14px; margin: 0 0 26px; }
.login-card .field { text-align: right; }
.login-card .btn-primary { width: 100%; padding: 13px; margin-top: 8px; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }

@media (max-width: 640px) {
  .app-shell { padding: 16px 10px 40px; }
  .top-header { flex-direction: column; align-items: stretch; gap: 12px; padding: 16px 18px; }
  .top-header > div:last-child { display: flex; gap: 8px; }
  .top-header .btn { flex: 1; }
  .brand { font-size: 17px; }

  .tabs { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-btn { padding: 9px 14px; font-size: 13px; white-space: nowrap; }

  .stat-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 16px 14px; }
  .stat-card .value { font-size: 20px; }
  .stat-card .label { font-size: 12px; }

  .panel-section { padding: 16px; }
  .panel-section h2 { font-size: 16px; }

  table { min-width: 620px; }
  th, td { padding: 10px 8px; font-size: 13px; }

  .modal-box { width: 94%; padding: 20px; max-height: 86vh; overflow-y: auto; }
  .modal-box h3 { font-size: 16px; }

  .grid-2 { grid-template-columns: 1fr; gap: 0; }

  .field input, .field select, .field textarea { padding: 11px 12px; font-size: 16px; }

  td .btn, td .icon-btn { margin-bottom: 4px; }
  td { white-space: normal; }

  .login-card { padding: 32px 22px; }
}

@media (max-width: 400px) {
  .stat-cards { grid-template-columns: 1fr; }
}
