/* =========================================
   CSS Variables & Base
   ========================================= */
:root {
  --sidebar-bg: #0f172a;
  --sidebar-width: 256px;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #eef2ff;
  --success: #10b981;
  --success-light: #ecfdf5;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --info: #3b82f6;
  --info-light: #eff6ff;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* =========================================
   Layout
   ========================================= */
.layout {
  display: flex;
  min-height: 100vh;
}

/* =========================================
   Sidebar
   ========================================= */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  min-height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  border-right: 1px solid rgba(255,255,255,0.05);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo-icon-wrap {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(99,102,241,0.4);
}

.logo-name {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.logo-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  font-weight: 400;
  margin-top: 1px;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
}

.nav-section-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.3);
  padding: 4px 8px 10px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
}

.nav-link:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.9);
}

.nav-link.active {
  background: linear-gradient(135deg, rgba(99,102,241,0.9) 0%, rgba(139,92,246,0.9) 100%);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(99,102,241,0.35);
}

.nav-link svg {
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-link.active svg {
  opacity: 1;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer-text {
  font-size: 11px;
  color: rgba(255,255,255,0.25);
  text-align: center;
}

/* =========================================
   Main Content
   ========================================= */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* =========================================
   Top Header
   ========================================= */
.top-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.page-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.breadcrumb-sep {
  color: var(--border);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.total-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.total-badge .count {
  font-size: 15px;
  font-weight: 700;
}

/* =========================================
   Content Area
   ========================================= */
.content-area {
  padding: 24px 28px;
  flex: 1;
}

/* =========================================
   Card
   ========================================= */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafafa;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title svg {
  color: var(--primary);
}

.card-body {
  padding: 20px;
}

/* =========================================
   Filter Form
   ========================================= */
.filter-form {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-control {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  font-size: 14px;
  color: var(--text);
  background: #ffffff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 220px;
  font-family: inherit;
}

.form-control::placeholder {
  color: #c0cada;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%2364748b'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.filter-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

/* =========================================
   Buttons
   ========================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  line-height: 1;
  font-family: inherit;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(99,102,241,0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99,102,241,0.4);
}

.btn-ghost {
  background: var(--bg);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}

.btn-ghost:hover {
  background: #e9eef5;
  color: var(--text-secondary);
}

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
  border: 1.5px solid #fecaca;
}

.btn-danger:hover {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}

.btn-info {
  background: var(--info-light);
  color: var(--info);
  border: 1.5px solid #bfdbfe;
}

.btn-info:hover {
  background: var(--info);
  color: #ffffff;
  border-color: var(--info);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 6px;
}

/* =========================================
   Table
   ========================================= */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  background: #f8fafc;
  padding: 11px 18px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background 0.1s;
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: #f8fafc;
}

tbody td {
  padding: 14px 18px;
  color: var(--text);
  vertical-align: middle;
}

.mobile-cell {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text);
  letter-spacing: 0.02em;
}

.tele-id-cell {
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 13.5px;
}

.tele-name-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.row-num {
  color: #c0cada;
  font-size: 13px;
  font-weight: 500;
}

.actions-cell {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* =========================================
   Badges
   ========================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-machine-1 {
  background: var(--info-light);
  color: var(--info);
  border: 1px solid #bfdbfe;
}

.badge-machine-2 {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid #a7f3d0;
}

.badge-filtering {
  background: var(--warning-light);
  color: var(--warning);
  border: 1px solid #fde68a;
  font-size: 11px;
}

/* =========================================
   Empty State
   ========================================= */
.empty-state {
  text-align: center;
  padding: 64px 20px;
}

.empty-icon {
  width: 56px;
  height: 56px;
  background: var(--border-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.empty-state p {
  font-size: 14px;
  color: var(--text-muted);
}

/* =========================================
   Pagination
   ========================================= */
.pagination-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  background: #fafafa;
}

.pagination-info {
  font-size: 13px;
  color: var(--text-muted);
}

.pagination {
  display: flex;
  gap: 4px;
  list-style: none;
}

.page-item a,
.page-item span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  background: #ffffff;
  transition: all 0.15s;
  cursor: pointer;
}

.page-item a:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.page-item.active span {
  background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(99,102,241,0.3);
}

.page-item.disabled span {
  opacity: 0.4;
  cursor: not-allowed;
  background: #f8fafc;
}

.page-ellipsis {
  border: none !important;
  cursor: default !important;
  background: transparent !important;
  color: var(--text-muted) !important;
}

/* =========================================
   Modal
   ========================================= */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

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

.modal-box {
  background: #ffffff;
  border-radius: 16px;
  max-width: 620px;
  width: calc(100% - 32px);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { transform: scale(0.95) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title-icon {
  width: 34px;
  height: 34px;
  background: var(--primary-light);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close {
  background: var(--bg);
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  transition: background 0.15s;
}

.modal-close:hover {
  background: var(--border);
  color: var(--text);
}

.modal-body {
  padding: 24px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 14px;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid var(--border-light);
}

.detail-item.full-width {
  grid-column: 1 / -1;
}

.detail-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.detail-value {
  font-size: 13.5px;
  color: var(--text-secondary);
  font-weight: 500;
  word-break: break-all;
  line-height: 1.5;
}

.detail-value.highlight {
  color: var(--primary);
  font-weight: 700;
  font-size: 15px;
}

.btn-open {
  background: #e0f2fe;
  color: #0284c7;
  border: 1.5px solid #bae6fd;
}

.btn-open:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

.account-row {
  cursor: pointer;
}

tbody tr.row-selected {
  background: #e0f2fe !important;
}

tbody tr.row-selected td {
  color: #0369a1;
}

/* =========================================
   Toast Notification
   ========================================= */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: white;
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  z-index: 9999;
  display: none;
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ── Copyable cell ─────────────────────── */
.copyable-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.btn-copy:hover {
  opacity: 1;
  background: var(--primary-light);
  color: var(--primary);
}

.btn-copy.copied {
  opacity: 1;
  color: var(--success);
}
