:root{
    --bg: #10141a;
    --surface: #1a212b;
    --surface-2: #212a36;
    --border: #2b3542;
    --text: #e7ebf0;
    --muted: #8b96a5;
    --amber: #e0a527;
    --amber-dim: #7a5c1c;
    --green: #4fb87a;
    --red: #e0575c;
    --radius: 10px;
    --mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  }

  *{ box-sizing: border-box; }

  html, body{
    margin:0; padding:0; height:100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    -webkit-font-smoothing: antialiased;
  }

  #app{
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
  }

  header{
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 5;
  }

  header .mark{
    width: 34px; height: 34px;
    border-radius: 8px;
    background: linear-gradient(155deg, var(--amber), var(--amber-dim));
    flex-shrink: 0;
    display:flex; align-items:center; justify-content:center;
    font-family: var(--mono);
    font-weight: 700;
    color: #171310;
    font-size: 15px;
  }

  header h1{
    font-size: 17px;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.01em;
  }

  header .back{
    background: none; border: none; color: var(--muted);
    font-size: 22px; line-height: 1; padding: 6px;
    cursor: pointer; margin-left: -6px;
  }
  header .back:active{ color: var(--text); }

  main{ flex: 1; padding: 16px 16px 40px; }

  /* ---- Lista de tarjetas ---- */

  .card-row{
    display:flex; align-items:center; gap: 14px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    cursor: pointer;
    transition: border-color .15s ease;
  }
  .card-row:active{ border-color: var(--amber-dim); }

  .card-row .dot{
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--amber);
    flex-shrink: 0;
  }

  .card-row .info{ flex: 1; min-width: 0; }
  .card-row .info .name{ font-weight: 600; font-size: 15px; }
  .card-row .info .sub{
    font-family: var(--mono); font-size: 12px; color: var(--muted);
    margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .card-row .chev{ color: var(--muted); font-size: 18px; }

  .empty{
    text-align: center; color: var(--muted);
    padding: 60px 20px 20px;
    font-size: 14px; line-height: 1.6;
  }

  .add-btn{
    width: 100%;
    padding: 14px;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 4px;
  }
  .add-btn:active{ border-color: var(--amber-dim); color: var(--amber); }

  /* ---- Formularios / campos ---- */

  label{
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin: 18px 0 6px;
    text-transform: none;
  }
  label:first-of-type{ margin-top: 0; }

  input[type=text], input[type=password]{
    width: 100%;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--mono);
    font-size: 14px;
    outline: none;
  }
  input[type=text]:focus, input[type=password]:focus{ border-color: var(--amber-dim); }
  input[type=text]::placeholder{ color: #545e6c; font-family: var(--sans); }

  .field-row{ display:flex; gap: 8px; align-items: stretch; }
  .field-row input{ flex: 1; }

  .ghost-btn{
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
  }
  .ghost-btn:active{ border-color: var(--amber); color: var(--amber); }

  .primary-btn{
    width: 100%;
    padding: 14px;
    background: var(--amber);
    border: none;
    border-radius: 8px;
    color: #171310;
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 8px;
  }
  .primary-btn:active{ filter: brightness(0.92); }
  .primary-btn:disabled{ background: var(--surface-2); color: var(--muted); }

  .secondary-btn{
    width: 100%;
    padding: 14px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
  }
  .secondary-btn:active{ border-color: var(--amber-dim); }

  /* ---- Detalle de tarjeta ---- */

  .detail-head{
    margin-bottom: 4px;
  }
  .detail-head .name{ font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }

  .keyb-row{
    display:flex; align-items:center; gap: 8px;
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
  }
  .keyb-row .lbl{ font-size: 11px; color: var(--muted); font-weight: 600; }
  .keyb-row .val{
    font-family: var(--mono); font-size: 14px;
    letter-spacing: 0.03em;
    flex: 1;
  }
  .keyb-row button{
    background: none; border: none; color: var(--muted);
    font-size: 13px; cursor: pointer; padding: 4px;
  }

  .section{
    margin-top: 26px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
  }
  .section-title{
    font-size: 13px; font-weight: 700; color: var(--text);
    margin-bottom: 2px;
  }
  .section-hint{
    font-size: 12px; color: var(--muted); margin-bottom: 4px; line-height: 1.5;
  }

  .value-readout{
    display:flex; align-items: baseline; gap: 8px;
    margin-top: 10px;
    padding: 12px 14px;
    background: var(--surface-2);
    border-radius: 8px;
    border: 1px solid var(--border);
  }
  .value-readout .num{
    font-family: var(--mono); font-size: 22px; font-weight: 700;
    color: var(--amber);
  }
  .value-readout .unit{ font-size: 12px; color: var(--muted); }
  .value-readout.invalid .num{ color: var(--red); }

  .slider-wrap{ margin-top: 16px; }
  .slider-top{
    display:flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 8px;
  }
  .slider-top .amount{
    font-family: var(--mono); font-size: 18px; font-weight: 700;
  }
  .slider-top .amount.neg{ color: var(--red); }
  .slider-top .amount.pos{ color: var(--green); }

  input[type=range]{
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    outline: none;
  }
  input[type=range]::-webkit-slider-thumb{
    -webkit-appearance: none;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--amber);
    border: 3px solid var(--bg);
    box-shadow: 0 0 0 1px var(--amber);
    cursor: pointer;
  }
  input[type=range]::-moz-range-thumb{
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--amber);
    border: 3px solid var(--bg);
    cursor: pointer;
  }

  .slider-scale{
    display:flex; justify-content: space-between;
    font-size: 11px; color: var(--muted); margin-top: 4px;
    font-family: var(--mono);
  }

  .btn-pair{ display:flex; gap: 8px; margin-top: 18px; }
  .btn-pair button{ flex: 1; margin-top: 0; }

  .result{
    margin-top: 18px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--amber-dim);
    border-radius: 8px;
    display: none;
  }
  .result.show{ display: block; }
  .result .row{ margin-bottom: 10px; }
  .result .row:last-child{ margin-bottom: 0; }
  .result .k{ font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
  .result .v{ font-family: var(--mono); font-size: 13px; word-break: break-all; }
  .result .v.big{ font-size: 18px; font-weight: 700; color: var(--amber); }

  .copy-line{ display:flex; align-items:center; gap:8px; }
  .copy-line .v{ flex:1; }

  .toast{
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--surface-2); border: 1px solid var(--amber-dim);
    color: var(--text); padding: 10px 18px; border-radius: 100px;
    font-size: 13px; opacity: 0; pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
    z-index: 50;
  }
  .toast.show{ opacity: 1; transform: translateX(-50%) translateY(-4px); }

  .modal-backdrop{
    position: fixed; inset: 0; background: rgba(8,10,13,0.7);
    display:none; align-items: flex-end; justify-content: center;
    z-index: 40;
  }
  .modal-backdrop.show{ display:flex; }
  .modal{
    width: 100%; max-width: 480px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    padding: 20px 20px 28px;
  }
  .modal h2{ font-size: 16px; margin: 0 0 4px; }
  .modal .close{
    position: absolute; margin-top: -6px; margin-left: 400px;
  }

  .warn{
    font-size: 11px; color: var(--muted); line-height: 1.5;
    padding: 10px 12px;
    background: var(--surface-2);
    border-radius: 8px;
    margin-top: 16px;
  }
  .warn b{ color: var(--text); }

  /* ---- Login ---- */

  .login-wrap{
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 76px);
    justify-content: center;
    padding: 20px 4px 60px;
  }

  .login-wrap .mark-big{
    width: 56px; height: 56px;
    border-radius: 14px;
    background: linear-gradient(155deg, var(--amber), var(--amber-dim));
    display:flex; align-items:center; justify-content:center;
    font-family: var(--mono);
    font-weight: 700;
    color: #171310;
    font-size: 22px;
    margin: 0 auto 20px;
  }

  .login-wrap h2{
    text-align: center;
    font-size: 19px;
    margin: 0 0 4px;
  }
  .login-wrap .login-sub{
    text-align: center;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 28px;
  }

  .login-error{
    font-size: 13px;
    color: var(--red);
    background: rgba(224,87,92,0.1);
    border: 1px solid rgba(224,87,92,0.3);
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 14px;
    display: none;
  }
  .login-error.show{ display: block; }