﻿:root {
  color-scheme: light;
  --bg: #f5f4f1;
  --bg-accent: #e6e1d9;
  --card: #ffffff;
  --ink: #1b1b1d;
  --placeholder: #8a8a94;
  --muted: #6b6b72;
  --shadow: 0 20px 60px rgba(20, 20, 30, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-ui: "Inter", "Inter Tight", "Inter Display";
  --font-title: "Quicksand", "Inter", "Inter Tight", "Inter Display";
}

* {
  box-sizing: border-box;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  background: radial-gradient(circle at top, #f7f0e7 0%, var(--bg) 45%, var(--bg-accent) 100%);
  color: var(--ink);
}

.app {
  min-height: 100vh;
  padding: 24px 18px 40px;
  max-width: 540px;
  margin: 0 auto;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

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

.icon-link {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.05);
  color: var(--ink);
  text-decoration: none;
  border: none;
  padding: 0;
}

.icon-link svg {
  width: 18px;
  height: 18px;
}

.icon-link--primary {
  background: var(--ink);
  color: #ffffff;
}

.icon-link--ghost {
  background: rgba(0, 0, 0, 0.05);
  color: var(--ink);
}

.title-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.app-title {
  font-family: var(--font-title);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.app-subtitle {
  font-size: 14px;
  color: var(--muted);
}

.summary-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  backdrop-filter: blur(6px);
}

.settings-card {
  background: var(--card);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-title {
  font-weight: 800;
  font-size: 14px;
}

.settings-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.settings-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.06);
  margin: 16px 0;
}

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

.file-input {
  max-width: 240px;
}

.settings-status {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.summary-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.summary-value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 8px;
}

.filter-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-lg);
  padding: 6px;
  gap: 8px;
  box-shadow: 0 10px 30px rgba(20, 20, 30, 0.08);
}

.sort-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 24px rgba(20, 20, 30, 0.06);
}

.sort-row label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sort-row select {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  background: #fff;
  font-family: inherit;
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 10px 12px;
  border-radius: 999px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.tab-btn.active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(20, 20, 30, 0.1);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 20px;
}

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  border-left: 6px solid var(--brand, #d4d4d8);
  animation: slideUp 0.35s ease;
}

.card.is-inactive {
  background: #f2f2f2;
  border-left-color: #cfcfd6;
  box-shadow: 0 14px 40px rgba(20, 20, 30, 0.08);
}

.card.is-inactive .card-title,
.card.is-inactive .card-sub,
.card.is-inactive .card-cost strong,
.card.is-inactive .card-cost span {
  color: #8a8a94;
}

.card.is-inactive .logo {
  background: rgba(0, 0, 0, 0.03);
  color: #8a8a94;
}

.card.is-inactive .logo img {
  filter: grayscale(1) saturate(0.2);
  opacity: 0.7;
}

.card-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-title {
  font-weight: 700;
  font-size: 16px;
}

.card-sub {
  color: var(--muted);
  font-size: 13px;
}

.card-cost {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-cost strong {
  white-space: nowrap;
}

.card-cost strong {
  font-size: 16px;
}

.card-cost span {
  color: var(--muted);
  font-size: 12px;
}

.logo {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.06);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-weight: 700;
  color: #1d1d1f;
}

.logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.empty-icon-btn {
  width: 64px;
  height: 64px;
  border-radius: 22px;
  background: rgba(0, 0, 0, 0.05);
  display: inline-grid;
  place-items: center;
  border: none;
  cursor: pointer;
  margin: 0 auto 16px;
  font-size: 28px;
  color: var(--ink);
}

.empty-title {
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

.attribution {
  margin-top: 24px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}

.attribution a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}

.primary-btn,
.ghost-btn,
.icon-btn,
.danger-btn {
  border: none;
  border-radius: 999px;
  padding: 0 16px;
  font-weight: 600;
  cursor: pointer;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}


.primary-btn {
  background: #1b1b1d;
  color: #fff;
}

.ghost-btn {
  background: rgba(0, 0, 0, 0.05);
  color: var(--ink);
}

.small-btn {
  padding: 8px 12px;
  font-size: 12px;
}

.icon-btn {
  background: rgba(0, 0, 0, 0.05);
  color: var(--ink);
}

.danger-btn {
  margin-top: 12px;
  background: #ffefef;
  color: #c0392b;
  width: 100%;
}

.form-footer {
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

.danger-link {
  background: none;
  border: none;
  padding: 0;
  color: #c0392b;
  font-size: 12px;
  text-decoration: underline;
  text-decoration-color: rgba(192, 57, 43, 0.3);
  cursor: pointer;
}

.mini-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

.mini-modal.open {
  display: flex;
}

.mini-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 16, 20, 0.35);
  backdrop-filter: blur(6px);
}

.mini-modal-sheet {
  position: relative;
  width: min(92vw, 460px);
  background: var(--card);
  border-radius: 22px;
  padding: 20px;
  box-shadow: var(--shadow);
  z-index: 1;
}

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

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}

.modal.open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 16, 20, 0.4);
  backdrop-filter: blur(8px);
}

.modal-sheet {
  position: relative;
  width: min(100%, 560px);
  background: var(--card);
  border-radius: 30px 30px 0 0;
  border-top: 4px solid var(--modal-brand, transparent);
  padding: 16px 16px 18px;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s ease;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-header--center {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 12px;
}

.modal-header--with-toggle {
  grid-template-columns: 40px 1fr auto 40px;
}

.modal-header--center .modal-title {
  text-align: center;
}

.modal-subtitle {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: 0.02em;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 20px;
}

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

.general-grid {
  display: grid;
  grid-template-columns: 1fr 40px;
  gap: 10px;
  align-items: end;
}

.general-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.logo-field label {
  display: none;
}

.form-section + .form-section {
  margin-top: 14px;
}

.form-section--status {
  margin-top: 20px;
}

.form-section--financial {
  margin-top: 32px !important;
}

.section-title {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  height: 40px;
  background: #fff;
}

.input-group:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}

.input-prefix {
  color: var(--muted);
  font-size: 16px;
  font-weight: 400;
}

.input-group input {
  border: none;
  padding: 0;
  height: 100%;
  flex: 1;
  background: transparent;
  outline: none;
}

.field-help {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
}

.card-sub.renewal {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.renewal-icon {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
}

.renewal-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.segment-btn {
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.segment-btn.active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 6px 16px rgba(20, 20, 30, 0.08);
}

.custom-cycle {
  background: rgba(0, 0, 0, 0.04);
  border-radius: var(--radius-sm);
  padding: 10px;
  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.25s ease, transform 0.35s ease;
}

.custom-cycle.is-open {
  max-height: 200px;
  opacity: 1;
  transform: translateY(0);
  margin-top: 6px;
}

.custom-cycle-row {
  display: grid;
  grid-template-columns: 30% 70%;
  gap: 10px;
}

.cycle-preview {
  font-size: 12px;
  color: var(--muted);
}

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

.subtle-link {
  align-self: flex-start;
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  text-decoration: underline;
  text-decoration-color: rgba(0, 0, 0, 0.15);
  cursor: pointer;
}

.logo-thumb.is-clickable {
  cursor: pointer;
  user-select: none;
}

.two-col {
  display: grid;
  grid-template-columns: 45% 55%;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 12px;
  color: var(--muted);
}

.field input::placeholder,
.field textarea::placeholder,
.field select::placeholder {
  color: var(--placeholder);
  font-weight: 400;
}

.field-primary input {
  font-size: 18px;
  font-weight: 600;
  height: 46px;
  border-color: rgba(27, 27, 29, 0.2);
}

.field input,
.field textarea,
.field select {
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 16px;
  font-family: inherit;
  font-weight: 400;
  color: var(--ink);
  height: 40px;
  line-height: 1.2;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
}

.field .input-group input {
  border: none;
  padding: 0;
  height: 100%;
}

.field select {
  text-align-last: left;
}

.field input[type="date"] {
  line-height: 1.2;
}

.field input[type="color"] {
  padding: 0;
  height: 42px;
  width: 100%;
}

.field input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.field input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: var(--radius-sm);
}

.field input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: var(--radius-sm);
}

.logo-preview {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-top: 0;
}

.logo-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.06);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-weight: 700;
  color: #1d1d1f;
}

.logo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.logo-thumb.has-image img {
  display: block;
}

.logo-thumb.has-image span {
  display: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.form-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  justify-content: flex-start;
}

.status-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.header-actions-inline .status-label {
  font-size: 12px;
  color: var(--muted);
}

.status-label {
  font-size: 14px;
  color: var(--ink);
}

.switch {
  position: relative;
  width: 46px;
  height: 26px;
  display: inline-flex;
  align-items: center;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.1);
  transition: background 0.2s ease;
}

.switch-track::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.switch input:checked + .switch-track {
  background: var(--ink);
}

.switch input:checked + .switch-track::before {
  transform: translateX(20px);
}

.spacer {
  flex: 1;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 370px) {
  .summary-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .modal-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .logo-thumb {
    width: 72px;
    height: 72px;
  }

  .form-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .mini-modal-sheet {
    width: min(92vw, 380px);
  }

  .card {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
  }

  .card-cost {
    grid-column: span 2;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}
