/* Steps Demo Platform — dark theme (develop / dev.steps.cl) */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --brand: #2563eb; --brand-dark: #1d4ed8;
  --surface: #0f172a; --card-bg: #1e293b;
  --border: #334155; --text: #f1f5f9;
  --text-muted: #94a3b8; --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.2), 0 4px 16px rgba(0,0,0,.3);
}
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--surface); color: var(--text); min-height: 100vh; }

/* Login */
#login-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 2rem; gap: 2rem; }
.login-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2.5rem 3rem; text-align: center; max-width: 400px; width: 100%; }
.login-logo { font-size: 2rem; font-weight: 800; letter-spacing: -1px; color: var(--brand); margin-bottom: .25rem; }
.login-sub { color: var(--text-muted); font-size: .9rem; margin-bottom: 2rem; }
.login-error { color: #f87171; font-size: .85rem; margin-top: 1rem; display: none; }

/* App picker */
#app-picker { display: none; flex-direction: column; min-height: 100vh; }
.picker-header { background: var(--card-bg); border-bottom: 1px solid var(--border); padding: .875rem 1.5rem; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 65; }
.picker-logo { font-size: 1.25rem; font-weight: 800; letter-spacing: -.5px; color: var(--brand); }
.picker-right { display: flex; align-items: center; gap: .75rem; }
.user-badge { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--text-muted); }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; font-size: .75rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.admin-tag { background: #78350f; color: #fde68a; font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; border: 1px solid #92400e; text-transform: uppercase; letter-spacing: .5px; }
.btn-logout { background: none; border: 1px solid var(--border); border-radius: 8px; padding: .375rem .75rem; font-size: .8rem; color: var(--text-muted); cursor: pointer; transition: all .15s; }
.btn-logout:hover { background: #334155; color: var(--text); }

/* Filters */
.filters-section { background: var(--card-bg); border-bottom: 1px solid var(--border); padding: .75rem 1.5rem; }
.filters-wrap { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: flex-start; }
.filter-group { display: flex; align-items: center; gap: .375rem; flex-wrap: wrap; }
.filter-group-label { font-size: .72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; padding-right: .125rem; }
.chip { display: inline-flex; align-items: center; gap: .25rem; padding: .28rem .7rem; border-radius: 99px; font-size: .78rem; font-weight: 500; cursor: pointer; border: 1px solid var(--border); background: #0f172a; color: var(--text-muted); transition: all .15s; user-select: none; }
.chip:hover { border-color: #64748b; color: var(--text); }
.chip.todos.active { background: #3b82f6; border-color: #2563eb; color: #fff; }

/* Grid */
.picker-body { flex: 1; padding: 1.5rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.section-title { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); }
.btn-create { background: var(--brand); color: #fff; border: none; border-radius: 8px; padding: .4rem .85rem; font-size: .82rem; font-weight: 700; cursor: pointer; transition: background .15s; white-space: nowrap; }
.btn-create:hover { background: var(--brand-dark); }
.apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }

/* Card */
.app-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; display: flex; flex-direction: column; gap: .75rem; transition: box-shadow .15s, transform .15s; cursor: pointer; }
.app-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.4); transform: translateY(-1px); }
.app-card.hidden { display: none; }
.card-top { display: flex; align-items: flex-start; gap: .75rem; }
.card-logo { width: 44px; height: 44px; border-radius: 10px; object-fit: contain; border: 1px solid var(--border); flex-shrink: 0; background: #1e293b; }
.card-logo-placeholder { width: 44px; height: 44px; border-radius: 10px; background: linear-gradient(135deg, #1e3a8a, #1d4ed8); display: flex; align-items: center; justify-content: center; font-size: 1.25rem; font-weight: 700; color: #93c5fd; flex-shrink: 0; }
.card-meta { flex: 1; min-width: 0; }
.card-name { font-size: .95rem; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-desc { font-size: .82rem; color: var(--text-muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-actions { display: flex; gap: .5rem; margin-top: auto; }
.card-btn { flex: 1; text-align: center; padding: .5rem; border-radius: 8px; font-size: .82rem; font-weight: 600; text-decoration: none; cursor: pointer; border: none; transition: all .15s; }
.card-btn-primary { background: var(--brand); color: #fff; }
.card-btn-primary:hover { background: var(--brand-dark); }
.card-btn-secondary { background: #1e293b; color: var(--text-muted); border: 1px solid var(--border); }
.card-btn-secondary:hover { background: #334155; color: var(--text); }
.card-tag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-size: .68rem; font-weight: 600; border: 1px solid; white-space: nowrap; margin-top: .25rem; }
.card-tipo-uso { font-size: .75rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: .15rem .6rem; margin-top: .5rem; }
.card-tipo-uso-item { display: flex; align-items: center; gap: .3rem; }
.card-tipo-uso-label { font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: #64748b; }
.card-tipo-uso-value { font-size: .78rem; color: var(--text-muted); }
.no-results { text-align: center; padding: 3rem; color: var(--text-muted); font-size: .9rem; display: none; }

/* Modals */
.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 100; align-items: center; justify-content: center; padding: 1rem; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--card-bg); border-radius: var(--radius); box-shadow: 0 8px 40px rgba(0,0,0,.5); width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; display: flex; flex-direction: column; border: 1px solid var(--border); }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--card-bg); z-index: 1; }
.modal-title { font-size: 1.05rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.25rem; color: var(--text-muted); cursor: pointer; line-height: 1; padding: .25rem; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }

/* Detail modal */
.detail-logo-wrap { display: flex; align-items: center; gap: 1rem; }
.detail-logo { width: 56px; height: 56px; border-radius: 12px; object-fit: contain; border: 1px solid var(--border); }
.detail-logo-placeholder { width: 56px; height: 56px; border-radius: 12px; background: linear-gradient(135deg, #1e3a8a, #1d4ed8); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 700; color: #93c5fd; }
.detail-name { font-size: 1.2rem; font-weight: 700; }
.detail-desc { font-size: .9rem; color: var(--text-muted); line-height: 1.55; }
.detail-section-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: .4rem; margin-top: .25rem; }
.detail-meta { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.detail-meta-full { grid-column: 1 / -1; }
.detail-meta-item { background: #0f172a; border: 1px solid var(--border); border-radius: 8px; padding: .6rem .85rem; }
.detail-meta-label { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); margin-bottom: .2rem; }
.detail-meta-value { font-size: .85rem; font-weight: 500; color: var(--text); word-break: break-all; }
.detail-meta-value a { color: #60a5fa; text-decoration: none; }
.detail-meta-value a:hover { text-decoration: underline; }
.detail-divider { border: none; border-top: 1px solid var(--border); margin: .25rem 0; }
.detail-actions { display: flex; gap: .75rem; }
.detail-btn { flex: 1; padding: .65rem; border-radius: 8px; font-size: .88rem; font-weight: 600; text-align: center; text-decoration: none; border: 1px solid transparent; cursor: pointer; transition: all .15s; }
.detail-btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.detail-btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.detail-btn-secondary { background: transparent; color: var(--text); border-color: var(--border); }
.detail-btn-secondary:hover { background: #334155; border-color: #475569; }

/* Users list */
.users-list { display: flex; flex-direction: column; gap: .35rem; }
.user-row { display: flex; align-items: center; justify-content: space-between; padding: .45rem .75rem; background: #0f172a; border: 1px solid var(--border); border-radius: 8px; font-size: .82rem; }
.user-email { color: var(--text); font-weight: 500; }
.user-status-tag { font-size: .68rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; text-transform: uppercase; letter-spacing: .3px; }
.user-status-tag.activo { background: #14532d; color: #86efac; border: 1px solid #166534; }
.user-status-tag.admin  { background: #78350f; color: #fde68a; border: 1px solid #92400e; }

/* Clone / Create modals — shared form styles */
.clone-step { display: none; flex-direction: column; gap: 1rem; }
.clone-step.active { display: flex; }
label { font-size: .85rem; font-weight: 600; color: var(--text); }
input[type=text], input[type=email], select, textarea { width: 100%; padding: .55rem .75rem; border: 1px solid var(--border); border-radius: 8px; font-size: .88rem; font-family: inherit; color: var(--text); background: #0f172a; transition: border-color .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); }
select option { background: #1e293b; color: var(--text); }
textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; flex-direction: column; gap: .35rem; }
.form-row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.form-hint { font-size: .76rem; color: var(--text-muted); }
.clone-actions { display: flex; gap: .75rem; justify-content: flex-end; }
.btn-secondary { background: transparent; border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: .55rem 1.1rem; font-size: .85rem; font-weight: 600; cursor: pointer; transition: all .15s; }
.btn-secondary:hover { background: #334155; border-color: #475569; }
.btn-primary { background: var(--brand); border: none; color: #fff; border-radius: 8px; padding: .55rem 1.1rem; font-size: .85rem; font-weight: 600; cursor: pointer; transition: all .15s; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.clone-success-links { display: flex; flex-direction: column; gap: .5rem; margin-top: .5rem; }
.clone-success-link { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
.clone-success-link a { color: #60a5fa; text-decoration: none; word-break: break-all; }
.clone-success-link a:hover { text-decoration: underline; }

/* Sidebar layout */
.picker-layout { display: flex; flex: 1; }
.picker-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.sidebar { width: 220px; min-width: 220px; min-height: 100vh; background: var(--card-bg); border-right: 1px solid var(--border); padding: 1rem 0; flex-shrink: 0; }
.sidebar-nav { display: flex; flex-direction: column; }
.sidebar-section-label { font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .7px; color: var(--text-muted); padding: .9rem 1.25rem .3rem; margin-top: .25rem; }
.sidebar-list { list-style: none; padding: 0; margin: 0; }
.sidebar-item { display: flex; align-items: center; gap: .55rem; padding: .5rem 1.25rem; font-size: .875rem; color: var(--text-muted); cursor: pointer; transition: background .12s, color .12s; user-select: none; }
.sidebar-item:hover:not(.soon) { background: rgba(255,255,255,.05); color: var(--text); }
.sidebar-item.active { background: rgba(37,99,235,.15); color: var(--brand); font-weight: 600; }
.sidebar-item.soon { cursor: default; opacity: .5; }
.soon-badge { margin-left: auto; font-size: .58rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; background: #1e293b; color: var(--text-muted); padding: 1px 6px; border-radius: 99px; border: 1px solid var(--border); }

/* Section header right */
.section-header-right { display: flex; align-items: center; gap: .75rem; }

/* View toggle */
.view-toggle { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 2px; gap: 2px; }
.view-btn { display: flex; align-items: center; gap: .3rem; padding: .3rem .65rem; border-radius: 6px; font-size: .78rem; font-weight: 600; color: var(--text-muted); background: none; border: none; cursor: pointer; transition: all .15s; white-space: nowrap; }
.view-btn.active { background: var(--card-bg); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.view-btn:hover:not(.active) { color: var(--text); }

/* Search */
.filters-row { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.5rem; }
.search-wrap { position: relative; display: flex; align-items: center; flex-shrink: 0; }
.search-icon { position: absolute; left: .6rem; color: var(--text-muted); pointer-events: none; }
#apps-search { padding: .35rem .75rem .35rem 2rem; border: 1px solid var(--border); border-radius: 20px; font-size: .82rem; font-family: inherit; background: var(--surface); color: var(--text); width: 220px; transition: border-color .15s; }
#apps-search:focus { outline: none; border-color: var(--brand); }
#apps-search::placeholder { color: var(--text-muted); }

/* Apps table */
.apps-table-wrap { overflow-x: auto; }
.apps-table { width: 100%; border-collapse: collapse; }
.apps-table th { text-align: left; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); padding: .6rem .75rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.th-sortable { cursor: pointer; user-select: none; }
.th-sortable:hover { color: var(--text); }
.sort-icon::after { content: ''; margin-left: .2rem; opacity: .25; font-size: .75em; }
.th-sortable:hover .sort-icon::after { content: '↕'; opacity: .4; }
.th-sortable.sort-asc .sort-icon::after { content: '↑'; opacity: 1; color: var(--brand); }
.th-sortable.sort-desc .sort-icon::after { content: '↓'; opacity: 1; color: var(--brand); }
.apps-table td { padding: .6rem .75rem; border-bottom: 1px solid rgba(51,65,85,.6); vertical-align: middle; }
.table-row:hover td { background: rgba(255,255,255,.025); }
.table-row.hidden { display: none; }
.table-logo { width: 32px; height: 32px; border-radius: 8px; object-fit: contain; border: 1px solid var(--border); display: block; }
.table-logo-placeholder { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, #1e3a8a, #1d4ed8); display: flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 700; color: #93c5fd; }
.table-name { font-size: .875rem; font-weight: 600; color: var(--text); white-space: nowrap; }
.table-muted { font-size: .82rem; color: var(--text-muted); }
.table-desc { max-width: 200px; font-size: .82rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-actions { display: flex; gap: .4rem; }

/* Sidebar toggle (hamburger) — hidden on desktop */
.sidebar-toggle { display: none; align-items: center; justify-content: center; background: none; border: 1px solid var(--border); border-radius: 8px; padding: .35rem .45rem; cursor: pointer; color: var(--text-muted); transition: all .15s; flex-shrink: 0; }
.sidebar-toggle:hover { background: rgba(255,255,255,.06); color: var(--text); }

/* Sidebar close button — hidden on desktop */
.sidebar-close { display: none; position: absolute; top: .6rem; right: .6rem; background: none; border: none; color: var(--text-muted); cursor: pointer; padding: .3rem; border-radius: 6px; line-height: 1; transition: all .15s; }
.sidebar-close:hover { color: var(--text); background: rgba(255,255,255,.06); }

/* Drawer backdrop */
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 55; }
.sidebar-backdrop.open { display: block; }

/* Tablet/Mobile ≤900px: sidebar as off-canvas drawer */
@media (max-width: 900px) {
  .sidebar-toggle { display: flex; }
  .sidebar-close { display: block; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    min-height: unset;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
    padding-top: 3rem;
  }
  .sidebar.open { transform: translateX(0); }
  .picker-layout { display: block; }
  .section-header-right { gap: .5rem; }
  .view-btn { padding: .3rem .5rem; font-size: .72rem; }
}

/* Small screens ≤480px */
@media (max-width: 480px) {
  .picker-header { padding: .75rem 1rem; }
  .picker-body { padding: 1rem; }
  .section-header { flex-wrap: wrap; gap: .5rem; }
  .section-header-right { justify-content: flex-end; }
  .filters-section { padding: .6rem 1rem; }
  .filters-row { gap: .5rem .75rem; }
  #apps-search { width: 100%; max-width: 100%; }
  .filters-wrap { width: 100%; }
  .user-badge span#user-email-display { display: none; }
}

/* Proposal cards */
.proposal-card { border-top: 3px solid var(--brand); }
.proposal-card-header { display: flex; align-items: flex-start; gap: .75rem; }
.proposal-card-title { flex: 1; min-width: 0; }
.proposal-card-client { font-size: .78rem; color: var(--text-muted); font-weight: 500; margin-top: .15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proposal-meta-chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.proposal-chip { display: inline-flex; align-items: center; gap: .25rem; padding: .22rem .55rem; border-radius: 6px; font-size: .72rem; background: rgba(37,99,235,.1); border: 1px solid rgba(37,99,235,.18); color: #3b82f6; white-space: nowrap; }
.proposal-chip-label { font-weight: 700; text-transform: uppercase; font-size: .62rem; letter-spacing: .3px; opacity: .7; margin-right: .1rem; }
.proposal-commercial-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .5rem .75rem; background: rgba(37,99,235,.07); border: 1px solid rgba(37,99,235,.15); border-radius: 8px; }
.proposal-monto { font-size: .88rem; font-weight: 700; color: var(--text); }
.proposal-estado-chip { font-size: .72rem; font-weight: 600; color: var(--text-muted); padding: .15rem .5rem; background: rgba(148,163,184,.12); border: 1px solid rgba(148,163,184,.25); border-radius: 99px; }
.proposal-sep { color: var(--text-muted); font-size: .8rem; }

/* Admin entity cards */
.entity-card { cursor: pointer; }
.entity-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.35); transform: translateY(-1px); }
.entity-status { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-size: .72rem; font-weight: 600; letter-spacing: .3px; text-transform: uppercase; border: 1px solid transparent; }
.entity-status.activo  { background: #14532d; color: #86efac; border-color: #166534; }
.entity-status.admin   { background: #78350f; color: #fde68a; border-color: #92400e; }
.entity-status.inactivo{ background: #450a0a; color: #fca5a5; border-color: #7f1d1d; }
.entity-slug-chip { display: inline-flex; align-items: center; padding: .18rem .55rem; border-radius: 6px; font-size: .72rem; background: rgba(148,163,184,.1); border: 1px solid rgba(148,163,184,.2); color: var(--text-muted); font-family: monospace; white-space: nowrap; }

/* Admin entity detail */
.entity-detail-row { display: flex; flex-direction: column; gap: .3rem; padding: .45rem 0; }
.entity-detail-label { font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); }
.entity-detail-section { background: #0f172a; border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; }

/* Admin form section label */
.admin-form-section-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); padding: .25rem 0 .1rem; border-top: 1px solid var(--border); margin-top: .25rem; }

/* Spinner / Toast */
.spinner { width: 20px; height: 20px; border: 2px solid #334155; border-top-color: var(--brand); border-radius: 50%; animation: spin .6s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
#toast { position: fixed; bottom: 1.5rem; right: 1.5rem; background: #334155; color: #fff; padding: .75rem 1.25rem; border-radius: 10px; font-size: .85rem; box-shadow: 0 4px 20px rgba(0,0,0,.4); z-index: 200; transform: translateY(120%); transition: transform .25s; max-width: 320px; }
#toast.show { transform: translateY(0); }
#toast.success { background: #15803d; }
#toast.error   { background: #dc2626; }
