:root {
    --ink: #18232b;
    --muted: #6d7880;
    --line: #dfe5e8;
    --panel: #ffffff;
    --canvas: #f4f6f7;
    --navy: #0d3d57;
    --navy-deep: #082c40;
    --orange: #ed8425;
    --lime: #91cc23;
    --danger: #b83a36;
    --sidebar: 286px;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    color: var(--ink);
    background: var(--canvas);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
button, input, select { font: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

/* LOGIN */
.login-page { min-height: 100vh; background: #fff; }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(430px, 46%) 1fr; }
.login-identity { position: relative; overflow: hidden; padding: 56px; background: var(--navy-deep); color: #fff; display: grid; place-items: center; border-top: 6px solid var(--orange); }
.login-identity::before { content: ""; position: absolute; inset: auto -120px -160px auto; width: 430px; height: 430px; border: 1px solid rgba(255,255,255,.08); border-radius: 50%; box-shadow: 0 0 0 55px rgba(255,255,255,.025), 0 0 0 110px rgba(255,255,255,.018); }
.identity-inner { width: min(500px, 100%); position: relative; z-index: 1; }
.identity-logo-card { background: #fff; padding: 24px 28px; border-radius: 3px; box-shadow: 0 18px 45px rgba(0,0,0,.16); }
.identity-logo-card img { display: block; width: 100%; max-height: 285px; object-fit: contain; }
.identity-copy { margin-top: 30px; padding-left: 3px; }
.identity-copy span { color: #f0a05c; letter-spacing: .18em; font-size: 11px; font-weight: 800; }
.identity-copy h2 { margin: 7px 0 8px; font-size: 28px; letter-spacing: -.025em; }
.identity-copy p { margin: 0; max-width: 450px; color: #b9ccd5; line-height: 1.6; font-size: 14px; }
.login-panel { display: grid; place-items: center; padding: 48px; border-top: 6px solid var(--orange); }
.login-box { width: min(430px, 100%); }
.login-eyebrow, .page-kicker, .modal-kicker { color: var(--orange); font-weight: 800; font-size: 11px; letter-spacing: .14em; }
.login-box h1 { margin: 9px 0 7px; font-size: 36px; letter-spacing: -.035em; }
.login-copy { margin: 0 0 31px; color: var(--muted); }
.login-box label { display: block; margin: 18px 0 7px; font-size: 13px; font-weight: 700; }
.login-box input { width: 100%; height: 48px; border: 1px solid #bdc7cc; border-radius: 3px; padding: 0 13px; outline: none; background: #fff; }
.login-box input:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(13,61,87,.1); }
.primary-button { width: 100%; margin-top: 24px; height: 48px; border: 0; border-radius: 3px; background: var(--navy); color: #fff; font-weight: 800; cursor: pointer; }
.primary-button:hover { background: var(--navy-deep); }
.primary-button:disabled { opacity: .6; cursor: wait; }
.primary-button.compact { width: auto; min-width: 110px; margin: 0; padding: 0 18px; }
.form-error { margin-top: 14px; padding: 10px 12px; border-left: 4px solid var(--danger); background: #fff2f1; color: #7f2724; font-size: 13px; }
.login-foot { margin-top: 36px; padding-top: 17px; border-top: 1px solid var(--line); color: #88939a; font-size: 12px; }

/* APP */
.app-page { min-height: 100vh; background: var(--canvas); }
.topbar { position: fixed; z-index: 50; inset: 0 0 auto 0; height: 64px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 22px 0 14px; }
.topbar-left, .topbar-tools { display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-logo { width: 46px; height: 40px; display: grid; place-items: center; overflow: hidden; background: #fff; }
.brand-logo img { width: 100%; height: 100%; object-fit: contain; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.05; }
.brand-copy strong { font-size: 16px; text-transform: uppercase; letter-spacing: .035em; }
.brand-copy small { color: var(--muted); margin-top: 4px; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
.menu-toggle { width: 40px; height: 40px; border: 0; background: transparent; display: grid; align-content: center; gap: 5px; cursor: pointer; }
.menu-toggle span { display: block; width: 24px; height: 2px; background: var(--ink); }
.patio-control { height: 42px; display: flex; align-items: center; border: 1px solid var(--line); background: #fff; }
.patio-control > span { padding: 0 10px; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; border-right: 1px solid var(--line); }
.patio-control select { min-width: 145px; height: 40px; border: 0; padding: 0 30px 0 10px; color: var(--ink); background: #fff; outline: none; }
.pending-wrap { position: relative; }
.pending-button { width: 42px; height: 42px; border: 0; background: var(--orange); color: #12212a; font-weight: 900; cursor: pointer; }
.pending-button.has-warning { background: #2566b1; color: #fff; }
.pending-popover { position: absolute; right: 0; top: 50px; width: 250px; padding: 14px; background: #fff; border: 1px solid var(--line); box-shadow: 0 14px 35px rgba(18,32,42,.16); }
.pending-title { font-weight: 800; font-size: 13px; margin-bottom: 8px; }
.pending-detail { display:flex; justify-content:space-between; padding: 7px 0; border-top:1px solid #edf0f2; font-size: 13px; }
.pending-warning { margin-top: 8px; padding: 8px; background:#edf4ff; color:#184d88; font-size:12px; }
.user-chip { height: 42px; display: flex; align-items: center; gap: 8px; padding: 0 4px 0 8px; max-width: 190px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--lime); flex: 0 0 auto; }
.logout-button { height: 36px; border: 0; background: transparent; color: #637078; cursor: pointer; padding: 0 8px; font-size: 13px; }
.logout-button:hover { color: var(--danger); }

.sidebar { position: fixed; z-index: 40; top: 64px; bottom: 0; left: 0; width: var(--sidebar); background: #fff; border-right: 1px solid var(--line); display:flex; flex-direction:column; transform:translateX(-100%); box-shadow:10px 0 30px rgba(12,35,47,.14); transition: transform .2s ease; }
body.sidebar-open .sidebar { transform:translateX(0); }
.sidebar-search-wrap { position: relative; padding: 14px; border-bottom: 1px solid var(--line); }
.sidebar-search { width:100%; height:38px; padding:0 36px 0 11px; border:1px solid #cfd7db; background:#f9fafb; outline:none; }
.sidebar-search:focus { border-color: var(--navy); background:#fff; }
.search-hint { position:absolute; right:26px; top:23px; color:#7e8a91; font-size:18px; }
.sidebar-nav { overflow-y:auto; padding: 8px 0 24px; }
.home-link { display:block; padding:11px 18px; text-decoration:none; font-size:13px; font-weight:800; color:#536069; }
.home-link.active { color:var(--navy); background:#eef4f6; border-left:3px solid var(--orange); padding-left:15px; }
.menu-group { border-top: 1px solid #edf0f1; }
.menu-group summary { list-style:none; cursor:pointer; padding:13px 17px; display:flex; align-items:center; justify-content:space-between; font-size:12px; font-weight:900; text-transform:uppercase; letter-spacing:.07em; color:#25343d; user-select:none; }
.menu-group summary::-webkit-details-marker { display:none; }
.menu-group summary span { font-size:20px; font-weight:300; color:#69767d; transition:transform .15s ease; }
.menu-group[open] summary { background: var(--navy); color:#fff; }
.menu-group[open] summary span { transform:rotate(45deg); color:#fff; }
.menu-items { padding:6px 0; background:#fbfcfc; }
.menu-item { display:block; padding:8px 16px 8px 28px; text-decoration:none; color:#35434b; font-size:13px; border-left:3px solid transparent; }
.menu-item:hover { background:#eef2f4; }
.menu-item.active { color:var(--navy); font-weight:800; border-left-color:var(--orange); background:#edf4f6; }
.workspace { margin-left:0; padding:96px 34px 40px; min-height:100vh; }
.page-head { max-width: 1260px; margin:0 auto 22px; display:flex; justify-content:space-between; align-items:flex-end; gap:24px; }
.page-head h1 { margin:5px 0 4px; font-size:32px; letter-spacing:-.035em; }
.page-head p { margin:0; color:var(--muted); }
.context-strip { min-width:190px; padding:11px 14px; border-left:4px solid var(--orange); background:#fff; box-shadow:0 1px 2px rgba(0,0,0,.03); }
.context-strip span { display:block; color:var(--muted); text-transform:uppercase; font-size:9px; letter-spacing:.12em; }
.context-strip strong { display:block; margin-top:3px; font-size:15px; }
.welcome-board, .migration-placeholder { max-width:1260px; margin:0 auto; background:#fff; border:1px solid var(--line); padding:32px; }
.welcome-board { display:flex; gap:20px; align-items:flex-start; }
.welcome-line { width:5px; min-height:70px; background:linear-gradient(to bottom, var(--orange) 0 50%, var(--navy) 50% 100%); flex:0 0 auto; }
.welcome-board strong { font-size:18px; }
.welcome-board p { color:var(--muted); max-width:760px; line-height:1.6; margin:7px 0 0; }
.migration-placeholder { border-top:4px solid var(--navy); }
.migration-placeholder h2 { margin:10px 0 7px; font-size:22px; }
.migration-placeholder p { margin:0; color:var(--muted); line-height:1.6; max-width:820px; }
.migration-code { display:inline-block; padding:6px 9px; background:#edf2f4; color:#39505d; font-family:Consolas,monospace; font-size:12px; }
.sidebar-overlay { display:none; position:fixed; z-index:35; inset:64px 0 0 0; background:rgba(4,20,30,.07); }
body.sidebar-open .sidebar-overlay { display:block; }

/* MODAL */
.modal-backdrop { position:fixed; z-index:100; inset:0; background:rgba(7,24,34,.6); display:grid; place-items:center; padding:20px; }
.system-modal { width:min(700px,100%); max-height:82vh; background:#fff; display:flex; flex-direction:column; box-shadow:0 20px 60px rgba(0,0,0,.28); }
.modal-head { display:flex; justify-content:space-between; gap:20px; padding:20px 22px; border-bottom:1px solid var(--line); }
.modal-head h2 { margin:4px 0 0; font-size:21px; }
.icon-button { border:0; background:transparent; font-size:28px; cursor:pointer; color:#66747b; }
.minimum-list { overflow:auto; padding:0 22px; }
.minimum-row { display:flex; justify-content:space-between; gap:24px; padding:13px 0; border-bottom:1px solid #edf0f1; font-size:13px; }
.minimum-row span { color:var(--muted); text-align:right; }
.modal-actions { padding:16px 22px; display:flex; justify-content:flex-end; border-top:1px solid var(--line); }

@media (max-width: 980px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-identity { min-height: 320px; padding:34px; }
    .identity-inner { width: min(420px, 100%); }
    .identity-logo-card { padding:18px 20px; }
    .identity-copy { margin-top:20px; }
    .login-panel { padding:36px 22px; }
    .sidebar-overlay { background:rgba(4,20,30,.38); }
    .workspace { padding:92px 20px 32px; }
    .brand-copy { display:none; }
    .user-chip { display:none; }
}
@media (max-width: 650px) {
    .topbar { padding-right:8px; }
    .topbar-tools { gap:5px; }
    .patio-control > span { display:none; }
    .patio-control select { min-width:112px; max-width:145px; }
    .logout-button { display:none; }
    .page-head { align-items:flex-start; flex-direction:column; }
    .context-strip { width:100%; }
    .minimum-row { flex-direction:column; gap:4px; }
    .minimum-row span { text-align:left; }
}

/* =========================================================
   COMPONENTES V2 · BOTONES / FORMULARIOS / CATÁLOGOS
   Regla: <button> para acciones, <a> únicamente para navegar.
   ========================================================= */
.btn {
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 3px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    text-decoration: none;
    font-weight: 750;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease, transform .1s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: wait; transform: none; }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-deep); border-color: var(--navy-deep); }
.btn-secondary { background: #fff; color: #43515a; border-color: #cbd4d8; }
.btn-secondary:hover { background: #f3f6f7; border-color: #aebbc1; }
.btn-accent { background: var(--orange); color: #17232a; border-color: var(--orange); }
.btn-accent:hover { background: #dc761b; border-color: #dc761b; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #9f302d; border-color: #9f302d; }

.module-page { max-width: 1320px; margin: 0 auto; }
.module-head { margin-bottom: 20px; display:flex; align-items:flex-end; justify-content:space-between; gap:24px; }
.module-head h1 { margin:5px 0 4px; font-size:32px; letter-spacing:-.035em; }
.module-head p { margin:0; color:var(--muted); }
.catalog-card, .form-card { background:#fff; border:1px solid var(--line); box-shadow:0 1px 2px rgba(18,35,44,.025); }
.catalog-toolbar { display:flex; align-items:flex-end; gap:14px; padding:18px; border-bottom:1px solid var(--line); background:#fbfcfc; }
.field { display:flex; flex-direction:column; gap:6px; min-width:180px; }
.field > span { color:#5c6971; font-size:11px; font-weight:800; text-transform:uppercase; letter-spacing:.065em; }
.field input, .field select { height:40px; border:1px solid #c6d0d5; border-radius:2px; background:#fff; color:var(--ink); padding:0 11px; outline:none; }
.field input:focus, .field select:focus { border-color:var(--navy); box-shadow:0 0 0 3px rgba(13,61,87,.08); }
.search-field { flex:1; min-width:260px; max-width:520px; }
.compact-field { min-width:150px; }
.toolbar-actions { margin-left:auto; display:flex; gap:8px; }
.table-wrap { width:100%; overflow-x:auto; }
.data-table { width:100%; border-collapse:collapse; background:#fff; }
.data-table th { padding:13px 14px; background:var(--navy); color:#fff; text-align:left; font-size:11px; text-transform:uppercase; letter-spacing:.07em; font-weight:800; }
.data-table td { padding:12px 14px; border-bottom:1px solid #e8edef; font-size:13px; vertical-align:middle; }
.data-table tbody tr:hover { background:#f8fafb; }
.actions-column { width:116px; }
.status-column { width:150px; }
.row-actions { display:flex; gap:7px; }
.btn-icon { width:34px; height:34px; border-radius:3px; display:inline-grid; place-items:center; border:1px solid #ccd5d9; background:#fff; cursor:pointer; text-decoration:none; transition:.15s ease; }
.btn-icon svg { width:17px; height:17px; fill:currentColor; }
.btn-icon-edit { color:var(--navy); }
.btn-icon-edit:hover { background:#edf5f8; border-color:#9db5c0; }
.btn-icon-danger { color:var(--danger); }
.btn-icon-danger:hover { background:#fff1f0; border-color:#dfaaa7; }
.btn-icon:disabled { opacity:.45; cursor:wait; }
.status-badge { min-width:72px; display:inline-flex; align-items:center; justify-content:center; padding:5px 9px; border-radius:999px; font-size:11px; font-weight:800; }
.status-active { background:#edf7e1; color:#456d11; }
.status-inactive { background:#f1f3f4; color:#68747b; }
.table-message { padding:28px !important; text-align:center; color:var(--muted); }
.table-error { color:var(--danger); }
.table-footer { min-height:58px; padding:10px 14px; display:flex; align-items:center; justify-content:space-between; gap:15px; border-top:1px solid var(--line); }
.table-count { color:var(--muted); font-size:12px; }
.pagination { display:flex; gap:5px; }
.page-button { min-width:34px; height:34px; border:1px solid #ccd5d9; background:#fff; color:#48565e; cursor:pointer; }
.page-button:hover:not(:disabled) { border-color:#9eb0b8; background:#f5f7f8; }
.page-button.active { background:var(--navy); border-color:var(--navy); color:#fff; font-weight:800; }
.page-button:disabled { opacity:.4; cursor:default; }

.form-card { padding:24px; }
.form-grid { display:grid; grid-template-columns:minmax(260px, 2fr) minmax(180px, .7fr); gap:18px; max-width:820px; }
.field-wide { min-width:0; }
.form-actions { margin-top:26px; padding-top:18px; border-top:1px solid var(--line); display:flex; justify-content:flex-end; gap:9px; }

.toast-stack { position:fixed; z-index:180; right:20px; top:82px; display:flex; flex-direction:column; gap:8px; pointer-events:none; }
.toast { min-width:260px; max-width:420px; padding:12px 14px; border-left:4px solid var(--navy); background:#fff; color:#26333b; box-shadow:0 12px 32px rgba(13,35,46,.18); transform:translateX(18px); opacity:0; transition:.18s ease; font-size:13px; }
.toast.show { transform:translateX(0); opacity:1; }
.toast-success { border-left-color:#6eaa22; }
.toast-error { border-left-color:var(--danger); }
.confirm-backdrop { position:fixed; z-index:170; inset:0; display:grid; place-items:center; padding:20px; background:rgba(6,22,31,.56); }
.confirm-box { width:min(430px,100%); background:#fff; padding:24px; box-shadow:0 24px 70px rgba(0,0,0,.27); }
.confirm-box h2 { margin:0 0 8px; font-size:20px; }
.confirm-box p { margin:0; color:var(--muted); line-height:1.55; }
.confirm-actions { margin-top:22px; display:flex; justify-content:flex-end; gap:8px; }

@media (max-width: 760px) {
    .module-head { align-items:flex-start; flex-direction:column; }
    .catalog-toolbar { align-items:stretch; flex-direction:column; }
    .search-field, .compact-field { min-width:0; max-width:none; width:100%; }
    .toolbar-actions { margin-left:0; }
    .toolbar-actions .btn { width:100%; }
    .form-grid { grid-template-columns:1fr; }
    .form-actions { flex-direction:column-reverse; }
    .form-actions .btn { width:100%; }
}
