/* ═══════════════════════════════════════════════════════════
   OHTTEK — Components
═══════════════════════════════════════════════════════════ */

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--r);
  font-size: 12.5px; font-weight: 600; border: none;
  transition: all .13s; line-height: 1; white-space: nowrap;
  font-family: inherit; cursor: pointer;
}
.btn-primary   { background: var(--ac); color: var(--bg); }
.btn-primary:hover { background: #e8e8e8; box-shadow: 0 0 20px var(--ac-glow); }
.btn-secondary { background: var(--s3); color: var(--tx); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--s4); border-color: var(--border-l); }
.btn-ghost     { background: transparent; color: var(--tx2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--s3); color: var(--tx); }
.btn-danger    { background: var(--red-bg); color: var(--red); border: 1px solid rgba(248,113,113,.2); }
.btn-danger:hover { background: rgba(248,113,113,.18); }
.btn-success   { background: var(--green-bg); color: var(--green); border: 1px solid rgba(52,211,153,.2); }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Cards ── */
.card {
  background: var(--s1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px; margin-bottom: 16px;
}
.card:last-child { margin-bottom: 0; }
.card-title { font-family: var(--font-display); font-size: 14px; font-weight: 700; margin-bottom: 14px; letter-spacing: -.1px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }

/* ── KPI tiles ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 12px; margin-bottom: 20px; }
.kpi {
  background: var(--s1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 17px 18px;
  position: relative; overflow: hidden;
  transition: border-color .15s, transform .15s;
}
.kpi::before { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 2px; background: var(--kc, var(--ac)); }
.kpi:hover { border-color: var(--kc, var(--border-l)); transform: translateY(-1px); }
.kpi-icon { font-size: 11px; color: var(--kc, var(--ac)); font-family: var(--font-display); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; opacity: .7; }
.kpi-val  { font-family: var(--font-body); font-size: 28px; font-weight: 700; color: var(--tx); line-height: 1; letter-spacing: -0.5px; }
.kpi-lbl  { font-size: 11px; color: var(--tx3); margin-top: 3px; }

/* ── Tables ── */
.tbl-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--s1); }
thead th {
  background: var(--s2); color: var(--tx3);
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; padding: 10px 14px; text-align: left;
  white-space: nowrap; border-bottom: 1px solid var(--border);
}
tbody td { padding: 11px 14px; font-size: 13px; color: var(--tx); border-bottom: 1px solid rgba(255,255,255,.06); }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--ac-bg); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .3px;
  text-transform: uppercase; white-space: nowrap;
}
.badge::before { content: ''; width: 4px; height: 4px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.b-tentative { background: var(--amber-bg);  color: var(--amber); }
.b-enquiry   { background: rgba(255,255,255,0.08); color: #ffffff; }
.b-confirmed { background: var(--blue-bg);   color: var(--blue); }
.b-completed { background: var(--teal-bg);   color: var(--teal); }
.b-invoiced  { background: var(--purple-bg); color: var(--purple); }
.b-paid      { background: var(--green-bg);  color: var(--green); }
.b-cancelled { background: var(--red-bg);    color: var(--red); }
.b-draft     { background: rgba(100,100,130,.15); color: #888; }
.b-sent      { background: var(--blue-bg);   color: var(--blue); }
.b-overdue   { background: var(--red-bg);    color: var(--red); }

/* ── Notification badge (sidebar) ── */
.notif-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; font-family: var(--font-mono);
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: auto;
}

/* ── Forms ── */
.fg { margin-bottom: 13px; }
.fl { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--tx3); margin-bottom: 5px; }
.fc {
  width: 100%; background: var(--s3); border: 1px solid var(--border);
  border-radius: var(--r); color: var(--tx);
  font-family: inherit; font-size: 13px; padding: 9px 12px;
  transition: border-color .12s, box-shadow .12s; outline: none;
}
.fc:focus { border-color: var(--ac); box-shadow: 0 0 0 3px var(--ac-bg); }
.fc::placeholder { color: var(--tx3); }
select.fc option { background: var(--s3); }
textarea.fc { resize: vertical; min-height: 68px; }

/* ── Filter bar ── */
.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filter-bar .fc { width: auto; }
.search-box { flex: 1; min-width: 180px; max-width: 300px; }

/* ── Modal ── */
#modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7); backdrop-filter: blur(6px);
  z-index: 300; opacity: 0; pointer-events: none; transition: opacity .18s;
}
#modal-bg.open { opacity: 1; pointer-events: all; }
#modal {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%,-48%) scale(.95);
  background: var(--s2); border: 1px solid var(--border-l);
  border-radius: 14px; z-index: 301;
  width: 540px; max-width: 92vw; max-height: 86vh;
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; pointer-events: none;
  transition: transform .22s cubic-bezier(.34,1.4,.64,1), opacity .18s;
}
#modal.open { transform: translate(-50%,-50%) scale(1); opacity: 1; pointer-events: all; }
.modal-hd { padding: 18px 20px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.modal-hd h3 { font-family: var(--font-display); font-size: 14px; font-weight: 700; }
.modal-x { background: none; border: none; color: var(--tx3); font-size: 16px; cursor: pointer; transition: color .12s; padding: 4px; }
.modal-x:hover { color: var(--tx); }
#modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
#modal-foot { padding: 13px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0; }

/* ── Toast ── */
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 7px; }
@media (max-width: 768px) { #toasts { bottom: 78px; right: 12px; left: 12px; } #toasts .toast { min-width: 0; max-width: 100%; } }
.toast {
  background: var(--s3); border: 1px solid var(--border-l);
  border-radius: var(--r); padding: 11px 15px;
  font-size: 12.5px; min-width: 240px; max-width: 340px;
  display: flex; align-items: center; gap: 9px;
  box-shadow: 0 8px 30px rgba(0,0,0,.6);
  animation: tIn .2s ease;
}
.toast-s { border-left: 3px solid var(--green); }
.toast-e { border-left: 3px solid var(--red); }
.toast-i { border-left: 3px solid var(--ac); }
@keyframes tIn { from { transform: translateX(110%); opacity: 0; } }

/* ── Currency switcher ── */
.cur-switcher { display: flex; align-items: center; gap: 2px; background: var(--s3); border: 1px solid var(--border); border-radius: var(--r); padding: 2px; flex-shrink: 0; }
.cur-btn { padding: 4px 9px; border-radius: 5px; font-size: 11px; font-weight: 700; font-family: var(--font-mono); cursor: pointer; border: none; background: transparent; color: var(--tx3); transition: all .12s; line-height: 1; }
.cur-btn:hover { color: var(--tx); background: var(--s4); }
.cur-btn.active { background: var(--ac); color: var(--bg); }

/* ── Empty state ── */
.empty { text-align: center; padding: 48px 20px; color: var(--tx3); }
.empty i { font-size: 40px; opacity: .2; margin-bottom: 12px; display: block; }
.empty p { font-size: 13px; color: var(--tx2); margin-bottom: 16px; }

/* ── Info rows ── */
.info-row { margin-bottom: 11px; }
.info-lbl { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--tx3); margin-bottom: 2px; }
.info-val { font-size: 13px; color: var(--tx); }

/* ── Tabs ── */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 16px; }
.tab  { padding: 8px 16px; font-size: 13px; font-weight: 600; color: var(--tx3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .12s; }
.tab:hover { color: var(--tx2); }
.tab.active { color: var(--ac); border-bottom-color: var(--ac); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── PIN screen ── */
#pin-screen { position: fixed; inset: 0; background: var(--bg); z-index: 999; display: flex; align-items: center; justify-content: center; flex-direction: column; }
#pin-screen.hidden { display: none; }
.pin-card { background: var(--s2); border: 1px solid var(--border-l); border-radius: 16px; padding: 36px 40px; width: 320px; text-align: center; }
.pin-logo { font-family: var(--font-display); font-size: 24px; font-weight: 800; color: var(--ac); letter-spacing: -1px; margin-bottom: 6px; }
.pin-sub  { font-size: 12px; color: var(--tx3); margin-bottom: 28px; }
.pin-dots { display: flex; justify-content: center; gap: 10px; margin-bottom: 20px; }
.pin-dot  { width: 12px; height: 12px; border-radius: 50%; background: var(--s4); border: 2px solid var(--border); transition: all .15s; }
.pin-dot.filled { background: var(--ac); border-color: var(--ac); }
.pin-dot.error  { background: var(--red); border-color: var(--red); }
.pin-pad  { display: grid; grid-template-columns: repeat(3,1fr); gap: 9px; margin-bottom: 14px; }
.pin-key  { padding: 14px; border-radius: 10px; background: var(--s3); border: 1px solid var(--border); font-size: 18px; font-weight: 600; cursor: pointer; color: var(--tx); font-family: var(--font-display); transition: all .1s; user-select: none; }
.pin-key:hover  { background: var(--s4); border-color: var(--border-l); }
.pin-key:active { transform: scale(.93); }
.pin-key.wide   { grid-column: span 2; }
.pin-err { font-size: 12px; color: var(--red); min-height: 18px; margin-bottom: 6px; }

/* ── T&C modal footer — sticky so Accept stays visible when scrolling body ── */
#terms-modal .modal-footer {
  position: sticky;
  bottom: 0;
  background: var(--s1);
}

/* ── Save button in topbar ── */
.tb-save-btn { display: flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: var(--r); font-size: 12px; font-weight: 600; cursor: pointer; border: 1px solid rgba(255,255,255,.2); background: var(--ac-bg); color: var(--ac); transition: all .15s; flex-shrink: 0; }
.tb-save-btn:hover { background: var(--ac); color: var(--bg); }
