/* =========================================================
   Global Reset & Theme Variables
========================================================= */
:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning: #f59e0b;
  --info: #0284c7;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border-color: #e2e8f0;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.09);
  --font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* =========================================================
   Navbar (Desktop & Mobile Header)
========================================================= */
.navbar {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.brand-icon {
  font-size: 1.6rem;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--primary-light);
  padding: 2px 7px;
  border-radius: 9999px;
  margin-left: 2px;
}

.nav-tabs {
  display: flex;
  gap: 0.4rem;
  background: #f1f5f9;
  padding: 4px;
  border-radius: var(--radius-md);
}

.nav-tab {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-tab:hover {
  color: var(--text-main);
}

.nav-tab.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  background: var(--bg-main);
  padding: 5px 10px;
  border-radius: 9999px;
  border: 1px solid var(--border-color);
}

/* =========================================================
   Mobile Bottom Navigation (모바일 최적화)
========================================================= */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 64px;
  background: #ffffff;
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
  z-index: 60;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  height: 100%;
  transition: all 0.15s ease;
}

.bottom-nav-item i {
  font-size: 1.25rem;
}

.bottom-nav-item.active {
  color: var(--primary);
}

.bottom-nav-item.active i {
  transform: translateY(-2px);
}

@media (max-width: 768px) {
  .desktop-only {
    display: none !important;
  }
  .mobile-bottom-nav {
    display: flex;
  }
  body {
    padding-bottom: 74px; /* Space for bottom nav */
  }
  .nav-container {
    height: 54px;
  }
  .brand-subtitle {
    display: none;
  }
}

/* =========================================================
   Layout & Container
========================================================= */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem 1rem;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* =========================================================
   Buttons & Inputs
========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.825rem;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
}

.btn-secondary {
  background-color: #64748b;
  color: white;
}
.btn-secondary:hover {
  background-color: #475569;
}

.btn-danger {
  background-color: var(--danger);
  color: white;
}
.btn-danger:hover {
  background-color: #b91c1c;
}

.btn-outline-danger {
  background: transparent;
  border-color: #fca5a5;
  color: var(--danger);
}
.btn-outline-danger:hover {
  background-color: var(--danger-bg);
}

.btn-outline {
  background: white;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background-color: #f1f5f9;
}

.btn-success {
  background-color: var(--success);
  color: white;
}
.btn-success:hover {
  background-color: #15803d;
}

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

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 500px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }
}

.label-with-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

.form-group label, .label-with-action label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

/* 오늘 날짜 즉시 세팅 뱃지 버튼 */
.btn-today-badge {
  background: #e0e7ff;
  color: var(--primary);
  border: 1px solid #c7d2fe;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-today-badge:hover {
  background: #c7d2fe;
}

.form-input, .form-textarea, .form-select-sm {
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.95rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: white;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.card-header {
  padding: 0.9rem 1.15rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 1.15rem;
}

/* =========================================================
   Auth Section
========================================================= */
.auth-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 160px);
}

.auth-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
}

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

.auth-logo {
  font-size: 2.75rem;
  margin-bottom: 0.4rem;
}

.auth-header h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.3rem;
}

.auth-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.auth-tabs {
  display: flex;
  background: #f1f5f9;
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 1.25rem;
}

.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.auth-tab.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.input-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon-wrap i {
  position: absolute;
  left: 12px;
  color: var(--text-light);
  font-size: 0.95rem;
}

.input-icon-wrap input {
  padding-left: 36px;
  width: 100%;
  padding-top: 10px;
  padding-bottom: 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
}

.input-icon-wrap input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.alert-danger {
  background-color: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecaca;
}

/* =========================================================
   Sheet Toolbar
========================================================= */
.sheet-toolbar, .calendar-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  background: white;
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}

.sheet-selector-group, .calendar-select-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.sheet-select-label, .cal-select-label {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 5px;
}

.sheet-select {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: #f8fafc;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
  max-width: 220px;
}

/* =========================================================
   ⭐ TOP DASHBOARD (핵심 합계금액 대시보드) ⭐
========================================================= */
.summary-dashboard {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 850px) {
  .summary-dashboard {
    grid-template-columns: 1fr;
  }
}

.summary-card {
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.total-balance-card {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  color: white;
  border: none;
  box-shadow: 0 8px 20px rgba(49, 46, 129, 0.22);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.total-balance-card .summary-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #c7d2fe;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 0.35rem;
}

.summary-amount-main {
  font-size: 2.35rem;
  font-weight: 800;
  letter-spacing: -1px;
  color: #ffffff;
  margin-bottom: 0.2rem;
  word-break: break-all;
}

@media (max-width: 600px) {
  .summary-amount-main {
    font-size: 1.95rem;
  }
}

.summary-amount-main.positive { color: #38bdf8; }
.summary-amount-main.negative { color: #f87171; }

.summary-status {
  font-size: 0.8rem;
  color: #a5b4fc;
}

.summary-sub-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.summary-sub-cards .summary-card {
  padding: 0.9rem 1rem;
}

.summary-card.count-card {
  grid-column: span 2;
}

.summary-sub-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 0.3rem;
}

.sub-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
}

.income-icon { background-color: var(--success-bg); color: var(--success); }
.expense-icon { background-color: var(--danger-bg); color: var(--danger); }
.count-icon { background-color: #f0f9ff; color: #0284c7; }

.sub-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.summary-amount-sub {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.text-income { color: var(--success); }
.text-expense { color: var(--danger); }
.text-count { color: #0284c7; }

/* =========================================================
   Entry Input Panel
========================================================= */
.entry-input-card {
  border-top: 4px solid var(--primary);
}

.hint-badge {
  font-size: 0.75rem;
  color: var(--primary);
  background: var(--primary-light);
  padding: 3px 8px;
  border-radius: 9999px;
  font-weight: 500;
}

.entry-form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.flex-date {
  flex: 1.2;
  min-width: 150px;
}

.flex-2 {
  flex: 2;
  min-width: 200px;
}

.amount-input-group {
  display: flex;
  gap: 0.4rem;
}

.type-toggle-btns {
  display: flex;
  background: #f1f5f9;
  border-radius: var(--radius-sm);
  padding: 2px;
}

.btn-toggle {
  border: none;
  background: transparent;
  padding: 8px 10px;
  font-size: 0.825rem;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-toggle.income.active {
  background: #2563eb;
  color: white;
}

.btn-toggle.expense.active {
  background: var(--danger);
  color: white;
}

.amount-field {
  font-weight: 700;
  font-size: 1.05rem;
}

.label-sub {
  font-size: 0.75rem;
  font-weight: normal;
  color: var(--text-muted);
}

.quick-amounts-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: -0.25rem;
}

.quick-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.btn-chip {
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
}

.btn-chip-reset {
  color: var(--text-muted);
  border-style: dashed;
}

.form-submit-wrap {
  margin-left: auto;
}

@media (max-width: 600px) {
  .flex-date, .flex-2, .form-submit-wrap {
    flex: 1 1 100%;
    min-width: 100%;
  }
}

/* =========================================================
   Entry Table
========================================================= */
.table-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.table-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sheet-desc-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 2px 7px;
  border-radius: 4px;
}

.table-filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-pills {
  display: flex;
  background: #f1f5f9;
  border-radius: var(--radius-sm);
  padding: 2px;
}

.pill {
  border: none;
  background: transparent;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
}

.pill.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  background-color: #f8fafc;
  padding: 10px 14px;
  font-size: 0.825rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 12px 14px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.badge-tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge-income { background-color: #dbeafe; color: #1d4ed8; }
.badge-expense { background-color: #fee2e2; color: #b91c1c; }

.amount-cell {
  font-size: 0.975rem;
  font-weight: 700;
  text-align: right;
}

.amount-income { color: #1d4ed8; }
.amount-expense { color: #dc2626; }

.actions-cell {
  text-align: center;
  white-space: nowrap;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  font-size: 0.85rem;
}

.btn-icon:hover { color: var(--text-main); background-color: #e2e8f0; }
.btn-icon.delete:hover { color: var(--danger); background-color: var(--danger-bg); }

.empty-table-msg {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* =========================================================
   Memos View
========================================================= */
.memo-options-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border-color);
}

.color-picker-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.color-picker-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.color-choices {
  display: flex;
  gap: 6px;
}

.color-dot {
  position: relative;
  cursor: pointer;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.color-dot input {
  position: absolute;
  opacity: 0;
}

.color-dot span {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.1);
  transition: transform 0.15s;
}

.color-dot.yellow span { background: #fef08a; }
.color-dot.pink span { background: #fbcfe8; }
.color-dot.blue span { background: #bae6fd; }
.color-dot.green span { background: #bbf7d0; }
.color-dot.purple span { background: #e9d5ff; }
.color-dot.white span { background: #f8fafc; border-color: #cbd5e1; }

.color-dot input:checked + span {
  transform: scale(1.2);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px white, 0 0 0 4px var(--primary);
}

.custom-checkbox {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}

.memo-search-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  gap: 0.75rem;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  max-width: 350px;
}

.search-input-wrap i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
}

.search-input-wrap input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  outline: none;
  background: white;
  font-family: inherit;
  font-size: 0.875rem;
}

.memo-count-badge {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.memos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.memo-card {
  border-radius: var(--radius-md);
  padding: 1.15rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid rgba(0, 0, 0, 0.08);
  min-height: 160px;
  position: relative;
}

.memo-pinned-badge {
  position: absolute;
  top: 10px;
  right: 12px;
  color: #d97706;
  font-size: 0.85rem;
}

.memo-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  padding-right: 18px;
  word-break: break-all;
}

.memo-body {
  font-size: 0.9rem;
  color: #334155;
  white-space: pre-wrap;
  word-break: break-all;
  flex-grow: 1;
  margin-bottom: 0.75rem;
}

.memo-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding-top: 0.6rem;
  font-size: 0.72rem;
  color: #64748b;
}

/* =========================================================
   ⭐ SHARED CALENDAR (회원별 공유 캘린더) ⭐
========================================================= */
.cal-nav-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.cal-current-month {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
  min-width: 110px;
  text-align: center;
}

.shared-cal-banner {
  background: linear-gradient(135deg, #e0e7ff 0%, #ede9fe 100%);
  border: 1px solid #c7d2fe;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: #3730a3;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.calendar-container {
  padding: 0.5rem;
  background: white;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
  background: #f8fafc;
  border-radius: 6px 6px 0 0;
}

.weekday.sun { color: #dc2626; }
.weekday.sat { color: #2563eb; }

.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(90px, 1fr);
  border-top: 1px solid var(--border-color);
}

@media (max-width: 600px) {
  .calendar-days-grid {
    grid-auto-rows: minmax(70px, 1fr);
  }
}

.calendar-day-cell {
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 4px;
  display: flex;
  flex-direction: column;
  background: white;
  cursor: pointer;
  transition: background-color 0.15s;
  overflow: hidden;
}

.calendar-day-cell:nth-child(7n) {
  border-right: none;
}

.calendar-day-cell:hover {
  background-color: #f8fafc;
}

.calendar-day-cell.other-month {
  background-color: #fbfcfe;
  opacity: 0.45;
}

.calendar-day-cell.today {
  background-color: #eef2ff;
}

.calendar-day-cell.today .day-number {
  background: var(--primary);
  color: white;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}

.day-number {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}

.day-cell-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  max-height: 80px;
}

/* 캘린더 내 일정 칩 */
.cal-event-chip {
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.cal-event-author {
  font-size: 0.65rem;
  background: rgba(0,0,0,0.25);
  padding: 1px 4px;
  border-radius: 3px;
}

/* 공유 멤버 목록 */
.share-invite-box {
  background: #f8fafc;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 1rem;
}

.input-with-btn {
  display: flex;
  gap: 0.5rem;
  margin-top: 4px;
  margin-bottom: 4px;
}

.member-list-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.member-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.member-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.member-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.member-role-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.role-owner { background: #e0e7ff; color: #4338ca; }
.role-member { background: #f1f5f9; color: #64748b; }

.event-detail-banner {
  background: #f1f5f9;
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border-left: 4px solid var(--primary);
}

.event-detail-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.event-detail-meta {
  font-size: 0.825rem;
  color: var(--text-muted);
}

.event-detail-content {
  font-size: 0.95rem;
  white-space: pre-wrap;
  line-height: 1.6;
  min-height: 60px;
}

/* =========================================================
   Modals & Toasts
========================================================= */
.empty-state-card {
  text-align: center;
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 3rem 1.5rem;
  box-shadow: var(--shadow-sm);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}

.empty-state-card h3 {
  font-size: 1.2rem;
  margin-bottom: 0.4rem;
}

.empty-state-card p {
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-box {
  background: white;
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalIn 0.2s ease-out;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
}

.modal-footer {
  padding: 0.8rem 1.25rem;
  background-color: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.toast-container {
  position: fixed;
  bottom: 74px; /* above mobile nav */
  right: 16px;
  left: 16px;
  max-width: 400px;
  margin: 0 auto;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.toast {
  background: #1e293b;
  color: white;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.toast.success { background-color: #065f46; border-left: 4px solid #10b981; }
.toast.error { background-color: #991b1b; border-left: 4px solid #ef4444; }

/* =========================================================
   Admin Styles (관리자 전용 스타일)
========================================================= */
.btn-dark {
  background-color: #0f172a;
  color: white;
  border: 1px solid #334155;
}
.btn-dark:hover {
  background-color: #1e293b;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.25);
}

.btn-link {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 8px;
}
.btn-link:hover {
  color: var(--primary);
}

.auth-footer-link {
  text-align: center;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.admin-section {
  max-width: 1200px;
  margin: 0 auto;
}

.admin-header-bar {
  background: white;
  padding: 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
  border-top: 4px solid #0f172a;
}

.admin-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #0f172a;
  color: #f8fafc;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  width: fit-content;
}

.admin-header-bar h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
}

.admin-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* 관리자 통계 카드 그리드 */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
}

.users-icon { background: #e0e7ff; color: #4338ca; }
.sheets-icon { background: #dcfce7; color: #15803d; }
.memos-icon { background: #fef9c3; color: #a16207; }

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-val {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
}

.admin-search-wrap {
  position: relative;
  min-width: 240px;
}

.admin-search-wrap i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 0.85rem;
}

.admin-search-wrap input {
  width: 100%;
  padding: 6px 12px 6px 32px;
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  font-size: 0.85rem;
  outline: none;
}

.admin-search-wrap input:focus {
  border-color: var(--primary);
}

.target-user-info {
  background: #f1f5f9;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  border-left: 4px solid var(--primary);
}

.badge-count {
  background: #f1f5f9;
  padding: 2px 7px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
  margin-right: 4px;
}

/* =========================================================
   만원 단위 체크박스 & 실시간 환산 미리보기
========================================================= */
.unit-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #eef2ff;
  color: #4338ca;
  padding: 2px 9px;
  border-radius: 9999px;
  border: 1px solid #c7d2fe;
  cursor: pointer;
  user-select: none;
  font-size: 0.8rem;
  transition: all 0.15s ease;
}

.unit-checkbox-label:hover {
  background: #e0e7ff;
}

.unit-checkbox-label input[type="checkbox"] {
  accent-color: #4f46e5;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.unit-text {
  font-size: 0.825rem;
  font-weight: 700;
  color: #3730a3;
}

.amount-calc-preview {
  margin-top: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.amount-calc-preview.preview-income {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.amount-calc-preview.preview-expense {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* =========================================================
   Store Management & User Profile Styles
========================================================= */
.user-badge.clickable {
  cursor: pointer;
  transition: all 0.15s ease;
}

.user-badge.clickable:hover {
  background-color: var(--primary-light);
  border-color: #c7d2fe;
}

.store-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 600px) {
  .store-stats-grid {
    grid-template-columns: 1fr;
  }
}

.store-stat-icon {
  background: #fdf2f8;
  color: #db2777;
}

.machine-stat-icon {
  background: #f0fdf4;
  color: #16a34a;
}

.store-create-card {
  border-top: 4px solid #059669;
}

/* =========================================================
   카테고리별 총 합계 요약 카드 (Category Summary Breakdown)
========================================================= */
.category-summary-card {
  margin-bottom: 1.25rem;
  border: 1px solid #e2e8f0;
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.category-summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #f1f5f9;
  flex-wrap: wrap;
  gap: 8px;
}

.category-summary-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  color: var(--text-main);
}

.category-summary-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.category-summary-body {
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  min-height: 52px;
}

.category-summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  padding: 8px 14px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  user-select: none;
}

.category-summary-chip:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  transform: translateY(-1px);
}

.category-summary-chip.active {
  background: #e0e7ff;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

.category-summary-chip .chip-cat-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-summary-chip .chip-machines {
  font-weight: 800;
  font-size: 0.95rem;
  color: #16a34a;
  background: #dcfce7;
  padding: 2px 8px;
  border-radius: 9999px;
}

.category-summary-chip .chip-stores {
  font-size: 0.78rem;
  font-weight: 600;
  color: #475569;
  background: #e2e8f0;
  padding: 2px 7px;
  border-radius: 9999px;
}

.category-summary-chip.is-total {
  background: #f0fdf4;
  border-color: #86efac;
}

.category-summary-chip.is-total:hover {
  background: #dcfce7;
  border-color: #4ade80;
}

.category-summary-chip.is-total.active {
  background: #bbf7d0;
  border-color: #16a34a;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.2);
}

.category-summary-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 4px 0;
}

.badge-filter-total {
  display: inline-flex;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: #16a34a;
  background: #dcfce7;
  border: 1px solid #bbf7d0;
  padding: 4px 10px;
  border-radius: 9999px;
  margin-left: 6px;
}

.table-summary-row {
  background: #f8fafc;
  border-top: 2px solid var(--border-color);
}

/* 카테고리 관리 칩 목록 */
.category-list-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: #f8fafc;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  min-height: 50px;
}

.category-item-chip {
  background: white;
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

.category-item-chip .chip-name {
  color: var(--text-main);
}

.category-item-chip .chip-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 9999px;
}

.btn-delete-chip {
  background: transparent;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  line-height: 1;
}

.btn-delete-chip:hover {
  color: var(--danger);
}

/* 내 정보 프로필 카드 */
.profile-info-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: #f8fafc;
  padding: 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.profile-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
}

.profile-details h4 {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.profile-details p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.form-sub-heading {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border-color);
}

/* =========================================================
   32 Colors Palette Styles (32색상 팔레트)
========================================================= */
.profile-color-section {
  margin-bottom: 1.5rem;
  background: white;
  border: 1px solid var(--border-color);
  padding: 1.15rem;
  border-radius: var(--radius-sm);
}

.color-setting-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.color-palette-32 {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  margin-bottom: 0.75rem;
}

@media (max-width: 500px) {
  .color-palette-32 {
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
  }
}

.color-swatch-btn {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  outline: none;
}

.color-swatch-btn:hover {
  transform: scale(1.2);
  z-index: 2;
}

.color-swatch-btn.selected {
  transform: scale(1.15);
  border-color: #0f172a;
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #0f172a;
  z-index: 3;
}

.current-selected-color-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.color-preview-badge, .selected-color-tag {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
  display: inline-block;
  box-shadow: var(--shadow-sm);
}

.ml-auto {
  margin-left: auto;
}




