:root {
  color-scheme: light;
  --ui-bg: #f4f6fa;
  --ui-surface: #ffffff;
  --ui-ink: #172033;
  --ui-muted: #68758a;
  --ui-border: #e3e8f0;
  --ui-accent: #1d4ed8;
  --ui-accent-hover: #1e40af;
  --ui-shadow: 0 14px 38px rgba(22, 34, 54, .08);
}

html {
  scroll-behavior: smooth;
}

body {
  color: var(--ui-ink);
  background-color: var(--ui-bg);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.55;
}

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

button, [type="button"], [type="submit"] {
  border-radius: 9px;
}

button, [type="button"], [type="submit"], [role="button"] {
  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

button:not(:disabled), [type="button"]:not(:disabled), [type="submit"]:not(:disabled) {
  cursor: pointer;
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(37, 99, 235, .28);
  outline-offset: 2px;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
textarea {
  border: 1px solid #d6deea;
  border-radius: 10px;
  background-color: var(--ui-surface);
  color: var(--ui-ink);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus,
select:focus,
textarea:focus {
  border-color: #7399f5;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .1);
}

.topbar {
  background: rgba(255, 255, 255, .94);
  border-color: var(--ui-border);
  box-shadow: 0 3px 16px rgba(22, 34, 54, .035);
}

.topbar__inner {
  width: min(100%, 1320px);
}

.brand img {
  max-width: min(260px, 48vw);
  object-fit: contain;
}

.user__btn {
  min-height: 42px;
  border-color: var(--ui-border);
}

.user__menu {
  z-index: 2100;
  border-color: var(--ui-border);
}

.main-content,
.main,
.page,
.app-container,
.card,
.panel,
.container {
  border-color: var(--ui-border);
}

.main-content {
  width: min(1320px, calc(100% - 40px));
  margin: 24px auto;
  padding: clamp(20px, 3vw, 36px);
  border: 1px solid var(--ui-border);
  border-radius: 18px;
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow);
}

.header-tools {
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.page-title {
  color: var(--ui-ink);
  font-size: clamp(1.75rem, 3vw, 2.4rem);
  font-weight: 750;
  letter-spacing: -.035em;
}

.template-card,
.folder-card {
  border: 1px solid var(--ui-border);
  border-radius: 16px;
  background: var(--ui-surface);
  box-shadow: 0 8px 24px rgba(22, 34, 54, .055);
}

.template-card:hover,
.folder-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 16px 32px rgba(22, 34, 54, .1);
}

.template-card .template-title,
.folder-card h2 {
  color: var(--ui-ink);
}

.template-actions .btn,
.template-card .actions .btn,
.save-button,
.create-button,
.folder-link {
  min-height: 40px;
  border-radius: 10px;
  font-weight: 650;
}

.template-actions .btn.btn-crear,
.folder-link {
  border-color: var(--ui-accent);
  background: var(--ui-accent);
  color: white;
}

.template-actions .btn.btn-crear:hover,
.folder-link:hover {
  border-color: var(--ui-accent-hover);
  background: var(--ui-accent-hover);
  color: white;
}

.template-actions .btn.btn-eliminar {
  border-color: #fecaca;
  background: #fff1f2;
  color: #b42318;
}

.template-actions .btn.btn-edit {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

table {
  width: 100%;
  border-color: var(--ui-border);
}

th {
  color: #455268;
  background: #f7f9fc;
  font-weight: 700;
  white-space: nowrap;
}

th, td {
  border-color: var(--ui-border);
  padding: 12px 14px;
  vertical-align: middle;
}

tbody tr:hover {
  background-color: #f8faff;
}

form label,
.form-label {
  color: #344054;
  font-weight: 600;
}

form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
form select,
form textarea {
  min-height: 42px;
  padding: 9px 12px;
}

form textarea {
  min-height: 110px;
}

.main button,
.main-content button,
.page button,
.card button,
.panel button,
form button {
  min-height: 40px;
}

.main button:hover,
.main-content button:hover,
.page button:hover,
.card button:hover,
.panel button:hover,
form button:hover {
  box-shadow: 0 5px 14px rgba(22, 34, 54, .1);
}

.modal-content {
  border: 1px solid var(--ui-border);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(16, 24, 40, .2);
}

.modal-header, .modal-footer {
  border-color: var(--ui-border);
}

@media (max-width: 700px) {
  .main-content {
    width: calc(100% - 24px);
    margin: 12px auto;
    padding: 18px;
    border-radius: 14px;
  }

  .header-tools {
    align-items: stretch;
  }

  .header-tools .create-button {
    margin-left: 0;
  }

  .templates-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
    gap: 14px;
  }

  .template-card {
    min-height: 0;
  }

  .template-actions .btn {
    flex: 1 1 100%;
  }

  .template-row {
    flex-wrap: wrap;
  }

  .table-responsive,
  .table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  th, td {
    padding: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}

@media print {
  body {
    background: white !important;
    color: black !important;
  }

  .main-content, .template-card, .folder-card, .panel, .card, .app-container {
    box-shadow: none !important;
  }
}
