:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --border: #e5e7eb;
  --border-strong: #d7dce3;
  --text: #18212f;
  --muted: #6b7280;
  --muted-strong: #4b5563;
  --primary: #246bfd;
  --primary-dark: #1d4ed8;
  --primary-soft: #edf3ff;
  --sidebar: #111827;
  --sidebar-soft: #1f2937;
  --sidebar-muted: #9ca3af;
  --success: #16815d;
  --success-soft: #e8f7f1;
  --warning: #b7791f;
  --warning-soft: #fff6df;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --shadow: 0 12px 30px rgba(15, 23, 42, .08);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: flex; }
.sidebar { width: 256px; flex: 0 0 256px; display: flex; flex-direction: column; min-height: 100vh; background: var(--sidebar); color: #fff; border-right: 1px solid rgba(255,255,255,.05); }
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(135deg,#2563eb,#60a5fa); font-size: 13px; font-weight: 800; color: white; letter-spacing: .08em; }
.brand-copy { display: flex; flex-direction: column; min-width: 0; }
.brand-copy strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-copy span { margin-top: 2px; color: var(--sidebar-muted); font-size: 12px; }
.sidebar-nav { padding: 4px 10px 12px; overflow-y: auto; }
.nav-heading { margin: 19px 10px 7px; color: #64748b; font-size: 10px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.nav-item { display: flex; align-items: center; gap: 11px; min-height: 40px; margin: 2px 0; padding: 8px 10px; border-radius: 10px; color: #d1d5db; font-size: 13px; transition: .18s ease; }
.nav-item:hover, .nav-item.is-active { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.is-active { box-shadow: inset 3px 0 0 #60a5fa; }
.nav-icon { display: inline-grid; place-items: center; width: 18px; font-size: 14px; color: #93c5fd; }
.sidebar-footer { margin-top: auto; padding: 10px; border-top: 1px solid rgba(255,255,255,.06); }

.app-main { min-width: 0; flex: 1; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px; min-height: 68px; padding: 12px 28px; background: rgba(255,255,255,.92); border-bottom: 1px solid var(--border); backdrop-filter: blur(14px); }
.mobile-menu-button { display: none; }
.global-search { display: flex; align-items: center; flex: 1; max-width: 580px; padding: 0 14px; border: 1px solid var(--border); border-radius: 11px; background: #f8fafc; }
.search-icon { color: #94a3b8; font-size: 20px; }
.global-search input, .filter-main input { width: 100%; border: 0; outline: 0; padding: 10px 9px; background: transparent; color: var(--text); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.quick-create, .primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid transparent; font-size: 13px; font-weight: 700; transition: .18s ease; }
.quick-create, .primary-button { background: var(--primary); color: white; }
.quick-create:hover, .primary-button:hover { background: var(--primary-dark); }
.secondary-button { background: white; border-color: var(--border-strong); color: var(--text); }
.secondary-button:hover { background: #f8fafc; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 10px; background: white; color: var(--muted-strong); }
.user-menu { position: relative; }
.user-menu summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; }
.user-menu summary::-webkit-details-marker { display: none; }
.avatar, .profile-avatar { display: grid; place-items: center; border-radius: 999px; background: #dbeafe; color: #1d4ed8; font-weight: 800; }
.avatar { width: 36px; height: 36px; font-size: 13px; }
.profile-avatar { width: 58px; height: 58px; flex: 0 0 58px; font-size: 20px; }
.user-name { font-size: 13px; font-weight: 700; }
.user-menu-panel { position: absolute; top: calc(100% + 10px); right: 0; min-width: 190px; padding: 8px; background: white; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.user-menu-panel a, .user-menu-panel button { display: block; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; font-size: 13px; }
.user-menu-panel a:hover, .user-menu-panel button:hover { background: #f3f4f6; }

.content { padding: 28px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 22px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 7px; color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: clamp(27px, 3vw, 38px); letter-spacing: -.04em; }
h2 { margin-bottom: 4px; font-size: 16px; letter-spacing: -.01em; }
.page-subtitle, .panel-header p, .client-profile-card p { margin-bottom: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.header-actions { display: flex; gap: 9px; }

.stat-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 5px 18px rgba(15,23,42,.035); }
.stat-card { display: flex; flex-direction: column; min-height: 134px; padding: 18px; }
.stat-label { color: var(--muted-strong); font-size: 12px; font-weight: 700; }
.stat-card strong { margin-top: auto; font-size: 27px; letter-spacing: -.04em; }
.stat-card small, td small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(250px, 1fr); gap: 16px; }
.panel { min-width: 0; }
.panel-wide { grid-column: span 1; }
.panel-full { grid-column: 1 / -1; }
.panel-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 17px 18px 14px; border-bottom: 1px solid var(--border); }
.panel-header a { color: var(--primary); font-size: 12px; font-weight: 800; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 13px 15px; color: var(--muted); border-bottom: 1px solid var(--border); background: #fbfcfd; font-size: 10px; letter-spacing: .09em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 15px; border-bottom: 1px solid #eef1f4; color: var(--muted-strong); font-size: 13px; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.compact-table td { padding: 13px 15px; }
.entity-link, .table-action { color: var(--primary); font-weight: 800; }
.align-right { text-align: right; }
.muted { color: var(--muted); }
.empty-state { color: var(--muted); font-size: 13px; text-align: center; }

.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; background: #f3f4f6; color: var(--muted-strong); font-size: 10px; font-weight: 800; }
.badge-media, .badge-neutral { background: #f3f4f6; color: #4b5563; }
.badge-baja, .badge-success { background: var(--success-soft); color: var(--success); }
.badge-alta, .badge-urgente { background: var(--danger-soft); color: var(--danger); }
.mini-stat-list { padding: 7px 18px 13px; }
.mini-stat-list div { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 47px; border-bottom: 1px solid #eef1f4; }
.mini-stat-list div:last-child { border-bottom: 0; }
.mini-stat-list span { color: var(--muted-strong); font-size: 13px; }
.mini-stat-list strong { font-size: 18px; }
.warning-list strong { color: var(--warning); }

.filters { display: flex; align-items: center; gap: 10px; padding: 14px; border-bottom: 1px solid var(--border); }
.filter-main { display: flex; align-items: center; flex: 1; padding: 0 11px; border: 1px solid var(--border); border-radius: 10px; background: #f8fafc; }
.filters select { min-height: 40px; padding: 0 10px; border: 1px solid var(--border); border-radius: 10px; background: white; color: var(--text); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 15px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.pagination a { color: var(--primary); font-weight: 800; }

.client-summary-grid { display: grid; grid-template-columns: minmax(320px,1.8fr) repeat(3,minmax(0,1fr)); gap: 14px; margin-bottom: 16px; }
.client-profile-card { display: flex; align-items: flex-start; gap: 14px; padding: 18px; }
.client-profile-card h2 { font-size: 20px; }
.profile-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 11px 18px; margin: 18px 0 0; }
.profile-list div { min-width: 0; }
.profile-list dt { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.profile-list dd { margin: 4px 0 0; color: var(--muted-strong); font-size: 12px; overflow-wrap: anywhere; }
.profile-list a { color: var(--primary); }
.stack-list { padding: 8px 18px 13px; }
.stack-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid #eef1f4; font-size: 12px; }
.stack-item:last-child { border-bottom: 0; }
.stack-item strong { color: var(--text); }
.stack-item span { color: var(--muted); text-align: right; }

.placeholder-panel { max-width: 720px; padding: 34px; text-align: center; }
.placeholder-icon { display: grid; place-items: center; width: 62px; height: 62px; margin: 0 auto 18px; border-radius: 18px; background: var(--primary-soft); color: var(--primary); font-size: 34px; }
.placeholder-panel p { max-width: 560px; margin: 0 auto 22px; color: var(--muted); font-size: 14px; line-height: 1.75; }

.login-body { min-height: 100vh; background: #eef3fb; }
.login-shell { display: grid; grid-template-columns: minmax(0,1.15fr) minmax(400px,.85fr); min-height: 100vh; }
.login-brand-panel { display: flex; flex-direction: column; justify-content: space-between; padding: 44px; color: white; background: linear-gradient(145deg,#111827,#172554 58%,#1d4ed8); }
.login-brand-panel h1 { max-width: 640px; margin-bottom: 16px; font-size: clamp(38px,6vw,72px); line-height: 1.02; }
.login-brand-panel p:not(.eyebrow) { max-width: 600px; color: #cbd5e1; font-size: 17px; line-height: 1.8; }
.large-brand { padding: 0; }
.login-card { align-self: center; width: min(430px,calc(100% - 48px)); margin: 24px auto; padding: 30px; border: 1px solid var(--border); border-radius: 20px; background: white; box-shadow: var(--shadow); }
.login-card h2 { margin-bottom: 7px; font-size: 30px; }
.login-form { display: grid; gap: 16px; margin-top: 24px; }
.login-form label span { display: block; margin-bottom: 7px; color: var(--muted-strong); font-size: 12px; font-weight: 800; }
.login-form input { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 10px; outline: none; }
.login-form input:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px #dbeafe; }
.login-submit { width: 100%; min-height: 44px; margin-top: 4px; }
.form-error { margin-top: 18px; padding: 11px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 12px; font-weight: 700; }
.sidebar-toggle { display: none; }

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .client-summary-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .client-profile-card { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; transform: translateX(-102%); transition: transform .22s ease; box-shadow: 12px 0 30px rgba(15,23,42,.2); }
  .sidebar-toggle:checked ~ .app-shell .sidebar { transform: translateX(0); }
  .mobile-menu-button { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 10px; background: white; color: var(--text); cursor: pointer; }
  .topbar { padding: 11px 16px; }
  .global-search { max-width: none; }
  .user-name { display: none; }
  .content { padding: 20px 16px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .panel-wide, .panel-full { grid-column: 1; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand-panel { min-height: 270px; padding: 28px; }
  .login-brand-panel h1 { max-width: 560px; font-size: 42px; }
  .login-brand-panel p:not(.eyebrow) { display: none; }
}

@media (max-width: 620px) {
  .quick-create, .icon-button { display: none; }
  .global-search input { min-width: 0; }
  .page-header { flex-direction: column; }
  .header-actions { width: 100%; }
  .header-actions > * { flex: 1; }
  .stat-grid, .client-summary-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: 118px; }
  .filters { align-items: stretch; flex-direction: column; }
  .filters select, .filters button { width: 100%; }
  .profile-list { grid-template-columns: 1fr; }
  .login-brand-panel { min-height: 230px; }
  .login-card { width: calc(100% - 28px); padding: 23px; }
}
