/* =============================================
   Calculadora de Corte — app.css
   ============================================= */
:root {
  --bg: #0f0f0f;
  --surface: #181818;
  --surface2: #222;
  --border: #2a2a2a;
  --border2: #333;
  --accent: #c8f060;
  --accent2: #60c8f0;
  --text: #f0f0ef;
  --text2: #888;
  --text3: #555;
  --used: #4a8fc4;
  --vert: #c46450;
  --waste-color: #e8a020;
  --radius: 12px;
  --radius-sm: 6px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ---- HEADER ---- */
.app-header {
  border-bottom: 1px solid var(--border);
  padding: .75rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg);
  position: sticky; top: 0; z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.logo-mark { width: 32px; height: 32px; background: var(--accent); border-radius: 7px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.app-name { font-size: 14px; font-weight: 500; }
.header-right { display: flex; align-items: center; gap: 10px; }
.user-name { font-size: 13px; color: var(--text2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--surface2); border: 1px solid var(--border2); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 500; color: var(--text2); }
.btn-logout { font-size: 12px; color: var(--text3); text-decoration: none; padding: 4px 10px; border: 0.5px solid var(--border2); border-radius: var(--radius-sm); transition: color .15s, border-color .15s; }
.btn-logout:hover { color: var(--text); border-color: var(--text3); }

/* ---- FORMULARIOS (login / registro) ---- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.auth-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 360px; }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: .5rem; margin-bottom: 1.5rem; }
.auth-logo .logo-mark { width: 44px; height: 44px; border-radius: 10px; }
.auth-logo .logo-mark svg { width: 24px; height: 24px; }
.auth-title { font-size: 20px; font-weight: 500; text-align: center; }
.auth-sub { font-size: 13px; color: var(--text2); text-align: center; }
.form-field { margin-bottom: 1rem; }
.form-field label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 6px; }
.form-field input { width: 100%; background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--radius-sm); color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 14px; padding: 10px 12px; outline: none; transition: border-color .2s; }
.form-field input:focus { border-color: var(--accent); }
.btn-primary { width: 100%; background: var(--accent); border: none; border-radius: var(--radius-sm); padding: 11px; font-size: 14px; font-weight: 500; color: #0f0f0f; cursor: pointer; transition: opacity .15s; }
.btn-primary:hover { opacity: .88; }
.btn-secondary { width: 100%; background: transparent; border: 0.5px solid var(--border2); border-radius: var(--radius-sm); padding: 10px; font-size: 13px; color: var(--text2); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; transition: border-color .15s, color .15s; }
.btn-secondary:hover { border-color: var(--text3); color: var(--text); }
.divider { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text3); margin: .875rem 0; }
.divider::before, .divider::after { content: ''; flex: 1; border-top: 0.5px solid var(--border2); }
.auth-footer { text-align: center; font-size: 13px; color: var(--text3); margin-top: 1.25rem; }
.auth-footer a { color: var(--accent); text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }
.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 1rem; }
.alert-error { background: rgba(196,100,80,.12); border: 0.5px solid rgba(196,100,80,.3); color: #f0a090; }
.alert-success { background: rgba(139,195,74,.12); border: 0.5px solid rgba(139,195,74,.3); color: #b0d870; }

/* ---- PROYECTOS ---- */
.proyectos-page { padding: 2rem 1.5rem; max-width: 1100px; margin: 0 auto; }
.proyectos-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.75rem; }
.proyectos-title { font-size: 22px; font-weight: 500; }
.proyectos-sub { font-size: 13px; color: var(--text2); margin-top: 3px; }
.proyectos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.proj-card-new { background: var(--surface); border: 0.5px dashed var(--border2); border-radius: var(--radius); padding: 1.5rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 160px; cursor: pointer; text-decoration: none; transition: border-color .2s, background .2s; }
.proj-card-new:hover { border-color: var(--accent); background: rgba(200,240,96,.04); }
.proj-card-new .icon { font-size: 28px; color: var(--text3); }
.proj-card-new span { font-size: 13px; color: var(--text3); }
.proj-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; text-decoration: none; display: block; transition: border-color .2s, transform .15s; }
.proj-card:hover { border-color: var(--border2); transform: translateY(-2px); }
.proj-card-thumb { height: 100px; background: var(--surface2); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.proj-card-info { padding: .875rem; }
.proj-card-name { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px; }
.proj-card-date { font-size: 11px; color: var(--text3); }
.proj-card-badge { display: inline-block; font-size: 10px; padding: 2px 7px; border-radius: 20px; margin-top: 5px; }
.badge-green { background: rgba(139,195,74,.12); color: #8bc34a; }
.badge-blue  { background: rgba(74,143,196,.12); color: #60a0e0; }
.badge-amber { background: rgba(232,160,32,.12);  color: #e8a020; }
.badge-red   { background: rgba(196,100,80,.12);  color: #e07060; }
.proj-card-actions { display: flex; gap: 6px; padding: 0 .875rem .875rem; }
.btn-sm { font-size: 11px; padding: 4px 10px; border-radius: 4px; border: 0.5px solid var(--border2); background: transparent; color: var(--text2); cursor: pointer; text-decoration: none; transition: all .15s; }
.btn-sm:hover { color: var(--text); border-color: var(--text3); }
.btn-sm-danger:hover { color: #f07060; border-color: #c46450; }

/* ---- HERRAMIENTA ---- */
.tool-header { border-bottom: 1px solid var(--border); padding: .75rem 1.5rem; display: flex; align-items: center; gap: 10px; background: var(--bg); }
.tool-back { width: 30px; height: 30px; background: var(--surface2); border: 0.5px solid var(--border2); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--text2); font-size: 18px; transition: color .15s; }
.tool-back:hover { color: var(--text); }
.tool-project-name { font-size: 15px; font-weight: 500; flex: 1; }
.btn-save { background: var(--accent); border: none; border-radius: var(--radius-sm); padding: 8px 18px; font-size: 13px; font-weight: 500; color: #0f0f0f; cursor: pointer; display: flex; align-items: center; gap: 6px; transition: opacity .15s; }
.btn-save:hover { opacity: .88; }
.app-layout { display: grid; grid-template-columns: 300px 1fr 260px; gap: 0; min-height: calc(100vh - 108px); }
@media (max-width: 900px) { .app-layout { grid-template-columns: 1fr; } }
.col { padding: 1.25rem; border-right: 1px solid var(--border); }
.col:last-child { border-right: none; }
.col-mid { background: var(--surface); }
.col-title { font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--text3); margin-bottom: 1rem; }
.field { margin-bottom: 1.1rem; }
.field-label { font-size: 12px; color: var(--text2); margin-bottom: 6px; display: flex; align-items: center; gap: 5px; }
.field-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-sep { font-size: 18px; color: var(--text3); }
.unit-wrap { position: relative; flex: 1; }
.unit-wrap input { padding-right: 32px; }
.unit-tag { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font-size: 11px; color: var(--text3); pointer-events: none; font-family: 'DM Mono', monospace; }
input[type=number] { width: 100%; background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--radius-sm); color: var(--text); font-family: 'DM Mono', monospace; font-size: 15px; padding: 9px 11px; outline: none; transition: border-color .2s; -moz-appearance: textfield; }
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }
input[type=number]:focus { border-color: var(--accent); }
.orient-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.orient-btn { background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--radius-sm); color: var(--text2); font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 500; padding: 9px; cursor: pointer; text-align: center; transition: all .15s; }
.orient-btn.active { background: rgba(200,240,96,.1); border-color: var(--accent); color: var(--accent); }
hr.div { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.canvas-wrap { display: flex; flex-direction: column; align-items: center; gap: .875rem; }
#pliego-canvas { border-radius: var(--radius-sm); display: block; max-width: 100%; }
.canvas-legend { display: flex; gap: 1rem; font-size: 11px; color: var(--text2); flex-wrap: wrap; justify-content: center; }
.legend-item { display: flex; align-items: center; gap: 4px; }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.dims-row { font-size: 11px; color: var(--text3); font-family: 'DM Mono', monospace; }
.orient-info { background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--radius-sm); padding: .75rem 1rem; font-size: 12px; color: var(--text2); line-height: 1.5; width: 100%; }
.orient-info strong { color: var(--accent); font-weight: 500; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 1rem; }
.metric-card { background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--radius-sm); padding: .75rem; }
.metric-card.hl { background: rgba(200,240,96,.06); border-color: rgba(200,240,96,.25); }
.metric-label { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--text3); margin-bottom: 4px; }
.metric-value { font-family: 'DM Mono', monospace; font-size: 22px; color: var(--text); line-height: 1; }
.metric-card.hl .metric-value { color: var(--accent); }
.metric-sub { font-size: 10px; color: var(--text3); margin-top: 3px; }
.stat-list { margin: .5rem 0; }
.stat-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.stat-row:last-child { border-bottom: none; }
.stat-name { color: var(--text2); }
.stat-val { font-family: 'DM Mono', monospace; color: var(--text); font-size: 12px; }
.usage-section { margin-top: .875rem; }
.usage-label { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 5px; }
.usage-label .u { color: var(--used); font-family: 'DM Mono', monospace; }
.usage-label .w { color: var(--waste-color); font-family: 'DM Mono', monospace; }
.bar-track { height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; margin-bottom: 4px; }
.bar-fill-used  { height: 100%; background: var(--used); border-radius: 3px; transition: width .4s ease; }
.bar-fill-waste { height: 100%; background: var(--waste-color); border-radius: 3px; transition: width .4s ease; }
.efficiency-wrap { display: flex; align-items: center; gap: .875rem; margin-top: .875rem; padding: .75rem; background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--radius-sm); }
.eff-val { font-family: 'DM Mono', monospace; font-size: 20px; color: var(--text); line-height: 1; }
.eff-label { font-size: 11px; color: var(--text2); margin-top: 3px; }
.eff-grade { font-size: 10px; margin-top: 5px; padding: 2px 8px; border-radius: 20px; display: inline-block; }
.tip-box { margin-top: 1rem; padding: .75rem; background: rgba(96,200,240,.06); border: 1px solid rgba(96,200,240,.15); border-radius: var(--radius-sm); font-size: 11px; color: var(--text2); line-height: 1.6; }
.tip-box strong { color: var(--accent2); font-weight: 500; }

/* ---- MODAL ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 1000; opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--surface); border: 0.5px solid var(--border2); border-radius: var(--radius); padding: 1.5rem; width: 100%; max-width: 380px; }
.modal-title { font-size: 16px; font-weight: 500; margin-bottom: .25rem; }
.modal-sub { font-size: 12px; color: var(--text2); margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: 8px; margin-top: 1.25rem; }
.modal-actions .btn-cancel { flex: 1; background: transparent; border: 0.5px solid var(--border2); border-radius: var(--radius-sm); padding: 9px; font-size: 13px; color: var(--text2); cursor: pointer; }
.modal-actions .btn-confirm { flex: 2; background: var(--accent); border: none; border-radius: var(--radius-sm); padding: 9px; font-size: 13px; font-weight: 500; color: #0f0f0f; cursor: pointer; }

/* ---- TOAST ---- */
.toast { position: fixed; bottom: 1.5rem; right: 1.5rem; background: var(--surface); border: 0.5px solid var(--border2); border-radius: var(--radius-sm); padding: .75rem 1.25rem; font-size: 13px; color: var(--text); box-shadow: 0 4px 16px rgba(0,0,0,.4); transform: translateY(10px); opacity: 0; transition: all .25s; z-index: 2000; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: rgba(139,195,74,.4); }
.toast.error   { border-color: rgba(196,100,80,.4); }

/* ---- BOTÓN PDF (diseño B) ---- */
.btn-pdf { background: transparent; border: 1px solid rgba(200,240,96,.45); border-radius: var(--radius-sm); padding: 7px 16px; font-size: 13px; font-weight: 500; color: var(--accent); cursor: pointer; display: flex; align-items: center; gap: 7px; transition: all .2s; }
.btn-pdf:hover { background: rgba(200,240,96,.08); border-color: var(--accent); }
.btn-pdf:active { transform: scale(0.97); }
.btn-pdf svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ---- BOTÓN PDF EN CARD ---- */
.btn-sm-pdf { color: #c8f060 !important; border-color: rgba(200,240,96,.3) !important; }
.btn-sm-pdf:hover { background: rgba(200,240,96,.08) !important; border-color: #c8f060 !important; }