  * { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    font-family: 'SolaimanLipi', 'Noto Sans Bengali', Arial, sans-serif;
    background: #f0f0f0;
    color: #333;
    font-size: 13px;
  }

  /* ── Sidebar ── */
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 185px; height: 100%;
    background: #2e7d32;
    color: #fff;
    overflow-y: auto;
    z-index: 100;
  }
  .sidebar-header {
    padding: 15px 12px;
    border-bottom: 1px solid rgba(255,255,255,.2);
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    color: #2e7d32;
    font-weight: bold;
    font-size: 16px;
    flex-shrink: 0;
  }
  .sidebar-header .user-info { font-size: 11px; line-height: 1.4; }
  .sidebar-header .user-info span { display: block; font-size: 13px; font-weight: 600; }
  .sidebar-menu-label {
    padding: 10px 12px 4px;
    font-size: 11px;
    letter-spacing: 1px;
    opacity: .7;
    font-weight: 700;
    text-transform: uppercase;
  }
  .menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    cursor: pointer;
    font-size: 12.5px;
    border-left: 3px solid transparent;
    transition: background .15s;
    text-decoration: none;
    color: #fff;
  }
  .menu-item:hover, .menu-item.active { background: rgba(255,255,255,.15); border-left-color: #a5d6a7; }
  .menu-item svg { opacity: .7; flex-shrink: 0; }
  .menu-item .label { flex: 1; margin-left: 8px; }

  /* ── Main content ── */
  .main {
    margin-left: 185px;
    padding: 0;
    min-height: 100vh;
  }

  .topbar {
    background: #fff;
    border-bottom: 1px solid #ddd;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .topbar h1 { font-size: 16px; color: #333; font-weight: 600; }
  .btn-guide {
    background: #2e7d32;
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 3px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
  }
  .btn-guide:hover { background: #1b5e20; }

  .form-wrapper { padding: 16px; }

  /* ── Sections ── */
  .form-section {
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 2px;
    margin-bottom: 14px;
  }
  .section-header {
    background: #f7f7f7;
    border-bottom: 1px solid #d0d0d0;
    padding: 9px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-weight: 600;
    font-size: 13.5px;
    color: #333;
  }
  .section-header .chevron { font-size: 14px; color: #888; }
  .section-body { padding: 16px 18px; }

  /* ── Field rows ── */
  .field-row {
    display: flex;
    align-items: flex-start;
    margin-bottom: 10px;
    gap: 14px;
    flex-wrap: wrap;
  }
  .field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 150px;
  }
  .field-group label {
    font-size: 12px;
    color: #555;
    white-space: nowrap;
  }
  .field-group label .req { color: #c0392b; }

  /* ── Inputs ── */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="date"],
  select,
  textarea {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 2px;
    font-size: 12.5px;
    font-family: inherit;
    color: #333;
    background: #fff;
    outline: none;
    transition: border-color .15s;
  }
  input:focus, select:focus, textarea:focus { border-color: #2e7d32; }
  input[readonly], select[disabled], .readonly-field {
    background: #e9e9e9;
    color: #555;
    cursor: not-allowed;
  }
  textarea { resize: vertical; min-height: 60px; }
  select { cursor: pointer; }

  /* ── Labelled full-width rows (right-aligned label) ── */
  .labeled-row {
    display: flex;
    align-items: center;
    margin-bottom: 9px;
    gap: 10px;
  }
  .labeled-row .lbl {
    width: 340px;
    min-width: 240px;
    text-align: right;
    font-size: 12.5px;
    color: #555;
    line-height: 1.4;
    flex-shrink: 0;
  }
  .labeled-row .lbl .req { color: #c0392b; }
  .labeled-row .ctrl { flex: 1; }

  /* ── Address grids ── */
  .addr-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 24px;
  }
  .addr-item { display: flex; flex-direction: column; gap: 3px; }
  .addr-item label { font-size: 12px; color: #555; }

  .subsection-title {
    font-weight: 600;
    font-size: 13px;
    color: #333;
    text-align: center;
    padding: 8px 0 10px;
    border-bottom: 1px solid #eee;
    margin-bottom: 12px;
  }

  /* ── Business type row ── */
  .biz-type-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
  }
  .biz-type-row .fg { display: flex; flex-direction: column; gap: 4px; }
  .biz-type-row .fg label { font-size: 12px; color: #555; }
  .combo { position: relative; display: flex; align-items: stretch; }
  .combo input { flex: 1; min-width: 0; width: auto; border-radius: 2px 0 0 2px; }
  .combo-btn {
    width: 28px;
    flex-shrink: 0;
    border: 1px solid #ccc;
    border-left: 0;
    background: #fff;
    color: #555;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
  }
  .combo-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 30;
    margin: 0;
    padding: 0;
    list-style: none;
    background: #fff;
    border: 1px solid #ccc;
    max-height: 180px;
    overflow-y: auto;
    box-shadow: 0 4px 10px rgba(0,0,0,.08);
  }
  .combo-list li { padding: 6px 8px; cursor: pointer; font-size: 12.5px; }
  .combo-list li:hover { background: #e8f5e9; }

  /* ── Attachment row ── */
  .attach-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
  }
  .attach-row .fg { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 180px; }
  .attach-row .fg label { font-size: 12px; color: #555; }
  .file-input-group { display: flex; align-items: center; gap: 8px; }
  .file-input-group input[type="file"] { display: none; }
  .choose-file-btn {
    background: #e8e8e8;
    border: 1px solid #bbb;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    border-radius: 2px;
    font-family: inherit;
    white-space: nowrap;
  }
  .file-name-display { font-size: 12px; color: #888; white-space: nowrap; }
  .btn-upload {
    background: #2e7d32;
    color: #fff;
    border: none;
    padding: 5px 12px;
    border-radius: 2px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
  }
  .btn-upload:hover { background: #1b5e20; }
  .btn-add {
    background: #2e7d32;
    color: #fff;
    border: none;
    padding: 5px 12px;
    border-radius: 2px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    align-self: flex-end;
    margin-bottom: 1px;
  }
  .btn-add:hover { background: #1b5e20; }

  /* ── Fee fields ── */
  .fee-label { font-weight: 600; }

  /* Auto-calculated but editable: looks like a normal input, and picks up a
   * tint once the applicant has typed their own amount into it. */
  .fee-input { text-align: right; }
  .fee-input.fee-overridden {
    background: #fffdf2;
    border-color: #b8860b;
    color: #6b4e00;
    font-weight: 600;
  }

  .fee-note {
    background: #f4f8f4;
    border-left: 3px solid #2e7d32;
    padding: 8px 10px;
    margin-bottom: 12px;
    font-size: 12px;
    color: #445;
    line-height: 1.6;
  }
  .fee-note-chip {
    background: #fffdf2;
    border: 1px solid #b8860b;
    color: #6b4e00;
    font-weight: 600;
    padding: 0 5px;
    border-radius: 2px;
  }

  .btn-reset-fees {
    background: #fff;
    color: #2e7d32;
    border: 1px solid #2e7d32;
    padding: 6px 12px;
    border-radius: 3px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    white-space: nowrap;
  }
  .btn-reset-fees:hover { background: #f1f8f1; }

  /* ── Bottom actions ── */
  .form-actions {
    background: #fff;
    border: 1px solid #d0d0d0;
    padding: 16px 18px;
    border-radius: 2px;
    margin-bottom: 20px;
  }
  .confirm-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 12.5px; }
  .confirm-row input[type="checkbox"] { width: 14px; height: 14px; accent-color: #2e7d32; }
  .action-buttons { display: flex; gap: 10px; }
  .btn-submit {
    background: #2e7d32;
    color: #fff;
    border: none;
    padding: 7px 20px;
    border-radius: 3px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
  }
  .btn-submit:hover { background: #1b5e20; }
  .btn-preview {
    background: #e67e22;
    color: #fff;
    border: none;
    padding: 7px 20px;
    border-radius: 3px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
  }
  .btn-preview:hover { background: #ca6f1e; }

  /* ── Footer ── */
  .page-footer {
    text-align: right;
    padding: 8px 16px;
    font-size: 11px;
    color: #888;
    border-top: 1px solid #ddd;
    background: #fafafa;
  }
  .page-footer a { color: #2e7d32; text-decoration: none; }

  /* ── Calculate button ── */
  .btn-calc {
    background: #1565c0;
    color: #fff;
    border: none;
    padding: 6px 16px;
    border-radius: 3px;
    font-size: 12.5px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
  }
  .btn-calc:hover { background: #0d47a1; }

  /* ── Toast ── */
  .toast {
    position: fixed;
    bottom: 24px; right: 24px;
    background: #2e7d32;
    color: #fff;
    padding: 10px 18px;
    border-radius: 4px;
    font-size: 13px;
    opacity: 0;
    transition: opacity .3s;
    z-index: 9999;
    pointer-events: none;
  }
  .toast.show { opacity: 1; }

  @media (max-width: 1100px) {
    .labeled-row .lbl { width: 220px; min-width: 140px; }
    .addr-grid { grid-template-columns: 1fr; }
  }

  @media (max-width: 768px) {
    .sidebar { width: 0; overflow: hidden; }
    .main { margin-left: 0; }
    .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
    .topbar h1 { font-size: 15px; line-height: 1.4; }
    .form-wrapper { padding: 10px; }
    .section-body { padding: 12px; }
    .labeled-row { flex-direction: column; align-items: stretch; gap: 4px; }
    .labeled-row .lbl { width: 100%; min-width: 0; text-align: left; }
    .field-group { min-width: 0; }
    .field-group label { white-space: normal; }
    .addr-grid { grid-template-columns: 1fr; gap: 8px; }
    .attach-row { flex-direction: column; }
    .attach-row .fg { min-width: 0; width: 100%; }
    .file-input-group { flex-wrap: wrap; }
    .file-name-display { white-space: normal; word-break: break-word; }
    .biz-type-row { align-items: stretch; }
    .biz-type-row .fg { min-width: 100% !important; flex: 1 1 100%; }
    .biz-type-row .btn-add { align-self: stretch; width: 100%; }
    .action-buttons { flex-wrap: wrap; }
    .btn-submit, .btn-preview { flex: 1 1 140px; }
    .confirm-row { align-items: flex-start; }
    .toast { left: 12px; right: 12px; bottom: 12px; text-align: center; }
    .cert-mgr-head { flex-direction: column; align-items: stretch; }
    .admin-wrap, .cert-qr-page { padding: 12px; }
  }

  @media (max-width: 480px) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    select,
    textarea { font-size: 16px; }
  }

/* ── Added for the backend-connected system: link banner, admin, view page ── */
.link-banner {
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  border-radius: 4px;
  padding: 14px 16px;
  margin-bottom: 14px;
  font-size: 13px;
  color: #1b5e20;
}
.link-banner .link-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  margin-top: 8px;
}
.link-banner input[type="text"],
.link-banner textarea#shareLinkInput {
  flex: none;
  width: 100%;
  min-width: 0;
  min-height: 72px;
  background: #fff;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
  word-break: break-all;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  resize: vertical;
  color: #1565c0;
}
.link-banner .link-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.link-banner .btn-copy {
  background: #2e7d32;
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 3px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.link-banner .btn-copy:hover { background: #1b5e20; }

/* Generated QR shown next to the stored certificate link */
.link-banner .qr-result {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #a5d6a7;
}
.link-banner .qr-result img {
  width: 120px;
  height: 120px;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid #a5d6a7;
  padding: 4px;
}
.link-banner .qr-slot-empty {
  width: 120px;
  height: 120px;
  flex-shrink: 0;
  background: #fff;
}
.link-banner .qr-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.link-banner .tiny-created {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  word-break: break-all;
}
.link-banner .tiny-created a { color: #1b5e20; }
.cert-qr-list {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #a5d6a7;
}
.cert-qr-list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 13px;
}
.cert-qr-list-head a { color: #1b5e20; font-weight: 600; }
.cert-qr-empty { font-size: 12.5px; color: #666; }
#certQrList {
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}
#certGrid {
  max-height: min(70vh, 640px);
  overflow-y: auto;
  padding-right: 4px;
}
#certQrList::-webkit-scrollbar,
#certGrid::-webkit-scrollbar { width: 8px; }
#certQrList::-webkit-scrollbar-thumb,
#certGrid::-webkit-scrollbar-thumb {
  background: #81c784;
  border-radius: 4px;
}
.cert-qr-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed #c8e6c9;
  font-size: 13px;
}
.cert-qr-row:last-child { border-bottom: 0; }
.cert-qr-serial { font-weight: 700; min-width: 28px; color: #2e7d32; }
.cert-qr-row img {
  width: 48px;
  height: 48px;
  background: #fff;
  border: 1px solid #a5d6a7;
  padding: 2px;
  flex-shrink: 0;
}
.cert-qr-row a {
  color: #1565c0;
  font-weight: 600;
  word-break: break-all;
}
.cert-qr-page { max-width: 860px; margin: 24px auto; padding: 0 16px 40px; }
.cert-qr-page h1 { font-size: 18px; margin-bottom: 6px; }
.cert-qr-page .note { font-size: 13px; color: #555; margin-bottom: 16px; }
.cert-qr-page .back { display: inline-block; margin-bottom: 14px; color: #2e7d32; font-weight: 600; }
.cert-mgr-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.cert-mgr-actions { display: flex; gap: 8px; align-items: center; }
.cert-upload-btn { cursor: pointer; }
.cert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
#certGrid { display: block; }
#certGrid .cert-grid + .cert-group-title,
.cert-group-title { font-size: 15px; margin: 22px 0 10px; color: #333; }
.cert-card {
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  padding: 14px;
}
.cert-card-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.cert-card-top .cert-serial {
  flex-shrink: 0; font-weight: 700; color: #2e7d32; min-width: 22px;
}
.cert-card-top strong { flex: 1; font-size: 13.5px; word-break: break-word; }
.cert-source {
  flex-shrink: 0; font-size: 11px; color: #2e7d32; background: #e8f5e9;
  border-radius: 3px; padding: 2px 6px;
}
.cert-desc { font-size: 12.5px; color: #555; margin-bottom: 10px; }
.cert-field { display: block; font-size: 12.5px; margin-bottom: 10px; color: #444; }
.cert-field input { width: 100%; margin-top: 4px; }

.banner-error {
  background: #fdecea;
  border: 1px solid #f5c6cb;
  color: #a12622;
  border-radius: 4px;
  padding: 12px 16px;
  margin-bottom: 14px;
  font-size: 13px;
}

.readonly-view .r-row {
  display: flex;
  border-bottom: 1px dashed #e5e5e5;
  padding: 7px 2px;
  font-size: 12.5px;
  gap: 10px;
}
.readonly-view .r-row .k { width: 260px; color: #666; flex-shrink: 0; }
.readonly-view .r-row .v { flex: 1; color: #222; font-weight: 500; word-break: break-word; }

.admin-login {
  max-width: 340px;
  margin: 80px auto;
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  padding: 24px;
}
.admin-login h1 { font-size: 15px; margin-bottom: 14px; text-align: center; }
.admin-login input {
  margin-bottom: 10px;
}
.admin-login .btn-submit { width: 100%; }
.admin-login .err { color: #c0392b; font-size: 12px; margin-bottom: 8px; min-height: 14px; }

.admin-table-wrap { overflow-x: auto; background: #fff; border: 1px solid #d0d0d0; border-radius: 2px; }
table.admin-table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 900px; }
table.admin-table th, table.admin-table td {
  border-bottom: 1px solid #eee;
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
}
table.admin-table th { background: #f7f7f7; font-weight: 600; color: #444; position: sticky; top: 0; }
table.admin-table tr:hover td { background: #f9fdf9; }
table.admin-table a { color: #2e7d32; text-decoration: none; font-weight: 600; }
table.admin-table a:hover { text-decoration: underline; }

.admin-topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border-bottom: 1px solid #ddd; padding: 12px 20px; margin-bottom: 16px;
}
.admin-topbar h1 { font-size: 16px; }
.btn-logout {
  background: #c0392b; color: #fff; border: none; padding: 6px 14px;
  border-radius: 3px; font-size: 12px; cursor: pointer; font-family: inherit;
}
.btn-logout:hover { background: #922b21; }
.admin-wrapper { padding: 0 16px 24px; max-width: 1200px; margin: 0 auto; }
.admin-search { margin-bottom: 12px; display: flex; gap: 8px; }
.admin-search input { max-width: 320px; }
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #f0f0f0; }

.admin-wrapper { max-width: 1400px; }
table.admin-table { min-width: 1100px; }
td.admin-actions { white-space: normal; min-width: 320px; }
.admin-link-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.admin-link-row input {
  flex: 1; min-width: 0; font-size: 11px; padding: 4px 6px;
  border: 1px solid #ccc; border-radius: 2px; background: #fafafa;
}
.admin-link-row.tiny input { color: #1565c0; }
.admin-link-btns { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.admin-link-btns .choose-file-btn, .admin-link-btns .btn-calc, .admin-link-btns a.choose-file-btn {
  text-decoration: none; display: inline-block; padding: 4px 8px; font-size: 11.5px;
}

.admin-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 80;
}
.admin-modal[hidden] { display: none; }
.admin-modal-card {
  background: #fff; padding: 20px 22px; border-radius: 6px; width: min(420px, 92vw);
  box-shadow: 0 8px 28px rgba(0,0,0,.2);
}
.admin-modal-card h2 { font-size: 15px; margin-bottom: 8px; }
.admin-modal-note { font-size: 12px; color: #555; line-height: 1.5; margin-bottom: 12px; }
.admin-modal-card img { display: block; width: 180px; height: 180px; margin: 0 auto 12px; object-fit: contain; }
.admin-modal-card input { width: 100%; margin-bottom: 12px; font-size: 12px; }
