@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap");

:root {
  color-scheme: dark;
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --background: #101829;
  --surface: #172235;
  --surface-raised: #202c40;
  --border: #29364b;
  --text: #eef2fb;
  --muted: #8290a9;
  --accent: #5549f5;
  --accent-light: #9c8cff;
  --success: #51d6a0;
  --danger: #ff828c;
  --shadow: 0 14px 40px rgb(0 0 0 / 24%);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: #080e19;
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 3px;
}

.app-shell {
  display: flex;
  width: min(100%, 620px);
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
  margin: 0 auto;
  overflow: hidden;
  background: var(--background);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid #222d40;
}

.brand,
.brand-copy,
.header-actions {
  display: flex;
}

.brand {
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.brand-mark,
.icon-button {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  background: linear-gradient(145deg, #9259ff, #6245f5);
  box-shadow: 0 5px 15px rgb(98 69 245 / 32%);
}

.brand-mark svg {
  width: 21px;
  stroke: white;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.brand-copy {
  flex-direction: column;
  gap: 2px;
}

.brand-copy h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.brand-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.icon-button {
  width: 38px;
  height: 38px;
  cursor: pointer;
}

.header-actions {
  align-items: center;
  gap: 8px;
}

.install-button {
  background: #202b3e;
  color: #a9b5ca;
}

.install-button svg {
  width: 19px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.add-button {
  background: var(--accent);
  box-shadow: 0 4px 12px rgb(85 73 245 / 30%);
}

.add-button svg {
  width: 21px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.view-content {
  flex: 1;
  padding: 18px 18px 36px;
}

.toolbar {
  margin-bottom: 28px;
}

.search-box {
  display: flex;
  height: 40px;
  align-items: center;
  gap: 9px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #1b2638;
}

.search-box:focus-within {
  border-color: var(--accent-light);
}

.search-box svg {
  width: 17px;
  flex: 0 0 auto;
  stroke: #8290a9;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
}

.search-box input::placeholder {
  color: #8290a9;
}

.list-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 0 1px 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #a79bff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
}

.list-heading h2 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -0.5px;
}

.note-count {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
}

.note-list {
  display: grid;
  gap: 11px;
}

.note-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

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

.note-card h3 {
  overflow-wrap: anywhere;
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
}

.note-date {
  flex: 0 0 auto;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.note-body {
  overflow-wrap: anywhere;
  margin: 10px 0 0;
  color: #c1cad9;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.note-amount {
  width: fit-content;
  margin: 12px 0 0;
  padding: 6px 9px;
  border: 1px solid #315244;
  border-radius: 8px;
  background: #193329;
  color: #a4d5b9;
  font-size: 11px;
}

.note-amount strong {
  color: #c5f0d4;
  font-weight: 700;
}

.note-attachment {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  padding: 7px 10px;
  border: 1px solid #354159;
  border-radius: 9px;
  background: #1b2638;
  color: #b8adff;
  cursor: pointer;
  font-size: 10px;
}

.note-attachment svg {
  width: 14px;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.note-attachment span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 11px;
  border-top: 1px solid #263349;
}

.text-button {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #aeb9ce;
  cursor: pointer;
  font-size: 10px;
}

.text-button:hover {
  background: #263349;
  color: var(--text);
}

.text-button svg {
  width: 14px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.delete-button {
  color: var(--danger);
}

.empty-state {
  display: grid;
  justify-items: center;
  padding: 58px 18px;
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  margin-bottom: 14px;
  border: 1px solid #354159;
  border-radius: 17px;
  background: #1c283b;
  color: #a79bff;
}

.empty-icon svg {
  width: 25px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.empty-state h2 {
  margin: 0;
  font-size: 17px;
}

.empty-state p {
  max-width: 330px;
  margin: 8px 0 17px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  min-height: 39px;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.secondary-button {
  border: 1px solid #354159;
  background: #202b3e;
  color: #d3d9e5;
}

.app-dialog {
  width: min(100% - 24px, 540px);
  max-height: min(90dvh, 760px);
  padding: 0;
  overflow: auto;
  border: 1px solid #354159;
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 80px rgb(0 0 0 / 45%);
}

.app-dialog::backdrop {
  background: rgb(3 7 14 / 72%);
  backdrop-filter: blur(3px);
}

.dialog-form {
  display: grid;
  gap: 15px;
  padding: 20px;
}

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

.dialog-heading h2 {
  overflow-wrap: anywhere;
  margin: 0;
  font-size: 18px;
}

.close-button {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 9px;
  background: #263349;
  color: #aeb9ce;
  cursor: pointer;
  font-size: 21px;
  line-height: 1;
}

.form-field {
  display: grid;
  gap: 7px;
  color: #d3d9e5;
  font-size: 11px;
  font-weight: 600;
}

.form-field input,
.form-field textarea {
  width: 100%;
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid #354159;
  border-radius: 10px;
  outline: 0;
  background: #111b2b;
  color: var(--text);
  font-size: 12px;
  font-weight: 400;
}

.form-field textarea {
  min-height: 150px;
  resize: vertical;
  line-height: 1.6;
}

.form-field input:focus,
.form-field textarea:focus {
  border-color: var(--accent-light);
}

.form-field input[type="file"] {
  padding: 8px;
  color: var(--muted);
}

.form-field input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 7px 10px;
  border: 0;
  border-radius: 7px;
  background: #29364b;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.optional,
.field-hint {
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
}

.field-hint {
  margin-top: -3px;
}

.attachment-current {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid #354159;
  border-radius: 10px;
  color: #b8adff;
  font-size: 11px;
}

.attachment-current span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove-attachment-button {
  flex: 0 0 auto;
  padding: 5px 7px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-size: 10px;
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 11px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 9px;
  margin-top: 2px;
}

.attachment-dialog {
  width: min(100% - 24px, 760px);
}

.attachment-dialog h2 {
  max-width: 580px;
}

.attachment-preview-content {
  display: grid;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.attachment-preview-image {
  display: block;
  max-width: 100%;
  max-height: min(62vh, 640px);
  border-radius: 10px;
  object-fit: contain;
}

.attachment-preview-pdf {
  width: 100%;
  height: min(62vh, 640px);
  border: 1px solid #354159;
  border-radius: 10px;
  background: white;
}

.attachment-download {
  display: inline-flex;
  min-height: 39px;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.toast {
  position: fixed;
  z-index: 3;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
  width: fit-content;
  max-width: min(440px, calc(100% - 32px));
  margin-inline: auto;
  padding: 11px 15px;
  border: 1px solid #354159;
  border-radius: 11px;
  background: #202c40;
  color: var(--text);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

[hidden] {
  display: none !important;
}

@media (max-width: 420px) {
  .topbar {
    padding-inline: 12px;
  }

  .view-content {
    padding-inline: 12px;
  }

  .dialog-form {
    padding: 16px;
  }

  .note-card {
    padding: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
