:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #131722;
  --muted: #5a6578;
  --line: #e6eaf0;
  --primary: #2f6df6;
  --shadow: 0 10px 30px rgba(16, 24, 40, 0.06);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d12;
    --panel: #121722;
    --text: #eaf0ff;
    --muted: #a3afc7;
    --line: #29344a;
    --primary: #78a2ff;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #131722;
  --muted: #5a6578;
  --line: #e6eaf0;
  --primary: #2f6df6;
  --shadow: 0 10px 30px rgba(16, 24, 40, 0.06);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d12;
  --panel: #121722;
  --text: #eaf0ff;
  --muted: #a3afc7;
  --line: #29344a;
  --primary: #78a2ff;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
}

main,
.topbar,
.tabs {
  max-width: 1200px;
  margin: 1rem auto;
  padding: 0 1rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

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

h1,
h2,
h3 {
  margin: 0 0 0.5rem;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.tabs {
  display: flex;
  gap: 0.5rem;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button,
.file-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
}

button:hover,
.file-btn:hover {
  border-color: var(--primary);
}

.ghost {
  background: transparent;
}

.danger {
  color: #d23b3b;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.field-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.grid.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.metric {
  min-height: 100px;
}

.metric-label {
  color: var(--muted);
  margin: 0;
  font-size: 0.88rem;
}

.metric-value {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0.4rem 0 0;
}

.payroll {
  display: grid;
  gap: 0.35rem;
}

.line {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.2rem 0;
}

.line.strong {
  font-weight: 700;
  border-top: 1px dashed var(--line);
  margin-top: 0.25rem;
  padding-top: 0.45rem;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.toolbar-group {
  display: flex;
  gap: 0.5rem;
}

.calendar-headers,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.5rem;
}

.header-cell {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.day-cell {
  position: relative;
  text-align: left;
  min-height: 95px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.day-cell-actions {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  display: flex;
  gap: 0.25rem;
}

.mini-btn {
  border-radius: 8px;
  font-size: 0.72rem;
  padding: 0.15rem 0.35rem;
  opacity: 0.8;
}

.mini-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.day-cell.outside {
  opacity: 0.45;
}

.day-cell.today {
  border-color: var(--primary);
}

.day-number {
  font-size: 0.87rem;
  color: var(--muted);
}

.day-badge {
  background: color-mix(in oklab, var(--primary), transparent 80%);
  color: var(--text);
  border-radius: 999px;
  padding: 0.2rem 0.45rem;
  width: fit-content;
  font-size: 0.75rem;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.6rem;
  text-align: left;
}

th[data-sort] {
  cursor: pointer;
}

th.sorted {
  color: var(--primary);
}

td.actions {
  display: flex;
  gap: 0.4rem;
}

.config-grid {
  display: grid;
  gap: 0.9rem;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem;
  display: grid;
  gap: 0.55rem;
}

legend {
  color: var(--muted);
  padding: 0 0.3rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.92rem;
}

label.optional::after {
  content: "(sin horario)";
  color: var(--muted);
  font-size: 0.8rem;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  padding: 0.55rem;
}

.config-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.file-btn {
  position: relative;
  overflow: hidden;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

dialog {
  border: none;
  border-radius: 14px;
  padding: 0;
  width: min(520px, 95vw);
  background: transparent;
}

dialog::backdrop {
  background: rgba(8, 12, 19, 0.55);
}

.modal-form {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  display: grid;
  gap: 0.7rem;
}

.time-input-wrap {
  position: relative;
}

.time-input-wrap::after {
  content: "🕒";
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 0.9rem;
  opacity: 0.8;
}

.time-input-wrap input[type="time"] {
  padding-right: 2rem;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin: 0.2rem 0 0;
  padding: 0;
}

.toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 9999;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 860px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .calendar-headers,
  .calendar-grid {
    gap: 0.35rem;
  }

  .day-cell {
    min-height: 78px;
    padding: 0.35rem;
  }
}
