/* ==========================================================================
   Tokens
   ========================================================================== */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --hover: #f3f4f6;
  --border: #e7e9ee;
  --border-strong: #d5d9e0;
  --text: #0f1219;
  --text-2: #4a5263;
  --text-3: #8a91a0;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --accent-text: #4338ca;
  --on-accent: #ffffff;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fef2f2;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --success: #15803d;
  --success-soft: #ecfdf3;
  --focus: 0 0 0 3px rgba(79, 70, 229, 0.22);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 24px 60px -16px rgba(16, 24, 40, 0.28);
  --radius-sm: 7px;
  --radius: 10px;
  --radius-lg: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'Cascadia Code', 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0c0d10;
    --surface: #131519;
    --surface-2: #171a1f;
    --hover: #1c1f25;
    --border: #252932;
    --border-strong: #333845;
    --text: #eceef2;
    --text-2: #a4abb8;
    --text-3: #6c7382;
    --accent: #7c75ff;
    --accent-hover: #918bff;
    --accent-soft: rgba(124, 117, 255, 0.14);
    --accent-text: #a9a4ff;
    --danger: #f25b5b;
    --danger-hover: #ff7474;
    --danger-soft: rgba(242, 91, 91, 0.12);
    --warn: #f0b04a;
    --warn-soft: rgba(240, 176, 74, 0.1);
    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, 0.1);
    --focus: 0 0 0 3px rgba(124, 117, 255, 0.3);
    --shadow-sm: none;
    --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #0c0d10;
  --surface: #131519;
  --surface-2: #171a1f;
  --hover: #1c1f25;
  --border: #252932;
  --border-strong: #333845;
  --text: #eceef2;
  --text-2: #a4abb8;
  --text-3: #6c7382;
  --accent: #7c75ff;
  --accent-hover: #918bff;
  --accent-soft: rgba(124, 117, 255, 0.14);
  --accent-text: #a9a4ff;
  --danger: #f25b5b;
  --danger-hover: #ff7474;
  --danger-soft: rgba(242, 91, 91, 0.12);
  --warn: #f0b04a;
  --warn-soft: rgba(240, 176, 74, 0.1);
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.1);
  --focus: 0 0 0 3px rgba(124, 117, 255, 0.3);
  --shadow-sm: none;
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

/* ==========================================================================
   Base
   ========================================================================== */

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

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
p {
  margin: 0;
}

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

a {
  color: var(--accent-text);
}

.icon {
  flex-shrink: 0;
  display: block;
}

.muted {
  color: var(--text-2);
}

.small {
  font-size: 12px;
}

.mono {
  font-family: var(--mono);
  font-size: 13px;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.align-right {
  text-align: right;
}

.spacer {
  flex: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 500;
  font-size: 13.5px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--hover);
  color: var(--text);
}

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

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

.btn-danger-text {
  color: var(--danger);
}

.btn-danger-text:hover:not(:disabled) {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
}

.btn-block {
  width: 100%;
  height: 38px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 0;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}

.icon-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.icon-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent-text);
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}

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

/* ==========================================================================
   Forms
   ========================================================================== */

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.input {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.12s, box-shadow 0.12s;
  min-width: 0;
}

.input::placeholder {
  color: var(--text-3);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}

textarea.input {
  height: auto;
  padding: 8px 11px;
  resize: vertical;
  min-height: 64px;
}

.select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a91a0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  cursor: pointer;
}

.input-auto {
  width: auto;
  min-width: 170px;
}

.input-code {
  font-family: var(--mono);
  font-size: 20px;
  letter-spacing: 0.3em;
  text-align: center;
  height: 46px;
}

.input-group {
  display: flex;
  align-items: center;
  gap: 2px;
  position: relative;
}

.input-group .input {
  flex: 1;
}

.hint {
  font-size: 12.5px;
  color: var(--text-3);
}

.hint:empty {
  display: none;
}

.hint-accent {
  color: var(--accent-text);
}

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

.form-error:empty {
  display: none;
}

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

/* Segmented control */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 9px;
  background: var(--hover);
  border: 1px solid var(--border);
  align-self: flex-start;
}

.seg-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 12px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
}

.seg-item:hover {
  color: var(--text);
}

.seg-item[aria-selected='true'] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08), 0 0 0 1px var(--border);
}

.seg-sm .seg-item {
  height: 26px;
  padding: 0 10px;
  font-size: 12.5px;
}

.seg-count {
  font-size: 11.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* Strength meter */
.meter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}

.meter-track {
  flex: 1;
  height: 4px;
  border-radius: 4px;
  background: var(--hover);
  overflow: hidden;
}

.meter-bar {
  height: 100%;
  width: 0;
  border-radius: 4px;
  transition: width 0.2s, background 0.2s;
}

.meter-label {
  font-size: 12px;
  color: var(--text-3);
  min-width: 44px;
  text-align: right;
}

.meter[data-score='1'] .meter-bar { width: 25%; background: var(--danger); }
.meter[data-score='2'] .meter-bar { width: 50%; background: var(--warn); }
.meter[data-score='3'] .meter-bar { width: 75%; background: #65a30d; }
.meter[data-score='4'] .meter-bar { width: 100%; background: var(--success); }

/* Callouts */
.callout {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 11px 13px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
}

.callout:has(> .icon) {
  flex-direction: row;
  align-items: flex-start;
  gap: 9px;
}

.callout > .icon {
  margin-top: 1px;
}

.callout ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text-2);
}

.callout-title {
  font-weight: 600;
}

.callout-warn {
  background: var(--warn-soft);
  border-color: transparent;
  color: var(--warn);
}

.callout-error {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

/* ==========================================================================
   Auth screens
   ========================================================================== */

.auth {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  gap: 20px;
  background: radial-gradient(ellipse 80% 50% at 50% -10%, var(--accent-soft), transparent 70%), var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px 28px 28px;
}

.auth-card h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.auth-card > p {
  margin-bottom: 24px;
}

.auth-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  margin-bottom: 20px;
  box-shadow: 0 6px 16px -4px rgba(79, 70, 229, 0.5);
}

.auth-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
}

/* ==========================================================================
   Shell
   ========================================================================== */

.shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 12px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
}

.nav,
.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--hover);
  color: var(--text);
}

.nav-item[aria-current='page'] {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.nav-label {
  flex: 1;
}

.nav-count {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.nav-item[aria-current='page'] .nav-count {
  color: inherit;
  opacity: 0.8;
}

.main {
  min-width: 0;
  padding: 28px 36px 64px;
  max-width: 1180px;
  width: 100%;
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 20px;
}

.topbar-row,
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar h1 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  width: 280px;
}

.search > .icon {
  position: absolute;
  left: 11px;
  color: var(--text-3);
  pointer-events: none;
}

.search-input {
  padding-left: 34px;
  padding-right: 34px;
}

.search-input::-webkit-search-cancel-button {
  display: none;
}

.kbd {
  position: absolute;
  right: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0 6px;
  line-height: 18px;
  background: var(--surface-2);
  pointer-events: none;
}

.search-input:focus + .kbd,
.search-input:not(:placeholder-shown) + .kbd {
  display: none;
}

/* ==========================================================================
   Cards, lists
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.list {
  overflow: hidden;
}

.list-meta {
  font-size: 12.5px;
  color: var(--text-2);
  margin: 0 2px 10px;
}

.list-head {
  padding: 10px 18px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.pw-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.6fr) minmax(0, 1.2fr) 72px;
  gap: 16px;
  align-items: center;
}

.sub-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.2fr) 96px 72px;
  gap: 16px 24px;
  align-items: center;
}

.cell-name {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.name-stack {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 550;
  min-width: 0;
}

.sub {
  font-size: 12.5px;
  color: var(--text-3);
}

.cell-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 13.5px;
  flex-shrink: 0;
}

/* Logos sit on a white tile in both themes so dark or transparent icons stay visible. */
.avatar-img {
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--border);
}

.avatar-img img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.av-0 { background: #eef0ff; color: #4338ca; }
.av-1 { background: #e8f8f0; color: #047857; }
.av-2 { background: #fff1e6; color: #c2410c; }
.av-3 { background: #fdf0f7; color: #be185d; }
.av-4 { background: #eaf2ff; color: #1d4ed8; }
.av-5 { background: #f4f0ff; color: #6d28d9; }
.av-6 { background: #e6f7f5; color: #0f766e; }
.av-7 { background: #fdf8e3; color: #a16207; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .av-0 { background: rgba(99, 102, 241, 0.16); color: #a5b4fc; }
  :root:not([data-theme='light']) .av-1 { background: rgba(16, 185, 129, 0.14); color: #6ee7b7; }
  :root:not([data-theme='light']) .av-2 { background: rgba(249, 115, 22, 0.14); color: #fdba74; }
  :root:not([data-theme='light']) .av-3 { background: rgba(236, 72, 153, 0.14); color: #f9a8d4; }
  :root:not([data-theme='light']) .av-4 { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
  :root:not([data-theme='light']) .av-5 { background: rgba(139, 92, 246, 0.16); color: #c4b5fd; }
  :root:not([data-theme='light']) .av-6 { background: rgba(20, 184, 166, 0.14); color: #5eead4; }
  :root:not([data-theme='light']) .av-7 { background: rgba(234, 179, 8, 0.14); color: #fde047; }
}

:root[data-theme='dark'] .av-0 { background: rgba(99, 102, 241, 0.16); color: #a5b4fc; }
:root[data-theme='dark'] .av-1 { background: rgba(16, 185, 129, 0.14); color: #6ee7b7; }
:root[data-theme='dark'] .av-2 { background: rgba(249, 115, 22, 0.14); color: #fdba74; }
:root[data-theme='dark'] .av-3 { background: rgba(236, 72, 153, 0.14); color: #f9a8d4; }
:root[data-theme='dark'] .av-4 { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
:root[data-theme='dark'] .av-5 { background: rgba(139, 92, 246, 0.16); color: #c4b5fd; }
:root[data-theme='dark'] .av-6 { background: rgba(20, 184, 166, 0.14); color: #5eead4; }
:root[data-theme='dark'] .av-7 { background: rgba(234, 179, 8, 0.14); color: #fde047; }

.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--hover);
  color: var(--text-2);
  flex-shrink: 0;
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  margin-left: 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  background: var(--warn-soft);
  color: var(--warn);
  vertical-align: 1px;
}

.date-label {
  white-space: nowrap;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* Password buckets */
.bucket + .bucket {
  border-top: 1px solid var(--border);
}

.bucket-head {
  padding: 11px 18px;
  cursor: pointer;
  transition: background 0.1s;
}

.bucket-head:hover {
  background: var(--surface-2);
}

.bucket-head:focus-visible {
  box-shadow: inset var(--focus);
}

.cell-user {
  color: var(--text-2);
}

.chev {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--text-3);
  transition: transform 0.15s;
}

.bucket.open .chev {
  transform: rotate(180deg);
}

.hover-only {
  opacity: 0;
}

.bucket-head:hover .hover-only,
.sub-row:hover .hover-only,
.hover-only:focus-visible {
  opacity: 1;
}

.bucket-body {
  display: none;
  padding: 0 18px 12px 62px;
  flex-direction: column;
  gap: 8px;
}

.bucket.open .bucket-body {
  display: flex;
}

.bucket.open .bucket-head {
  background: var(--surface-2);
}

.bucket.open .bucket-body {
  background: var(--surface-2);
}

.entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px 10px 14px;
}

.entry-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.4fr) minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.kv {
  min-width: 0;
}

.kv .k {
  font-size: 11.5px;
  color: var(--text-3);
  margin-bottom: 1px;
}

.kv .v {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 30px;
  min-width: 0;
}

.kv .v > .truncate {
  margin-right: 2px;
}

.pw-value {
  letter-spacing: 0.08em;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  margin-right: 2px;
}

.pw-value.revealed {
  letter-spacing: 0.02em;
  color: var(--text);
  user-select: all;
}

.entry-actions {
  display: flex;
  gap: 2px;
}

.entry-notes {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 13px;
  color: var(--text-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Subscriptions */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  padding: 14px 16px;
  min-width: 0;
}

.stat-label {
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 500;
}

.stat-value {
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 4px 0 2px;
  font-variant-numeric: tabular-nums;
}

.stat-extra {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-3);
}

.sub-row {
  padding: 11px 18px;
  cursor: pointer;
  transition: background 0.1s;
}

.sub-row + .sub-row {
  border-top: 1px solid var(--border);
}

.sub-row:hover {
  background: var(--surface-2);
}

.sub-row:focus-visible {
  box-shadow: inset var(--focus);
}

.sub-row.is-inactive .cell-name,
.sub-row.is-inactive .amount {
  opacity: 0.6;
}

.amount {
  font-weight: 550;
  font-variant-numeric: tabular-nums;
}

.due-soon {
  color: var(--warn);
  font-weight: 500;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-active {
  background: var(--success-soft);
  color: var(--success);
}

.status-paused {
  background: var(--hover);
  color: var(--text-2);
}

.status-cancelled {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Empty state */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 64px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-text);
  margin-bottom: 16px;
}

.empty h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.empty p {
  max-width: 380px;
}

.empty-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

/* ==========================================================================
   Settings
   ========================================================================== */

.settings-section {
  max-width: 760px;
  margin-bottom: 28px;
}

.settings-head {
  margin-bottom: 10px;
}

.settings-head h2 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 18px;
}

.settings-row + .settings-row {
  border-top: 1px solid var(--border);
}

.settings-text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
}

.settings-label {
  font-weight: 550;
  font-size: 14px;
  margin-bottom: 2px;
}

.settings-control {
  flex-shrink: 0;
}

.settings-version {
  max-width: 760px;
  color: var(--text-3);
  font-family: var(--mono);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.steps {
  margin: 0;
  padding-left: 20px;
  color: var(--text-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.totp-setup {
  display: flex;
  gap: 20px;
  align-items: center;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.qr {
  background: #fff;
  border-radius: 10px;
  padding: 6px;
  line-height: 0;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.qr img {
  width: 168px;
  height: 168px;
}

.totp-key {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.totp-key .k {
  font-size: 12px;
  color: var(--text-3);
}

.secret {
  font-size: 14px;
  line-height: 1.6;
  word-spacing: 0.2em;
  overflow-wrap: anywhere;
}

/* ==========================================================================
   Import
   ========================================================================== */

.import-help {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.import-help .small {
  display: flex;
  align-items: center;
  gap: 5px;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 28px 16px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-3);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.12s, background 0.12s;
}

.dropzone:hover,
.dropzone.drag {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone:focus-within {
  box-shadow: var(--focus);
}

.drop-title {
  color: var(--text);
  font-weight: 550;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.import-result {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.import-result:empty {
  display: none;
}

.preview {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.preview-label {
  font-size: 12px;
  color: var(--text-3);
  padding: 7px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.preview-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 8px 12px;
  font-size: 13px;
}

.preview-row + .preview-row {
  border-top: 1px solid var(--border);
}

/* ==========================================================================
   Modal & toasts
   ========================================================================== */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: rgba(10, 12, 18, 0.45);
  backdrop-filter: blur(2px);
  overflow-y: auto;
  animation: fade 0.12s ease-out;
}

.modal {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: pop 0.14s ease-out;
}

.modal-sm {
  max-width: 400px;
}

.modal-lg {
  max-width: 600px;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 0;
}

.modal-head h2 {
  font-size: 16px;
  font-weight: 600;
}

.modal-head p {
  font-size: 13px;
  margin-top: 2px;
}

.modal-head .icon-btn {
  margin: -4px -6px 0 0;
}

.modal-body {
  padding: 18px 20px 20px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.push-left {
  margin-right: auto;
}

.confirm-text {
  color: var(--text-2);
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.985);
  }
}

#toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 380px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: #15171c;
  color: #f2f3f5;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: pop 0.16s ease-out;
  transition: opacity 0.35s, transform 0.35s;
}

.toast-success .icon {
  color: #4ade80;
}

.toast-error .icon {
  color: #f87171;
}

.toast-info .icon {
  color: #a5b4fc;
}

.toast-out {
  opacity: 0;
  transform: translateY(4px);
}

:root[data-theme='dark'] .toast {
  background: #262a33;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .toast {
    background: #262a33;
  }
}

/* ==========================================================================
   Subscriptions: payments to log, variable amounts, history
   ========================================================================== */

.nav-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 11.5px;
  font-weight: 600;
  display: inline-grid;
  place-items: center;
  font-variant-numeric: tabular-nums;
}

.pending {
  margin-bottom: 16px;
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  overflow: hidden;
}

.pending-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  background: var(--accent-soft);
}

.pending-icon {
  color: var(--accent-text);
  margin-top: 1px;
}

.pending-title {
  font-weight: 600;
}

.pending-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
}

.money-input {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.money-input:focus-within {
  border-color: var(--accent);
  box-shadow: var(--focus);
}

.currency-tag {
  padding: 0 8px;
  font-size: 12px;
  color: var(--text-3);
  border-right: 1px solid var(--border);
  align-self: stretch;
  display: grid;
  place-items: center;
  background: var(--surface-2);
}

.money-input .input {
  border: 0;
  box-shadow: none;
  height: 32px;
  border-radius: 0;
}

.money-input .input:focus {
  box-shadow: none;
}

.input-amount {
  width: 110px;
  font-variant-numeric: tabular-nums;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.check input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.check > span {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.check-title {
  font-size: 13px;
  font-weight: 500;
}

.history {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.history-head h3 {
  font-size: 13.5px;
  font-weight: 600;
}

.history-list {
  display: flex;
  flex-direction: column;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.history-list > .muted.small {
  padding: 12px;
}

.history-row {
  display: grid;
  grid-template-columns: 110px auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 6px 8px 6px 12px;
  font-size: 13px;
}

.history-row + .history-row {
  border-top: 1px solid var(--border);
}

.history-date {
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}

.history-tags {
  display: flex;
  gap: 6px;
  min-width: 0;
}

.history-add {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.history-add > .input {
  width: auto;
}

.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

/* ==========================================================================
   Analytics
   ========================================================================== */

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

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

.card-head h2 {
  font-size: 14.5px;
  font-weight: 600;
}

.card-total {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.chart-card {
  margin-bottom: 16px;
}

.chart-body {
  padding: 8px 18px 14px;
  min-height: 120px;
}

.chart-wrap {
  position: relative;
}

.chart {
  display: block;
  overflow: visible;
}

.chart .grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart .axis {
  stroke: var(--border-strong);
  stroke-width: 1;
}

.chart .tick {
  fill: var(--text-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart .peak {
  fill: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
}

.chart .bar {
  fill: var(--accent);
  transition: opacity 0.12s;
}

.chart .bar-current {
  opacity: 0.45;
}

.chart .bar.hover {
  opacity: 0.8;
}

.chart .bar-current.hover {
  opacity: 0.6;
}

.chart .hit {
  fill: transparent;
  outline: none;
}

.chart .hit:focus-visible {
  fill: var(--accent-soft);
}

.chart-tip {
  position: absolute;
  z-index: 5;
  min-width: 160px;
  max-width: 240px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
  font-size: 12.5px;
}

.chart-tip.show {
  opacity: 1;
}

.tip-value {
  font-size: 15px;
  font-weight: 650;
}

.tip-label {
  color: var(--text-2);
  margin-bottom: 4px;
}

.tip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.chart-empty {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 4px;
  padding: 36px 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.chart-note {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 18px 14px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-weight: 500;
  font-size: 12px;
  color: var(--text-3);
}

.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.list-card .card-empty {
  padding: 8px 18px 18px;
}

.share-list,
.upcoming-list {
  display: flex;
  flex-direction: column;
  padding: 6px 18px 14px;
}

.share-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
}

.share-main {
  flex: 1;
  min-width: 0;
}

.share-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.share-amount {
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.share-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 5px;
}

.share-track {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--hover);
  overflow: hidden;
}

.share-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
}

.share-pct {
  width: 34px;
  text-align: right;
  font-size: 11.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.upcoming-row {
  display: grid;
  grid-template-columns: 96px auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 7px 0;
  font-size: 13px;
}

.upcoming-row + .upcoming-row {
  border-top: 1px solid var(--border);
}

.upcoming-date {
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.delta {
  font-weight: 500;
}

.delta-up {
  color: var(--danger);
}

.delta-down {
  color: var(--success);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1024px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .main {
    padding: 24px 24px 64px;
  }
}

@media (max-width: 760px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: auto;
    z-index: 40;
    flex-direction: row;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--border);
  }

  .brand,
  .sidebar-foot .nav-item:last-child {
    display: none;
  }

  .nav {
    flex-direction: row;
    flex: 1;
  }

  .sidebar-foot {
    margin: 0;
    padding: 0 0 0 6px;
    border-top: 0;
    border-left: 1px solid var(--border);
  }

  .nav-item {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    height: 50px;
    font-size: 11px;
  }

  .nav-count {
    display: none;
  }

  .main {
    padding: 18px 16px 96px;
  }

  .topbar-row {
    flex-wrap: wrap;
  }

  .topbar-row .btn-secondary {
    display: none;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar .spacer {
    display: none;
  }

  .search {
    width: 100%;
  }

  .kbd {
    display: none;
  }

  .hide-sm {
    display: none;
  }

  .pw-grid {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .sub-grid {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .list-head {
    display: none;
  }

  .hover-only {
    opacity: 1;
  }

  .bucket-body {
    padding: 0 12px 12px;
  }

  .entry-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .entry-actions {
    justify-content: flex-end;
    border-top: 1px solid var(--border);
    padding-top: 6px;
  }

  .settings-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .totp-setup {
    flex-direction: column;
    align-items: center;
  }

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

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

  .pending-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .pending-row .money-input {
    grid-column: 1 / 3;
  }

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

  .history-row .history-tags {
    grid-column: 1 / -1;
    order: 5;
  }

  .upcoming-row {
    grid-template-columns: 70px auto minmax(0, 1fr) auto;
  }

  #toasts {
    left: 16px;
    right: 16px;
    bottom: 84px;
    align-items: stretch;
  }
}
