@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --border: #e5e5ea;
  --text: #1c1c1e;
  --text2: #636366;
  --text3: #aeaeb2;
  --accent: #5856d6;
  --accent-light: rgba(88,86,214,0.1);
  --green: #34c759;
  --green-light: rgba(52,199,89,0.12);
  --red: #ff3b30;
  --red-light: rgba(255,59,48,0.1);
  --orange: #ff9500;
  --orange-light: rgba(255,149,0,0.12);
  --blue: #007aff;
  --blue-light: rgba(0,122,255,0.1);
  --r: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  margin: 0;
}
::selection { background: var(--accent); color: #fff; }

/* Word wrap everywhere */
h1,h2,h3,h4,h5,h6,p,div,span,a,td,th,li,label,input,textarea {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

h1,h2,h3,h4,h5,h6 { font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
a { color: var(--accent); text-decoration: none; }
hr { border-color: var(--border); opacity: 1; margin: 12px 0; }

/* ── Navbar ── */
.navbar {
  background: rgba(255,255,255,0.85) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-brand { font-weight: 700; font-size: 1.05rem; color: var(--text) !important; }
.navbar-brand i { color: var(--accent); }
.nav-link { color: var(--text2) !important; font-size: .85rem; font-weight: 500; padding: 6px 12px !important; border-radius: 8px; }
.nav-link:hover { background: var(--bg); }
.nav-link.active { color: var(--accent) !important; background: var(--accent-light); }
.navbar-text { color: var(--text3) !important; font-size: .8rem; }
.navbar-toggler { border: none; padding: 4px; }
.navbar-toggler:focus { box-shadow: none; }
.btn-outline-light { color: var(--text2) !important; border: 1px solid var(--border) !important; font-size: .8rem; }
.btn-outline-light:hover { background: var(--bg) !important; }

/* ── Cards ── */
.card {
  background: var(--card) !important;
  border: none !important;
  border-radius: var(--r) !important;
  box-shadow: var(--shadow);
}
.card-header {
  background: var(--card) !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 12px 16px;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text3);
}
.card-header h5, .card-header h6 {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text3);
  margin: 0;
}
.card-body { padding: 16px; }

/* ── Badges ── */
.badge {
  font-weight: 600;
  font-size: .7rem;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: .02em;
  border: none;
}
.badge.bg-success { background: var(--green-light) !important; color: var(--green) !important; }
.badge.bg-danger { background: var(--red-light) !important; color: var(--red) !important; }
.badge.bg-warning { background: var(--orange-light) !important; color: var(--orange) !important; }
.badge.bg-info { background: var(--accent-light) !important; color: var(--accent) !important; }
.badge.bg-secondary { background: #f2f2f7 !important; color: var(--text2) !important; }
.badge.bg-dark { background: #f2f2f7 !important; color: var(--text) !important; font-family: 'JetBrains Mono', monospace; }
.badge.bg-primary { background: var(--accent-light) !important; color: var(--accent) !important; }

/* ── Buttons ── */
.btn {
  font-weight: 600;
  font-size: .9rem;
  border-radius: 10px;
  padding: 10px 18px;
  border: none;
  cursor: pointer;
  transition: all .15s ease;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn:active { transform: scale(0.97); }
.btn-sm { font-size: .82rem; padding: 8px 14px; min-height: 38px; border-radius: 8px; }

.btn-primary { background: var(--accent) !important; color: #fff !important; }
.btn-primary:hover { opacity: .9; }
.btn-success { background: var(--green) !important; color: #fff !important; }
.btn-warning { background: var(--orange) !important; color: #fff !important; }
.btn-danger { background: var(--red) !important; color: #fff !important; }
.btn-info { background: var(--blue) !important; color: #fff !important; }
.btn-secondary { background: #e5e5ea !important; color: var(--text) !important; }
.btn-secondary:hover { background: #d1d1d6 !important; }

.btn-outline-primary { color: var(--accent) !important; border: 1.5px solid var(--accent) !important; background: transparent !important; }
.btn-outline-primary:hover { background: var(--accent-light) !important; }
.btn-outline-secondary { color: var(--text2) !important; border: 1.5px solid var(--border) !important; background: transparent !important; }
.btn-outline-secondary:hover { background: var(--bg) !important; }
.btn-outline-danger { color: var(--red) !important; border: 1.5px solid rgba(255,59,48,.3) !important; background: transparent !important; }
.btn-outline-danger:hover { background: var(--red-light) !important; }
.btn-outline-success { color: var(--green) !important; border: 1.5px solid rgba(52,199,89,.3) !important; background: transparent !important; }

.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: 10px 0 0 10px; }
.btn-group .btn:last-child { border-radius: 0 10px 10px 0; }
.btn-group-sm .btn { min-height: 36px; font-size: .8rem; padding: 6px 14px; }

/* ── Forms ── */
.form-control, .form-select {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 16px;
  min-height: 44px;
  color: var(--text);
  transition: .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  background: #fff;
}
.form-control-sm { min-height: 38px; padding: 8px 12px; font-size: 15px; }
textarea.form-control { min-height: unset; font-size: 14px; line-height: 1.5; }
.form-label { font-size: .8rem; font-weight: 600; color: var(--text2); margin-bottom: 4px; }
.form-check-input { width: 20px; height: 20px; margin-top: 2px; }
.form-check-label { font-size: .85rem; padding-left: 4px; }

/* ── List Groups ── */
.list-group { border-radius: var(--r) !important; overflow: hidden; }
.list-group-item {
  border-color: var(--border) !important;
  padding: 14px 16px;
  min-height: 64px;
  background: var(--card);
  transition: background .1s;
}
.list-group-item:active { background: var(--bg); }
.list-group-item-action { color: var(--text); }
.list-group-item-action:hover { background: #fafafa; color: var(--text); }

/* ── Alerts ── */
.alert { border-radius: 10px; border: none; font-size: .85rem; }
.alert-warning { background: var(--orange-light); color: #7c4a00; }
.alert-danger { background: var(--red-light); color: #990000; }

/* ── Modals ── */
.modal-content { border-radius: 16px; border: none; overflow: hidden; }
.modal-header { padding: 14px 20px; }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); }
.modal-title { font-size: 1rem; font-weight: 700; }

/* ── Dropdown ── */
.dropdown-menu {
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  padding: 6px;
  overflow: hidden;
}
.dropdown-item {
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .88rem;
  font-weight: 500;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.dropdown-item:active { background: var(--accent-light); color: var(--accent); }
.dropdown-divider { margin: 4px 0; }

/* ── Toast ── */
.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 400px;
}
.toast-msg {
  background: var(--card);
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  font-size: .88rem;
  font-weight: 500;
  animation: toastIn .3s ease;
  text-align: center;
}
.toast-msg.success { border-left: 4px solid var(--green); }
.toast-msg.error { border-left: 4px solid var(--red); }
.toast-msg.info { border-left: 4px solid var(--blue); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-20px); } }

/* ── Bottom Navigation ── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: 4px 0;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
  z-index: 1000;
  justify-content: space-around;
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text3);
  font-size: .65rem;
  font-weight: 500;
  text-decoration: none;
  padding: 6px 16px;
  border-radius: 10px;
}
.bottom-nav a i { font-size: 1.4rem; margin-bottom: 2px; }
.bottom-nav a.active { color: var(--accent); }
.bottom-nav a:active { background: var(--bg); }

/* ── Spinner ── */
.spinner-border { width: 1.2rem; height: 1.2rem; border-width: 2px; }
.spinner-border-sm { width: 1rem; height: 1rem; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Utilities ── */
.min-width-0 { min-width: 0 !important; }
.flex-grow-1 { min-width: 0; }
.text-muted { color: var(--text3) !important; }
small, .small { color: var(--text3) !important; }
p { color: var(--text2) !important; }

/* ── Desktop tweaks ── */
@media (min-width: 769px) {
  main.container-fluid { padding: 24px 32px; }
  .list-group-item { padding: 16px 20px; }
}

/* ── Mobile ── */
@media (max-width: 768px) {
  .navbar .collapse { display: none !important; }
  .bottom-nav { display: flex !important; }
  main.container-fluid { padding: 16px 16px 90px 16px !important; }
  
  /* Modals slide up from bottom */
  .modal-dialog { margin: 0; max-width: 100%; position: fixed; bottom: 0; left: 0; right: 0; }
  .modal-content { border-radius: 16px 16px 0 0; max-height: 90vh; overflow-y: auto; }
  .modal.fade .modal-dialog { transform: translateY(100%); }
  .modal.show .modal-dialog { transform: translateY(0); }
  
  /* Dropdowns */
  .dropdown-menu { width: calc(100vw - 32px) !important; }
  
  /* Pre-wrap areas */
  [style*="pre-wrap"], pre { max-width: 100% !important; overflow-x: auto !important; word-break: break-word !important; }
}

/* Biometric button */
.btn-biometric { background: var(--bg); border: 1.5px solid var(--border); border-radius: 10px; color: var(--text2); padding: 12px; font-size: .85rem; cursor: pointer; width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; }
.btn-biometric:hover { border-color: var(--accent); color: var(--accent); }

/* Animations */
.card { animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ── Action Bar sticky on mobile ── */
@media (max-width: 768px) {
  #actionBar {
    position: fixed;
    bottom: 56px;
    left: 0;
    right: 0;
    z-index: 50;
    border-radius: 0 !important;
    margin: 0 !important;
    border-left: none;
    border-right: none;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
  }
}

/* ── Section labels ── */
.section-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text3);
  padding: 0 4px;
  margin-bottom: 8px;
}
