:root{
  --bg:#f4f5f9;
  --surface:#ffffff;
  --surface-2:#eef0f6;
  --border:#e0e3ec;
  --text:#171a24;
  --text-dim:#6b7280;
  --accent-gs:#2dd4bf;
  --accent-usd:#f2a900;
  --accent-primary:#5b7cfa;
  --danger:#ef4444;
  --radius:14px;
  --shadow-header:0 4px 16px rgba(23,26,36,.08);
  --shadow-overlay:rgba(15,17,26,.55);
}

:root[data-theme="dark"]{
  --bg:#0b0f1a;
  --surface:#131829;
  --surface-2:#1b2238;
  --border:#242b42;
  --text:#eef1f8;
  --text-dim:#9aa3ba;
  --shadow-header:0 4px 16px rgba(0,0,0,.25);
  --shadow-overlay:rgba(0,0,0,.6);
}

*{box-sizing:border-box;}

html,body{
  margin:0;
  padding:0;
  height:100%;
  background:var(--bg);
  color:var(--text);
  font-family:'Segoe UI',system-ui,-apple-system,Roboto,sans-serif;
  -webkit-tap-highlight-color:transparent;
}

body{
  padding-bottom:calc(90px + env(safe-area-inset-bottom));
  overscroll-behavior-y:none;
}

input,button{
  font-family:inherit;
  font-size:16px;
}

button{
  cursor:pointer;
  -webkit-user-select:none;
  user-select:none;
}

/* ---------- Header ---------- */

.cpy-header{
  position:sticky;
  top:0;
  z-index:10;
  background:var(--surface);
  border-bottom:1px solid var(--border);
  padding:14px 16px calc(14px + env(safe-area-inset-top)) 16px;
  padding-top:calc(14px + env(safe-area-inset-top));
  box-shadow:var(--shadow-header);
}

.cpy-header-top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:12px;
}

.cpy-brand{
  font-weight:700;
  font-size:17px;
  letter-spacing:.2px;
  margin:0;
}
.cpy-brand span{
  font-weight:400;
  color:var(--text-dim);
  font-size:13px;
  margin-left:4px;
}

.cpy-tagline{
  margin:2px 0 0 0;
  font-size:11px;
  color:var(--text-dim);
  line-height:1.3;
  max-width:230px;
}

.cpy-header-actions{
  display:flex;
  gap:8px;
}

.cpy-icon-btn{
  background:var(--surface-2);
  border:1px solid var(--border);
  color:var(--text-dim);
  border-radius:10px;
  width:38px;
  height:38px;
  display:flex;
  align-items:center;
  justify-content:center;
  flex-shrink:0;
}
.cpy-icon-btn:active{
  background:var(--border);
}

.cpy-moeda-toggle{
  display:flex;
  gap:8px;
  margin-bottom:12px;
}

.cpy-moeda-btn{
  flex:1 1 0;
  padding:10px 8px;
  border-radius:10px;
  border:1px solid var(--border);
  background:var(--surface-2);
  color:var(--text-dim);
  font-weight:600;
  font-size:14px;
  transition:background .15s,color .15s,border-color .15s;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:7px;
}

.cpy-flag{
  width:20px;
  height:14px;
  border-radius:2px;
  flex-shrink:0;
  display:block;
  box-shadow:0 0 0 1px rgba(0,0,0,.08);
}

.cpy-moeda-btn[aria-pressed="true"]{
  color:#0b0f1a;
}

#btnMoedaGs[aria-pressed="true"]{
  background:var(--accent-gs);
  border-color:var(--accent-gs);
}

#btnMoedaUsd[aria-pressed="true"]{
  background:var(--accent-usd);
  border-color:var(--accent-usd);
}

.cpy-cambio-row{
  display:none;
  align-items:center;
  gap:10px;
  background:var(--surface-2);
  border:1px solid var(--border);
  border-radius:10px;
  padding:8px 12px;
  margin-bottom:12px;
}

.cpy-cambio-row.cpy-visible{
  display:flex;
}

.cpy-cambio-label{
  font-size:14px;
  color:var(--text-dim);
  white-space:nowrap;
}

.cpy-cambio-input{
  flex:1;
  min-width:0;
  background:transparent;
  border:none;
  color:var(--text);
  font-weight:600;
  font-size:16px;
  text-align:right;
  outline:none;
}

.cpy-cambio-unit{
  font-size:14px;
  color:var(--text-dim);
}

.cpy-total-box{
  background:var(--surface-2);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:14px 16px;
  text-align:center;
}

.cpy-total-label{
  display:block;
  font-size:12px;
  color:var(--text-dim);
  text-transform:uppercase;
  letter-spacing:.6px;
  margin-bottom:10px;
}

.cpy-total-cols{
  display:flex;
  align-items:stretch;
  gap:12px;
}

.cpy-total-col{
  flex:1 1 0;
  min-width:0;
}

.cpy-total-col-head{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  font-size:12px;
  color:var(--text-dim);
  margin-bottom:4px;
}

.cpy-total-value{
  font-size:22px;
  font-weight:800;
  line-height:1.2;
  word-break:break-word;
}

.cpy-total-divider{
  width:1px;
  background:var(--border);
  flex-shrink:0;
}

/* ---------- Lista de itens ---------- */

.cpy-list{
  padding:14px 16px;
  display:flex;
  flex-direction:column;
  gap:10px;
  min-height:120px;
}

.cpy-empty{
  text-align:center;
  color:var(--text-dim);
  font-size:14px;
  padding:40px 20px;
}

.cpy-about{
  padding:8px 20px 24px 20px;
  border-top:1px solid var(--border);
  margin-top:8px;
}

.cpy-about h2{
  font-size:13px;
  color:var(--text-dim);
  text-transform:uppercase;
  letter-spacing:.5px;
  margin:16px 0 8px 0;
}

.cpy-about p{
  font-size:12px;
  color:var(--text-dim);
  line-height:1.5;
  margin:0 0 8px 0;
}

.cpy-footer{
  text-align:center;
  padding:4px 20px 20px 20px;
  font-size:12px;
  color:var(--text-dim);
}

.cpy-footer a{
  color:var(--accent-primary);
  font-weight:600;
  text-decoration:none;
}

.cpy-item-card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:12px 14px;
  display:flex;
  align-items:center;
  gap:10px;
}

.cpy-item-info{
  flex:1;
  min-width:0;
}

.cpy-item-nome{
  font-weight:600;
  font-size:15px;
  overflow-wrap:anywhere;
}

.cpy-item-sub{
  font-size:13px;
  color:var(--text-dim);
  margin-top:2px;
}

.cpy-item-valores{
  text-align:right;
  flex-shrink:0;
}

.cpy-item-original{
  font-weight:700;
  font-size:15px;
}

.cpy-item-brl{
  font-size:12px;
  color:var(--text-dim);
  margin-top:2px;
}

.cpy-item-del{
  background:transparent;
  border:none;
  color:var(--text-dim);
  flex-shrink:0;
  width:32px;
  height:32px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:8px;
}
.cpy-item-del:active{
  background:rgba(239,68,68,.15);
  color:var(--danger);
}

/* ---------- FAB ---------- */

.cpy-fab{
  position:fixed;
  right:20px;
  bottom:calc(20px + env(safe-area-inset-bottom));
  width:58px;
  height:58px;
  border-radius:50%;
  background:var(--accent-primary);
  color:#fff;
  border:none;
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow:0 6px 18px rgba(91,124,250,.45);
  z-index:20;
}
.cpy-fab:active{
  transform:scale(.94);
}

/* ---------- Overlays / Sheet / Confirm ---------- */

.cpy-overlay{
  position:fixed;
  inset:0;
  background:var(--shadow-overlay);
  display:none;
  align-items:flex-end;
  justify-content:center;
  z-index:30;
}
.cpy-overlay.cpy-open{
  display:flex;
}
#confirmOverlay.cpy-open{
  align-items:center;
}

.cpy-sheet{
  width:100%;
  max-width:520px;
  background:var(--surface);
  border-radius:20px 20px 0 0;
  padding:10px 20px calc(20px + env(safe-area-inset-bottom)) 20px;
  max-height:88vh;
  overflow-y:auto;
  overscroll-behavior:contain;
}

.cpy-sheet-handle{
  width:40px;
  height:4px;
  background:var(--border);
  border-radius:4px;
  margin:0 auto 14px auto;
}

.cpy-sheet-title{
  font-size:18px;
  margin:0 0 14px 0;
}

.cpy-field-label{
  display:block;
  font-size:13px;
  color:var(--text-dim);
  margin-bottom:6px;
  margin-top:14px;
}
.cpy-field-label:first-of-type{
  margin-top:0;
}

.cpy-field-input{
  width:100%;
  background:var(--surface-2);
  border:1px solid var(--border);
  color:var(--text);
  border-radius:10px;
  padding:12px 14px;
  outline:none;
}
.cpy-field-input:focus{
  border-color:var(--accent-primary);
}

.cpy-sheet-actions{
  display:flex;
  gap:10px;
  margin-top:22px;
}

.cpy-btn{
  flex:1;
  padding:13px 10px;
  border-radius:10px;
  border:1px solid var(--border);
  font-weight:600;
  font-size:15px;
}

.cpy-btn-ghost{
  background:var(--surface-2);
  color:var(--text);
}

.cpy-btn-primary{
  background:var(--accent-primary);
  border-color:var(--accent-primary);
  color:#fff;
}

.cpy-btn-danger{
  background:var(--danger);
  border-color:var(--danger);
  color:#fff;
}

.cpy-confirm-box{
  width:calc(100% - 40px);
  max-width:420px;
  background:var(--surface);
  border-radius:var(--radius);
  border:1px solid var(--border);
  padding:22px 20px;
}

.cpy-confirm-text{
  margin:0 0 18px 0;
  font-size:15px;
  line-height:1.45;
}

.cpy-confirm-actions{
  display:flex;
  gap:10px;
}

@media (min-width:560px){
  .cpy-list,
  .cpy-about,
  .cpy-footer{
    max-width:560px;
    margin-left:auto;
    margin-right:auto;
    width:100%;
  }
  .cpy-header-top,
  .cpy-moeda-toggle,
  .cpy-cambio-row,
  .cpy-total-box{
    max-width:560px;
    margin-left:auto;
    margin-right:auto;
  }
}
