* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 140, 66, 0.16), transparent 38%),
    radial-gradient(circle at 88% 12%, rgba(34, 197, 94, 0.12), transparent 34%),
    linear-gradient(180deg, #f3f8fb, #ffffff 52%, #f9fbff);
  color: #1f2937;
}

.container {
  width: min(1200px, 92%);
  margin: 0 auto;
}

.topbar {
  background: linear-gradient(120deg, var(--primary), #284f76);
  color: #fff;
  padding: 16px 0;
  margin-bottom: 24px;
  box-shadow: 0 10px 30px rgba(18, 48, 74, 0.28);
}

.topbar-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 4px;
  background: #fff;
}

nav a {
  color: #fff;
  text-decoration: none;
  margin-left: 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  transition: all 0.18s ease;
}

nav a:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.2);
}

nav i {
  font-size: 0.9rem;
}

.title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card {
  background: linear-gradient(160deg, #ffffff, #fdfefe);
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 20px;
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.08);
  margin-bottom: 18px;
}

.narrow {
  max-width: 560px;
  margin: 0 auto 18px;
}

.settings-card {
  max-width: 1200px;
  margin: 0 auto 18px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.settings-panel {
  display: grid;
  gap: 12px;
  align-content: start;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 16px;
  background: #fff;
}

.single-company-fields {
  display: grid;
  gap: 12px;
}

.doc-type-form {
  margin-bottom: 12px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

input,
select,
button {
  font: inherit;
  padding: 11px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
}

button,
.btn {
  background: linear-gradient(120deg, var(--accent), #ff6b6b);
  border: 0;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
  font-weight: 700;
  padding: 12px 16px;
  border-radius: 4px;
  box-shadow: 0 10px 22px rgba(255, 107, 107, 0.28);
  transition: all 0.2s ease;
}

button:hover,
.btn:hover {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 14px 26px rgba(255, 107, 107, 0.34);
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 4px;
  padding: 7px 11px;
  margin-right: 6px;
  text-decoration: none;
  color: #fff;
  font-weight: 600;
  background: linear-gradient(120deg, #1f7a8c, #15616d);
  box-shadow: 0 7px 16px rgba(21, 97, 109, 0.22);
}

.action-btn.secondary {
  background: linear-gradient(120deg, #5f6c7b, #3f4d5c);
  box-shadow: 0 7px 16px rgba(63, 77, 92, 0.22);
}

.action-btn.icon-only {
  width: 34px;
  height: 34px;
  justify-content: center;
  padding: 0;
  margin-right: 4px;
  position: relative;
}

.action-btn:hover {
  transform: translateY(-1px);
}

.has-tooltip {
  position: relative;
}

.has-tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 6px 9px;
  font-size: 0.78rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 20;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.has-tooltip::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 3px);
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #111827;
  opacity: 0;
  pointer-events: none;
  z-index: 21;
}

.has-tooltip:hover::after,
.has-tooltip:hover::before {
  opacity: 1;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 4px;
  padding: 6px 12px;
  font-weight: 700;
  font-size: 0.84rem;
  border: 1px solid transparent;
}

.status-pill.synced {
  color: #166534;
  background: #dcfce7;
  border-color: #86efac;
}

.status-pill.pending {
  color: #9a3412;
  background: #ffedd5;
  border-color: #fdba74;
}

.status-pill.in-use {
  color: #1d4ed8;
  background: #dbeafe;
  border-color: #93c5fd;
}

.status-pill.mandatory-yes {
  color: #166534;
  background: #dcfce7;
  border-color: #86efac;
}

.status-pill.mandatory-no {
  color: #374151;
  background: #e5e7eb;
  border-color: #9ca3af;
}

.status-pill.range-activo {
  color: #166534;
  background: #dcfce7;
  border-color: #86efac;
}

.status-pill.range-alerta {
  color: #9a3412;
  background: #ffedd5;
  border-color: #fdba74;
}

.status-pill.range-consumido {
  color: #991b1b;
  background: #fee2e2;
  border-color: #fca5a5;
}

.status-pill.range-desactivado {
  color: #374151;
  background: #e5e7eb;
  border-color: #9ca3af;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-form input {
  width: 110px;
}

.actions-cell {
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.flash-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
}

.flash-list li {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  border-radius: 4px;
  padding: 8px 10px;
  margin-bottom: 8px;
}

.hint {
  color: #4b5563;
  font-size: 0.95rem;
}

.table-tools {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 10px;
}

.table-export-btn {
  border: 0;
  border-radius: 4px;
  padding: 8px 12px;
  color: #fff;
  background: linear-gradient(120deg, #15803d, #16a34a);
  box-shadow: 0 7px 16px rgba(22, 163, 74, 0.22);
  cursor: pointer;
  font-weight: 700;
}

.table-filter-row input {
  width: 100%;
  padding: 7px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
}

.donut-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.donut-card {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #e5e7eb;
  background: #fff;
  padding: 12px;
}

.donut {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: conic-gradient(#16a34a 0 var(--available-deg), #e5e7eb var(--available-deg) 360deg);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.donut-center {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  line-height: 1;
  text-align: center;
  font-size: 0.8rem;
}

.donut-center strong {
  font-size: 1rem;
}

.donut-info {
  display: grid;
  gap: 3px;
  font-size: 0.9rem;
}

@media (max-width: 800px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .topbar-content,
  .title-row {
    flex-direction: column;
    align-items: flex-start;
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
  }

  thead {
    display: none;
  }

  tr {
    border: 1px solid #e5e7eb;
    margin-bottom: 8px;
    border-radius: 4px;
    padding: 6px;
  }

  td {
    border-bottom: none;
    padding: 6px;
  }
}
