/* ===== Reset & Base ===== */
*{margin:0;padding:0;box-sizing:border-box}
html{font-size:16px;-webkit-text-size-adjust:100%}
body{
  font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
  background:#f5f5f7;
  color:#1d1d1f;
  min-height:100vh;
  padding-bottom:80px;
}

/* ===== Header ===== */
.header{
  background:#fff;
  padding:16px 20px 12px;
  border-bottom:1px solid #e5e5ea;
  position:sticky;top:0;z-index:100;
}
.header h1{font-size:20px;font-weight:700;letter-spacing:-0.3px}
.header .sub{font-size:12px;color:#8e8e93;margin-top:2px}

/* ===== Tab Bar ===== */
.tab-bar{
  display:flex;
  position:fixed;bottom:0;left:0;right:0;
  background:#fff;
  border-top:1px solid #e5e5ea;
  z-index:100;
  padding-bottom:env(safe-area-inset-bottom, 0);
}
.tab-bar button{
  flex:1;
  border:none;background:transparent;
  padding:8px 0 6px;
  font-size:10px;color:#8e8e93;
  display:flex;flex-direction:column;align-items:center;gap:2px;
  cursor:pointer;
  -webkit-tap-highlight-color:transparent;
}
.tab-bar button.active{color:#007aff}
.tab-bar button .icon{font-size:22px;line-height:1}

/* ===== Content ===== */
.content{padding:16px;display:none}
.content.active{display:block}

/* ===== Cards ===== */
.card{
  background:#fff;
  border-radius:14px;
  padding:16px;
  margin-bottom:12px;
  box-shadow:0 1px 3px rgba(0,0,0,0.06);
}
.card-title{
  font-size:15px;font-weight:700;
  display:flex;align-items:center;gap:6px;
  margin-bottom:10px;
}
.card-title .badge{
  font-size:11px;font-weight:600;
  padding:2px 8px;border-radius:10px;
  color:#fff;
}
.badge-today{background:#ff9500}
.badge-past{background:#ff3b30}

/* ===== Data Row ===== */
.data-row{
  display:flex;justify-content:space-between;
  padding:6px 0;
  border-bottom:1px solid #f2f2f7;
  font-size:14px;
}
.data-row:last-child{border-bottom:none}
.data-row .label{color:#8e8e93}
.data-row .value{font-weight:600;text-align:right}

/* ===== Progress Bar ===== */
.progress-wrap{
  background:#f2f2f7;border-radius:6px;
  height:8px;margin:6px 0 2px;overflow:hidden;
}
.progress-bar{
  height:100%;border-radius:6px;
  background:linear-gradient(90deg,#34c759,#30d158);
  transition:width 0.4s ease;
}

/* ===== Next Buy Highlight ===== */
.next-buy{
  margin-top:10px;padding:10px 12px;
  border-radius:10px;
  background:#f2f2f7;
  text-align:center;
  font-size:14px;font-weight:600;
}
.next-buy.today{background:#fff3cd;color:#856404}
.next-buy.past{background:#fecdd3;color:#9b1c31}

/* ===== FX Card ===== */
.fx-card{
  background:linear-gradient(135deg,#007aff,#5856d6);
  color:#fff;border-radius:14px;
  padding:14px 16px;margin-bottom:12px;
  display:flex;justify-content:space-between;align-items:center;
}
.fx-card .fx-label{font-size:13px;opacity:0.85}
.fx-card .fx-value{font-size:22px;font-weight:700}

/* ===== Form ===== */
.form-group{margin-bottom:14px}
.form-group label{
  display:block;font-size:13px;font-weight:600;
  color:#6e6e73;margin-bottom:4px;
}
.form-group input,.form-group select{
  width:100%;padding:12px;
  border:1px solid #d1d1d6;border-radius:10px;
  font-size:16px;background:#fff;
  -webkit-appearance:none;
  appearance:none;
}
.form-group select{
  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='%238e8e93' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right 12px center;
  padding-right:32px;
}
.form-group input:focus,.form-group select:focus{
  outline:none;border-color:#007aff;
  box-shadow:0 0 0 3px rgba(0,122,255,0.15);
}

/* ===== Buttons ===== */
.btn{
  width:100%;padding:14px;border:none;border-radius:12px;
  font-size:16px;font-weight:600;
  cursor:pointer;position:relative;
  -webkit-tap-highlight-color:transparent;
  transition:opacity 0.15s;
}
.btn:active{opacity:0.7}
.btn-primary{background:#007aff;color:#fff}
.btn-green{background:#34c759;color:#fff}
.btn-outline{
  background:transparent;color:#007aff;
  border:1.5px solid #007aff;
}
.btn-danger{background:transparent;color:#ff3b30;border:1.5px solid #ff3b30}
.btn-sm{padding:10px 16px;font-size:14px;border-radius:10px;width:auto}
.btn+.btn{margin-top:10px}

/* ===== Calc preview ===== */
.calc-preview{
  text-align:center;font-size:18px;font-weight:700;
  color:#007aff;margin:12px 0 4px;
}

/* ===== History List ===== */
.history-item{
  display:flex;justify-content:space-between;align-items:center;
  padding:10px 0;
  border-bottom:1px solid #f2f2f7;
  font-size:14px;
}
.history-item:last-child{border-bottom:none}
.history-left{display:flex;flex-direction:column;gap:2px}
.history-date{color:#8e8e93;font-size:12px}
.history-right{text-align:right;font-weight:600}

/* ===== Action Buttons ===== */
.action-card{
  background:#fff;border-radius:14px;
  overflow:hidden;margin-bottom:12px;
  box-shadow:0 1px 3px rgba(0,0,0,0.06);
}
.action-btn{
  display:flex;align-items:center;gap:12px;
  padding:14px 16px;
  border:none;background:transparent;
  font-size:15px;font-weight:500;
  width:100%;text-align:left;
  cursor:pointer;
  -webkit-tap-highlight-color:transparent;
  border-bottom:1px solid #f2f2f7;
}
.action-btn:last-child{border-bottom:none}
.action-btn:active{background:#f2f2f7}
.action-btn .action-icon{font-size:22px;width:28px;text-align:center}
.action-btn .action-text{flex:1}
.action-btn .action-arrow{color:#c7c7cc;font-size:16px}

/* ===== Toast ===== */
.toast{
  position:fixed;top:60px;left:50%;transform:translateX(-50%);
  background:#1d1d1f;color:#fff;
  padding:10px 20px;border-radius:10px;
  font-size:14px;font-weight:500;
  z-index:200;opacity:0;
  transition:opacity 0.3s;
  pointer-events:none;
  max-width:90%;text-align:center;
}
.toast.show{opacity:1}

/* ===== Loading ===== */
.loading{
  display:flex;flex-direction:column;
  align-items:center;justify-content:center;
  padding:60px 20px;color:#8e8e93;
}
.spinner{
  width:32px;height:32px;
  border:3px solid #e5e5ea;
  border-top-color:#007aff;
  border-radius:50%;
  animation:spin 0.8s linear infinite;
  margin-bottom:12px;
}
@keyframes spin{to{transform:rotate(360deg)}}

/* ===== Pull to Refresh (visual) ===== */
.refresh-btn{
  display:flex;align-items:center;justify-content:center;
  gap:6px;padding:8px;
  color:#007aff;font-size:14px;font-weight:500;
  background:transparent;border:none;
  width:100%;margin-bottom:8px;
  cursor:pointer;
}
.refresh-btn:active{opacity:0.5}

/* ===== Empty State ===== */
.empty{
  text-align:center;padding:40px 20px;
  color:#8e8e93;font-size:15px;
}

/* ===== Settings section title ===== */
.section-title{
  font-size:13px;font-weight:600;
  color:#8e8e93;text-transform:uppercase;
  letter-spacing:0.5px;
  padding:0 4px;margin-bottom:8px;
}
.section-title+.action-card{margin-top:4px}

/* ===== LINE status ===== */
.line-status{
  padding:12px 16px;
  border-radius:10px;
  font-size:13px;
  margin-bottom:12px;
}
.line-ok{background:#e8f5e9;color:#2e7d32}
.line-ng{background:#fff3e0;color:#e65100}

/* ===== History actions ===== */
.history-item{position:relative}
.history-actions{
  display:flex;gap:8px;
  margin-top:6px;
}
.history-actions button{
  border:none;background:transparent;
  font-size:13px;font-weight:500;
  padding:4px 10px;border-radius:6px;
  cursor:pointer;
  -webkit-tap-highlight-color:transparent;
}
.btn-edit{color:#007aff;background:#e8f0fe}
.btn-edit:active{background:#d0e0fc}
.btn-del{color:#ff3b30;background:#ffeaea}
.btn-del:active{background:#ffd4d4}

/* ===== Modal Overlay ===== */
.modal-overlay{
  position:fixed;top:0;left:0;right:0;bottom:0;
  background:rgba(0,0,0,0.4);
  z-index:300;display:none;
  align-items:flex-end;justify-content:center;
}
.modal-overlay.show{display:flex}
.modal-sheet{
  background:#fff;
  border-radius:16px 16px 0 0;
  width:100%;max-width:500px;
  padding:20px 20px calc(20px + env(safe-area-inset-bottom, 0));
  max-height:85vh;overflow-y:auto;
  animation:slideUp 0.25s ease;
}
@keyframes slideUp{from{transform:translateY(100%)}to{transform:translateY(0)}}
.modal-header{
  display:flex;justify-content:space-between;align-items:center;
  margin-bottom:16px;
}
.modal-header h2{font-size:17px;font-weight:700}
.modal-close{
  border:none;background:#f2f2f7;
  width:30px;height:30px;border-radius:50%;
  font-size:16px;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  color:#8e8e93;
}
.modal-close:active{background:#e5e5ea}
