:root{
    --bg: #14171a;
    --surface: #1c2024;
    --surface-2: #23282d;
    --surface-3: #2b3137;
    --line: #33393f;
    --line-soft: #262b30;
    --ink: #eeeae2;
    --ink-dim: #a3aab1;
    --ink-faint: #6d747b;
    --amber: #e8871e;
    --amber-soft: rgba(232,135,30,.14);
    --teal: #3fa79f;
    --green: #55b98a;
    --red: #d9695f;
    --radius: 14px;
    --mono: 'JetBrains Mono', ui-monospace, monospace;
    --sans: 'Vazirmatn', sans-serif;
  }

  *{box-sizing:border-box;}
  html{scroll-behavior:smooth;}
  body{
    margin:0;
    background:
      radial-gradient(1100px 600px at 85% -10%, rgba(232,135,30,.07), transparent 60%),
      radial-gradient(900px 500px at -10% 110%, rgba(63,167,159,.06), transparent 60%),
      var(--bg);
    color:var(--ink);
    font-family:var(--sans);
    -webkit-font-smoothing:antialiased;
    line-height:1.6;
    padding-bottom:60px;
  }

  .wrap{max-width:760px; margin:0 auto; padding:0 18px;}

  /* ---------- header ---------- */
  header{
    padding:34px 0 26px;
    position:relative;
  }
  .header-row{display:flex; align-items:flex-start; justify-content:space-between; gap:14px;}
  .eyebrow{
    font-family:var(--mono);
    font-size:11.5px;
    letter-spacing:.14em;
    color:var(--amber);
    text-transform:uppercase;
    margin:0 0 10px;
    display:flex; align-items:center; gap:8px;
  }
  .eyebrow::before{content:''; width:16px; height:1px; background:var(--amber);}
  h1{
    font-size:26px;
    font-weight:800;
    margin:0 0 8px;
    letter-spacing:-.01em;
  }
  header p.sub{margin:0; color:var(--ink-dim); font-size:14.5px;}

  .icon-btn{
    flex:none;
    width:42px; height:42px;
    border-radius:11px;
    background:var(--surface-2);
    border:1px solid var(--line);
    color:var(--ink-dim);
    display:flex; align-items:center; justify-content:center;
    cursor:pointer;
    transition:.15s;
  }
  .icon-btn:hover{color:var(--amber); border-color:var(--amber); background:var(--amber-soft);}
  .icon-btn svg{width:19px; height:19px;}

  /* ---------- section cards ---------- */
  .card{
    background:var(--surface);
    border:1px solid var(--line);
    border-radius:var(--radius);
    padding:22px;
    margin-bottom:16px;
  }
  .card-head{display:flex; align-items:center; gap:10px; margin-bottom:18px;}
  .card-head .idx{
    font-family:var(--mono);
    font-size:12px;
    color:var(--amber);
    background:var(--amber-soft);
    border:1px solid rgba(232,135,30,.3);
    border-radius:6px;
    padding:3px 7px;
    flex:none;
  }
  .card-head h2{font-size:15.5px; font-weight:700; margin:0;}

  .grid{display:grid; grid-template-columns:1fr 1fr; gap:14px;}
  .field{display:flex; flex-direction:column; gap:7px; margin-bottom:14px;}
  .field.full{grid-column:1/-1;}
  label{font-size:13px; color:var(--ink-dim); font-weight:500;}
  label .unit{color:var(--ink-faint); font-size:11.5px;}

  input[type=text], input[type=number], select{
    background:var(--surface-2);
    border:1px solid var(--line);
    color:var(--ink);
    border-radius:9px;
    padding:11px 12px;
    font-size:14.5px;
    font-family:var(--sans);
    width:100%;
    transition:.15s;
  }
  input[type=number]{font-family:var(--mono); direction:ltr; text-align:right;}
  input:focus, select:focus{
    outline:none; border-color:var(--amber);
    box-shadow:0 0 0 3px rgba(232,135,30,.15);
  }
  select{appearance:none; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a3aab1' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:left 12px center; padding-left:32px;}

  .time-row{display:flex; gap:10px;}
  .time-row .field{flex:1; margin-bottom:0;}

  /* profile chips */
  .profiles{display:flex; gap:8px; flex-wrap:wrap; margin-bottom:16px;}
  .profile-chip{
    flex:1; min-width:110px;
    background:var(--surface-2);
    border:1px solid var(--line);
    border-radius:10px;
    padding:11px 10px;
    cursor:pointer;
    text-align:center;
    transition:.15s;
    position:relative;
  }
  .profile-chip.active{border-color:var(--amber); background:var(--amber-soft);}
  .profile-chip .p-name{font-size:12.5px; color:var(--ink-dim); display:block; margin-bottom:3px;}
  .profile-chip.active .p-name{color:var(--amber);}
  .profile-chip .p-val{font-family:var(--mono); font-size:15px; font-weight:600;}
  .profile-chip input{position:absolute; opacity:0; pointer-events:none;}

  .custom-profit-row{display:none; gap:10px; align-items:center; margin-bottom:4px;}
  .custom-profit-row.show{display:flex;}

  /* button */
  .btn-primary{
    width:100%;
    background:var(--amber);
    color:#191305;
    border:none;
    border-radius:11px;
    padding:15px;
    font-size:15.5px;
    font-weight:700;
    font-family:var(--sans);
    cursor:pointer;
    transition:.15s;
    letter-spacing:.01em;
  }
  .btn-primary:hover{filter:brightness(1.08); transform:translateY(-1px);}
  .btn-primary:active{transform:translateY(0);}

  .btn-ghost{
    background:transparent;
    border:1px solid var(--line);
    color:var(--ink-dim);
    border-radius:9px;
    padding:10px 14px;
    font-family:var(--sans);
    font-size:13px;
    cursor:pointer;
    transition:.15s;
  }
  .btn-ghost:hover{border-color:var(--amber); color:var(--amber);}
  .btn-ghost.danger:hover{border-color:var(--red); color:var(--red);}

  /* ---------- result ---------- */
  #result{display:none;}
  .price-card{
    background:linear-gradient(165deg, var(--surface-3), var(--surface));
    border:1px solid rgba(232,135,30,.35);
    border-radius:18px;
    padding:30px 24px;
    text-align:center;
    margin-bottom:16px;
    position:relative;
    overflow:hidden;
  }
  .price-card::before{
    content:'';
    position:absolute; inset:0;
    background:repeating-linear-gradient(45deg, rgba(255,255,255,.015) 0 1px, transparent 1px 14px);
    pointer-events:none;
  }
  .price-label{font-size:12.5px; color:var(--ink-dim); margin-bottom:10px; font-weight:500;}
  .price-value{
    font-family:var(--mono);
    font-size:38px;
    font-weight:700;
    color:var(--amber);
    direction:ltr;
    letter-spacing:-.01em;
  }
  .price-value .cur{font-family:var(--sans); font-size:16px; color:var(--ink-dim); margin-right:6px;}
  .price-sub{font-size:12.5px; color:var(--ink-faint); margin-top:8px; font-family:var(--mono); direction:ltr;}

  .breakdown{
    font-family:var(--mono);
    font-size:13px;
    direction:ltr;
    text-align:left;
  }
  .b-row{
    display:flex; justify-content:space-between; align-items:baseline;
    padding:6px 0;
    color:var(--ink-dim);
  }
  .b-row .b-label{color:var(--ink); flex:none;}
  .b-row .b-dots{flex:1; border-bottom:1px dotted var(--line); margin:0 8px 4px;}
  .b-row .b-val{color:var(--ink); flex:none; font-weight:500;}
  .b-row.neg .b-val{color:var(--red);}
  .b-divider{border-top:1px solid var(--line); margin:8px 0;}
  .b-row.total .b-val, .b-row.total .b-label{color:var(--amber); font-weight:700; font-size:14px;}
  .b-row.sub .b-label, .b-row.sub .b-val{color:var(--teal);}

  .profit-strip{
    display:flex; gap:10px; margin-top:16px;
  }
  .profit-box{
    flex:1;
    background:var(--surface-2);
    border:1px solid var(--line);
    border-radius:10px;
    padding:13px;
    text-align:center;
  }
  .profit-box .pb-label{font-size:11.5px; color:var(--ink-dim); margin-bottom:5px;}
  .profit-box .pb-val{font-family:var(--mono); font-size:15.5px; font-weight:700; color:var(--green); direction:ltr;}

  .result-actions{display:flex; gap:10px; margin-top:16px;}
  .result-actions .btn-ghost{flex:1; text-align:center;}

  /* ---------- saved projects ---------- */
  .proj-item{
    background:var(--surface-2);
    border:1px solid var(--line);
    border-radius:11px;
    padding:14px 16px;
    display:flex; justify-content:space-between; align-items:center;
    margin-bottom:10px;
    gap:10px;
  }
  .proj-info .p-title{font-size:14px; font-weight:600; margin-bottom:4px;}
  .proj-info .p-meta{font-size:12px; color:var(--ink-faint); font-family:var(--mono); direction:ltr; display:inline-block;}
  .proj-price{font-family:var(--mono); font-size:14.5px; color:var(--amber); font-weight:700; direction:ltr; flex:none;}
  .proj-actions{display:flex; gap:6px; flex:none;}
  .proj-actions button{
    background:none; border:1px solid var(--line); color:var(--ink-faint);
    width:32px; height:32px; border-radius:8px; cursor:pointer; display:flex; align-items:center; justify-content:center;
    transition:.15s;
  }
  .proj-actions button:hover{border-color:var(--amber); color:var(--amber);}
  .proj-actions button.del:hover{border-color:var(--red); color:var(--red);}
  .proj-actions svg{width:15px; height:15px;}
  .empty-note{color:var(--ink-faint); font-size:13px; text-align:center; padding:18px 0;}

  /* ---------- modal ---------- */
  .modal-overlay{
    display:none;
    position:fixed; inset:0; background:rgba(10,11,13,.72);
    backdrop-filter:blur(3px);
    z-index:50;
    align-items:flex-end;
    justify-content:center;
  }
  .modal-overlay.show{display:flex;}
  .modal{
    background:var(--surface);
    border:1px solid var(--line);
    border-radius:20px 20px 0 0;
    width:100%; max-width:760px;
    max-height:88vh;
    overflow-y:auto;
    padding:22px;
    animation:slideUp .22s ease;
  }
  @keyframes slideUp{from{transform:translateY(24px); opacity:0;} to{transform:translateY(0); opacity:1;}}
  .modal-head{display:flex; justify-content:space-between; align-items:center; margin-bottom:20px; position:sticky; top:0; background:var(--surface); padding-bottom:4px;}
  .modal-head h2{font-size:17px; margin:0;}
  .modal-head .icon-btn{width:36px; height:36px;}

  .settings-group{margin-bottom:22px;}
  .settings-group h3{
    font-size:12px; text-transform:uppercase; letter-spacing:.08em;
    color:var(--ink-faint); margin:0 0 12px; font-family:var(--mono); font-weight:500;
  }

  .fil-item{
    display:flex; justify-content:space-between; align-items:center;
    background:var(--surface-2); border:1px solid var(--line); border-radius:10px;
    padding:11px 14px; margin-bottom:8px;
  }
  .fil-item .fi-name{font-size:13.5px; font-weight:600;}
  .fil-item .fi-meta{font-size:11.5px; color:var(--ink-faint); font-family:var(--mono); direction:ltr;}
  .fil-item .fi-price{font-family:var(--mono); font-size:13px; color:var(--teal); direction:ltr;}
  .fil-add-form{
    background:var(--surface-2); border:1px dashed var(--line); border-radius:10px; padding:14px; margin-top:8px;
  }

  .toast{
    position:fixed; bottom:24px; left:50%; transform:translateX(-50%) translateY(20px);
    background:var(--surface-3); border:1px solid var(--amber); color:var(--ink);
    padding:12px 20px; border-radius:10px; font-size:13.5px;
    opacity:0; transition:.25s; z-index:100; pointer-events:none;
  }
  .toast.show{opacity:1; transform:translateX(-50%) translateY(0);}

  footer{text-align:center; color:var(--ink-faint); font-size:12px; margin-top:30px;}

  @media (max-width:520px){
    .grid{grid-template-columns:1fr;}
    .price-value{font-size:31px;}
    h1{font-size:22px;}
    .card{padding:18px 16px;}
  }

/* ---------- shared: last-updated banner ---------- */
.updated-note{
  display:flex; align-items:center; gap:8px;
  font-family:var(--mono); font-size:11.5px; color:var(--ink-faint);
  margin-top:10px; direction:ltr; justify-content:flex-end;
}
.updated-note .dot{width:6px; height:6px; border-radius:50%; background:var(--teal); flex:none;}
.updated-note.stale .dot{background:var(--red);}

/* ---------- admin page ---------- */
.admin-badge{
  display:inline-block; font-family:var(--mono); font-size:11px; color:var(--amber);
  background:var(--amber-soft); border:1px solid rgba(232,135,30,.3);
  border-radius:6px; padding:3px 8px; margin-bottom:10px;
}
.readonly-row{
  display:flex; justify-content:space-between; padding:9px 0;
  border-bottom:1px solid var(--line-soft); font-size:13.5px;
}
.readonly-row:last-child{border-bottom:none;}
.readonly-row .r-label{color:var(--ink-dim);}
.readonly-row .r-val{font-family:var(--mono); direction:ltr; font-weight:600;}
.settings-link-btn{
  display:block; text-align:center; text-decoration:none;
  background:var(--surface-2); border:1px solid var(--line); color:var(--ink);
  border-radius:10px; padding:12px; font-size:13.5px; margin-top:14px; transition:.15s;
}
.settings-link-btn:hover{border-color:var(--amber); color:var(--amber);}
.save-download-note{
  font-size:12.5px; color:var(--ink-faint); line-height:1.8; margin-top:14px;
  background:var(--surface-2); border:1px solid var(--line); border-radius:10px; padding:14px;
}
.save-download-note b{color:var(--ink);}
.fetch-fail{
  background:rgba(217,105,95,.1); border:1px solid rgba(217,105,95,.35);
  color:var(--red); border-radius:10px; padding:12px 14px; font-size:13px; margin-bottom:16px;
}
