:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --danger: #b91c1c;
  --ok: #047857;
  --radius: 10px;
  /* Tamaños de imagen del panel: cámbialos aquí para ajustar todo el CMS */
  --thumb-list: 96px;
  --thumb-list-h: 72px;
  --thumb-preview: 560px;
  --thumb-preview-h: 420px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: #eef2f7; padding: 1px 5px; border-radius: 4px; }

.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 250px;
  flex: 0 0 250px;
  background: #10231f;
  color: #cfe3df;
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; gap: 10px; align-items: center; color: #fff; padding: 4px 8px 18px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 13.5px; }
.brand-text small { font-size: 11px; color: #8fb3ad; letter-spacing: .12em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section { display: flex; flex-direction: column; }
.nav-items { display: flex; flex-direction: column; gap: 1px; }
.nav-group {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; margin: 14px 0 6px; padding: 4px 8px;
  background: none; border: 0; cursor: pointer; text-align: left;
  font: inherit; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em;
  color: #6f918b;
}
.nav-group:hover { color: #a9c6c0; }
.nav-group:focus-visible { outline: 2px solid rgba(20,184,166,.5); border-radius: 6px; }
.nav-group .chevron { font-size: 11px; line-height: 1; color: #7fa39c; transition: transform .15s ease; }
.nav-group:hover .chevron { color: #cfe3df; }
.nav-section.collapsed .chevron { transform: rotate(-90deg); }
.nav-section.collapsed .nav-items { display: none; }
.nav-item {
  padding: 7px 10px; border-radius: 7px; color: #cfe3df; font-size: 13.5px;
}
.nav-item:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav-item.active { background: rgba(20,184,166,.18); color: #fff; font-weight: 600; }

.logout { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.logout .link { background: none; border: 0; color: #9dbcb6; font-size: 12px; cursor: pointer; padding: 0; }
.logout .link:hover { color: #fff; }

/* Main */
.main { flex: 1; padding: 26px 30px 60px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.02em; }
.page-head p { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 28px 0 12px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.card-title { margin: 0 0 14px; font-size: 15px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 13px; border-radius: 8px; font-size: 13.5px; cursor: pointer; font-weight: 500;
  text-decoration: none; line-height: 1.2;
}
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.danger { color: var(--danger); border-color: #f3d4d4; }
.btn.danger:hover { background: #fdf2f2; }
.btn.small { padding: 5px 9px; font-size: 12.5px; }
.btn.tiny { padding: 3px 7px; font-size: 11px; }
.btn.block { width: 100%; }
form.inline { display: inline; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 9px 10px; border-bottom: 1px solid #f1f3f5; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fbfcfd; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; }
.badge.on { background: #e7f6ef; color: var(--ok); }
.badge.neutral { background: #eef2f7; color: #4b5563; margin-left: 6px; }
.badge.role-super { background: #e0f2f1; color: #0f766e; }
.badge.role-admin { background: #e0ecff; color: #1d4ed8; }
.badge.role-editor { background: #eef2f7; color: #4b5563; }
.badge.off { background: #fdeaea; color: var(--danger); }

.thumb { border-radius: 8px; border: 1px solid var(--line); background: #fff; object-fit: cover; }
.thumb.tiny { width: 64px; height: 48px; }

/* Miniatura del listado */
.thumb-link { display: inline-block; line-height: 0; }
.thumb-link:hover .thumb { border-color: var(--brand); }
.thumb.row-thumb { width: var(--thumb-list); height: var(--thumb-list-h); }
.thumb.row-thumb.contain { object-fit: contain; padding: 4px; background: #fff; }
.thumb.row-thumb.empty {
  display: grid; place-items: center; background: #f4f6f8;
  border: 1px dashed #cdd5df; color: #9aa4b2; font-weight: 600; font-size: 13px;
}

/* Imagen en la ficha de edición: grande, sin ampliar las que son pequeñas */
.thumb.preview {
  width: auto; height: auto; align-self: flex-start;
  max-width: min(100%, var(--thumb-preview)); max-height: var(--thumb-preview-h);
  margin-top: 10px; display: block; object-fit: contain;
  background: #f4f6f8; padding: 6px;
  border-radius: 10px; box-shadow: 0 1px 3px rgba(16,24,40,.08);
}
.thumb.preview:not([src]), .thumb.preview[src=''] { display: none; }
.thumb.preview.empty {
  width: 320px; height: 240px; max-width: 100%; padding: 0;
  display: grid; place-items: center; border-style: dashed; color: #9aa4b2;
  font-size: 13px; font-weight: 600; background: #f4f6f8;
}

/* Forms */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: #374151; }
.field .req { color: var(--danger); }
input[type='text'], input[type='number'], input[type='date'], input[type='password'], input[type='search'], input[type='file'], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #d6dbe2; border-radius: 8px;
  font: inherit; font-size: 13.5px; background: #fff; color: var(--ink);
}
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15,118,110,.18); border-color: var(--brand); }
.checkbox { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 500; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--brand); }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.help { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

.media-field { display: flex; flex-direction: column; gap: 6px; }
.media-row { display: flex; gap: 8px; align-items: center; }
.media-row input { flex: 1; }

.form-actions { display: flex; gap: 10px; padding: 4px 0 20px; }

/* Flash */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13.5px; }
.flash.ok { background: #e7f6ef; color: #065f46; border: 1px solid #bfe8d4; }
.flash.error { background: #fdeaea; color: #991b1b; border: 1px solid #f3cfcf; }

/* Dashboard */
.stats { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow); }
.stat-value { display: block; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.stat-label { color: var(--muted); font-size: 12px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.tile {
  display: flex; flex-direction: column; gap: 2px; padding: 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); box-shadow: var(--shadow);
}
.tile:hover { border-color: #b7d9d4; text-decoration: none; transform: translateY(-1px); }
.tile-value { font-size: 20px; font-weight: 700; }
.tile-label { font-weight: 600; font-size: 13.5px; }
.tile-section { color: var(--muted); font-size: 11.5px; }

/* Breadcrumb + filtros de la biblioteca */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13.5px; margin: -4px 0 16px; flex-wrap: wrap; }
.breadcrumb a { color: var(--brand); }
.breadcrumb .sep { color: #bcc4cf; }
.breadcrumb .current { font-weight: 600; }
.breadcrumb button {
  background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer;
}
.breadcrumb button:hover { text-decoration: underline; }
.breadcrumb button.current { color: var(--ink); cursor: default; text-decoration: none; }
.folder-tile { text-align: left; font: inherit; cursor: pointer; }
.modal-folders { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.modal-folders .folder-cover { height: 58px; }
.modal-folders .folder-name { font-size: 12px; }
.modal-folders .folder-count { font-size: 10.5px; }

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filters input[type='search'] { max-width: 320px; }
.filters select { width: auto; min-width: 150px; }

.upload-box { border-top: 1px solid var(--line); padding-top: 12px; }
.upload-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.upload-form input[type='file'] { max-width: 380px; }

/* Carpetas */
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 10px; }
.folder-tile {
  display: flex; flex-direction: column; gap: 5px; padding: 10px; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; color: var(--ink); box-shadow: var(--shadow);
}
.folder-tile:hover { border-color: #b7d9d4; text-decoration: none; transform: translateY(-1px); }
.folder-cover { height: 88px; border-radius: 6px; overflow: hidden; background: #eef2f7; display: grid; place-items: center; }
.folder-cover img { width: 100%; height: 100%; object-fit: cover; }
.folder-icon { font-size: 26px; font-weight: 700; color: #94a3b8; }
.folder-name { font-weight: 600; font-size: 13px; word-break: break-word; }
.folder-count { font-size: 11.5px; color: var(--muted); }

.pagination { display: flex; gap: 10px; align-items: center; justify-content: center; padding-top: 14px; margin-top: 8px; border-top: 1px solid var(--line); }
.media-meta { font-size: 11px; color: var(--muted); }

/* Media library */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 8px; }
.media-item { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.media-item img { width: 100%; height: 140px; object-fit: cover; border-radius: 6px; background: #f1f3f5; }
.media-item figcaption { font-size: 11px; color: var(--muted); word-break: break-all; line-height: 1.3; max-height: 2.6em; overflow: hidden; }
.file-ext { height: 140px; display: grid; place-items: center; background: #eef2f7; border-radius: 6px; font-weight: 700; color: #64748b; }
.search-form, .upload-form { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.search-form input { max-width: 340px; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: grid; place-items: center; padding: 24px; z-index: 50; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 12px; width: min(1000px, 100%); max-height: 85vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line); }
.modal-head input { flex: 1; }
.modal-body { overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.modal .media-grid { overflow: visible; padding: 0; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.modal .media-item img { height: 112px; cursor: pointer; }
.modal .file-ext { height: 112px; }
.modal .breadcrumb { margin: 0; }

/* Login */
.login-body { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(160deg, #0f2b26, #143b34 45%, #f6f7f9 45.1%); }
.login-card { background: #fff; padding: 30px; border-radius: 14px; box-shadow: 0 20px 50px rgba(2, 20, 17, .25); width: min(380px, 92vw); }
.login-card h1 { font-size: 19px; margin: 18px 0 4px; }
.login-brand { padding: 0; }
.login-brand .brand-text strong { color: var(--ink); }
.login-brand .brand-text small { color: var(--muted); }
.login-card .form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .nav { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .nav-section { grid-column: 1 / -1; }
  .nav-group { margin-top: 10px; }
  .main { padding: 18px 16px 50px; }
}
