* {
  box-sizing: border-box;
}

:root {
  --bg-color: #f5f7fa;
  --panel-color: #ffffff;
  --border-color: #e2e8f0;
  --primary-color: #1d4ed8;
  --text-color: #0f172a;
  --muted-color: #475569;
  --error-color: #dc2626;
  --success-color: #15803d;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 36px;
}

.profiles-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.profiles-header h1 {
  margin: 0;
  font-size: 1.8rem;
}

.helper-text {
  margin: 4px 0 0;
  color: var(--muted-color);
  font-size: 0.95rem;
}

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

.night-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--muted-color);
}

.night-toggle-label {
  font-weight: 500;
}

.toggle-switch {
  position: relative;
  width: 46px;
  height: 26px;
  display: inline-flex;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background-color: #cbd5f5;
  transition: background-color 0.2s;
  cursor: pointer;
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
}

.toggle-switch input:focus-visible + .toggle-slider {
  outline: 2px solid rgba(59, 130, 246, 0.6);
  outline-offset: 2px;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.toggle-state {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.toggle-state[data-state="enabled"] {
  color: var(--success-color);
}

.toggle-state[data-state="disabled"] {
  color: var(--error-color);
}

.status-label {
  font-size: 0.9rem;
  color: var(--muted-color);
  min-width: 160px;
}

.status-label.is-error {
  color: var(--error-color);
}

.primary-button,
.link-button {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 8px 14px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, border 0.2s;
}

.primary-button {
  background: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
}

.primary-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.primary-button:hover:not(:disabled) {
  background: #1e40af;
}

.link-button {
  background: transparent;
  color: var(--text-color);
  border-color: var(--border-color);
  text-decoration: none;
}

.table-controls {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.async-summary {
  font-size: 0.9rem;
  color: var(--muted-color);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.async-summary code {
  background: #eef2ff;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.85rem;
}

.table-controls label {
  font-size: 0.9rem;
  color: var(--muted-color);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 500;
}

.table-controls input,
.table-controls select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  min-width: 220px;
  font-size: 0.95rem;
}

.pdrs-session-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: var(--muted-color);
}

.pdrs-session-controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.table-wrap {
  background: var(--panel-color);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  padding: 12px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 900px;
}

.profiles-table th,
.profiles-table td {
  text-align: center;
}

.profiles-table th:nth-child(1),
.profiles-table td:nth-child(1) {
  width: 60px;
}
.profiles-table th:nth-child(2),
.profiles-table td:nth-child(2) {
  width: 60px;
}
.profiles-table th:nth-child(3),
.profiles-table td:nth-child(3) {
  width: 110px;
}
.profiles-table th:nth-child(4),
.profiles-table td:nth-child(4) {
  width: 90px;
}
.profiles-table th:nth-child(5),
.profiles-table td:nth-child(5) {
  width: 100px;
}
.profiles-table th:nth-child(6),
.profiles-table td:nth-child(6) {
  width: 95px;
}
.profiles-table th:nth-child(7),
.profiles-table td:nth-child(7) {
  width: 100px;
}
.profiles-table th:nth-child(8),
.profiles-table td:nth-child(8) {
  width: 100px;
}
.profiles-table th:nth-child(9),
.profiles-table td:nth-child(9) {
  width: 90px;
}
.profiles-table th:nth-child(10),
.profiles-table td:nth-child(10) {
  width: 70px;
}
.profiles-table th:nth-child(11),
.profiles-table td:nth-child(11) {
  width: 70px;
}
.profiles-table th:nth-child(12),
.profiles-table td:nth-child(12) {
  width: 90px;
}
.profiles-table th:nth-child(13),
.profiles-table td:nth-child(13) {
  width: 70px;
}

.read-only-cell {
  display: block;
  width: 100%;
}

.operator-airtel {
  color: #dc2626;
  font-weight: 600;
}

.operator-jio {
  color: #16a34a;
  font-weight: 600;
}

.status-cell.status-on select {
  background: #dcfce7;
  color: #15803d;
  font-weight: 600;
}

.status-cell.status-off select {
  background: #fee2e2;
  color: #b91c1c;
  font-weight: 600;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: middle;
}

.profiles-table td {
  text-align: center;
}

.profiles-table td input,
.profiles-table td select {
  text-align: center;
}

th {
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted-color);
}

.async-cell {
  width: 70px;
  text-align: center;
}

.async-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.async-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

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

input[type="text"],
input[type="number"],
select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.9rem;
  background: #fff;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
}

.save-btn {
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  background: #2563eb;
  color: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  margin-right: 6px;
}

.save-btn:hover:not(:disabled) {
  background: #1d4ed8;
}

.save-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.row-status {
  font-size: 0.8rem;
  color: var(--muted-color);
}

.row-status[data-error="true"] {
  color: var(--error-color);
}

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

@media (max-width: 960px) {
  .profiles-header {
    flex-direction: column;
  }

  .table-controls {
    flex-direction: column;
  }

  table {
    font-size: 0.78rem;
  }
}
