:root {
  --primary: #0d6efd;
  --primary-dark: #084db4;
  --primary-soft: #eaf3ff;
  --bg: #eef5ff;
  --card: #ffffff;
  --text: #071f45;
  --text-soft: #253858;
  --muted: #667085;
  --border: #d8e7ff;
  --success: #198754;
  --danger: #dc3545;
  --shadow: 0 14px 34px rgba(13, 110, 253, 0.10);
  --shadow-soft: 0 8px 22px rgba(13, 110, 253, 0.07);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --topbar-h: 72px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg,
video,
canvas {
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

/* App frame */
.app-shell {
  width: 100%;
  max-width: 520px;
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(var(--topbar-h) + 18px) 16px 32px;
  background: var(--bg);
}

.auth-shell {
  min-height: 100vh;
  min-height: 100svh;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

@media (min-width: 700px) {
  body {
    background: #eaf3ff;
  }

  .app-shell {
    box-shadow: 0 0 0 1px rgba(216, 231, 255, 0.9);
  }
}

/* Topbar */
.app-topbar {
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 100;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  min-height: var(--topbar-h);
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 46px;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, #ffffff, #f7fbff);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.04);
}

.topbar-title,
.app-topbar > div {
  min-width: 0;
  text-align: center;
}

.app-topbar strong,
.topbar-title strong {
  display: block;
  max-width: 100%;
  font-size: 17px;
  line-height: 1.15;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-topbar small,
.topbar-title small {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.2;
  color: var(--muted);
}

.top-icon {
  width: 42px;
  height: 42px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 18px;
  font-weight: 900;
}

/* Typography */
h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
.page-title {
  margin: 0 0 8px;
  font-size: 25px;
  line-height: 1.13;
  letter-spacing: -0.02em;
  color: var(--text);
}

h2 {
  margin: 0 0 10px;
  font-size: 21px;
  line-height: 1.2;
  color: var(--text);
}

h3 {
  margin: 0 0 9px;
  font-size: 17px;
  line-height: 1.25;
  color: var(--text);
}

.center {
  text-align: center;
}

.muted,
.subtitle,
.page-subtitle {
  color: var(--muted);
}

.subtitle,
.page-subtitle {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.45;
}

/* Cards */
.card,
.soft-card,
.form-card,
.panel,
.toolbar {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.soft-card {
  background: #f8fbff;
  border-style: dashed;
  box-shadow: none;
}

.logo-circle {
  width: 78px;
  height: 78px;
  margin: 0 auto 18px;
  border-radius: 24px;
  background: var(--primary);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-size: 32px;
  font-weight: 900;
  box-shadow: 0 16px 34px rgba(13, 110, 253, 0.22);
}

/* Login */
.login-card,
.auth-card {
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
  border-radius: 28px;
}

.login-card h1 {
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
}

.alert {
  width: 100%;
  margin: 0 0 14px;
  padding: 13px 15px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
}

.login-error {
  margin: 0 0 16px;
}

.alert.success {
  background: #ecfff4;
  color: #137447;
  border: 1px solid #b8f2cf;
}

.alert.error {
  background: #fff1f1;
  color: #b4232f;
  border: 1px solid #ffb8c0;
}

/* Forms */
.form-group {
  width: 100%;
  margin-bottom: 15px;
}

label {
  display: block;
  margin: 0 0 7px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-soft);
}

input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  min-height: 46px;
  border: 1px solid #cfe0fb;
  border-radius: 16px;
  padding: 13px 15px;
  background: #ffffff;
  color: var(--text);
  font-size: 15px;
  outline: none;
}

textarea {
  min-height: 116px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.10);
}

/* Buttons */
.btn,
button.btn,
input[type="submit"] {
  min-height: 44px;
  border: 0;
  border-radius: 15px;
  padding: 12px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--primary);
  color: #ffffff;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(13, 110, 253, 0.18);
}

.btn:hover,
button.btn:hover {
  background: var(--primary-dark);
}

.btn.full {
  width: 100%;
}

.btn.small {
  min-height: 38px;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 12px;
  white-space: nowrap;
}

.btn.light,
.btn.secondary {
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: none;
}

.btn.danger {
  background: var(--danger);
}

.btn.success {
  background: var(--success);
}

.row-actions,
.actions,
.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Dashboard */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.menu-card {
  min-height: 150px;
  border-radius: 24px;
  padding: 18px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-weight: 900;
  color: var(--text);
  text-align: center;
}

.menu-card .icon {
  width: 62px;
  height: 62px;
  border-radius: 20px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 30px;
}

/* Search */
.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 14px;
}

.filters {
  width: 100%;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.chip {
  min-height: 36px;
  padding: 8px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

/* Service list */
.service-list-card {
  width: 100%;
  margin-bottom: 14px;
  padding: 16px;
  border-radius: 22px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px;
  gap: 12px;
  align-items: center;
}

.service-list-left {
  min-width: 0;
}

.customer-code,
.code-badge,
.badge {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 9px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.1;
}

.service-list-left h3,
.list-card-left h3,
.service-card h3 {
  margin: 0 0 8px;
  color: #061b3a;
  font-size: 18px;
  line-height: 1.24;
  word-break: break-word;
}

.dealer-info,
.list-meta {
  margin: 0;
  color: #5f6f89;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}

.service-list-actions {
  width: 116px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.service-list-actions .btn {
  width: 100%;
  box-shadow: none;
}

/* Generic list */
.list-card,
.service-card,
.list-item {
  width: 100%;
  margin-bottom: 13px;
  padding: 15px;
  border-radius: 20px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.list-card-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.list-item strong,
.list-card strong {
  display: block;
  color: #061b3a;
  font-size: 16px;
  line-height: 1.25;
  word-break: break-word;
}

.list-item span,
.list-card span {
  display: block;
  margin-top: 5px;
  color: #5f6f89;
  font-size: 14px;
  line-height: 1.35;
  word-break: break-word;
}

.amount {
  font-weight: 900;
}

.debit {
  color: #d63384;
}

.credit {
  color: var(--success);
}

/* Searchable dealer */
.dealer-search-list {
  margin-top: 10px;
  max-height: 270px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #ffffff;
}

.dealer-option {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #eef4ff;
  padding: 13px 14px;
  background: #ffffff;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
}

.dealer-option:last-child {
  border-bottom: 0;
}

.dealer-option strong {
  display: block;
  color: var(--text);
  font-size: 14px;
}

.dealer-option span {
  display: block;
  margin-top: 3px;
  color: #6b7890;
  font-size: 12px;
}

.dealer-option.selected {
  background: var(--primary-soft);
}

.selected-dealer-text {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

/* Mic */
.voice-field {
  position: relative;
  width: 100%;
}

.voice-field textarea {
  padding-right: 62px !important;
}

.mic-btn {
  position: absolute !important;
  top: 10px !important;
  right: 10px !important;
  left: auto !important;
  bottom: auto !important;
  z-index: 4;
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  min-height: 44px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: var(--primary-soft) !important;
  color: var(--primary) !important;
  display: grid !important;
  place-items: center !important;
  font-size: 20px !important;
  line-height: 1 !important;
  cursor: pointer;
  box-shadow: none !important;
}

.mic-btn::before {
  content: "🎙";
  display: block;
}

.mic-btn svg,
.mic-btn img,
.mic-btn i,
.mic-btn span {
  display: none !important;
}

.mic-btn.recording {
  background: var(--danger) !important;
  color: #ffffff !important;
  animation: micPulse 1s infinite;
}

.mic-btn.recording::before {
  content: "■";
  font-size: 18px;
}

@keyframes micPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* Images */
.thumb-grid,
.image-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.thumb {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 13px;
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: pointer;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  padding: 20px;
  background: rgba(0, 0, 0, 0.78);
  display: none;
  align-items: center;
  justify-content: center;
}

.image-modal.open {
  display: flex;
}

.image-modal img {
  max-width: 100%;
  max-height: 82vh;
  border-radius: 18px;
}

.image-modal button {
  position: absolute;
  top: 18px;
  right: 18px;
}

/* QR / ledger */
.qr-box {
  margin-top: 12px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: #ffffff;
  text-align: center;
}

.qr-box img {
  width: 190px;
  height: 190px;
  max-width: 100%;
}

.ledger-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.summary-box {
  padding: 12px;
  border-radius: 16px;
  background: #f8fbff;
  border: 1px solid var(--border);
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 18px;
  background: #ffffff;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 20px 0 10px;
}

.section-title span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

.hidden {
  display: none !important;
}

.footer-space {
  height: 20px;
}

/* Mobile */
@media (max-width: 520px) {
  :root {
    --topbar-h: 68px;
  }

  .app-shell {
    padding: calc(var(--topbar-h) + 14px) 12px 28px;
  }

  .auth-shell {
    padding: 18px;
  }

  .app-topbar {
    min-height: var(--topbar-h);
    padding: 10px 12px;
    grid-template-columns: 42px minmax(0, 1fr) 42px;
  }

  .top-icon {
    width: 40px;
    height: 40px;
    border-radius: 14px;
  }

  .app-topbar strong,
  .topbar-title strong {
    font-size: 16px;
  }

  .card,
  .soft-card,
  .form-card,
  .panel,
  .toolbar {
    border-radius: 20px;
    padding: 15px;
  }

  h1,
  .page-title {
    font-size: 23px;
  }

  .search-row {
    grid-template-columns: 1fr;
  }

  .search-row .btn {
    width: 100%;
  }

  .service-list-card {
    grid-template-columns: 1fr;
    align-items: stretch;
    padding: 16px;
  }

  .service-list-actions {
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }

  .list-item {
    grid-template-columns: 1fr;
  }

  .actions,
  .card-actions,
  .row-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .btn.small {
    width: 100%;
    min-height: 38px;
    padding: 9px 8px;
    font-size: 12px;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .thumb-grid,
  .image-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .ledger-summary {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 360px) {
  .app-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  .service-list-actions,
  .actions,
  .card-actions,
  .row-actions {
    grid-template-columns: 1fr;
  }

  .thumb-grid,
  .image-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* PWA safe area */
.pwa-mode body {
  background: var(--bg);
}

@supports (padding: max(0px)) {
  .app-topbar {
    padding-top: max(10px, env(safe-area-inset-top));
  }

  .app-shell {
    padding-bottom: max(28px, env(safe-area-inset-bottom));
  }
}

/* Print */
@media print {
  body {
    background: #ffffff;
  }

  .app-topbar,
  .no-print,
  .btn {
    display: none !important;
  }

  .app-shell {
    max-width: none;
    min-height: auto;
    padding: 0;
    box-shadow: none;
    background: #ffffff;
  }

  .card,
  .soft-card,
  .form-card,
  .panel {
    box-shadow: none;
    border: 1px solid #dddddd;
  }
}


/* =========================================================
   DS SERVICE LIST FINAL MOBILE UI
   Unique classes to avoid old CSS conflict
========================================================= */

.ds-filter-card {
    width: 100%;
    background: #ffffff;
    border: 1px solid #d8e7ff;
    border-radius: 24px;
    padding: 18px;
    margin: 0 0 18px;
    box-shadow: 0 14px 34px rgba(13, 110, 253, 0.10);
}

.ds-filter-card h2 {
    margin: 0 0 14px;
    font-size: 22px;
    line-height: 1.15;
    font-weight: 900;
    color: #071f45;
}

.ds-search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 78px;
    gap: 10px;
    margin-bottom: 14px;
}

.ds-search-row input {
    width: 100%;
    min-width: 0;
}

.ds-search-btn {
    width: 78px;
    min-height: 46px;
    padding: 0;
    font-size: 12px;
    border-radius: 14px;
}

.ds-chip-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 0 14px;
}

.ds-chip {
    min-height: 36px;
    padding: 9px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #d8e7ff;
    border-radius: 999px;
    background: #ffffff;
    color: #667085;
    font-size: 13px;
    font-weight: 700;
}

.ds-chip.active {
    background: #0d6efd;
    border-color: #0d6efd;
    color: #ffffff;
}

.ds-add-service-btn {
    min-height: 48px;
    border-radius: 16px;
    font-size: 15px;
    font-weight: 900;
}

.ds-service-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ds-service-card {
    width: 100%;
    background: #ffffff;
    border: 1px solid #d8e7ff;
    border-radius: 22px;
    padding: 16px;
    box-shadow: 0 12px 28px rgba(13, 110, 253, 0.08);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 126px;
    gap: 12px;
    align-items: center;
}

.ds-service-content {
    min-width: 0;
    width: 100%;
}

.ds-cust-code {
    width: fit-content;
    max-width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    margin-bottom: 8px;
    border-radius: 999px;
    background: #eaf3ff;
    color: #0d6efd;
    font-size: 12px;
    line-height: 1;
    font-weight: 900;
}

.ds-cust-name {
    margin: 0 0 8px;
    font-size: 18px;
    line-height: 1.25;
    font-weight: 900;
    color: #071f45;
    word-break: break-word;
}

.ds-dealer-line {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
    color: #5f6f89;
    font-weight: 500;
    word-break: break-word;
}

.ds-service-actions {
    width: 126px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ds-card-btn {
    width: 100%;
    min-height: 38px;
    padding: 9px 8px;
    border-radius: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 12px;
    line-height: 1.1;
    font-weight: 900;
    text-decoration: none;
    white-space: nowrap;
}

.ds-card-btn-primary {
    background: #0d6efd;
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(13, 110, 253, 0.18);
}

.ds-card-btn-light {
    background: #eaf3ff;
    color: #0d6efd;
}

/* Mobile app view */
@media (max-width: 520px) {
    .app-shell {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .ds-filter-card {
        border-radius: 22px;
        padding: 16px;
        margin-bottom: 16px;
    }

    .ds-service-card {
        grid-template-columns: minmax(0, 1fr) 124px;
        gap: 10px;
        padding: 15px;
        border-radius: 22px;
    }

    .ds-service-actions {
        width: 124px;
    }

    .ds-card-btn {
        min-height: 38px;
        font-size: 12px;
        padding-left: 7px;
        padding-right: 7px;
    }
}

/* Very small phones */
@media (max-width: 360px) {
    .ds-service-card {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .ds-service-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}

/* =========================================================
   CREATE SERVICE DEALER SEARCH FINAL UI
========================================================= */

.dealer-search-list {
    width: 100% !important;
    margin-top: 10px !important;
    max-height: 280px !important;
    overflow-y: auto !important;
    border: 1px solid #d8e7ff !important;
    border-radius: 18px !important;
    background: #ffffff !important;
    padding: 8px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
}

.dealer-option {
    width: 100% !important;
    border: 1px solid #e3edff !important;
    border-radius: 14px !important;
    background: #ffffff !important;
    padding: 12px 14px !important;
    color: #071f45 !important;
    text-align: left !important;
    box-shadow: none !important;
    display: block !important;
}

.dealer-option strong {
    display: block !important;
    font-size: 14px !important;
    line-height: 1.2 !important;
    font-weight: 900 !important;
    color: #071f45 !important;
}

.dealer-option span {
    display: block !important;
    margin-top: 4px !important;
    font-size: 12px !important;
    line-height: 1.25 !important;
    color: #667085 !important;
}

.dealer-option.selected {
    background: #eaf3ff !important;
    border-color: #0d6efd !important;
}

.selected-dealer-text {
    display: block !important;
    margin-top: 10px !important;
    color: #5f6f89 !important;
    font-size: 13px !important;
}



/* =========================================================
   GLOBAL MIC + MODERN FILE UPLOAD UI
   Add this at the bottom of assets/css/style.css
========================================================= */

.voice-field {
    position: relative !important;
    width: 100% !important;
    display: block !important;
}

.voice-field textarea {
    width: 100% !important;
    padding-right: 66px !important;
    min-height: 130px !important;
}

.voice-mic-btn {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    left: auto !important;
    bottom: auto !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: #eaf3ff !important;
    color: #0d6efd !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 8px 18px rgba(13, 110, 253, 0.16) !important;
    z-index: 10 !important;
    cursor: pointer !important;
}

.voice-mic-btn svg {
    width: 22px !important;
    height: 22px !important;
    display: block !important;
    pointer-events: none !important;
}

.voice-mic-btn.recording {
    background: #dc3545 !important;
    color: #ffffff !important;
    animation: voicePulse 1s infinite;
}

@keyframes voicePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.mic-btn {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    left: auto !important;
    bottom: auto !important;
}

input[type="file"] {
    width: 100% !important;
    min-height: 56px !important;
    padding: 10px !important;
    border: 1px solid #d8e7ff !important;
    border-radius: 18px !important;
    background: #ffffff !important;
    color: #667085 !important;
    font-size: 14px !important;
    cursor: pointer !important;
}

input[type="file"]::file-selector-button {
    min-height: 38px;
    margin-right: 12px;
    padding: 9px 14px;
    border: 0;
    border-radius: 13px;
    background: #eaf3ff;
    color: #0d6efd;
    font-size: 13px;
    font-weight: 900;
    cursor: pointer;
}

input[type="file"]::-webkit-file-upload-button {
    min-height: 38px;
    margin-right: 12px;
    padding: 9px 14px;
    border: 0;
    border-radius: 13px;
    background: #eaf3ff;
    color: #0d6efd;
    font-size: 13px;
    font-weight: 900;
    cursor: pointer;
}

.upload-help {
    display: block;
    margin-top: 7px;
    color: #667085;
    font-size: 12px;
    line-height: 1.35;
}



/* =========================================================
   PREMIUM HEADER ICONS
========================================================= */

.app-topbar {
    width: 100%;
    max-width: 520px;
    min-height: 72px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid #d8e7ff;
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) 52px;
    align-items: center;
    gap: 10px;
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    box-shadow: 0 8px 24px rgba(13, 110, 253, 0.06);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.topbar-title {
    text-align: center;
    min-width: 0;
}

.topbar-title strong {
    display: block;
    font-size: 18px;
    line-height: 1.15;
    color: #071f45;
    font-weight: 900;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-title small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.2;
    color: #667085;
    font-weight: 600;
}

.top-icon {
    width: 46px;
    height: 46px;
    border-radius: 17px;
    background: #eaf3ff;
    color: #0d6efd;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 8px 18px rgba(13, 110, 253, 0.08);
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.top-icon svg {
    width: 24px;
    height: 24px;
    display: block;
}

.top-icon:active {
    transform: scale(0.94);
}

.app-home-icon {
    background: #eaf3ff;
    color: #0d6efd;
}

.app-logout-icon {
    background: #fff1f1;
    color: #dc3545;
}

.app-logout-icon:active {
    background: #dc3545;
    color: #ffffff;
}

@media (max-width: 520px) {
    .app-topbar {
        min-height: 68px;
        padding: 10px 14px;
        grid-template-columns: 48px minmax(0, 1fr) 48px;
    }

    .top-icon {
        width: 44px;
        height: 44px;
        border-radius: 16px;
    }

    .top-icon svg {
        width: 23px;
        height: 23px;
    }

    .topbar-title strong {
        font-size: 17px;
    }

    .topbar-title small {
        font-size: 11px;
    }
}

/* IMAGE PREVIEW + REMOVE + MODERN UPLOAD + MIC FIX */
.image-modal{position:fixed;inset:0;z-index:99998;padding:22px;background:rgba(7,31,69,.72);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);display:none;align-items:center;justify-content:center}
.image-modal.open{display:flex}
.image-modal img{max-width:100%;max-height:82vh;border-radius:20px;background:#fff;box-shadow:0 24px 60px rgba(0,0,0,.28)}
.image-modal [data-close-modal]{position:absolute;top:18px;right:18px;z-index:2}
.thumb-grid,.selected-image-preview{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-top:12px}
.selected-image-preview:not(.has-files){display:none}
.upload-thumb-wrap,.saved-thumb-wrap{position:relative;width:100%;aspect-ratio:1;border-radius:16px;overflow:hidden;border:1px solid #d8e7ff;background:#fff}
.upload-thumb-wrap .thumb,.saved-thumb-wrap .thumb,.thumb-grid .thumb{width:100%;height:100%;aspect-ratio:1;object-fit:cover;border-radius:16px;cursor:pointer;display:block}
.thumb-remove-btn{position:absolute;top:6px;right:6px;width:28px;height:28px;min-width:28px;min-height:28px;border:0;border-radius:50%;background:rgba(220,53,69,.96);color:#fff;display:flex;align-items:center;justify-content:center;font-size:18px;line-height:1;font-weight:900;padding:0;z-index:2;cursor:pointer;box-shadow:0 8px 18px rgba(220,53,69,.25)}
.image-delete-modal{position:fixed;inset:0;z-index:99999;background:rgba(7,31,69,.48);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);display:none;align-items:center;justify-content:center;padding:22px}
.image-delete-modal.open{display:flex}
.image-delete-box{width:100%;max-width:340px;background:#fff;border:1px solid #d8e7ff;border-radius:26px;padding:24px;text-align:center;box-shadow:0 24px 60px rgba(13,110,253,.24)}
.image-delete-icon{width:62px;height:62px;margin:0 auto 14px;border-radius:22px;background:#fff1f1;color:#dc3545;display:flex;align-items:center;justify-content:center;font-size:34px;font-weight:900}
.image-delete-box h3{margin:0 0 8px;font-size:22px;color:#071f45}
.image-delete-box p{margin:0 0 20px;color:#667085;font-size:15px}
.image-delete-actions{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.image-delete-cancel,.image-delete-confirm{min-height:46px;border:0;border-radius:15px;font-size:14px;font-weight:900;cursor:pointer}
.image-delete-cancel{background:#eaf3ff;color:#0d6efd}
.image-delete-confirm{background:#dc3545;color:#fff}
input[type=file]{width:100%!important;min-height:56px!important;padding:10px!important;border:1px solid #d8e7ff!important;border-radius:18px!important;background:#fff!important;color:#667085!important;font-size:14px!important;cursor:pointer!important}
input[type=file]::file-selector-button{min-height:38px;margin-right:12px;padding:9px 14px;border:0;border-radius:13px;background:#eaf3ff;color:#0d6efd;font-size:13px;font-weight:900;cursor:pointer}
input[type=file]::-webkit-file-upload-button{min-height:38px;margin-right:12px;padding:9px 14px;border:0;border-radius:13px;background:#eaf3ff;color:#0d6efd;font-size:13px;font-weight:900;cursor:pointer}
.upload-help{display:block;margin-top:7px;color:#667085;font-size:12px}
.voice-field,.ledger-voice-field{position:relative!important;width:100%!important;display:block!important}
.voice-field textarea,.ledger-voice-field textarea{width:100%!important;padding-right:68px!important;min-height:130px!important}
.voice-mic-btn,.ledger-mic-btn{position:absolute!important;top:12px!important;right:12px!important;left:auto!important;bottom:auto!important;width:46px!important;height:46px!important;min-width:46px!important;min-height:46px!important;padding:0!important;margin:0!important;border:0!important;border-radius:50%!important;background:#eaf3ff!important;color:#0d6efd!important;display:flex!important;align-items:center!important;justify-content:center!important;box-shadow:0 8px 18px rgba(13,110,253,.16)!important;z-index:20!important;cursor:pointer!important;appearance:none!important;-webkit-appearance:none!important}
.voice-mic-btn svg,.ledger-mic-btn svg{width:23px!important;height:23px!important;pointer-events:none!important}
.voice-mic-btn.recording,.ledger-mic-btn.recording{background:#dc3545!important;color:#fff!important;animation:micPulse 1s infinite}
@keyframes micPulse{0%{transform:scale(1)}50%{transform:scale(1.08)}100%{transform:scale(1)}}
@media(max-width:420px){.thumb-grid,.selected-image-preview{grid-template-columns:repeat(3,1fr)}}


/* FINAL IMAGE PREVIEW / REMOVE CSS - paste at bottom of style.css */
.image-modal{position:fixed!important;inset:0!important;z-index:99998!important;padding:22px!important;background:rgba(7,31,69,.72)!important;backdrop-filter:blur(8px)!important;-webkit-backdrop-filter:blur(8px)!important;display:none!important;align-items:center!important;justify-content:center!important}.image-modal.open{display:flex!important}.image-modal img{width:auto!important;height:auto!important;max-width:100%!important;max-height:82vh!important;object-fit:contain!important;border-radius:20px!important;background:#fff!important;box-shadow:0 24px 60px rgba(0,0,0,.28)!important}.image-modal [data-close-modal]{position:absolute!important;top:18px!important;right:18px!important;z-index:2!important}.selected-image-preview,.thumb-grid{display:grid!important;grid-template-columns:repeat(4,1fr)!important;gap:10px!important;margin-top:12px!important}.selected-image-preview:not(.has-files){display:none!important}.upload-thumb-wrap,.saved-thumb-wrap{position:relative!important;width:100%!important;aspect-ratio:1/1!important;border-radius:16px!important;overflow:hidden!important;border:1px solid #d8e7ff!important;background:#fff!important}.upload-thumb-wrap .thumb,.saved-thumb-wrap .thumb{width:100%!important;height:100%!important;aspect-ratio:1/1!important;object-fit:cover!important;display:block!important;cursor:pointer!important;border:0!important;border-radius:16px!important}.thumb-remove-btn{position:absolute!important;top:6px!important;right:6px!important;width:28px!important;height:28px!important;min-width:28px!important;min-height:28px!important;border:0!important;border-radius:50%!important;background:rgba(220,53,69,.96)!important;color:#fff!important;display:flex!important;align-items:center!important;justify-content:center!important;font-size:18px!important;line-height:1!important;font-weight:900!important;padding:0!important;margin:0!important;z-index:3!important;cursor:pointer!important;box-shadow:0 8px 18px rgba(220,53,69,.25)!important}.image-delete-modal{position:fixed!important;inset:0!important;z-index:99999!important;background:rgba(7,31,69,.48)!important;backdrop-filter:blur(8px)!important;-webkit-backdrop-filter:blur(8px)!important;display:none!important;align-items:center!important;justify-content:center!important;padding:22px!important}.image-delete-modal.open{display:flex!important}.image-delete-box{width:100%!important;max-width:340px!important;background:#fff!important;border:1px solid #d8e7ff!important;border-radius:26px!important;padding:24px!important;text-align:center!important;box-shadow:0 24px 60px rgba(13,110,253,.24)!important}.image-delete-icon{width:62px!important;height:62px!important;margin:0 auto 14px!important;border-radius:22px!important;background:#fff1f1!important;color:#dc3545!important;display:flex!important;align-items:center!important;justify-content:center!important;font-size:34px!important;font-weight:900!important}.image-delete-box h3{margin:0 0 8px!important;font-size:22px!important;color:#071f45!important}.image-delete-box p{margin:0 0 20px!important;color:#667085!important;font-size:15px!important}.image-delete-actions{display:grid!important;grid-template-columns:1fr 1fr!important;gap:10px!important}.image-delete-cancel,.image-delete-confirm{min-height:46px!important;border:0!important;border-radius:15px!important;font-size:14px!important;font-weight:900!important;cursor:pointer!important}.image-delete-cancel{background:#eaf3ff!important;color:#0d6efd!important}.image-delete-confirm{background:#dc3545!important;color:#fff!important}@media(max-width:420px){.selected-image-preview,.thumb-grid{grid-template-columns:repeat(3,1fr)!important}}


/* =========================================================
   MOBILE FINAL IMAGE / MIC FIX
   Paste this at the VERY BOTTOM of /assets/css/style.css
========================================================= */

.image-modal {
  position: fixed !important;
  inset: 0 !important;
  z-index: 999998 !important;
  padding: 22px !important;
  background: rgba(7, 31, 69, 0.72) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
}
.image-modal.open { display: flex !important; }
.image-modal img {
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: 82vh !important;
  object-fit: contain !important;
  border-radius: 20px !important;
  background: #fff !important;
  box-shadow: 0 24px 60px rgba(0,0,0,.28) !important;
}
.image-modal [data-close-modal] {
  position: absolute !important;
  top: 18px !important;
  right: 18px !important;
  z-index: 2 !important;
}

.selected-image-preview,
.thumb-grid {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 10px !important;
  margin-top: 12px !important;
}
.selected-image-preview:not(.has-files) { display: none !important; }

.upload-thumb-wrap,
.saved-thumb-wrap {
  position: relative !important;
  width: 100% !important;
  aspect-ratio: 1 / 1 !important;
  overflow: hidden !important;
  border-radius: 16px !important;
  border: 1px solid #d8e7ff !important;
  background: #fff !important;
}
.upload-thumb-wrap .thumb,
.saved-thumb-wrap .thumb {
  width: 100% !important;
  height: 100% !important;
  aspect-ratio: 1 / 1 !important;
  object-fit: cover !important;
  display: block !important;
  border: 0 !important;
  border-radius: 16px !important;
  cursor: pointer !important;
}
.thumb-remove-btn {
  position: absolute !important;
  top: 6px !important;
  right: 6px !important;
  left: auto !important;
  bottom: auto !important;
  width: 30px !important;
  height: 30px !important;
  min-width: 30px !important;
  min-height: 30px !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: #dc3545 !important;
  color: #fff !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 20px !important;
  line-height: 1 !important;
  font-weight: 900 !important;
  z-index: 10 !important;
  cursor: pointer !important;
  box-shadow: 0 8px 18px rgba(220,53,69,.28) !important;
  appearance: none !important;
  -webkit-appearance: none !important;
}

.image-delete-modal {
  position: fixed !important;
  inset: 0 !important;
  z-index: 999999 !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 22px !important;
  background: rgba(7, 31, 69, .48) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
}
.image-delete-modal.open { display: flex !important; }
.image-delete-box {
  width: 100% !important;
  max-width: 340px !important;
  padding: 24px !important;
  text-align: center !important;
  border-radius: 26px !important;
  border: 1px solid #d8e7ff !important;
  background: #fff !important;
  box-shadow: 0 24px 60px rgba(13,110,253,.24) !important;
}
.image-delete-icon {
  width: 62px !important;
  height: 62px !important;
  margin: 0 auto 14px !important;
  border-radius: 22px !important;
  background: #fff1f1 !important;
  color: #dc3545 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 34px !important;
  font-weight: 900 !important;
}
.image-delete-box h3 { margin: 0 0 8px !important; font-size: 22px !important; color: #071f45 !important; }
.image-delete-box p { margin: 0 0 20px !important; color: #667085 !important; font-size: 15px !important; }
.image-delete-actions { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
.image-delete-cancel,
.image-delete-confirm {
  min-height: 46px !important;
  border: 0 !important;
  border-radius: 15px !important;
  font-size: 14px !important;
  font-weight: 900 !important;
  cursor: pointer !important;
}
.image-delete-cancel { background: #eaf3ff !important; color: #0d6efd !important; }
.image-delete-confirm { background: #dc3545 !important; color: #fff !important; }

.voice-field,
.ledger-voice-field {
  position: relative !important;
  width: 100% !important;
  display: block !important;
}
.voice-field textarea,
.ledger-voice-field textarea {
  width: 100% !important;
  min-height: 130px !important;
  padding-right: 68px !important;
}
.voice-mic-btn,
.ledger-mic-btn {
  position: absolute !important;
  top: 12px !important;
  right: 12px !important;
  left: auto !important;
  bottom: auto !important;
  width: 46px !important;
  height: 46px !important;
  min-width: 46px !important;
  min-height: 46px !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: #eaf3ff !important;
  color: #0d6efd !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 8px 18px rgba(13,110,253,.16) !important;
  z-index: 20 !important;
  cursor: pointer !important;
  appearance: none !important;
  -webkit-appearance: none !important;
}
.voice-mic-btn svg,
.ledger-mic-btn svg {
  width: 23px !important;
  height: 23px !important;
  pointer-events: none !important;
}
.voice-mic-btn.recording,
.ledger-mic-btn.recording {
  background: #dc3545 !important;
  color: #fff !important;
  animation: micPulseFinal 1s infinite !important;
}
@keyframes micPulseFinal { 0%{transform:scale(1)} 50%{transform:scale(1.08)} 100%{transform:scale(1)} }

@media (max-width: 420px) {
  .selected-image-preview,
  .thumb-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  .thumb-remove-btn {
    width: 30px !important;
    height: 30px !important;
  }
}


/* =========================================================
   QR OPEN GUARANTEE BUTTON FIX
========================================================= */

.qr-box {
    text-align: center !important;
}

.qr-action-wrap {
    width: 100% !important;
    margin-top: 16px !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

.qr-guarantee-btn {
    width: 100% !important;
    max-width: 260px !important;
    min-height: 52px !important;

    padding: 12px 18px !important;
    border: 0 !important;
    border-radius: 18px !important;

    background: #eaf3ff !important;
    color: #0d6efd !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    font-size: 15px !important;
    font-weight: 900 !important;
    line-height: 1.15 !important;
    text-align: center !important;
    text-decoration: none !important;

    box-shadow: none !important;
    white-space: nowrap !important;
}

.qr-guarantee-btn:active {
    transform: scale(0.96) !important;
}

@media (max-width: 420px) {
    .qr-guarantee-btn {
        max-width: 240px !important;
        min-height: 50px !important;
        font-size: 14px !important;
    }
}