:root {
  --violet-900: #3b1366;
  --violet-700: #5b2d8f;
  --violet-600: #6d28d9;
  --violet-500: #7c3aed;
  --violet-100: #ede9fe;
  --violet-050: #f5f3ff;
  --ink: #1f1a2e;
  --muted: #6b6480;
  --line: #e7e3f0;
  --line-2: #efecf6;
  --bg: #faf8fd;
  --card: #ffffff;
  --ok: #0f9d58;
  --warn: #c2410c;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(31, 26, 46, .06), 0 8px 24px rgba(59, 19, 102, .07);
  --radius: 14px;
  --display: 'Plus Jakarta Sans', system-ui, sans-serif;
  --body: 'Inter', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
}

h1, h2, h3, .dsp {
  font-family: var(--display);
}

button {
  font-family: var(--body);
  cursor: pointer;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 18px 90px;
}

/* Header */
header.top {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand .mark {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--violet-600), var(--violet-900));
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--display);
  font-weight: 800;
  font-size: 18px;
  box-shadow: var(--shadow);
}

.brand h1 {
  font-size: 17px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -.01em;
  line-height: 1.1;
}

.brand .sub {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.grow {
  flex: 1;
}

.seg {
  display: inline-flex;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 3px;
  box-shadow: var(--shadow);
}

.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  transition: .15s;
}

.seg button.active {
  background: var(--violet-600);
  color: #fff;
}

/* Controls bar */
.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 13px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

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

.nav button {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--violet-700);
  font-size: 16px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.nav button:hover {
  background: var(--violet-050);
}

.nav .month {
  font-family: var(--display);
  font-weight: 700;
  font-size: 16px;
  min-width: 148px;
  text-align: center;
  text-transform: capitalize;
}

.field {
  position: relative;
}

.field input, .field select {
  font-family: var(--body);
  font-size: 13px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  padding: 8px 11px;
  color: var(--ink);
  outline: none;
}

.field input:focus, .field select:focus {
  border-color: var(--violet-500);
  box-shadow: 0 0 0 3px var(--violet-100);
}

.field input {
  min-width: 190px;
}

.btn-primary {
  border: 0;
  background: var(--violet-600);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  padding: 9px 15px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  transition: background 0.15s ease;
}

.btn-primary:hover {
  background: var(--violet-700);
}

.btn-ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--violet-700);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 13px;
  border-radius: 10px;
  transition: background 0.15s ease;
}

.btn-ghost:hover {
  background: var(--violet-050);
}

/* Summary chips */
.summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: .12s;
}

.chip:hover {
  border-color: var(--violet-500);
}

.chip.on {
  background: var(--violet-600);
  color: #fff;
  border-color: var(--violet-600);
}

.chip.on .dot {
  border: 1.5px solid #fff;
}

.chip .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.chip .ct {
  color: var(--muted);
  font-weight: 700;
}

.chip.on .ct {
  color: #fff;
  opacity: .85;
}

/* Calendar */
.cal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.cal .dow {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  background: var(--violet-050);
  border-bottom: 1px solid var(--line);
}

.cal .dow div {
  padding: 9px 10px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  color: var(--violet-700);
  text-align: left;
}

.cal .grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.cell {
  min-height: 118px;
  min-width: 0;
  border-right: 1px solid var(--line-2);
  border-bottom: 1px solid var(--line-2);
  padding: 7px 7px 5px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cell:nth-child(7n) {
  border-right: 0;
}

.cell.out {
  background: #fcfbfe;
}

.cell.today {
  background: var(--violet-050);
}

.cell .dnum {
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 5px;
}

.cell.out .dnum {
  color: #c3bdd2;
}

.cell.today .dnum .n {
  background: var(--violet-600);
  color: #fff;
  border-radius: 7px;
  padding: 0 6px;
}

.efem {
  font-size: 10px;
  color: var(--warn);
  font-weight: 600;
  line-height: 1.2;
  background: #fff5ec;
  border-radius: 5px;
  padding: 2px 5px;
}

.ev {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  border-radius: 6px;
  padding: 3px 6px;
  line-height: 1.25;
  cursor: pointer;
  border-left: 3px solid rgba(0, 0, 0, .18);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ev:hover {
  filter: brightness(1.06);
}

.ev.pend {
  background: #fff !important;
  color: var(--ink) !important;
  border: 1px dashed currentColor;
  border-left: 3px solid;
}

.ev .pin {
  font-size: 9px;
  opacity: .85;
}

.est {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}

.est.ok {
  background: #e7f6ee;
  color: #0f7a43;
}

.est.pend {
  background: #fff3e6;
  color: #b45309;
}

.est .d {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.add-day {
  margin-top: auto;
  font-size: 11px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 2px 0;
  text-align: center;
  background: #fff;
  opacity: 0;
  transition: .12s;
  width: 100%;
}

.cell:hover .add-day {
  opacity: 1;
}

.add-day:hover {
  color: var(--violet-700);
  border-color: var(--violet-500);
}

/* List */
.list {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

thead th {
  text-align: left;
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  color: var(--violet-700);
  background: var(--violet-050);
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
}

tbody td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: top;
}

tbody tr:hover {
  background: var(--violet-050);
}

.tdate {
  font-weight: 700;
  white-space: nowrap;
  font-family: var(--display);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}

.tact {
  font-weight: 600;
}

.meta {
  color: var(--muted);
  font-size: 12px;
}

.row-actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.ic {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  font-size: 14px;
}

.ic:hover {
  background: var(--violet-050);
}

.ic.del:hover {
  background: #fee;
  border-color: #f6b;
}

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}

.empty b {
  display: block;
  font-family: var(--display);
  color: var(--ink);
  font-size: 15px;
  margin-bottom: 5px;
}

/* FAB */
.fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: var(--violet-600);
  color: #fff;
  border: 0;
  border-radius: 14px;
  padding: 14px 20px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(91, 45, 143, .35);
  z-index: 30;
  transition: background 0.15s ease, transform 0.1s ease;
}

.fab:hover {
  background: var(--violet-700);
  transform: translateY(-2px);
}

/* Modal */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 26, 46, .45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 50;
  padding: 26px 16px;
  overflow: auto;
}

.overlay.show {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: 18px;
  width: 100%;
  max-width: 540px;
  box-shadow: 0 24px 60px rgba(31, 26, 46, .3);
  overflow: hidden;
  animation: pop .16s ease;
}

@keyframes pop {
  from {
    transform: translateY(8px);
    opacity: 0
  }
  to {
    transform: none;
    opacity: 1
  }
}

.modal header {
  background: linear-gradient(135deg, var(--violet-700), var(--violet-900));
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.modal header button {
  background: rgba(255, 255, 255, .15);
  border: 0;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 16px;
}

.modal .body {
  padding: 18px 20px;
  display: grid;
  gap: 13px;
}

.grp {
  display: grid;
  gap: 5px;
}

.grp.two {
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}

label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.grp input, .grp textarea, .grp select {
  font-family: var(--body);
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink);
  outline: none;
  width: 100%;
}

.grp input:focus, .grp textarea:focus, .grp select:focus {
  border-color: var(--violet-500);
  box-shadow: 0 0 0 3px var(--violet-100);
}

.grp textarea {
  resize: vertical;
  min-height: 60px;
}

.modal footer {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.save-state {
  font-size: 12px;
  color: var(--muted);
}

.idbadge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: border-color 0.12s ease;
}

.idbadge .who {
  color: var(--violet-700);
  font-weight: 700;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.idbadge:hover {
  border-color: var(--violet-500);
}

.attrib {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
  margin-top: 2px;
}

.attrib b {
  color: var(--ink);
  font-weight: 600;
}

.meta .by {
  color: var(--violet-700);
  font-weight: 600;
}

.hist .h-row {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line-2);
  font-size: 13px;
}

.hist .h-row:last-child {
  border-bottom: 0;
}

.hist .h-ic {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 13px;
  flex: none;
  color: #fff;
}

.hist .h-when {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.hist .h-who {
  font-weight: 700;
}

.hist-empty {
  padding: 30px 10px;
  text-align: center;
  color: var(--muted);
}

.notice {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-top: 16px;
  line-height: 1.5;
}

.notice b {
  color: var(--violet-700);
}

/* --- ESTILOS DE AUTENTICACIÓN (LOGIN / REGISTRO) --- */

.auth-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--violet-050) 0%, #ede9fe 100%);
  padding: 20px;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 40px rgba(59, 19, 102, .08);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.auth-logo .mark {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--violet-600), var(--violet-900));
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--display);
  font-weight: 800;
  font-size: 20px;
  box-shadow: var(--shadow);
}

.auth-logo h1 {
  font-size: 18px;
  font-weight: 800;
  margin: 0;
  color: var(--violet-900);
}

.auth-logo p {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-form .btn-primary {
  padding: 12px;
  font-size: 14px;
  margin-top: 8px;
}

.auth-footer {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin-top: 10px;
}

.auth-footer a {
  color: var(--violet-600);
  font-weight: 600;
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.error-message {
  background: #fdf2f2;
  color: var(--danger);
  border: 1px solid #fde8e8;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  display: none;
}

/* --- ESTILOS DE PANEL DE ADMINISTRACIÓN --- */

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.admin-title-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-title-area h1 {
  font-size: 20px;
  margin: 0;
  font-weight: 800;
}

.user-table-wrapper {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}

.user-table-wrapper select {
  font-family: var(--body);
  font-size: 13px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  padding: 4px 8px;
  color: var(--ink);
  outline: none;
  cursor: pointer;
}

.user-table-wrapper select:focus {
  border-color: var(--violet-500);
}

.admin-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4f46e5;
}

.admin-badge.admin-role {
  background: #fdf2f2;
  color: var(--danger);
}

.admin-badge.editor-role {
  background: #fef3c7;
  color: #d97706;
}

.admin-badge.viewer-role {
  background: #f0fdf4;
  color: #16a34a;
}

.ws-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.ws-status-badge.connected {
  background: #ecfdf5;
  color: #059669;
  border-color: #a7f3d0;
}

.ws-status-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

/* Responsividad */
@media (max-width: 760px) {
  .wrap {
    padding: 14px 12px 88px;
  }
  .cell {
    min-height: 92px;
  }
  .cal {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .cal .dow, .cal .grid {
    min-width: 680px;
  }
  .cal .dow div {
    font-size: 11px;
    padding: 8px 8px;
  }
  .cell {
    padding: 6px 6px 4px;
  }
  .ev {
    font-size: 10px;
    padding: 3px 5px;
  }
  .scroll-hint {
    display: block;
  }
  .field input {
    min-width: 140px;
  }
  .brand h1 {
    font-size: 15px;
  }
  .grp.two {
    grid-template-columns: 1fr;
  }
  .hide-sm {
    display: none;
  }
}

.scroll-hint {
  display: none;
  font-size: 12px;
  color: var(--muted);
  margin: 0 2px 8px;
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
