.dashboard {
  display: grid;
  gap: 18px;
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  display: flex;
  gap: 14px;
  min-width: 0;
  padding: 19px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.stat-card > div {
  min-width: 0;
}

.stat-icon {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 6px;
}

.stat-icon.green { color: #176b55; background: #e7f2ee; }
.stat-icon.gold { color: #8b6508; background: #f7f0db; }
.stat-icon.blue { color: #26658a; background: #e5f0f6; }
.stat-icon.rose { color: #9a3f55; background: #f7e9ed; }
.stat-icon.violet { color: #65508f; background: #eeeaf7; }

.stat-card small,
.stat-card strong,
.stat-card p {
  display: block;
}

.stat-card small {
  color: var(--muted);
  font-size: 11px;
}

.stat-card strong {
  margin: 4px 0 2px;
  font-size: 27px;
  line-height: 1.1;
}

.stat-card p {
  overflow: hidden;
  margin: 0;
  color: #94989c;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(280px, .85fr) minmax(380px, 1.15fr);
  gap: 14px;
}

.dashboard-panel {
  min-width: 0;
  padding: 21px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  max-height: 330px;
  overflow: auto;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.panel-heading h3,
.panel-heading p {
  margin: 0;
}

.panel-heading h3 {
  font-size: 15px;
}

.panel-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.text-link {
  padding: 3px;
  color: var(--green);
  background: transparent;
  border: 0;
  font-size: 11px;
}

.category-bars {
  display: grid;
  gap: 16px;
}

.bar-row {
  display: grid;
  grid-template-columns: 52px 1fr 28px;
  align-items: center;
  gap: 10px;
  font-size: 11px;
}

.bar-track {
  height: 7px;
  overflow: hidden;
  background: #eef0f0;
  border-radius: 4px;
}

.bar-track i {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: inherit;
}

.bar-track .bar-level-0 { width: 0; }
.bar-track .bar-level-1 { width: 10%; }
.bar-track .bar-level-2 { width: 20%; }
.bar-track .bar-level-3 { width: 30%; }
.bar-track .bar-level-4 { width: 40%; }
.bar-track .bar-level-5 { width: 50%; }
.bar-track .bar-level-6 { width: 60%; }
.bar-track .bar-level-7 { width: 70%; }
.bar-track .bar-level-8 { width: 80%; }
.bar-track .bar-level-9 { width: 90%; }
.bar-track .bar-level-10 { width: 100%; }

.bar-row em {
  color: var(--muted);
  font-style: normal;
  text-align: right;
}

.recent-list {
  display: grid;
}

.recent-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  min-height: 53px;
  border-top: 1px solid #f0f1f2;
}

.recent-row:first-child {
  border-top: 0;
}

.recent-badge {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--green);
  background: #edf3f1;
  border-radius: 5px;
  font-weight: 700;
}

.recent-info {
  min-width: 0;
}

.recent-info strong,
.recent-info small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-info strong {
  font-size: 12px;
}

.recent-info small,
.recent-time {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.dashboard-empty {
  padding: 34px 10px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.expiry-panel {
  padding: 21px;
  max-height: 260px;
}

.expiry-list {
  display: grid;
}

.expiry-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 0;
  background: transparent;
  border: 0;
  border-top: 1px solid #f0f1f2;
  text-align: left;
}

.expiry-row:first-child { border-top: 0; }
.expiry-row > span { color: #8a6c22; }
.expiry-row strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.expiry-row small { color: var(--muted); font-size: 10px; }
.expiry-row em { padding: 4px 7px; border-radius: 4px; font-size: 10px; font-style: normal; }
.expiry-row em.soon { color: #82620d; background: #f7f0db; }
.expiry-row em.urgent,
.expiry-row em.expired { color: var(--red); background: #fff0ef; }

.field-tools {
  display: flex !important;
  justify-content: flex-end;
  gap: 10px;
  margin: 7px 0 0 !important;
}

.field-tools button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
  color: #74797e;
  background: transparent;
  border: 0;
  font-size: 11px;
}

.field-tools button:hover {
  color: var(--green);
}

.field-tools svg {
  width: 13px;
  height: 13px;
}

.textarea-action {
  position: relative;
}

.textarea-action textarea {
  padding-right: 48px !important;
}

.textarea-action > button {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #777;
  background: #f5f7f6;
  border: 0;
  border-radius: 4px;
}

.textarea-action > button:hover {
  color: var(--green);
  background: var(--green-soft);
}

@media (max-width: 1060px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .stat-card { display: flex; align-items: center; gap: 10px; min-height: 68px; padding: 11px; }
  .stat-card > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 7px; }
  .stat-card small { grid-column: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .stat-card strong { grid-column: 2; grid-row: 1 / span 2; margin: 0; font-size: 24px; }
  .stat-icon { flex-basis: 34px; width: 34px; height: 34px; }
  .stat-card p { display: none; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-panel { padding: 17px; }
  .recent-row { grid-template-columns: 34px minmax(0, 1fr); }
  .recent-time { display: none; }
}

/* Card wallet stays compact until a specific document is opened. */
.wallet-card-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 68px;
  padding: 12px 15px;
  color: var(--ink);
  background: #fff;
  border: 0;
  text-align: left;
}
.wallet-card-summary:hover { background: #f7f9f8; }
.wallet-card-summary-icon { display: grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px; color: var(--green); background: var(--green-soft); border-radius: 6px; }
.wallet-card-summary-copy { display: grid; min-width: 0; gap: 4px; flex: 1; }
.wallet-card-summary-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.wallet-card-summary-copy small { color: var(--muted); font-size: 10px; }
.wallet-card-chevron { color: #8b9390; transform: rotate(90deg); transition: transform .18s; }
.wallet-card-summary[aria-expanded="true"] .wallet-card-chevron { transform: rotate(270deg); }
.wallet-card-details { border-top: 1px solid #eef1ef; }
.wallet-card-image-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1px; background: #dfe5e2; }
.wallet-card-details .wallet-card-image { aspect-ratio: 16 / 8; }
.wallet-card-details .wallet-card-image img { filter: none; transform: none; }
.wallet-card-details .wallet-card-body { padding: 13px 15px 15px; }

.notes-section {
  margin-top: 38px;
  padding-top: 30px;
  border-top: 1px solid var(--line);
}

.notes-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.notes-heading h3,
.notes-heading p {
  margin: 0;
}

.notes-heading h3 {
  margin-bottom: 5px;
  font-size: 20px;
}

.notes-heading p:last-child {
  color: var(--muted);
  font-size: 12px;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.note-card {
  min-width: 0;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.note-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.note-card-head h4 {
  overflow: hidden;
  margin: 0;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.linked-account {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  color: var(--green);
  font-size: 10px;
}

.note-preview {
  display: -webkit-box;
  overflow: hidden;
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.note-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid #f0f1f2;
}

.note-card-footer small {
  color: var(--muted);
  font-size: 10px;
}

.notes-empty {
  padding: 38px;
  color: var(--muted);
  background: #f8f9f9;
  border: 1px dashed #d9dddb;
  border-radius: 7px;
  font-size: 12px;
  text-align: center;
}

.note-form-body {
  padding: 23px 26px;
}

.note-form-body > label {
  display: block;
  margin-bottom: 24px;
}

.note-form-body > label > span {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}

.note-form-body select,
.note-title-input,
.note-content-input {
  width: 100%;
  padding: 12px 13px;
  background: #fff;
  border: 1px solid #d9dcdf;
  border-radius: 6px;
  outline: none;
}

.note-form-body select:focus,
.note-title-input:focus,
.note-content-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(23,107,85,.1);
}

.note-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.note-section-heading span,
.note-section-heading small {
  display: block;
}

.note-section-heading span {
  font-size: 13px;
  font-weight: 600;
}

.note-section-heading small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.add-section-btn {
  color: #fff;
  background: var(--green);
}

.add-section-btn:hover {
  color: #fff;
  background: var(--green-dark);
}

.note-sections {
  display: grid;
  gap: 13px;
}

.note-section-row {
  padding: 14px;
  background: #f7f8f8;
  border: 1px solid #ebeded;
  border-radius: 6px;
}

.note-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 9px;
}

.note-title-input {
  font-weight: 600;
}

.note-content-input {
  min-height: 112px;
  resize: vertical;
}

.note-field-tools {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}

.note-field-tools > div {
  display: flex;
  gap: 12px;
}

.note-field-tools button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
  color: #74797e;
  background: transparent;
  border: 0;
  font-size: 11px;
}

.note-field-tools button:hover {
  color: var(--green);
}

.note-field-tools .remove-note-section {
  color: var(--red);
}

@media (max-width: 760px) {
  .notes-heading { align-items: flex-start; }
  .notes-heading p:last-child { max-width: 210px; }
  .notes-grid { grid-template-columns: 1fr; }
  .note-form-body { padding: 20px; }
}

.notebook-section {
  display: grid;
  gap: 18px;
}

.notebook-heading {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 18px;
}

.notebook-heading h3,
.notebook-heading p {
  margin: 0;
}

.notebook-heading h3 {
  margin-bottom: 5px;
  font-size: 22px;
}

.notebook-heading p:last-child {
  color: var(--muted);
  font-size: 12px;
}

.notebook-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.notebook-card {
  display: flex;
  flex-direction: column;
  min-height: 205px;
  padding: 19px;
  background: #fff;
  border: 1px solid var(--line);
  border-top: 3px solid #b48a28;
  border-radius: 7px;
}

.notebook-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.notebook-card h4 {
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
}

.notebook-content {
  display: -webkit-box;
  overflow: hidden;
  margin: 17px 0;
  color: #5f6469;
  font-size: 12px;
  line-height: 1.8;
  white-space: pre-wrap;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.notebook-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 13px;
  border-top: 1px solid #f0f1f2;
}

.notebook-card-footer small {
  color: var(--muted);
  font-size: 10px;
}

.notebook-form-body {
  padding: 23px 26px;
}

.notebook-form-body label {
  display: block;
  margin-bottom: 18px;
}

.notebook-form-body label > span:first-child {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}

.notebook-form-body input,
.notebook-form-body textarea {
  width: 100%;
  padding: 12px 13px;
  background: #fff;
  border: 1px solid #d9dcdf;
  border-radius: 6px;
  outline: none;
}

.notebook-form-body textarea {
  resize: vertical;
}

.notebook-form-body input:focus,
.notebook-form-body textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(23,107,85,.1);
}

@media (max-width: 760px) {
  .notebook-heading { align-items: flex-start; }
  .notebook-grid { grid-template-columns: 1fr; }
  .notebook-form-body { padding: 20px; }
}

.card-wallet-section {
  display: grid;
  gap: 18px;
}

.card-wallet-toolbar,
.card-block-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.segment-control {
  display: inline-grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(5, minmax(74px, auto));
  min-width: 0;
  overflow-x: auto;
  padding: 3px;
  background: #e9eceb;
  border-radius: 6px;
}

.card-wallet-toolbar > .primary {
  flex: 0 0 auto;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .card-wallet-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .card-wallet-toolbar > .primary {
    align-self: flex-end;
  }
}

.segment-control button {
  min-height: 34px;
  padding: 7px 13px;
  color: #676d71;
  background: transparent;
  border: 0;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
}

.segment-control button.active {
  color: #202522;
  background: #fff;
  box-shadow: 0 1px 3px rgba(23, 34, 30, .12);
  font-weight: 600;
}

.card-wallet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.wallet-card {
  min-width: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  transition: .18s;
}

.wallet-card:hover {
  border-color: #c7d2ce;
  box-shadow: 0 8px 24px rgba(24, 38, 33, .07);
  transform: translateY(-1px);
}

.wallet-card-image {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  color: #9aa29e;
  background: #edf0ef;
  border: 0;
  padding: 0;
}

.wallet-card-image > svg {
  width: 42px;
  height: 42px;
}

.wallet-card-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.wallet-card-type {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 5px 8px;
  color: #fff;
  background: rgba(20, 27, 24, .78);
  border-radius: 4px;
  font-size: 10px;
}

.wallet-card-body {
  padding: 17px;
}

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

.wallet-card-head h3 {
  overflow: hidden;
  margin: 3px 0 0;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wallet-card-fields {
  display: grid;
  gap: 9px;
  min-height: 63px;
  margin-top: 15px;
  padding-top: 13px;
  border-top: 1px solid #f0f1f2;
}

.wallet-card-fields p {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 8px;
  margin: 0;
  font-size: 11px;
}

.wallet-card-fields span {
  color: var(--muted);
}

.wallet-card-fields strong {
  overflow: hidden;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wallet-card-fields .wallet-card-no-fields {
  display: block;
  color: var(--muted);
}

.wallet-card-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  color: var(--muted);
  font-size: 10px;
}

.wallet-expiry {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 13px;
  padding: 9px 10px;
  color: #676d71;
  background: #f5f6f6;
  border-radius: 5px;
  font-size: 10px;
}

.wallet-expiry.soon { color: #765806; background: #f7f0db; }
.wallet-expiry.urgent,
.wallet-expiry.expired { color: var(--red); background: #fff0ef; }

.card-modal {
  width: min(900px, calc(100% - 32px));
}

.card-form-body {
  display: grid;
  gap: 27px;
  padding: 23px 26px 28px;
}

.card-title-field > span,
.card-raw-field > span,
.card-category-field legend {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}

.card-title-field input,
.card-raw-field textarea,
.card-field-row input,
.card-field-row textarea {
  width: 100%;
  padding: 12px 13px;
  background: #fff;
  border: 1px solid #d9dcdf;
  border-radius: 6px;
  outline: none;
}

.card-title-field input:focus,
.card-raw-field textarea:focus,
.card-field-row input:focus,
.card-field-row textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(23, 107, 85, .1);
}

.card-category-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.card-expiry-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 12px;
}

.card-expiry-grid label > span {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}

.card-expiry-grid input,
.card-expiry-grid select {
  width: 100%;
  min-height: 43px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #d9dcdf;
  border-radius: 6px;
}

.card-type-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.card-type-options label {
  cursor: pointer;
}

.card-type-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.card-type-options label > span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 45px;
  padding: 8px;
  color: #686e72;
  background: #f7f8f8;
  border: 1px solid #e1e4e3;
  border-radius: 6px;
  font-size: 12px;
}

.card-type-options input:checked + span {
  color: var(--green);
  background: var(--green-soft);
  border-color: #91b5aa;
  box-shadow: 0 0 0 2px rgba(23, 107, 85, .08);
  font-weight: 600;
}

.card-block-heading h3,
.card-block-heading p {
  margin: 0;
}

.card-block-heading h3 {
  font-size: 14px;
}

.card-block-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.card-image-actions {
  display: flex;
  gap: 8px;
}

.card-image-actions label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.card-image-actions input {
  display: none;
}

.card-image-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 13px;
}

.card-image-preview {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  background: #f3f5f4;
  border: 1px solid #e1e4e3;
  border-radius: 6px;
}

.card-image-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
}

.card-image-preview figcaption {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
  min-height: 39px;
  padding: 5px 6px 5px 10px;
  background: #fff;
  border-top: 1px solid #e8eae9;
}

.card-image-preview figcaption > div {
  display: flex;
}

.card-image-preview figcaption span {
  overflow: hidden;
  color: #6a7074;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-image-empty {
  display: grid;
  place-items: center;
  min-height: 150px;
  margin-top: 13px;
  padding: 20px;
  color: var(--muted);
  background: #f8f9f9;
  border: 1px dashed #d4d9d7;
  border-radius: 6px;
  text-align: center;
}

.card-image-empty > svg {
  width: 29px;
  height: 29px;
  margin-bottom: 9px;
  color: var(--green);
}

.card-image-empty strong,
.card-image-empty small {
  display: block;
}

.card-image-empty strong {
  color: #424844;
  font-size: 12px;
}

.card-image-empty small {
  margin-top: 5px;
  font-size: 10px;
}

.ocr-progress {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  min-height: 54px;
  margin-top: 10px;
  padding: 10px 13px;
  background: #edf3f1;
  border-radius: 6px;
}

.ocr-spinner {
  width: 22px;
  height: 22px;
  border: 2px solid #b9cec7;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: ocr-spin .8s linear infinite;
}

@keyframes ocr-spin { to { transform: rotate(360deg); } }

.ocr-progress strong,
.ocr-progress small {
  display: block;
}

.ocr-progress strong {
  font-size: 11px;
}

.ocr-progress small,
.ocr-progress em {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
}

.ocr-quality {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 5px;
  font-size: 10px;
}

.ocr-quality.good { color: #176b55; background: #e7f2ee; }
.ocr-quality.medium { color: #765806; background: #f7f0db; }
.ocr-quality.low { color: var(--red); background: #fff0ef; }
.ocr-quality strong { font-size: 11px; }

.card-fields {
  display: grid;
  gap: 8px;
  margin-top: 13px;
}

.card-field-row {
  display: grid;
  grid-template-columns: 145px minmax(0, 1fr) 34px 34px;
  align-items: start;
  gap: 8px;
}

.card-field-row input,
.card-field-row textarea {
  min-height: 42px;
  padding: 10px 11px;
  resize: vertical;
  font-size: 12px;
}

.card-field-row .mini-btn {
  width: 34px;
  height: 42px;
  border: 1px solid #e1e4e3;
}

.card-field-row .card-field-remove {
  color: var(--red);
}

.card-field-warning {
  display: none;
  grid-column: 2 / -1;
  margin: -3px 0 3px;
  color: var(--red);
  font-size: 10px;
}

.card-field-row.invalid-id .card-field-value {
  border-color: #d78c86;
  background: #fff9f8;
}

.card-field-row.invalid-id .card-field-warning {
  display: block;
}

.settings-modal {
  width: min(720px, calc(100% - 32px));
}

.preference-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.preference-grid label > span {
  display: block;
  margin-bottom: 7px;
  font-size: 11px;
  font-weight: 600;
}

.preference-grid select {
  width: 100%;
  min-height: 41px;
  padding: 9px 11px;
  background: #fff;
  border: 1px solid #d9dcdf;
  border-radius: 6px;
}

.setting-toggle {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 17px;
  color: #555b60;
  font-size: 11px;
  line-height: 1.6;
}

.setting-toggle input {
  flex: 0 0 auto;
  margin-top: 2px;
}

.settings-section-title,
.settings-button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-pill {
  flex: 0 0 auto;
  padding: 4px 8px;
  color: #7a5c0b;
  background: #f7f0db;
  border-radius: 4px;
  font-size: 10px;
}

.status-pill.healthy { color: var(--green); background: var(--green-soft); }

.backup-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 18px 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.backup-stats span {
  padding: 12px;
  border-left: 1px solid var(--line);
}

.backup-stats span:first-child { border-left: 0; }
.backup-stats small,
.backup-stats strong { display: block; }
.backup-stats small { color: var(--muted); font-size: 9px; }
.backup-stats strong { margin-top: 4px; font-size: 15px; }

.backup-detail {
  margin: 0 0 14px !important;
}

.settings-button-row {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.settings-button-row label {
  cursor: pointer;
}

.settings-button-row input { display: none; }

.security-event-list {
  display: grid;
  max-height: 245px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.security-event-list > div {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 0 8px;
  padding: 10px 12px;
  border-top: 1px solid #f0f1f2;
}

.security-event-list > div:first-child { border-top: 0; }
.security-event-list svg { grid-row: span 2; color: var(--green); }
.security-event-list strong { font-size: 11px; }
.security-event-list small { margin-top: 3px; color: var(--muted); font-size: 9px; }

.import-body,
.totp-body {
  padding: 23px 26px;
}

.import-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  background: #f6f8f7;
  border-radius: 6px;
}

.import-summary span { color: var(--muted); font-size: 10px; }
.import-body fieldset { margin: 20px 0 0; padding: 0; border: 0; }
.import-body legend { margin-bottom: 9px; font-size: 12px; font-weight: 600; }
.import-body fieldset label { display: flex; align-items: flex-start; gap: 9px; padding: 12px 0; border-top: 1px solid var(--line); }
.import-body fieldset label > span,
.import-body fieldset strong,
.import-body fieldset small { display: block; }
.import-body fieldset small { margin-top: 4px; color: var(--muted); font-size: 10px; }

.totp-body > p { margin: 0 0 18px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.totp-body > label { display: block; margin-bottom: 16px; }
.totp-body > label > span { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 600; }
.totp-body input,
.privacy-dialog input { width: 100%; padding: 12px 13px; border: 1px solid #d9dcdf; border-radius: 6px; outline: none; }
.totp-setup { display: grid; grid-template-columns: 170px minmax(0, 1fr); align-items: center; gap: 18px; margin-bottom: 20px; }
.totp-setup img { width: 170px; height: 170px; }
.totp-setup small,
.totp-setup code { display: block; }
.totp-setup small { color: var(--muted); font-size: 10px; }
.totp-setup code { overflow-wrap: anywhere; margin: 8px 0; font-size: 12px; line-height: 1.6; }
.totp-setup .text-link { display: inline-flex; align-items: center; gap: 5px; }

.totp-body > h3 { margin: 0 0 7px; font-size: 16px; }

.recovery-code-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 17px 0;
}

.recovery-code-grid code {
  padding: 9px;
  background: #f3f5f4;
  border: 1px solid #e2e5e4;
  border-radius: 4px;
  font-size: 11px;
  text-align: center;
}

.privacy-dialog form > div {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin-top: 16px;
}

.card-add-field {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
}

.card-add-field svg {
  width: 14px;
  height: 14px;
}

.card-raw-field textarea {
  resize: vertical;
}

@media (max-width: 760px) {
  .card-wallet-toolbar { align-items: stretch; flex-direction: column; }
  .segment-control { grid-template-columns: repeat(5, minmax(72px, 1fr)); overflow-x: auto; }
  .segment-control button { padding: 7px 9px; }
  .card-wallet-grid { grid-template-columns: 1fr; }
  .card-form-body { padding: 20px; }
  .card-type-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-block-heading { align-items: flex-start; flex-direction: column; }
  .card-image-actions { width: 100%; }
  .card-image-actions label { justify-content: center; flex: 1; }
  .card-image-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-field-row { grid-template-columns: minmax(0, 1fr) 34px 34px; }
  .card-field-label { grid-column: 1 / -1; }
  .card-field-warning { grid-column: 1 / -1; }
  .card-expiry-grid,
  .preference-grid { grid-template-columns: 1fr; }
  .expiry-row { grid-template-columns: 28px minmax(0, 1fr) auto; }
  .expiry-row small { display: none; }
  .settings-button-row { align-items: stretch; flex-direction: column; }
  .settings-button-row > * { width: 100%; }
  .totp-setup { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .recovery-code-grid { grid-template-columns: 1fr; }
  .backup-stats strong { font-size: 13px; }
}
.app-shell {
  height: 100vh;
  overflow: hidden;
}

.workspace {
  height: 100vh;
  min-height: 0;
}

.content {
  height: calc(100vh - 78px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.item-grid,
.notes-grid,
.notebook-grid,
.card-wallet-grid {
  max-height: min(620px, calc(100vh - 260px));
  overflow-y: auto;
  overscroll-behavior: contain;
  align-content: start;
  padding-right: 4px;
  scrollbar-width: thin;
}

.data-row code {
  overflow-x: auto;
  text-overflow: clip;
  scrollbar-width: thin;
}

.note-preview,
.notebook-content {
  max-height: 120px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.note-preview {
  display: block;
  white-space: pre-wrap;
}

.notebook-content {
  display: block;
  -webkit-line-clamp: unset;
}

.wallet-card-image-grid {
  max-height: 300px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.wallet-card-fields {
  max-height: 220px;
  overflow-y: auto;
  padding-right: 3px;
  scrollbar-width: thin;
}

.wallet-card-fields p {
  grid-template-columns: 78px minmax(0, 1fr) 30px;
  align-items: center;
}

.wallet-card-fields strong {
  overflow-x: auto;
  text-overflow: clip;
  scrollbar-width: thin;
}

.wallet-field-copy {
  width: 28px;
  height: 28px;
}

.wallet-image-actions {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  overflow: hidden;
  color: #fff;
  background: rgba(20, 27, 24, .76);
  border-radius: 5px;
}

.wallet-image-actions button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
}

.wallet-image-actions button:hover {
  background: var(--green);
}

.card-image-preview figcaption .mini-btn {
  width: 25px;
  height: 28px;
}

.workbench-active .content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.workbench-active .content-heading {
  flex: 0 0 auto;
}

.workbench-section {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  gap: 14px;
}

.workbench-section #itemGrid {
  flex: 1 1 52%;
  min-height: 145px;
  max-height: none;
  overflow-y: auto;
  align-content: start;
}

.workbench-section #notesSection {
  display: flex;
  flex: 1 1 48%;
  flex-direction: column;
  min-height: 145px;
  max-height: none;
  margin-top: 0;
  padding-top: 14px;
  overflow: hidden;
}

.workbench-section .notes-heading {
  flex: 0 0 auto;
}

.workbench-section .notes-grid {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  align-content: start;
}

.workbench-section:not(.has-accounts) #itemGrid {
  display: none;
}

.workbench-section:not(.has-accounts) #emptyState {
  flex: 0 0 auto;
  padding: 30px 20px;
}

@media (max-width: 760px) {
  .content { height: calc(100vh - 68px); }
  .item-grid,
  .notes-grid,
  .notebook-grid,
  .card-wallet-grid { max-height: calc(100vh - 230px); }
  .workbench-section #itemGrid,
  .workbench-section #notesSection { min-height: 120px; }
}

.card-filter-selects {
  display: flex;
  flex: 0 1 340px;
  gap: 8px;
}

.card-filter-selects label {
  display: grid;
  flex: 1 1 0;
  min-width: 0;
  gap: 4px;
}

.card-filter-selects label > span {
  color: var(--muted);
  font-size: 10px;
}

.card-filter-selects select {
  width: 100%;
  min-height: 34px;
  padding: 6px 30px 6px 9px;
  color: #4d5451;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.card-identity-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(180px, .8fr);
  gap: 12px;
}

.wallet-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.wallet-tags span {
  padding: 3px 6px;
  color: #5d6965;
  background: #f0f3f2;
  border-radius: 3px;
  font-size: 9px;
}

.trash-section {
  display: grid;
  min-height: 0;
  gap: 16px;
}

.trash-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.trash-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.trash-grid {
  display: grid;
  max-height: min(620px, calc(100vh - 260px));
  overflow-y: auto;
  align-content: start;
  gap: 9px;
  padding-right: 4px;
  scrollbar-width: thin;
}

.trash-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.trash-type-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #68716d;
  background: #eef1f0;
  border-radius: 6px;
}

.trash-card-copy {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.trash-card-copy strong,
.trash-card-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trash-card-copy strong { font-size: 13px; }
.trash-card-copy small { color: var(--muted); font-size: 10px; }

.trash-card-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.trash-card-actions .secondary {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 11px;
}

.duplicate-dialog .confirm-icon.warning {
  color: #8a6408;
  background: #fff7dc;
}

.duplicate-reasons {
  display: grid !important;
  max-height: 160px;
  overflow-y: auto;
  gap: 6px !important;
  margin: 0 0 22px;
  padding: 10px 12px;
  background: #f7f8f8;
  border-radius: 6px;
  text-align: left;
}

.duplicate-reasons p {
  margin: 0;
  color: #4e5552;
  font-size: 12px;
}

.card-image-preview figcaption > div {
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 1180px) {
  .card-wallet-toolbar { align-items: stretch; flex-direction: column; }
  .card-filter-selects { flex-basis: auto; }
  .card-wallet-toolbar > .primary { align-self: flex-end; }
}

@media (max-width: 760px) {
  .card-filter-selects,
  .card-identity-grid { grid-template-columns: 1fr; }
  .card-filter-selects { display: grid; }
  .card-wallet-toolbar > .primary { width: 100%; }
  .trash-grid { max-height: calc(100vh - 245px); }
  .trash-toolbar { align-items: stretch; flex-direction: column; }
  .trash-toolbar .danger { align-self: flex-end; }
  .trash-card { grid-template-columns: 34px minmax(0, 1fr); }
  .trash-type-icon { width: 34px; height: 34px; }
  .trash-card-actions { grid-column: 2; justify-content: flex-end; }
  .card-image-preview figcaption { grid-template-columns: 1fr; }
  .card-image-preview figcaption > div { justify-content: flex-start; }
}
