/* Reset básico */
* { box-sizing: border-box; }
body, html { margin: 0; padding: 0; font-family: 'Inter', sans-serif; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* Fondo degradado */
.background-gradient{
  display:flex;
  min-height:100vh;
  background:linear-gradient(135deg,#ffa96d 0%,#b48bff 100%);
  padding:20px;
}

/* =========================
   PANEL + HEADER (sticky)
   ========================= */
.panel{
  flex:1 1 auto;
  max-width:960px;
  margin:30px auto;
  background:#fff;
  border-radius:24px;
  /* El panel es columna: header arriba + contenido */
  display:flex;
  flex-direction:column;
  /* El header sticky necesita que el contenedor tenga contexto,
     pero mantenemos el recorte de bordes redondeados */
  overflow:hidden;
  /* El padding lo da cada sección (top-bar y .page) */
  padding:0;
  box-shadow:0 8px 24px rgba(0,0,0,.08);
  position:relative;
}

/* Header dentro del panel */
.top-bar{
  position:sticky; top:0; z-index:20;
  display:flex; align-items:center; justify-content:space-between;
  gap:12px;
  padding:12px 16px;
  color:#1b1b1f;
  /* Fondo translúcido para scroll */
  background:linear-gradient(180deg,rgba(255,255,255,.95),rgba(255,255,255,.9));
  backdrop-filter:blur(6px);
  border-bottom:1px solid #eee;
}
.brand{
  font-weight:800; font-size:1.25em; margin-left:6px; color:#1b1b1f;
}
.top-links a{
  margin-right:12px; color:#444; font-size:.9em;
}
.top-links a:hover{ text-decoration:underline; }
.hamburger{
  display:none; background:transparent; color:#333; border:none;
  font-size:24px; padding:4px; cursor:pointer; margin-right:10px;
}
.top-user{ display:flex; align-items:center; gap:14px; }
.avatar-circle{
  display:inline-flex; align-items:center; justify-content:center;
  width:36px; height:36px; border-radius:50%;
  background:#6746e7; color:#fff; font-weight:700;
}
.top-avatar img{ width:36px; height:36px; border-radius:50%; object-fit:cover; }
.admin-link{ color:#333; font-size:1.2em; }
.logout-button{
  background:#ff6161; color:#fff; border:none; padding:6px 12px;
  border-radius:12px; cursor:pointer; font-size:.85em;
}
.logout-button:hover{ background:#e85656; }

/* Contenido del panel */
.page{ padding:24px; }

/* Overlay para el drawer móvil */
.overlay{
  position:fixed; inset:0; background:rgba(0,0,0,.35);
  opacity:0; pointer-events:none; transition:opacity .2s; z-index:30;
}
.overlay.show{ opacity:1; pointer-events:auto; }

/* Sidebar (comportamiento móvil) */
.sidebar{ position:relative; z-index:40; transition:transform .25s ease; }
.sidebar.open{ transform:translateX(0); }
@media (max-width:840px){
  .hamburger{ display:inline-block; }
  .sidebar{
    position:fixed;
    left:20px; top:20px; bottom:20px;  /* no dependemos del header */
    transform:translateX(-120%);
  }
  .sidebar.open{ transform:translateX(0); }
}

/* Auth */
.auth-panel{
  width:100%; max-width:420px; margin:0 auto; background:#fff;
  border-radius:24px; padding:32px; box-shadow:0 8px 24px rgba(0,0,0,.1);
}
.auth-panel .auth-note{ margin-top:14px; font-size:.85em; color:#555; }
.auth-panel h1{ margin:0 0 20px; font-size:1.6em; color:#333; }
.auth-panel form label{ display:block; font-size:.9em; color:#555; margin-bottom:4px; }
.auth-panel form input[type="text"],
.auth-panel form input[type="email"],
.auth-panel form input[type="password"]{
  width:100%; padding:12px 14px; border:1px solid #ddd; border-radius:12px;
  font-size:1em; margin-bottom:14px;
}
.auth-panel form button{
  width:100%; padding:12px 16px; border-radius:14px; font-size:1em;
  background:#7b5eff; color:#fff; border:none; cursor:pointer; font-weight:700;
}
.auth-panel form button:hover{ background:#6746e7; }

/* Pricing */
.pricing-grid{
  display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr));
  gap:20px; margin-top:20px;
}
.price-card{
  background:#fff; border:1px solid #eee; border-radius:20px; padding:24px;
  box-shadow:0 4px 12px rgba(0,0,0,.05);
  display:flex; flex-direction:column; justify-content:space-between;
  min-height:240px;
}
.price-card .pc-head{ display:flex; justify-content:space-between; align-items:center; margin-bottom:12px; }
.pc-price{ font-weight:700; font-size:1.2em; color:#4b4b5b; }
.pc-feats{ list-style:none; padding:0; margin:0 0 20px; }
.pc-feats li{ margin-bottom:6px; font-size:.85em; color:#555; }
.pc-feats strong{ color:#111; }
.price-card.free{ background:#f7f7fa; }

/* Cupón en pricing */
.buy-plan-form{ display:flex; flex-direction:column; gap:8px; margin-top:8px; }
.coupon-group{ display:flex; justify-content:center; }
.coupon-input{
  width:100%; padding:8px 10px; border:1px solid #ddd; border-radius:12px; font-size:.9em;
}

/* Admin payments */
.admin-table-wrapper{ overflow-x:auto; }
.badge-ok{
  background:#dcfce7; color:#065f46; padding:4px 8px; border-radius:999px; font-size:.75em; font-weight:700;
}
.admin-table input[type="url"]{
  width:100%; padding:4px 6px; border:1px solid #ddd; border-radius:8px; font-size:.85em;
}

/* Sidebar (aspecto) */
.sidebar{
  width:72px; background:#1f1f23; border-radius:20px; padding:12px 8px;
  display:flex; flex-direction:column; justify-content:space-between;
  margin-right:20px; color:#fff;
}
.sidebar .pill{
  display:flex; align-items:center; justify-content:center;
  width:44px; height:44px; margin-bottom:10px; border-radius:14px;
  background:#2e2e33; font-weight:600; color:#e1e1e7; transition:background .2s;
}
.sidebar .pill:hover{ background:#44444a; }
.sidebar .pill.active{ background:#7b5eff; color:#fff; }
.logout-form{ margin-top:10px; }
.sidebar .logout{ background:#ff6161; color:#fff; }
.sidebar .logout:hover{ background:#e05555; }
.sidebar-user{ display:flex; justify-content:center; margin-bottom:12px; }
.sidebar-avatar,.sidebar-avatar.placeholder{
  width:44px; height:44px; border-radius:14px; background:#44444a; color:#fff;
  display:flex; align-items:center; justify-content:center; font-size:1.3em; text-transform:uppercase;
}
.sidebar-avatar{ object-fit:cover; }
.sidebar-items{ flex:1; overflow-y:auto; }
.sidebar-items a:last-child{ margin-bottom:0; }

/* Alerts */
.user-bar{ text-align:right; font-size:.9em; color:#666; margin:10px 0; }
.link-back{ display:inline-block; margin-bottom:10px; color:#7b5eff; }
.alert{ padding:10px 14px; border-radius:12px; margin-bottom:12px; font-size:.9em; }
.alert-error{ background:#ffecec; color:#c43333; }
.alert-info{ background:#eaf2ff; color:#3a6fd8; }

/* Forms */
.form,.list-meta-form,.add-item-form,.clone-form form{ display:flex; flex-direction:column; gap:12px; }
.form-group label{ font-size:.9em; color:#555; margin-bottom:4px; }
.form-group input,.form-group textarea{ padding:10px 12px; border:1px solid #ddd; border-radius:12px; font-size:1em; }
.btn{ border:none; border-radius:14px; cursor:pointer; font-size:.9em; padding:10px 18px; }
.btn.primary{ background:#7b5eff; color:#fff; }
.btn.primary:hover{ background:#6746e7; }
.btn.secondary{ background:#f4f4f6; color:#333; }
.btn.secondary:hover{ background:#e8e8eb; }
.btn.danger{ background:#ff6161; color:#fff; }
.btn.danger:hover{ background:#e85656; }
.btn.small{ padding:6px 10px; font-size:.8em; }

/* Spaces */
.spaces-wrapper{ display:flex; gap:20px; flex-wrap:wrap; }
.spaces-list{ flex:1; display:flex; flex-direction:column; gap:10px; }
.space-card{ display:flex; align-items:center; padding:12px; border-radius:16px; background:#f7f7fa; transition:background .2s; }
.space-card:hover{ background:#edeef5; }
.space-card .initial{ width:40px; height:40px; border-radius:10px; background:#7b5eff; color:#fff; display:flex; align-items:center; justify-content:center; font-weight:700; margin-right:12px; }
.space-card .info span{ font-size:.8em; color:#666; }
.space-forms{ display:flex; flex-direction:column; gap:20px; width:250px; }
.form-card{ padding:16px; background:#f7f7fa; border-radius:16px; }
.space-forms{ width:100%; max-width:320px; }
.space-forms .form-card input[type="text"]{ width:100%; padding:10px 12px; border:1px solid #ddd; border-radius:12px; margin-bottom:10px; }
.space-forms .form-card button{ width:100%; padding:10px; border-radius:12px; font-size:.9em; }
.space-forms h2{ margin:0 0 8px; }

/* Space page */
.lists-wrapper{ display:flex; flex-wrap:wrap; gap:20px; }
.list-card{ padding:14px; border-radius:16px; background:#f7f7fa; min-width:180px; flex:0 0 auto; transition:background .2s; }
.list-card:hover{ background:#ececf3; }
.list-card.new form{ display:flex; flex-direction:column; gap:8px; }
.list-card .note{ font-size:.8em; color:#666; margin-top:4px; }
.pending-list,.members-list{ margin-bottom:20px; }
.pending-row,.member-row{ display:flex; align-items:center; justify-content:space-between; padding:8px 0; border-bottom:1px solid #eee; }
.member-row:last-child,.pending-row:last-child{ border-bottom:none; }
.member-row select{ border:1px solid #ddd; border-radius:8px; padding:4px 6px; }
.owner-label{ font-size:.8em; color:#999; }

/* List page */
.list-meta-form{
  display:flex; flex-direction:column; gap:10px; margin-bottom:12px;
}
.list-title-input{
  font-size:1.8em; border:none; border-bottom:1px solid #ddd; font-weight:700;
  width:100%; padding:4px 0; background:transparent;
}
.list-note-input{
  border:none; border-bottom:1px solid #eee; resize:vertical; min-height:40px;
  font-size:1em; color:#666; padding:4px 0; background:transparent;
}
.stats{
  display:flex; flex-wrap:wrap; gap:12px; margin-bottom:20px;
}
.stat{
  flex:1 1 120px; background:#fafafa; padding:16px; border-radius:16px; text-align:center;
  box-shadow:0 2px 6px rgba(0,0,0,.05);
}
.stat label{
  display:block; font-size:.7em; color:#888; margin-bottom:4px; text-transform:uppercase; letter-spacing:.5px;
}
.stat strong{ font-size:1.3em; color:#2d2d37; }
.chips{
  display:flex; gap:8px; margin-bottom:18px; overflow-x:auto; padding-bottom:4px;
}
.chip{
  display:inline-block; padding:6px 14px; border-radius:20px; background:#f0f0f4; color:#555;
  margin-right:6px; font-size:.78em; transition:background .2s;
}
.chip:hover{ background:#e7e7ef; }
.chip.active{ background:#7b5eff; color:#fff; }

.auth-wrapper{ max-width:400px; margin:0 auto; background:#f7f7fa; padding:24px; border-radius:20px; box-shadow:0 4px 20px rgba(0,0,0,.05); }
.auth-wrapper h1{ margin-top:0; margin-bottom:20px; }
.auth-wrapper .auth-note{ margin-top:14px; font-size:.85em; color:#666; }
.auth-sub{ margin:0 0 16px; font-size:.9em; color:#6b6f76; }
.btn-wide{ width:100%; padding:14px 16px; border-radius:14px; }

.add-item-form{
  display:grid; grid-template-columns:1fr 120px auto; gap:10px; margin-bottom:18px;
}
.add-item-form input{ border:1px solid #ddd; border-radius:12px; padding:8px; }
.items{ border:1px solid #eee; border-radius:16px; overflow:hidden; box-shadow:0 2px 8px rgba(0,0,0,.05); }

.item-row{
  display:grid;
  grid-template-columns:40px minmax(0,4fr) minmax(100px,1fr) minmax(100px,1fr) minmax(80px,1fr) 40px;
  align-items:flex-start; padding:14px 16px; border-bottom:1px solid #f0f0f4; gap:8px; font-size:.95em;
  transition:background .1s;
}
.item-row:first-child{ border-top:none; }
.item-row:hover{ background:#fafafa; }

.item-row input[type="text"], .item-row input[type="number"]{
  background:transparent; border:none; padding:4px; width:100%; font-size:.95em;
}
.item-row input[type="number"]:disabled{ color:#999; }
.state-cell{ text-align:center; }
.select-cell{ text-align:center; }
.estimate-cell,.actual-cell{ display:flex; flex-direction:column; }
.cell-label{
  font-size:.6em; color:#888; margin-bottom:2px; text-transform:uppercase; letter-spacing:.3px;
}

/* Barra de eliminación múltiple */
.bulk-bar{
  position:fixed; left:50%; transform:translateX(-50%); bottom:20px;
  display:none; align-items:center; background:#fff; padding:10px 18px;
  border-radius:18px; box-shadow:0 4px 20px rgba(0,0,0,.12); z-index:50;
}
.bulk-bar span{ margin-right:12px; }
.clone-form{ margin-top:20px; background:#f7f7fa; padding:16px; border-radius:16px; }
.clone-form h3{ margin-top:0; }

/* Responsive */
@media (max-width:600px){
  .sidebar{ display:none; }
  .panel{ margin:0 auto; border-radius:0; min-height:100vh; }
  .page{ padding:16px; }

  .item-row{
    grid-template-columns:40px 1fr 1fr;
    grid-template-rows:auto auto; align-items:start;
  }
  .item-row .name-cell{
    grid-column:2 / 4; grid-row:1; white-space:normal; overflow:visible;
  }
  .item-row .estimate-cell{ grid-column:2; grid-row:2; }
  .item-row .actual-cell{ grid-column:3; grid-row:2; }
  .item-row .subtotal-cell{ display:none; }
  .item-row .select-cell{ grid-column:3; grid-row:1; justify-self:end; }
  .item-row .estimate-cell,
  .item-row .actual-cell,
  .item-row .select-cell{ font-size:.8em; }
}

/* Perfil */
.profile-wrapper{ background:#f7f7fa; padding:20px; border-radius:20px; max-width:500px; margin:0 auto; }
.profile-form input[type="file"]{ margin-top:6px; }
.profile-image{ display:flex; flex-direction:column; align-items:center; margin-bottom:12px; }
.profile-image img{ width:80px; height:80px; border-radius:50%; object-fit:cover; margin-bottom:6px; }
.avatar-placeholder{ width:80px; height:80px; border-radius:50%; background:#ddd; display:flex; align-items:center; justify-content:center; font-size:36px; color:#aaa; margin-bottom:6px; }

/* Admin dashboard */
.admin-section{ background:#f7f7fa; padding:20px; border-radius:20px; margin-bottom:24px; }
.admin-section h2{ margin:0 0 12px; font-size:1.2em; }
.admin-table{ width:100%; border-collapse:collapse; }
.admin-table th,.admin-table td{ padding:8px 10px; border-bottom:1px solid #e0e0e5; text-align:left; }
.admin-table th{ background:#ececf3; font-size:.85em; color:#555; }
.admin-table tr:last-child td{ border-bottom:none; }
.plan-form input[type="text"], .plan-form input[type="number"],
.admin-table input[type="text"], .admin-table input[type="number"]{
  width:100%; padding:4px; border:1px solid #ddd; border-radius:8px; font-size:.9em;
}
.assign-plan-form select{ width:100%; padding:4px; border:1px solid #ddd; border-radius:8px; }
.settings-form input{ width:100%; padding:8px; border:1px solid #ddd; border-radius:10px; }

/* Admin nav links */
.admin-nav-links{ margin-bottom:20px; font-size:.9em; }
.admin-nav-links a{ color:#7b5eff; margin-right:12px; }
.admin-nav-links a:hover{ text-decoration:underline; }

/* Admin summary stats */
.admin-stats{ display:flex; flex-wrap:wrap; gap:14px; margin-bottom:20px; }
.admin-stat{
  flex:1; min-width:180px; background:#f7f7fa; border-radius:16px; padding:14px; text-align:center;
  box-shadow:0 4px 12px rgba(0,0,0,.04);
}
.admin-stat label{ display:block; font-size:.75em; color:#777; margin-bottom:4px; }
.admin-stat strong{ font-size:1.4em; color:#333; }
