:root {
  --bg: #f6f9f7;
  --card: #fff;
  --line: #d8e2dd;
  --text: #1f2a24;
  --main: #2f855a;
  --brand: #2f8f3a;
  --danger: #c0392b;
  --content-width: 1280px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.6;
}

.container,
.layout {
  width: min(var(--content-width), 100% - 32px);
  margin: 0 auto;
}

.site-header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.nav-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 12px 0;
}

.site-header a {
  color: var(--text);
  text-decoration: none;
}

.site-header h1 {
  flex: 0 0 auto;
  margin: 0;
}

.main-nav {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.nav-link,
.nav-dropdown-toggle,
.nav-menu-toggle {
  border: 1px solid transparent;
  border-radius: 10px;
  background: #edf2ef;
  color: #0f1f16;
  padding: 9px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.2;
  min-height: 40px;
  white-space: nowrap;
}

.nav-link:hover,
.nav-link:focus-visible,
.nav-dropdown-toggle:hover,
.nav-dropdown-toggle:focus-visible,
.nav-menu-toggle:hover,
.nav-menu-toggle:focus-visible {
  background: #e1eee7;
  border-color: #bdd7c8;
  color: #12351f;
  outline: none;
}

.nav-dropdown {
  position: relative;
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 1100;
  display: none;
  min-width: 190px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(31, 42, 36, 0.14);
}

.nav-dropdown-menu-right {
  right: 0;
  left: auto;
}

.nav-dropdown-menu a {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}

.nav-dropdown-menu a:hover,
.nav-dropdown-menu a:focus-visible {
  background: #eef8f1;
  color: var(--main);
  outline: none;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu,
.nav-dropdown.is-open .nav-dropdown-menu {
  display: block;
}

.logout-link {
  background: var(--danger);
  color: #fff !important;
}

.logout-link:hover,
.logout-link:focus-visible {
  background: #a93226;
  color: #fff !important;
}

.nav-menu-toggle {
  display: none;
}

.brand {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  white-space: nowrap;
}

.brand-title {
  color: var(--brand);
  font-size: 1.2rem;
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.2;
}

.brand-subtitle {
  color: #607268;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
}

.site-header nav a {
  white-space: nowrap;
}

.site-footer {
  text-align: center;
  color: #607268;
  font-size: 13px;
  padding: 20px 0 30px;
}

main {
  padding: 16px 0 52px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 14px;
}

.narrow { max-width: 560px; margin: 20px auto; }

h2, h3 {
  margin: 0 0 12px;
  line-height: 1.4;
}

h2 {
  font-size: 1.35rem;
  border-left: 4px solid var(--main);
  padding-left: 10px;
}

h3 { font-size: 1.1rem; }

.card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-title-row h3 {
  margin-bottom: 0;
}

.description {
  color: #43544b;
  font-size: 0.98rem;
}

.stack label {
  display: block;
  margin-bottom: 14px;
  font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
select,
textarea,
input[type="file"] {
  width: 100%;
  margin-top: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
  background: #fff;
}

.file-upload-field {
  cursor: pointer;
}

.file-upload-box {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  border: 1px dashed #9fc9b0;
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(47, 133, 90, 0.12), rgba(255, 255, 255, 0.96)),
    #f7fbf8;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.file-upload-field:hover .file-upload-box,
.file-upload-field:focus-within .file-upload-box {
  border-color: var(--main);
  box-shadow: 0 10px 24px rgba(47, 133, 90, 0.14);
  transform: translateY(-1px);
}

.file-upload-box input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  opacity: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.file-upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 46px;
  padding: 12px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--main), #44a86f);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(47, 133, 90, 0.24);
}


.file-upload-box.has-file {
  border-color: #2f855a;
  background:
    linear-gradient(135deg, rgba(47, 133, 90, 0.2), rgba(232, 248, 239, 0.98)),
    #eef9f2;
}

.file-upload-box.has-file .file-upload-button {
  background: linear-gradient(135deg, #1f6f46, #2f855a);
}

.file-upload-box.has-file .file-upload-button::before {
  content: "✅";
}

.file-upload-box.has-file .file-upload-note {
  color: #1f6f46;
  font-weight: 800;
}

.file-upload-button::before {
  content: "📷";
  font-size: 1.1rem;
  line-height: 1;
}

.file-upload-note {
  color: #43544b;
  font-size: 0.95rem;
  font-weight: 600;
}

.file-upload-preview {
  display: grid;
  gap: 8px;
  margin-top: -6px;
  padding: 12px;
  border: 1px solid rgba(47, 133, 90, 0.28);
  border-radius: 14px;
  background: #f2fbf5;
}

.file-upload-preview[hidden] {
  display: none;
}

.file-upload-preview-badge {
  width: fit-content;
  padding: 4px 10px;
  border-radius: 999px;
  background: #2f855a;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
}

.file-upload-preview-image {
  max-width: 240px;
  max-height: 180px;
  border-radius: 12px;
  object-fit: contain;
  background: #fff;
  border: 1px solid rgba(47, 133, 90, 0.18);
}

.file-upload-preview-name {
  color: #1f6f46;
  font-weight: 800;
  overflow-wrap: anywhere;
}

@media (max-width: 560px) {
  .file-upload-box {
    align-items: stretch;
    flex-direction: column;
  }

  .file-upload-button {
    width: 100%;
  }
}

textarea { min-height: 110px; }

button,
.btn {
  border: none;
  border-radius: 10px;
  background: #edf2ef;
  color: #0f1f16;
  padding: 14px 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  min-height: 48px;
}

.primary { background: var(--main); color: #fff; }
.danger { background: var(--danger); color: #fff; }
.site-header nav a.danger,
.site-header nav a.danger:hover,
.site-header nav a.danger:focus-visible {
  color: #fff;
}
.small { padding: 9px 10px; font-size: 0.92rem; min-height: 40px; white-space: nowrap; }

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

/* Dashboard menu */
.dashboard-menu-section > h3 {
  margin-bottom: 18px;
}

.dashboard-quick-actions h4,
.dashboard-menu-card h4 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.4;
}

.dashboard-quick-actions h4 {
  margin-bottom: 10px;
}

.dashboard-quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.dashboard-quick-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 0;
  min-height: 52px;
  padding: 12px 16px;
  border: 1px solid #28754f;
  border-radius: 10px;
  background: var(--main);
  color: #fff;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.dashboard-quick-action:hover,
.dashboard-quick-action:focus-visible {
  background: #276f4b;
  border-color: #205f40;
}

.dashboard-quick-action:focus-visible,
.dashboard-menu-link:focus-visible {
  outline: 3px solid rgba(47, 133, 90, 0.3);
  outline-offset: 2px;
}

.dashboard-quick-action-icon {
  flex: 0 0 auto;
  font-size: 1.15rem;
  line-height: 1;
}

.dashboard-menu-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.dashboard-menu-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid #cfe1d6;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(31, 42, 36, 0.04);
}

.dashboard-menu-card h4 {
  margin-bottom: 12px;
  color: #245f42;
}

.dashboard-menu-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dashboard-menu-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #e0ebe4;
  border-radius: 8px;
  background: #f5faf7;
  color: var(--text);
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  overflow-wrap: anywhere;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.dashboard-menu-link:hover,
.dashboard-menu-link:focus-visible {
  border-color: #a8cdb7;
  background: #eaf5ee;
  color: #1f6b46;
}

.dashboard-menu-link span:last-child {
  flex: 0 0 auto;
  color: var(--main);
  font-size: 1.35rem;
  line-height: 1;
}

@media (max-width: 1023px) {
  .dashboard-menu-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  .dashboard-quick-actions-grid,
  .dashboard-menu-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-menu-card {
    padding: 14px;
  }
}

.list { list-style: none; padding: 0; margin: 0; }
.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 12px 0;
  gap: 12px;
}

.inline-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-actions form { margin: 0; }

.table-wrap { overflow-x: auto; }

.floating-table-scrollbar {
  display: none;
  position: fixed;
  right: 0;
  bottom: 0;
  z-index: 30;
  height: 18px;
  overflow-x: auto;
  overflow-y: hidden;
  background: rgba(246, 249, 245, 0.94);
  border-top: 1px solid var(--line);
  box-shadow: 0 -2px 8px rgba(34, 73, 49, 0.08);
}

.floating-table-scrollbar.is-visible { display: block; }

.floating-table-scrollbar > div {
  height: 1px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.97rem;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}

th { font-size: 0.92rem; color: #425248; white-space: nowrap; }

.diary-table th:nth-child(1),
.diary-table td:nth-child(1) { width: 64px; }
.diary-table th:nth-child(2),
.diary-table td:nth-child(2) { width: 110px; }
.diary-table th:nth-child(3),
.diary-table td:nth-child(3) { width: 100px; }
.diary-table th:nth-child(4),
.diary-table td:nth-child(4),
.diary-table th:nth-child(5),
.diary-table td:nth-child(5),
.diary-table th:nth-child(6),
.diary-table td:nth-child(6) { width: 96px; }
.diary-table th:nth-child(8),
.diary-table td:nth-child(8),
.diary-table th:nth-child(9),
.diary-table td:nth-child(9) { width: 140px; }
.diary-table th:nth-child(10),
.diary-table td:nth-child(10) { width: 190px; }

.cell-note {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-form {
  background: #f8fbf9;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin: 16px 0;
}

.search-form h3 {
  margin-bottom: 10px;
}

.month-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.filter-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.filter-grid label {
  font-weight: 700;
}

.search-actions {
  margin-top: 14px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px 12px;
}

.detail-grid dt { font-weight: 700; }
.detail-grid dd { margin: 0; }

.account-detail {
  margin-top: 16px;
  padding: 14px;
  background: #fbfdfc;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.form-help {
  display: block;
  margin-top: 6px;
  color: #607268;
  font-size: 0.9rem;
  font-weight: 400;
}

.message-list {
  margin: 0;
  padding-left: 1.2rem;
}

.photo-box img {
  width: 100%;
  max-width: 380px;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.alert {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 12px;
  font-weight: 600;
}

.alert.success { background: #e8f6ee; color: #1f6b46; }
.alert.error { background: #fdeceb; color: #9b2c21; }

@media (max-width: 767px) {
  body { font-size: 16px; }
  .layout,
  .container { width: 100%; padding: 0 14px; }
  .nav-wrap {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
  }
  .brand-heading {
    min-width: 0;
  }
  .brand {
    max-width: 100%;
    white-space: normal;
  }
  .brand-title { font-size: 1.08rem; }
  .brand-subtitle { font-size: 0.72rem; }
  .nav-menu-toggle {
    display: inline-flex;
    margin-left: auto;
  }
  .main-nav {
    display: none;
    flex: 1 1 100%;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 8px;
    padding-top: 4px;
  }
  .main-nav.is-open {
    display: flex;
  }
  .nav-link,
  .nav-dropdown-toggle {
    width: 100%;
    justify-content: space-between;
    padding: 11px 12px;
    min-height: 44px;
    white-space: normal;
  }
  .nav-dropdown-menu {
    position: static;
    display: block;
    width: 100%;
    min-width: 0;
    margin-top: 6px;
    padding: 6px 6px 6px 16px;
    border-radius: 10px;
    box-shadow: none;
    background: #fbfdfc;
  }
  .nav-dropdown-menu a {
    padding: 9px 10px;
    white-space: normal;
  }
  .site-header .btn { white-space: nowrap; }
  .small { padding: 10px 12px; font-size: 0.94rem; min-height: 42px; }

  .button-row > * {
    flex: 1 1 calc(50% - 6px);
  }

  .button-row > form {
    flex: 1 1 100%;
  }

  .list li {
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 0;
  }

  .inline-actions {
    width: 100%;
  }

  .inline-actions .btn,
  .inline-actions button {
    flex: 1 1 calc(50% - 6px);
  }

  .detail-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .table-wrap { overflow: visible; }
  .diary-table,
  .diary-table thead,
  .diary-table tbody,
  .diary-table tr,
  .diary-table th,
  .diary-table td {
    display: block;
    width: 100%;
  }

  .diary-table thead { display: none; }

  .diary-table tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    padding: 8px 10px;
    margin-bottom: 10px;
  }

  .diary-table td {
    border-bottom: 1px dashed #dbe4de;
    padding: 9px 0;
  }

  .diary-table td:last-child { border-bottom: none; }

  .diary-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    color: #486054;
    margin-bottom: 2px;
  }

  .diary-table td.actions-cell {
    padding-top: 12px;
  }

  .diary-table td.actions-cell::before {
    margin-bottom: 8px;
  }
}

.form-label {
  display: block;
  margin: 0 0 8px;
  font-weight: 700;
}

.photo-edit-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
  background: #fbfdfc;
}

.current-photo {
  margin-bottom: 12px;
}

.checkbox-label {
  display: flex !important;
  gap: 8px;
  align-items: center;
  font-weight: 600;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.diary-photo,
.diary-photo-preview {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.diary-photo {
  max-height: 70vh;
  object-fit: contain;
}

.diary-photo-preview {
  max-height: 280px;
  object-fit: contain;
}

.diary-thumbnail {
  display: block;
  width: 80px;
  height: 80px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
}

input[type="number"] {
  width: 100%;
  margin-top: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
  background: #fff;
}

.summary-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin: 14px 0;
}

.summary-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdfc;
  padding: 14px;
}

.summary-card--month {
  border-color: #c7def8;
  background: #eef6ff;
}

.summary-card span {
  display: block;
  color: #607268;
  font-size: 0.92rem;
  margin-bottom: 4px;
}

.summary-card strong {
  color: var(--main);
  font-size: 1.35rem;
}

/* Dashboard financial summary */
.dashboard-summary-description {
  margin: 4px 0 20px;
  color: #52645a;
}

.dashboard-summary-group + .dashboard-summary-group {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid #e1e9e4;
}

.dashboard-summary-group-title {
  margin: 0 0 12px;
  padding-left: 10px;
  border-left: 4px solid var(--main);
  color: #245f42;
  font-size: 1rem;
  line-height: 1.4;
}

.dashboard-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.dashboard-summary-card {
  display: flex;
  min-width: 0;
  min-height: 116px;
  flex-direction: column;
  justify-content: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(31, 42, 36, 0.035);
}

.dashboard-summary-card--sales {
  border-color: #c8ded1;
}

.dashboard-summary-label {
  color: #52645a;
  font-size: 0.9rem;
  font-weight: 700;
}

.dashboard-summary-value {
  margin-top: 3px;
  color: #33443a;
  font-size: clamp(1.35rem, 2.4vw, 1.65rem);
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.dashboard-summary-card--sales .dashboard-summary-value {
  color: #24704a;
}

.dashboard-summary-card--balance {
  border-left-width: 4px;
}

.dashboard-summary-card--balance.is-positive {
  border-color: #8fc6a5;
  background: #eef8f1;
}

.dashboard-summary-card--balance.is-positive .dashboard-summary-value,
.dashboard-summary-card--balance.is-positive .dashboard-summary-status {
  color: #1f6b46;
}

.dashboard-summary-card--balance.is-negative {
  border-color: #dfa99f;
  background: #fff3f0;
}

.dashboard-summary-card--balance.is-negative .dashboard-summary-value,
.dashboard-summary-card--balance.is-negative .dashboard-summary-status {
  color: #a63227;
}

.dashboard-summary-card--balance.is-zero {
  border-color: #cbd4cf;
  background: #f5f7f6;
}

.dashboard-summary-card--balance.is-zero .dashboard-summary-value,
.dashboard-summary-card--balance.is-zero .dashboard-summary-status {
  color: #52615a;
}

.dashboard-summary-status {
  align-self: flex-start;
  margin-top: 7px;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.3;
}

@media (max-width: 767px) {
  .dashboard-summary-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-summary-card {
    min-height: 104px;
  }
}

.category-summary {
  background: #f8fbf9;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin: 16px 0;
}

.category-summary-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}
.category-summary-header h3,
.category-summary-header p {
  margin: 0;
}
.category-summary-header p {
  color: #607268;
  font-size: 0.94rem;
}

.category-chart-wrap {
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
}

.category-pie-chart {
  display: block;
  width: 220px;
  max-width: 100%;
  height: 220px;
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: 0 8px 22px rgba(31, 42, 36, 0.08);
}

.category-chart-legend,
.category-total-list {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}

.category-chart-legend li,
.category-total-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px dashed #dbe4de;
  padding: 6px 0;
}

.category-chart-legend li {
  justify-content: flex-start;
}

.category-chart-legend strong {
  margin-left: auto;
}

.category-color {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.category-name {
  min-width: 0;
  overflow-wrap: anywhere;
}


.weekday-sales-summary {
  overflow-x: auto;
}

.weekday-bar-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(76px, 1fr));
  align-items: end;
  gap: 12px;
  min-height: 230px;
  padding-top: 8px;
}

.weekday-bar-item {
  display: grid;
  grid-template-rows: 150px auto auto;
  gap: 8px;
  min-width: 0;
  text-align: center;
}

.weekday-bar-track {
  display: flex;
  align-items: end;
  justify-content: center;
  height: 150px;
  border-radius: 12px;
  background: linear-gradient(180deg, #eef6ff 0%, #f8fbf9 100%);
  border: 1px solid #dbe4de;
  overflow: hidden;
}

.weekday-bar {
  display: block;
  width: 58%;
  min-height: 0;
  border-radius: 10px 10px 0 0;
  background: linear-gradient(180deg, #48bb78 0%, var(--main) 100%);
  box-shadow: 0 -4px 14px rgba(47, 133, 90, 0.2);
}

.weekday-bar-item strong {
  color: var(--main);
  font-size: 1.05rem;
}

.weekday-bar-item span {
  color: #607268;
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}


.expense-table th:nth-child(1),
.expense-table td:nth-child(1) { width: 54px; }
.expense-table th:nth-child(2),
.expense-table td:nth-child(2) { width: 108px; }
.expense-table th:nth-child(3),
.expense-table td:nth-child(3),
.expense-table th:nth-child(4),
.expense-table td:nth-child(4),
.expense-table th:nth-child(5),
.expense-table td:nth-child(5),
.expense-table th:nth-child(9),
.expense-table td:nth-child(9),
.expense-table th:nth-child(10),
.expense-table td:nth-child(10) { width: 100px; }
.expense-table th:nth-child(8),
.expense-table td:nth-child(8) { width: 120px; }
.expense-table th:nth-child(11),
.expense-table td:nth-child(11) { width: 190px; }

button:disabled,
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

@media (max-width: 767px) {
  .expense-table,
  .expense-table thead,
  .expense-table tbody,
  .expense-table tr,
  .expense-table th,
  .expense-table td {
    display: block;
    width: 100%;
  }

  .expense-table thead { display: none; }

  .expense-table tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    padding: 8px 10px;
    margin-bottom: 10px;
  }

  .expense-table td {
    border-bottom: 1px dashed #dbe4de;
    padding: 9px 0;
  }

  .expense-table td:last-child { border-bottom: none; }

  .expense-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    color: #486054;
    margin-bottom: 2px;
  }

  .expense-table td.actions-cell {
    padding-top: 12px;
  }
}

.form-grid-3 {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.sale-table {
  min-width: 1500px;
}

.sale-table th:nth-child(1),
.sale-table td:nth-child(1) { width: 108px; }
.sale-table th:nth-child(2),
.sale-table td:nth-child(2),
.sale-table th:nth-child(3),
.sale-table td:nth-child(3),
.sale-table th:nth-child(4),
.sale-table td:nth-child(4),
.sale-table th:nth-child(12),
.sale-table td:nth-child(12),
.sale-table th:nth-child(13),
.sale-table td:nth-child(13) { width: 100px; }
.sale-table th:nth-child(5),
.sale-table td:nth-child(5),
.sale-table th:nth-child(6),
.sale-table td:nth-child(6) { width: 120px; }
.sale-table th:nth-child(7),
.sale-table td:nth-child(7) { width: 110px; }
.sale-table td:nth-child(7) { white-space: nowrap; }
.sale-table th:nth-child(8),
.sale-table td:nth-child(8),
.sale-table th:nth-child(9),
.sale-table td:nth-child(9),
.sale-table th:nth-child(10),
.sale-table td:nth-child(10),
.sale-table th:nth-child(11),
.sale-table td:nth-child(11) { width: 118px; }
.sale-table th:nth-child(14),
.sale-table td:nth-child(14) { width: 190px; }

@media (min-width: 768px) {
  .sale-table tbody td {
    padding-top: 8px;
    padding-bottom: 8px;
    vertical-align: middle;
  }

  .sale-table th:nth-child(15),
  .sale-table td:nth-child(15) { width: 190px; }

  .sale-table .inline-actions {
    flex-wrap: nowrap;
  }
}

@media (max-width: 767px) {
  .sale-table,
  .sale-table thead,
  .sale-table tbody,
  .sale-table tr,
  .sale-table th,
  .sale-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .sale-table thead { display: none; }

  .sale-table tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    padding: 8px 10px;
    margin-bottom: 10px;
  }

  .sale-table td {
    border-bottom: 1px dashed #dbe4de;
    padding: 9px 0;
  }

  .sale-table td:last-child { border-bottom: none; }

  .sale-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    color: #486054;
    margin-bottom: 2px;
  }

  .sale-table td.actions-cell { padding-top: 12px; }
}

.annual-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
}

.year-select-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbf9;
}

.year-select-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 700;
  color: #425248;
}

.year-select-form select {
  min-width: 120px;
  margin-top: 0;
  padding: 12px;
}

.annual-note {
  margin: 14px 0 0;
  background: #fff8e5;
  color: #6b4a00;
  border: 1px solid #ead69a;
}

.annual-summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.annual-summary-card {
  background: linear-gradient(180deg, #fbfdfc 0%, #eef8f1 100%);
}

.annual-summary-card strong {
  font-size: 1.55rem;
}

.amount-negative {
  color: var(--danger) !important;
}

.amount-positive {
  color: var(--main) !important;
}

.annual-table-wrap {
  margin-top: 10px;
}

.annual-table {
  min-width: 760px;
}

.monthly-table {
  min-width: 980px;
}

.annual-table th,
.annual-table td {
  white-space: normal;
}

.mini-bars {
  display: grid;
  gap: 4px;
  min-width: 120px;
}

.mini-bar {
  display: block;
  min-width: 2px;
  height: 8px;
  border-radius: 999px;
}

.mini-bar.sales {
  background: var(--main);
}

.mini-bar.expense {
  background: #d97706;
}

.mini-bar-legend {
  margin-bottom: 0;
}

.legend-sales {
  color: var(--main);
  margin-right: 4px;
}

.legend-expense {
  color: #d97706;
  margin: 0 4px 0 12px;
}

@media (max-width: 767px) {
  .annual-title-row,
  .year-select-form {
    flex-direction: column;
    align-items: stretch;
  }

  .year-select-form label,
  .year-select-form .btn {
    width: 100%;
  }

  .annual-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .annual-table,
  .monthly-table {
    min-width: 760px;
  }

  .annual-summary-card strong {
    font-size: 1.35rem;
  }
}

.export-hero .annual-note {
  margin-top: 14px;
}

.export-form {
  margin-top: 12px;
}

.export-form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.export-form-grid label {
  font-weight: 700;
}

.export-actions {
  margin-top: 18px;
}

.export-note-list {
  margin: 0;
  padding-left: 1.2rem;
}

.export-note-list li {
  margin-bottom: 8px;
}

.annual-export-actions {
  margin-top: 14px;
}

@media (max-width: 767px) {
  .export-form-grid {
    grid-template-columns: 1fr;
  }

  .export-actions .btn,
  .annual-export-actions .btn {
    width: 100%;
  }
}

.auth-card {
  box-shadow: 0 10px 30px rgba(31, 42, 36, 0.06);
}

.auth-form input[type="text"],
.auth-form input[type="password"] {
  min-height: 52px;
}

.auth-actions > button,
.auth-actions > .btn {
  flex: 1 1 190px;
}

.auth-links {
  margin: 18px 0 8px;
  padding: 16px;
  text-align: center;
  background: #f8fbf9;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.auth-links p {
  margin: 0 0 8px;
  color: #43544b;
  font-weight: 700;
}

.auth-links a {
  color: var(--main);
  font-weight: 700;
}

@media (max-width: 767px) {
  .auth-actions > button,
  .auth-actions > .btn {
    flex: 1 1 100%;
  }
}

.admin-hero {
  border-color: #bdd7c8;
  background: linear-gradient(135deg, #ffffff 0%, #f0faf4 100%);
}

.admin-link {
  background: #1f6b46;
  color: #fff !important;
}

.admin-summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.admin-table {
  min-width: 900px;
}

.admin-users-table th:nth-child(1),
.admin-users-table td:nth-child(1) { width: 64px; }
.admin-users-table th:nth-child(3),
.admin-users-table td:nth-child(3) { width: 120px; }
.admin-users-table th:nth-child(6),
.admin-users-table td:nth-child(6),
.admin-users-table th:nth-child(7),
.admin-users-table td:nth-child(7),
.admin-users-table th:nth-child(8),
.admin-users-table td:nth-child(8),
.admin-users-table th:nth-child(9),
.admin-users-table td:nth-child(9),
.admin-users-table th:nth-child(10),
.admin-users-table td:nth-child(10) { width: 72px; }
.admin-users-table th:nth-child(11),
.admin-users-table td:nth-child(11) { width: 90px; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-admin {
  background: #e8f6ee;
  color: #1f6b46;
  border: 1px solid #bdd7c8;
}

.badge-user {
  background: #eef2f0;
  color: #43544b;
  border: 1px solid var(--line);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.admin-detail-grid {
  grid-template-columns: 160px 1fr;
}

@media (max-width: 767px) {
  .table-wrap {
    overflow-x: auto;
  }

  .admin-table {
    min-width: 760px;
  }

  .admin-detail-grid {
    grid-template-columns: 1fr;
  }
}


@media (max-width: 767px) {
  .category-chart-wrap {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .category-chart-legend,
  .category-total-list {
    width: 100%;
    grid-template-columns: 1fr;
  }
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.footer-links a {
  color: #43544b;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.legal-page {
  max-width: 920px;
  margin: 20px auto;
}

.legal-section {
  margin-top: 24px;
}

.legal-section ul {
  margin: 8px 0 0;
  padding-left: 1.4em;
}

.legal-section li + li {
  margin-top: 6px;
}

/* Public guide / FAQ / legal pages */
.eyebrow { color: var(--main); font-weight: 800; letter-spacing: 0.08em; margin: 0 0 8px; }
.public-page { max-width: 1040px; margin: 20px auto; padding: 26px; }
.public-hero { padding: 8px 0 18px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.public-section { margin: 24px 0; }
.public-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.public-card-grid--compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.info-card { border: 1px solid var(--line); border-radius: 14px; background: #fbfdfb; padding: 18px; }
.info-card--wide { grid-column: 1 / -1; }
.step-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 0; list-style: none; }
.step-list li { display: flex; align-items: center; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-weight: 700; }
.step-list span { display: inline-grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px; border-radius: 999px; background: var(--main); color: #fff; }
.notice-box-app { border: 1px solid #f0d36a; border-radius: 12px; background: #fff8df; color: #55440d; padding: 16px; margin: 18px 0; }
.faq-list { display: grid; gap: 12px; }
.faq-card { border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 14px 16px; }
.faq-card summary { cursor: pointer; color: #12351f; font-weight: 800; }
.faq-card p { margin: 10px 0 0; color: #43544b; }
.legal-page .legal-section { padding: 16px 0; border-bottom: 1px solid var(--line); }
.legal-page .legal-section:last-child { border-bottom: 0; }
.auth-guide-links, .footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 16px; margin-top: 18px; }
.auth-guide-links a, .footer-links a { color: var(--main); font-weight: 700; }
.consent-note a { color: var(--main); font-weight: 800; }
.beginner-card { border-color: #b9dbc7; background: linear-gradient(135deg, #ffffff 0%, #f1faf4 100%); }
.onboarding-restore { display: none; margin-top: 8px; }
.onboarding-restore.is-visible { display: inline-flex; }
.onboarding-checklist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 16px 0; }
.onboarding-item { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--text); text-decoration: none; font-weight: 700; }
.onboarding-item:hover, .onboarding-item:focus-visible { border-color: #9cccaf; background: #f6fff8; outline: none; }
.onboarding-item.is-complete { background: #eef8f1; }
.onboarding-status { min-width: 20px; text-align: center; }
.status-badge { border-radius: 999px; padding: 4px 9px; font-size: 0.78rem; font-weight: 800; }
.status-badge.complete { background: #dff3e6; color: #1f6b3b; }
.status-badge.incomplete { background: #edf2ef; color: #607268; }

@media (max-width: 760px) {
  .public-page { padding: 18px; }
  .public-card-grid, .public-card-grid--compact, .step-list, .onboarding-checklist { grid-template-columns: 1fr; }
  .onboarding-item { grid-template-columns: 24px 1fr; }
  .status-badge { grid-column: 2; justify-self: start; }
}

/* Admin operations MVP */
.badge-success { background: #dff3e6; color: #1f6b3b; border: 1px solid #b8dfc6; }
.badge-danger { background: #fde2e2; color: #9f1d1d; border: 1px solid #f3b4b4; }
.btn.danger, button.danger { background: #c62828; color: #fff; border-color: #b71c1c; }
.btn.danger:hover, button.danger:hover { background: #a91f1f; }
.danger-zone { border-color: #f3b4b4; background: #fff8f8; }
.admin-table tr.is-suspended { background: #fff1f1; }
.required { color: #c62828; font-size: 0.85em; font-weight: 800; }
.checkbox-label { display: flex; align-items: center; gap: 8px; padding-top: 26px; }
.contact-form textarea, .danger-zone textarea { width: 100%; }
@media (max-width: 767px) { .admin-summary-grid { grid-template-columns: 1fr; } }

.photo-zoom-trigger {
  display: inline-block;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: zoom-in;
  text-align: left;
}

.photo-zoom-trigger:focus-visible {
  outline: 3px solid rgba(47, 133, 90, 0.45);
  outline-offset: 4px;
  border-radius: 10px;
}

.photo-zoom-hint {
  display: block;
  margin-top: 8px;
  color: #607268;
  font-size: 0.9rem;
  font-weight: 700;
}

.photo-modal[hidden] {
  display: none;
}

.photo-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.photo-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 31, 22, 0.76);
}

.photo-modal-content {
  position: relative;
  z-index: 1;
  max-width: min(1100px, 96vw);
  max-height: 92vh;
}

.photo-modal-image {
  display: block;
  max-width: 100%;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}

.photo-modal-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
}

.photo-modal-close:focus-visible {
  outline: 3px solid rgba(47, 133, 90, 0.65);
  outline-offset: 3px;
}

body.has-photo-modal {
  overflow: hidden;
}

@media (max-width: 767px) {
  .photo-modal {
    padding: 14px;
  }

  .photo-modal-close {
    top: 8px;
    right: 8px;
  }
}

.annual-ai-advice-card {
  border-color: #bfe3cf;
  background: linear-gradient(180deg, #f7fcf9 0%, #ffffff 100%);
}

.ai-advice-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #e1f4ea;
  color: #1f6b3b;
  font-size: 0.85rem;
  font-weight: 800;
  padding: 6px 12px;
}

.ai-advice-list {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

.ai-advice-item {
  border: 1px solid #d8e5dd;
  border-left: 6px solid #6aa57d;
  border-radius: 12px;
  background: #fff;
  padding: 14px 16px;
}

.ai-advice-item h4 {
  margin: 0 0 6px;
  color: #244532;
}

.ai-advice-item p {
  margin: 0;
  color: #43544a;
}

.ai-advice-item--success { border-left-color: #2f855a; }
.ai-advice-item--info { border-left-color: #3182ce; }
.ai-advice-item--warning { border-left-color: #d69e2e; }
.ai-advice-item--danger { border-left-color: #c53030; }

.ai-advice-error {
  margin: 16px 0;
}

.bulk-edit-form {
  margin: 18px 0;
}

.bulk-edit-panel {
  border: 1px solid #bdd7c8;
  border-radius: 14px;
  padding: 18px;
  background: linear-gradient(135deg, #f8fcf9 0%, #eef8f1 100%);
}

.bulk-edit-header h3 {
  margin: 0 0 6px;
}

.bulk-edit-header p {
  margin: 0 0 14px;
  color: #486054;
}

.bulk-edit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.bulk-edit-field {
  margin: 0;
}

.bulk-edit-field select,
.bulk-edit-field input[type="text"] {
  margin-top: 8px;
}

.bulk-edit-actions {
  align-items: center;
  margin-top: 16px;
}

.bulk-selected-count {
  color: #486054;
  font-weight: 700;
}

.table-check-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
}

.table-check-label input[type="checkbox"] {
  width: auto;
  margin: 0;
}

@media (max-width: 767px) {
  .bulk-edit-grid {
    grid-template-columns: 1fr;
  }

  .bulk-edit-actions .btn {
    width: 100%;
  }
}

.bulk-edit-field > .checkbox-label {
  align-items: center;
  border: 1px solid #cfe3d6;
  border-radius: 999px;
  background: #ffffff;
  color: #244532;
  cursor: pointer;
  gap: 10px;
  padding: 9px 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.bulk-edit-field > .checkbox-label:hover,
.table-check-label:hover input[type="checkbox"] {
  border-color: #2f855a;
  box-shadow: 0 0 0 4px rgba(47, 133, 90, 0.12);
}

.bulk-edit-field > .checkbox-label:has(input[type="checkbox"]:checked) {
  border-color: #2f855a;
  background: #edf8f1;
  box-shadow: 0 8px 18px rgba(47, 133, 90, 0.12);
}

.bulk-edit-field > .checkbox-label input[type="checkbox"],
.table-check-label input[type="checkbox"] {
  position: relative;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 2px solid #9cc6ad;
  border-radius: 7px;
  background: #ffffff;
  cursor: pointer;
  appearance: none;
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.bulk-edit-field > .checkbox-label input[type="checkbox"]::after,
.table-check-label input[type="checkbox"]::after {
  position: absolute;
  top: 2px;
  left: 6px;
  width: 6px;
  height: 11px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  content: "";
  opacity: 0;
  transform: rotate(45deg) scale(0.6);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.bulk-edit-field > .checkbox-label input[type="checkbox"]:checked,
.table-check-label input[type="checkbox"]:checked {
  border-color: #2f855a;
  background: linear-gradient(135deg, #2f855a 0%, #38a169 100%);
  box-shadow: 0 4px 10px rgba(47, 133, 90, 0.26);
}

.bulk-edit-field > .checkbox-label input[type="checkbox"]:checked::after,
.table-check-label input[type="checkbox"]:checked::after {
  opacity: 1;
  transform: rotate(45deg) scale(1);
}

.bulk-edit-field > .checkbox-label input[type="checkbox"]:focus-visible,
.table-check-label input[type="checkbox"]:focus-visible {
  outline: 3px solid rgba(47, 133, 90, 0.28);
  outline-offset: 3px;
}

.bulk-edit-field > .checkbox-label input[type="checkbox"]:active,
.table-check-label input[type="checkbox"]:active {
  transform: scale(0.92);
}

.table-check-label {
  min-width: 34px;
  min-height: 34px;
  border-radius: 999px;
  cursor: pointer;
}

.table-check-label input[type="checkbox"] {
  width: 24px;
  height: 24px;
  border-radius: 8px;
}

.sale-table tbody tr.is-selected,
.expense-table tbody tr.is-selected {
  background: #f1faf4;
  box-shadow: inset 4px 0 0 #2f855a;
}
.mail-preview { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; font-family: inherit; }
.checkbox-label { display: grid; grid-template-columns: auto 1fr; gap: .4rem .7rem; align-items: start; }
.checkbox-label .form-help { grid-column: 2; }
