:root {
  --bg-dark: #090d16;
  --card-bg: rgba(17, 24, 39, 0.85);
  --card-border: rgba(255, 255, 255, 0.08);
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --primary-glow: rgba(56, 189, 248, 0.25);
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-blue: #6366f1;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(99, 102, 241, 0.08) 0px, transparent 50%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: Consolas, Monaco, "JetBrains Mono", "Courier New", monospace;
}

.app-layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Top Nav */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0284c7, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 12px var(--primary-glow);
  flex-shrink: 0;
}

.brand-icon svg {
  width: 22px;
  height: 22px;
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.brand-text h1 span {
  color: var(--primary);
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.nav-metrics {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.metric-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
}

.time-pill {
  font-family: Consolas, Monaco, "JetBrains Mono", monospace;
  color: var(--primary);
  font-weight: 600;
}

.user-pill {
  color: #a5b4fc;
  gap: 0.5rem;
}

.btn-logout {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.72rem;
  cursor: pointer;
  margin-left: 0.25rem;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.4);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.grid-col {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-icon {
  font-size: 1.1rem;
}

.header-title h3 {
  font-size: 1rem;
  font-weight: 700;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.offline {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
  border-color: rgba(239, 68, 68, 0.3);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.call-mode-tag {
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border-radius: 6px;
  font-weight: 600;
}

/* Device Metrics */
.device-metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.metric-item {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--card-border);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.metric-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.metric-val {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.highlight-blue {
  color: #60a5fa;
}

/* Dial Input & Numpad */
.dial-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.dial-input-wrap input {
  width: 100%;
  padding: 0.8rem 2.2rem 0.8rem 1rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  color: white;
  font-size: 1.1rem;
  font-family: Consolas, Monaco, "JetBrains Mono", monospace;
  letter-spacing: 0.5px;
  outline: none;
  transition: all 0.2s ease;
}

.dial-input-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.clear-btn {
  position: absolute;
  right: 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.25rem;
}

.clear-btn:hover {
  color: white;
}

.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.num-key {
  padding: 0.75rem 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 1.15rem;
  font-family: Consolas, Monaco, "JetBrains Mono", monospace;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.num-key:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.num-key:active {
  transform: translateY(1px);
}

/* Action Buttons */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary-call {
  width: 100%;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: white;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-primary-call:hover {
  background: linear-gradient(135deg, #0ea5e9, #3b82f6);
  transform: translateY(-1px);
}

.btn-hangup {
  width: 100%;
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: white;
  box-shadow: 0 4px 16px rgba(220, 38, 38, 0.3);
}

/* In-Call Active Banner */
.active-call-banner {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.call-timer {
  font-family: Consolas, Monaco, "JetBrains Mono", monospace;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-green);
}

.call-wave-anim {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 18px;
}

.call-wave-anim span {
  width: 3px;
  background: var(--accent-green);
  border-radius: 2px;
  animation: wave 1s ease-in-out infinite;
}

.call-wave-anim span:nth-child(1) { height: 6px; animation-delay: 0.1s; }
.call-wave-anim span:nth-child(2) { height: 14px; animation-delay: 0.2s; }
.call-wave-anim span:nth-child(3) { height: 18px; animation-delay: 0.3s; }
.call-wave-anim span:nth-child(4) { height: 12px; animation-delay: 0.4s; }
.call-wave-anim span:nth-child(5) { height: 8px; animation-delay: 0.5s; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.4); }
  50% { transform: scaleY(1.2); }
}

/* Tabs Card */
.tabs-card {
  padding: 0;
  overflow: hidden;
}

.tabs-header {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid var(--card-border);
  overflow-x: auto;
}

.tab-btn {
  padding: 0.95rem 1.4rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
  transition: all 0.2s;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(56, 189, 248, 0.06);
}

.tab-count {
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.1rem 0.45rem;
  border-radius: 10px;
}

.tab-pane {
  display: none;
  padding: 1.25rem;
}

.tab-pane.active {
  display: block;
}

.pane-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
}

.pane-title {
  font-size: 0.95rem;
  font-weight: 700;
}

.btn-refresh {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  cursor: pointer;
}

.btn-refresh:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Data Table */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.2);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.82rem;
  white-space: nowrap;
}

.data-table th {
  background: rgba(0, 0, 0, 0.4);
  color: var(--text-muted);
  padding: 0.75rem 0.9rem;
  font-weight: 600;
  border-bottom: 1px solid var(--card-border);
}

.data-table td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.empty-hint {
  text-align: center;
  color: var(--text-muted);
  padding: 2.5rem !important;
}

/* SMS Composer */
.sms-composer {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--card-border);
  padding: 1.1rem;
  border-radius: var(--radius-md);
}

.sms-composer h4 {
  margin-bottom: 0.65rem;
  font-size: 0.9rem;
}

.sms-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.form-input, .form-textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: white;
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
}

.form-input:focus, .form-textarea:focus {
  border-color: var(--primary);
}

.btn-send-sms {
  align-self: flex-end;
  background: var(--accent-blue);
  color: white;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
}

.btn-send-sms:hover {
  background: #4f46e5;
}

.sms-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 260px;
  overflow-y: auto;
}

.sms-item {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--card-border);
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.sms-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Deploy Guide */
.deploy-guide {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.deploy-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.guide-steps {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.step-card {
  display: flex;
  gap: 0.85rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--card-border);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  align-items: center;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-glow);
  color: var(--primary);
  font-weight: 800;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-content h5 {
  font-size: 0.88rem;
  margin-bottom: 0.3rem;
}

.step-content code {
  background: rgba(0, 0, 0, 0.5);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  color: #38bdf8;
  font-family: Consolas, Monaco, "JetBrains Mono", monospace;
  font-size: 0.82rem;
}

/* Admin Login Modal */
.login-modal {
  max-width: 360px;
}

.login-brand-icon {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: linear-gradient(135deg, #0284c7, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.login-brand-icon svg {
  width: 28px;
  height: 28px;
}

.login-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  width: 100%;
  margin-top: 0.5rem;
}

/* Incoming Call Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.glass-modal {
  background: #111827;
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 2rem;
  border-radius: var(--radius-lg);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  max-width: 380px;
  width: 90%;
}

.incoming-ring-anim {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-green);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse-ring 1.2s infinite;
}

.incoming-ring-anim svg {
  width: 32px;
  height: 32px;
}

@keyframes pulse-ring {
  0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 16px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.incoming-number {
  font-family: Consolas, Monaco, "JetBrains Mono", monospace;
  font-size: 1.4rem;
  font-weight: 800;
  color: white;
}

.incoming-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.modal-actions {
  display: flex;
  gap: 0.85rem;
  width: 100%;
  margin-top: 0.4rem;
}

.btn-answer {
  flex: 1;
  background: var(--accent-green);
  color: white;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
}

.btn-reject {
  flex: 1;
  background: var(--accent-red);
  color: white;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* Toast Notifications */
.toast-msg {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  padding: 0.75rem 1.25rem;
  background: rgba(18, 24, 38, 0.95);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.25s ease;
  z-index: 10000;
  pointer-events: none;
}

.toast-msg.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.toast-error {
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.toast-info {
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}
