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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: #f0f4f8;
  color: #1a202c;
  min-height: 100vh;
}

/* ---- Auth page (login/register) ---- */

body.page-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10);
  width: 100%;
  max-width: 420px;
  padding: 2rem 2rem 2.5rem;
}

.auth-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-logo h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: #2b6cb0;
  letter-spacing: -0.5px;
}

.auth-logo p {
  font-size: 0.9rem;
  color: #718096;
  margin-top: 0.25rem;
}

.auth-tabs {
  display: flex;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 1.5rem;
}

.auth-tab {
  flex: 1;
  padding: 0.65rem 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  color: #718096;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.auth-tab:hover { color: #2b6cb0; }

.auth-tab.active {
  color: #2b6cb0;
  border-bottom-color: #2b6cb0;
}

.auth-panel { display: none; }
.auth-panel.active { display: block; }

/* ---- Shared form elements ---- */

.form-group { margin-bottom: 1.1rem; }

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid #cbd5e0;
  border-radius: 8px;
  font-size: 1rem;
  color: #1a202c;
  background: #f7fafc;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  font-family: inherit;
}

textarea {
  resize: vertical;
  min-height: 70px;
}

input:focus, textarea:focus {
  outline: none;
  border-color: #3182ce;
  box-shadow: 0 0 0 3px rgba(49,130,206,0.15);
  background: #fff;
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 0.75rem;
  background: #2b6cb0;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 1.5rem;
  transition: background 0.15s;
  min-height: 48px;
}

.btn-primary:hover { background: #2c5282; }
.btn-primary:disabled { background: #a0aec0; cursor: not-allowed; }

.btn-secondary {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  background: #e2e8f0;
  color: #2d3748;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  min-height: 36px;
}

.btn-secondary:hover { background: #cbd5e0; }

.form-error {
  display: none;
  background: #fff5f5;
  color: #c53030;
  border: 1px solid #feb2b2;
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.form-error.visible { display: block; }

/* ---- App shell (dashboard + manage + onboarding) ---- */

.app-header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.app-header .app-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #2b6cb0;
  flex: 1;
}

.app-header .header-user {
  font-size: 0.875rem;
  color: #718096;
}

.app-header a, .app-header button.link-btn {
  font-size: 0.875rem;
  color: #2b6cb0;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.app-header a:hover, .app-header button.link-btn:hover {
  text-decoration: underline;
}

.app-content {
  max-width: 680px;
  margin: 0 auto;
  padding: 1.25rem 1rem;
}

/* ---- Action bar ---- */

.action-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.action-btn {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  background: #2b6cb0;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
  white-space: nowrap;
}

.action-btn:hover { background: #2c5282; }

.action-btn-secondary {
  background: #e2e8f0;
  color: #2d3748;
}

.action-btn-secondary:hover { background: #cbd5e0; }

.dash-version {
  font-size: 0.7rem;
  color: #a0aec0;
  align-self: center;
}

.action-bar-divider {
  width: 1px;
  height: 28px;
  background: #e2e8f0;
  margin: 0 0.25rem;
}

.cat-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.cat-btn {
  padding: 0.5rem 1.1rem;
  border: 1.5px solid #cbd5e0;
  border-radius: 20px;
  background: #f7fafc;
  font-size: 0.875rem;
  font-weight: 600;
  color: #4a5568;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}

.cat-btn:hover {
  border-color: #2b6cb0;
  color: #2b6cb0;
}

.cat-btn.active {
  background: #2b6cb0;
  border-color: #2b6cb0;
  color: #fff;
}

/* ---- Back button ---- */

.back-btn {
  display: inline-block;
  margin-bottom: 0.75rem;
  padding: 0.4rem 0.9rem;
  background: none;
  border: 1.5px solid #cbd5e0;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #4a5568;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}

.back-btn:hover {
  border-color: #2b6cb0;
  color: #2b6cb0;
}

.brand-watermark {
  margin-left: 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #a0aec0;
  letter-spacing: 0.02em;
}

/* ---- Days bar ---- */

.days-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #718096;
  margin-bottom: 1rem;
}

.days-bar input[type="number"] {
  width: 52px;
  padding: 0.25rem 0.4rem;
  font-size: 0.85rem;
}

/* ---- Account button grid ---- */

.account-btn-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.account-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #fff;
  border: 1.5px solid #cbd5e0;
  border-radius: 10px;
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
  min-width: 140px;
}

.account-btn:hover {
  border-color: #2b6cb0;
  box-shadow: 0 2px 8px rgba(43,108,176,0.12);
  background: #ebf8ff;
}

.account-btn .acct-btn-priority-input {
  width: 30px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #a0aec0;
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 1px 3px;
  text-align: center;
  flex-shrink: 0;
  -moz-appearance: textfield;
  box-shadow: none;
  outline: none;
}
.account-btn .acct-btn-priority-input:focus {
  border-color: #2b6cb0;
  color: #2b6cb0;
  background: #fff;
}
.account-btn .acct-btn-priority-input::-webkit-inner-spin-button,
.account-btn .acct-btn-priority-input::-webkit-outer-spin-button { -webkit-appearance: none; }

.acct-name-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.acct-btn-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: #2b6cb0;
}

.acct-btn-sub {
  font-size: 0.78rem;
  color: #718096;
  margin-top: 0.15rem;
}

.acct-btn-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: #a0aec0;
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
}
.acct-btn-delete:hover { color: #e53e3e; }

/* Priority input in manage page */
.priority-input {
  width: 52px;
  padding: 0.25rem 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #4a5568;
  border: 1.5px solid #cbd5e0;
  border-radius: 6px;
  background: #f7fafc;
  text-align: center;
  -moz-appearance: textfield;
}
.priority-input:focus {
  border-color: #3182ce;
  outline: none;
  background: #fff;
}
.priority-input::-webkit-inner-spin-button,
.priority-input::-webkit-outer-spin-button { -webkit-appearance: none; }

.priority-ctrl {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.priority-arrows {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.priority-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 18px;
  padding: 0;
  font-size: 0.6rem;
  line-height: 1;
  background: #edf2f7;
  border: 1px solid #cbd5e0;
  border-radius: 4px;
  cursor: pointer;
  color: #4a5568;
  transition: background 0.15s;
}
.priority-arrow:hover {
  background: #bee3f8;
  border-color: #90cdf4;
  color: #2b6cb0;
}

/* ---- Add account box ---- */

.add-box {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.add-box h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 0.75rem;
}

.detected-handle {
  font-size: 0.85rem;
  color: #2b6cb0;
  font-weight: 600;
  min-height: 1.2em;
  margin-top: 0.35rem;
  margin-bottom: 0.5rem;
}

.optional-fields {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.optional-fields input {
  flex: 1;
}

/* ---- Show/hide password ---- */

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 3.8rem;
}

.show-pwd-btn {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: #718096;
  padding: 0.2rem 0.3rem;
  line-height: 1;
}

.show-pwd-btn:hover { color: #2b6cb0; }

/* ---- Textarea with clear button ---- */

.textarea-wrap {
  position: relative;
}

.textarea-wrap textarea {
  padding-right: 2.2rem;
}

.clear-textarea-btn {
  display: none;
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  width: 1.5rem;
  height: 1.5rem;
  align-items: center;
  justify-content: center;
  background: #e2e8f0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: #4a5568;
  transition: background 0.12s;
}

.clear-textarea-btn:hover { background: #cbd5e0; }

/* ---- Category tiles ---- */

.cat-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.cat-tile {
  padding: 0.45rem 0.9rem;
  border: 1.5px solid #cbd5e0;
  border-radius: 20px;
  background: #f7fafc;
  font-size: 0.875rem;
  font-weight: 600;
  color: #4a5568;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}

.cat-tile:hover {
  border-color: #2b6cb0;
  color: #2b6cb0;
}

.cat-tile.selected, .cat-tile:focus {
  background: #2b6cb0;
  border-color: #2b6cb0;
  color: #fff;
  outline: none;
}

.cat-tile:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.cat-tiles-label {
  font-size: 0.8rem;
  color: #718096;
  margin-top: 0.5rem;
}

/* ---- Account list ---- */

.account-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.account-row {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.account-row .reorder-btns {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.reorder-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #a0aec0;
  font-size: 0.75rem;
  line-height: 1;
  padding: 1px 3px;
  border-radius: 3px;
  transition: color 0.12s;
}

.reorder-btn:hover { color: #2b6cb0; }

.account-info {
  flex: 1;
  min-width: 0;
}

.account-handle a {
  font-weight: 700;
  color: #2b6cb0;
  text-decoration: none;
  font-size: 0.95rem;
}

.account-handle a:hover { text-decoration: underline; }

.account-meta {
  font-size: 0.8rem;
  color: #718096;
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 12px;
  background: #ebf8ff;
  color: #2b6cb0;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.account-actions {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #a0aec0;
  font-size: 0.95rem;
  padding: 4px 6px;
  border-radius: 5px;
  transition: color 0.12s, background 0.12s;
  line-height: 1;
}

.icon-btn:hover { color: #2d3748; background: #edf2f7; }
.icon-btn.danger:hover { color: #c53030; background: #fff5f5; }

/* ---- Inline edit form ---- */

.inline-edit {
  display: none;
  border-top: 1px solid #e2e8f0;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
}

.inline-edit.open { display: block; }

.inline-edit .edit-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.inline-edit .edit-row input {
  flex: 1;
  min-width: 120px;
}

.inline-edit .save-btn {
  padding: 0.4rem 0.9rem;
  background: #2b6cb0;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.inline-edit .save-btn:hover { background: #2c5282; }
.inline-edit .cancel-btn {
  padding: 0.4rem 0.9rem;
  background: #e2e8f0;
  color: #2d3748;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

/* ---- Onboarding ---- */

.onboarding-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10);
  width: 100%;
  max-width: 500px;
  margin: 2rem auto;
  padding: 2rem;
}

.onboarding-card h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #2b6cb0;
  margin-bottom: 0.5rem;
}

.onboarding-card .intro {
  color: #4a5568;
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.cat-add-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.cat-add-row input { flex: 1; }

.cat-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 36px;
  margin-bottom: 1.5rem;
}

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  background: #ebf8ff;
  color: #2b6cb0;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
}

.cat-chip .remove-cat {
  background: none;
  border: none;
  cursor: pointer;
  color: #718096;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.cat-chip .remove-cat:hover { color: #c53030; }

/* ---- Manage page sections ---- */

.section-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.1rem;
  margin-bottom: 1.25rem;
}

.section-card h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 1rem;
}

.manage-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f7fafc;
}

.manage-row:last-child { border-bottom: none; }

.manage-row .row-label {
  flex: 1;
  font-size: 0.9rem;
}

.manage-row .row-label strong { color: #2b6cb0; }
.manage-row .row-meta { font-size: 0.8rem; color: #718096; }

.inline-rename {
  display: none;
  flex: 1;
}

.inline-rename.open { display: flex; gap: 0.4rem; }
.inline-rename input { flex: 1; padding: 0.35rem 0.6rem; font-size: 0.875rem; }

/* ---- Empty state ---- */

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: #a0aec0;
  font-size: 0.9rem;
}

/* ---- Responsive ---- */

@media (max-width: 480px) {
  body.page-auth {
    align-items: flex-start;
    background: #fff;
  }

  .auth-card {
    padding: 1.5rem 1.25rem 2rem;
    border-radius: 0;
    box-shadow: none;
    min-height: 100vh;
  }

  .optional-fields {
    flex-direction: column;
  }

  .account-meta {
    max-width: 160px;
  }
}
