.preferences-card {
  max-width: 850px;
  margin-left: auto;
  margin-right: auto
}

.preferences-card label {
  display: block
}

.preferences-card .setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 20px 0;
  margin: 0;
  border-bottom: 1px solid #dbe7d7
}

.setting-row b {
  font-size: 16px;
  color: #1d5327
}

.setting-row small {
  display: block;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  margin-top: 6px;
  color: #49664b
}

.preferences-card .setting-row select {
  width: 220px;
  margin: 0
}

.preferences-card .setting-switch {
  appearance: none;
  position: relative;
  width: 48px;
  height: 28px;
  border: 0;
  border-radius: 20px;
  background: #bacbb6;
  margin: 0;
  cursor: pointer;
  flex-shrink: 0
}

.setting-switch:before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px #0002;
  transition: transform .15s
}

.preferences-card .setting-switch:checked {
  background: #0b7d04
}

.setting-switch:checked:before {
  transform: translateX(20px)
}

.preferences-card .actions {
  margin-top: 20px;
  align-items: center
}

.preferences-card h3 {
  margin: 24px 0 6px;
  color: #1d5327
}

.preferences-card input[readonly] {
  background: #f0f7ed;
  color: #49664b
}

.author-info {
  max-width: 850px;
  margin-left: auto;
  margin-right: auto
}

.author-info p {
  line-height: 1.6
}

.grading-warning {
  padding: 22px;
  border: 1px solid #cfe0d1;
  border-radius: 14px;
  width: min(580px, calc(100vw - 24px));
  max-height: 85dvh;
  overflow: auto;
  color: #203524;
  background: #fff
}

.grading-warning::backdrop {
  background: #102b2380
}

.grading-warning h3 {
  margin: 0 0 15px;
  color: #1d5327
}

.grading-warning li {
  line-height: 1.5;
  margin-bottom: 8px
}

.grading-warning .actions {
  position: sticky;
  bottom: 0;
  background: inherit;
  padding-top: 12px
}

body.night .setting-row b,
body.night .preferences-card h3,
body.night .grading-warning h3 {
  color: #c9ecc2
}

body.night .setting-row small {
  color: #d2e7cb
}

body.night .setting-row {
  border-color: #415345
}

body.night .preferences-card input[readonly] {
  background: #2c4030;
  color: #d2e7cb
}

body.night .grading-warning {
  background: #223028;
  color: #ecf4e9;
  border-color: #415345
}

body.night .preferences-card .setting-switch {
  background: #566b52
}

body.night .preferences-card .setting-switch:checked {
  background: #0b7d04
}

@media(max-width:560px) {
  .preferences-card .setting-row select {
    width: 100%;
    grid-column: 1/-1
  }

  .preferences-card .setting-row {
    gap: 12px
  }

  .setting-row b {
    font-size: 15px
  }

  .grading-warning {
    padding: 16px
  }
}

@media(prefers-reduced-motion:reduce) {
  .setting-switch:before {
    transition: none
  }
}

.grading-result-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px
}

.grading-result-top h3 {
  margin: 0;
  font-size: 18px
}

.grading-result-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  text-align: center;
  gap: 12px;
  padding: 24px 0;
  border-bottom: 1px solid #dbe7d7
}

.grading-result-summary>div+div {
  border-left: 1px solid #dbe7d7
}

.grading-result-summary small {
  display: block;
  color: #49664b;
  margin-bottom: 8px
}

.grading-result-summary strong {
  font-size: 32px;
  color: #0b7d04
}

.grading-result-summary b {
  display: block;
  font-size: 20px;
  overflow-wrap: anywhere;
  color: #1d5327
}

.grading-result-status {
  line-height: 1.5;
  color: #1d5327
}

.grading-result .actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px
}

.grading-result details {
  max-height: 180px;
  overflow: auto
}

.grading-result summary {
  cursor: pointer;
  color: inherit
}

.grading-result .muted {
  font-size: 13px
}

body.night .grading-result-summary small {
  color: #d2e7cb
}

body.night .grading-result-summary strong,
body.night .grading-result-summary b,
body.night .grading-result-status {
  color: #c9ecc2
}

body.night .grading-result-summary,
body.night .grading-result-summary>div+div {
  border-color: #415345
}

@media(max-width:420px) {
  .grading-result-top {
    gap: 6px
  }

  .grading-result-top h3 {
    font-size: 16px
  }

  .grading-result-top .btn {
    padding: 9px
  }

  .grading-result-summary {
    gap: 6px
  }

  .grading-result-summary b {
    font-size: 17px
  }
}

/* ========================================================
   Cài đặt thuật toán & Nhận dạng ô tô
   ======================================================== */
.settings-section-desc {
  font-size: 14px;
  color: #557257;
  margin: 4px 0 16px;
  line-height: 1.5
}

.setting-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  margin-bottom: 12px;
  background: #f7fbf6;
  border: 1px solid #dbe7d7;
  border-radius: 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s
}

.setting-action-row:hover {
  background: #edf7eb;
  border-color: #b5d6b0
}

.setting-row-content {
  display: flex;
  flex-direction: column;
  gap: 4px
}

.setting-row-content b {
  font-size: 15px;
  color: #1d5327
}

.setting-row-content small {
  font-size: 13px;
  color: #617f63
}

.setting-current-val {
  font-size: 14px;
  color: #0b7d04;
  font-weight: 600
}

.setting-chevron {
  font-size: 20px;
  color: #8ba98b;
  font-weight: bold;
  margin-left: 12px
}

/* Dialog: Yêu cầu độ nét ảnh */
.sharpness-dialog {
  padding: 0;
  border: none;
  border-radius: 24px;
  width: min(440px, calc(100vw - 32px));
  background: #fff;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.22);
  overflow: hidden
}

.sharpness-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px)
}

.sharpness-dialog-inner {
  padding: 24px 20px 16px
}

.sharpness-title {
  font-size: 19px;
  font-weight: 700;
  color: #1f2937;
  margin: 0 0 16px;
  text-align: left
}

.sharpness-options {
  display: flex;
  flex-direction: column;
  gap: 8px
}

.sharpness-option {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  transition: all .15s
}

.sharpness-option:hover {
  background: #f3f4f6
}

.sharpness-option.selected {
  background: #f0faf0;
  border-color: #82c97c
}

.sharpness-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none
}

.custom-radio {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #9ca3af;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .15s
}

.sharpness-option.selected .custom-radio {
  border-color: #129d08
}

.sharpness-option.selected .custom-radio:after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #129d08
}

.sharpness-text {
  display: flex;
  flex-direction: column;
  gap: 3px
}

.sharpness-opt-title {
  font-size: 15px;
  font-weight: 700;
  color: #111827
}

.sharpness-opt-desc {
  font-size: 13px;
  color: #4b5563;
  line-height: 1.4
}

.sharpness-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px
}

.btn-sharpness-cancel {
  background: transparent;
  border: none;
  color: #129d08;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 8px
}

.btn-sharpness-cancel:hover {
  background: #e8f5e9
}

/* View: Nhận dạng ô tô */
.bubble-algo-wrap {
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: 32px
}

.bubble-algo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--grade-green, #129d08);
  color: #fff;
  border-radius: 16px 16px 0 0;
  margin-bottom: 16px
}

.bubble-algo-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin: 0
}

.bubble-algo-header .header-btn {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 4px
}

.bubble-algo-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 4px
}

.bubble-card {
  position: relative;
  background: #fff;
  border: 1.5px solid #dce8db;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04)
}

.bubble-card#cardMinShade {
  border-color: var(--grade-green, #129d08)
}

.card-drag-badge {
  position: absolute;
  top: -10px;
  right: 14px;
  background: var(--grade-green, #129d08);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(18, 157, 8, 0.35);
  letter-spacing: 0.3px
}

.bubble-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px
}

.bubble-card-title {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b
}

.bubble-card-val {
  font-size: 16px;
  font-weight: 700;
  color: var(--grade-green, #129d08)
}

.slider-preview-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px
}

.slider-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px
}

.slider-box input[type="range"] {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  accent-color: var(--grade-green, #129d08);
  cursor: pointer
}

.range-limits {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #94a3b8;
  font-weight: 500
}

.bubble-preview-box {
  width: 84px;
  height: 48px;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0
}

.bubble-preview-box.double-bubble svg {
  width: 70px
}

.bubble-card-desc {
  font-size: 13px;
  color: #64748b;
  margin: 0;
  line-height: 1.4
}

.bubble-notice {
  font-size: 13px;
  color: #64748b;
  margin: 18px 8px 12px;
  line-height: 1.4
}

.btn-bubble-reset {
  display: block;
  width: 100%;
  padding: 14px;
  background: #e2efdf;
  color: #1d5327;
  border: 1px solid #c9dec5;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .1s
}

.btn-bubble-reset:hover {
  background: #d2e7ce
}

.btn-bubble-reset:active {
  transform: scale(.99)
}

/* ========================================================
   Cài đặt Header & Top Bar
   ======================================================== */
.settings-top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--grade-green, #129d08);
  color: #ffffff;
  padding: 14px 18px;
  margin: -24px -24px 20px -24px;
  border-radius: 14px 14px 0 0;
}

.settings-back-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 50%;
  transition: background 0.15s;
  flex-shrink: 0;
}

.settings-back-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.settings-top-bar h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
}

body.night .settings-top-bar {
  background: #0e6808;
  color: #ffffff;
}

/* ========================================================
   Cài đặt quét (Auto Scan, Sound/Vibrate, Torch)
   ======================================================== */
.scan-settings-group {
  margin: 10px 0 24px
}

.scan-settings-group-title {
  color: var(--grade-green, #129d08);
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 10px 2px
}

.scan-settings-card {
  background: #ffffff;
  border-radius: 18px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  overflow: hidden
}

.scan-setting-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 14px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background .15s
}

.scan-setting-item:last-child {
  border-bottom: none;
  cursor: default
}

.scan-setting-item:not(:last-child):hover {
  background: #f8fafc
}

.scan-setting-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #e8f5e9;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--grade-green, #129d08)
}

.scan-setting-info {
  flex: 1;
  display: flex;
  flex-direction: column
}

.scan-setting-name {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.3
}

.scan-setting-desc {
  font-size: 13px;
  color: #64748b;
  margin-top: 2px;
  line-height: 1.35
}

/* Switch styling for scan settings */
.scan-setting-item .switch-wrap .setting-switch {
  appearance: none;
  position: relative;
  width: 50px;
  height: 28px;
  border: 0;
  border-radius: 20px;
  background: #79747e;
  cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
}

.scan-setting-item .switch-wrap .setting-switch::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform .2s cubic-bezier(0.4, 0, 0.2, 1);
}

.scan-setting-item .switch-wrap .setting-switch:checked {
  background: var(--grade-green, #129d08);
}

.scan-setting-item .switch-wrap .setting-switch:checked::before {
  transform: translateX(22px);
}

body.night .scan-setting-item .switch-wrap .setting-switch {
  background: #566b52;
}

body.night .scan-setting-item .switch-wrap .setting-switch:checked {
  background: #129d08;
}

/* Dialog: Tự động quét & Rung và âm chụp */
.auto-scan-dialog {
  padding: 0;
  border: none;
  border-radius: 24px;
  width: min(330px, calc(100vw - 32px));
  background: #fff;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.22);
  overflow: hidden
}

.auto-scan-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px)
}

.auto-scan-dialog-inner {
  padding: 22px 20px 16px
}

.auto-scan-title {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 14px
}

.auto-scan-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 0 -20px 10px
}

.auto-scan-options {
  display: flex;
  flex-direction: column;
  max-height: 60vh;
  overflow-y: auto
}

.auto-scan-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 4px;
  cursor: pointer;
  transition: background .15s;
  border-radius: 8px
}

.auto-scan-option:hover {
  background: #f8fafc
}

.auto-scan-radio {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #79747e;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .15s
}

.auto-scan-option.selected .auto-scan-radio {
  border-color: var(--grade-green, #129d08)
}

.auto-scan-option.selected .auto-scan-radio::after {
  content: '';
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--grade-green, #129d08)
}

.auto-scan-label {
  font-size: 15px;
  font-weight: 500;
  color: #1e293b
}

.auto-scan-option.selected .auto-scan-label {
  font-weight: 600;
  color: #0f172a
}

.auto-scan-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px
}

.btn-auto-scan-cancel {
  background: transparent;
  border: none;
  color: var(--grade-green, #129d08);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 8px
}

.btn-auto-scan-cancel:hover {
  background: #e8f5e9
}

/* Night mode support */
body.night .scan-settings-card {
  background: #223326;
  border-color: #3d5743
}

body.night .scan-setting-item {
  border-bottom-color: #2c4232
}

body.night .scan-setting-item:not(:last-child):hover {
  background: #2a3d2f
}

body.night .scan-setting-icon {
  background: #1a281e;
  color: #57d64d
}

body.night .scan-setting-name {
  color: #ecf4e9
}

body.night .scan-setting-desc {
  color: #a8c7a2
}

body.night .auto-scan-dialog {
  background: #1f2922;
  color: #ecf4e9
}

body.night .auto-scan-title {
  color: #ecf4e9
}

body.night .auto-scan-divider {
  background: #3d5743
}

body.night .auto-scan-label {
  color: #ecf4e9
}

body.night .auto-scan-option:hover {
  background: #283a2d
}

body.night .btn-auto-scan-cancel {
  color: #57d64d
}

body.night .btn-auto-scan-cancel:hover {
  background: #283a2d
}

body.night .setting-action-row {
  background: #233527;
  border-color: #3a543f
}

body.night .setting-action-row:hover {
  background: #2a402e
}

body.night .setting-row-content b {
  color: #c9ecc2
}

body.night .setting-row-content small {
  color: #a8c7a2
}

body.night .setting-current-val {
  color: #57d64d
}

body.night .sharpness-dialog {
  background: #1f2922;
  color: #ecf4e9
}

body.night .sharpness-title {
  color: #ecf4e9
}

body.night .sharpness-option {
  background: #283a2d;
  border-color: #3d5743
}

body.night .sharpness-option.selected {
  background: #2e4734;
  border-color: #57d64d
}

body.night .sharpness-opt-title {
  color: #ecf4e9
}

body.night .sharpness-opt-desc {
  color: #b3cbb6
}

body.night .bubble-card {
  background: #223326;
  border-color: #3d5743
}

body.night .bubble-card#cardMinShade {
  border-color: #117b0a
}

body.night .card-drag-badge {
  background: #117b0a;
  box-shadow: 0 2px 6px rgba(17, 123, 10, 0.4)
}

body.night .bubble-card-title {
  color: #ecf4e9
}

body.night .bubble-card-val {
  color: #57d64d
}

body.night .bubble-preview-box {
  background: #1a281e;
  border-color: #3d5743
}

body.night .bubble-card-desc,
body.night .bubble-notice {
  color: #a8c7a2
}

body.night .btn-bubble-reset {
  background: #223e27;
  color: #b7e8b2;
  border-color: #385b3e
}

body.night .btn-bubble-reset:hover {
  background: #2c4d32
}