:root {
  --bg: #f6f1e7;
  --panel: #fffdf7;
  --panel-2: #fdf8ec;
  --text: #24352e;
  --muted: #718177;
  --line: #e8deca;
  --primary: #1f5b45;
  --primary-2: #2f7559;
  --primary-soft: #e5efe8;
  --accent: #b68b4c;
  --danger: #b95650;
  --warning: #c48b36;
  --success: #2f7559;
  --shadow: 0 22px 60px rgba(40, 63, 48, 0.12);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --font-sans: "Noto Sans TC", system-ui, sans-serif;
  --font-serif: "Noto Serif TC", serif;
}

[data-theme="burgundy"] {
  --primary: #7d263a;
  --primary-2: #9a4152;
  --primary-soft: #f4e5e8;
  --accent: #b88a63;
}

[data-mode="dark"] {
  --bg: #15201b;
  --panel: #1d2b25;
  --panel-2: #25352e;
  --text: #f2eadf;
  --muted: #aebbb2;
  --line: #35483e;
  --primary-soft: rgba(255, 255, 255, 0.08);
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(47, 117, 89, 0.14), transparent 34%),
    linear-gradient(135deg, var(--bg), #fbf7ef);
  font-family: var(--font-sans);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-view {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.login-leaf {
  position: absolute;
  width: 340px;
  height: 340px;
  border-radius: 44% 56% 62% 38%;
  background: rgba(31, 91, 69, 0.08);
  filter: blur(1px);
}

.leaf-a {
  left: -80px;
  top: 70px;
  transform: rotate(24deg);
}

.leaf-b {
  right: -90px;
  bottom: 40px;
  transform: rotate(-18deg);
}

.leaf-c {
  right: 18%;
  top: -140px;
  transform: rotate(45deg);
}

.login-card {
  position: relative;
  width: min(100%, 460px);
  padding: 44px;
  border: 1px solid rgba(232, 222, 202, 0.86);
  border-radius: 34px;
  background: rgba(255, 253, 247, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand-mark,
.brand-mini {
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  font-family: var(--font-serif);
  font-weight: 700;
}

.brand-mark {
  width: 64px;
  height: 64px;
  margin-bottom: 24px;
  border-radius: 22px;
  font-size: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-card h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(34px, 6vw, 48px);
  letter-spacing: 0.03em;
}

.login-desc {
  margin: 14px 0 30px;
  color: var(--muted);
  line-height: 1.9;
}

.login-form {
  display: grid;
  gap: 18px;
}

.login-form label:not(.check-label),
.form-field {
  display: grid;
  gap: 9px;
}

.login-form label span,
.form-field span,
.form-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px;
  outline: none;
  background: var(--panel);
  color: var(--text);
  transition: 0.2s ease;
}

input,
select {
  min-height: 44px;
  padding: 0 14px;
}

textarea {
  min-height: 120px;
  padding: 14px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.form-row.between {
  justify-content: space-between;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.check-label input {
  width: auto;
  min-height: auto;
  accent-color: var(--primary);
}

.error-text {
  min-height: 22px;
  margin: 0;
  color: var(--danger);
  font-size: 14px;
}

.primary-btn,
.ghost-btn,
.text-btn,
.icon-btn,
.soft-btn,
.danger-btn {
  border: 0;
  border-radius: 999px;
  transition: 0.2s ease;
}

.primary-btn {
  min-height: 44px;
  padding: 0 22px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 14px 30px rgba(31, 91, 69, 0.22);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(31, 91, 69, 0.28);
}

.ghost-btn,
.soft-btn {
  min-height: 40px;
  padding: 0 16px;
  color: var(--primary);
  background: var(--primary-soft);
}

.ghost-btn:hover,
.soft-btn:hover {
  background: var(--primary);
  color: #fff;
}

.text-btn {
  padding: 0;
  color: var(--primary);
  background: transparent;
  font-size: 14px;
  font-weight: 700;
}

.text-btn:hover {
  color: var(--primary-2);
  text-decoration: underline;
}

.danger-btn {
  min-height: 38px;
  padding: 0 14px;
  color: #fff;
  background: var(--danger);
}

.danger-btn:hover {
  filter: brightness(0.94);
}

.icon-btn {
  width: 42px;
  height: 42px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
}

.icon-btn:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.login-btn {
  width: 100%;
}

.login-note {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--primary-soft);
  color: var(--muted);
  font-size: 13px;
}

.login-note strong {
  color: var(--primary);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.84);
  backdrop-filter: blur(18px);
  overflow-y: auto;
  z-index: 20;
}

[data-mode="dark"] .sidebar {
  background: rgba(29, 43, 37, 0.9);
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 22px;
}

.brand-mini {
  width: 42px;
  height: 42px;
  border-radius: 15px;
}

.sidebar-head strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 18px;
}

.sidebar-head span {
  color: var(--muted);
  font-size: 12px;
}

.side-menu {
  display: grid;
  gap: 8px;
}

.accordion-group {
  border-radius: 18px;
  overflow: hidden;
}

.accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 13px 14px;
  border: 0;
  border-radius: 18px;
  color: var(--text);
  background: transparent;
  font-weight: 700;
  text-align: left;
}

.accordion-trigger:hover,
.accordion-group.open .accordion-trigger {
  background: var(--primary-soft);
  color: var(--primary);
}

.trigger-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chevron {
  transition: 0.2s ease;
}

.accordion-group.open .chevron {
  transform: rotate(90deg);
}

.accordion-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.28s ease;
}

.accordion-group.open .accordion-panel {
  max-height: 520px;
}

.menu-item {
  width: calc(100% - 14px);
  display: block;
  margin: 4px 0 4px 14px;
  padding: 10px 12px 10px 36px;
  border: 0;
  border-radius: 14px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.menu-item:hover,
.menu-item.active {
  color: var(--primary);
  background: var(--primary-soft);
}

.sidebar-foot {
  margin-top: 28px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
}

.sidebar-foot p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.theme-switcher {
  display: flex;
  gap: 10px;
}

.theme-dot {
  width: 28px;
  height: 28px;
  border: 3px solid var(--panel);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line);
}

.theme-dot.active {
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.theme-dot.forest {
  background: #1f5b45;
}

.theme-dot.burgundy {
  background: #7d263a;
}

.main-area {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 241, 231, 0.78);
  backdrop-filter: blur(18px);
  z-index: 15;
}

[data-mode="dark"] .topbar {
  background: rgba(21, 32, 27, 0.86);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-crumb {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.topbar h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 24px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-box {
  width: min(32vw, 320px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}

.search-box input {
  min-height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 12px 5px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-weight: 700;
}

.avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--primary);
  font-size: 13px;
}

.notify-wrap {
  position: relative;
}

.notify-panel {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 280px;
  display: none;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  z-index: 30;
}

.notify-panel.show {
  display: block;
}

.notify-panel strong {
  display: block;
  margin-bottom: 10px;
}

.notify-panel p {
  margin: 0;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.content-area {
  padding: 28px;
  animation: fadeIn 0.25s ease both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-card,
.card,
.panel-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-card {
  position: relative;
  overflow: hidden;
  padding: 30px;
}

.hero-card::after {
  content: "";
  position: absolute;
  right: -80px;
  top: -90px;
  width: 280px;
  height: 280px;
  border-radius: 48% 52% 60% 40%;
  background: var(--primary-soft);
  transform: rotate(24deg);
}

.hero-content {
  position: relative;
  z-index: 1;
}

.hero-card h3 {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: clamp(28px, 4vw, 42px);
}

.hero-card p {
  max-width: 640px;
  margin: 0;
  color: var(--muted);
  line-height: 1.9;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 18px;
}

.stat-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 16px 40px rgba(40, 63, 48, 0.08);
}

.stat-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.stat-number {
  margin: 16px 0 8px;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.success {
  background: rgba(47, 117, 89, 0.13);
  color: var(--success);
}

.badge.warning {
  background: rgba(196, 139, 54, 0.14);
  color: var(--warning);
}

.badge.danger {
  background: rgba(185, 86, 80, 0.14);
  color: var(--danger);
}

.badge.muted {
  color: var(--muted);
  background: rgba(113, 129, 119, 0.12);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.35fr 0.9fr;
  gap: 18px;
  margin-top: 18px;
}

.card {
  padding: 22px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.card-head h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 21px;
}

.card-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

canvas {
  width: 100%;
  height: 260px;
}

.activity-list,
.todo-list {
  display: grid;
  gap: 12px;
}

.activity-item,
.todo-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-2);
}

.activity-item strong,
.todo-item strong {
  display: block;
  margin-bottom: 4px;
}

.activity-item span,
.todo-item span {
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0;
}

.toolbar input,
.toolbar select {
  width: auto;
  min-width: 180px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

th,
td {
  padding: 15px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: var(--panel-2);
  font-size: 13px;
  white-space: nowrap;
}

tr:hover td {
  background: var(--primary-soft);
}

tr:last-child td {
  border-bottom: 0;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-btn {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: var(--panel);
  transition: 0.2s ease;
}

.mini-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.product-grid,
.image-grid,
.project-grid {
  display: grid;
  gap: 18px;
}

.product-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.image-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.project-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.product-card,
.image-card,
.project-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 16px 36px rgba(40, 63, 48, 0.08);
  transition: 0.2s ease;
}

.product-card:hover,
.image-card:hover,
.project-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.product-img,
.image-preview {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: var(--primary-soft);
}

.product-body,
.image-body,
.project-body {
  padding: 16px;
}

.product-body h4,
.image-body h4,
.project-body h4 {
  margin: 0 0 8px;
  font-size: 17px;
}

.meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.price {
  margin: 12px 0;
  color: var(--primary);
  font-size: 22px;
  font-weight: 800;
}

.upload-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 24px;
  border: 2px dashed var(--line);
  border-radius: 24px;
  background: var(--panel-2);
  text-align: center;
  transition: 0.2s ease;
}

.upload-zone.dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.upload-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  font-size: 42px;
}

.upload-zone strong {
  display: block;
  margin: 8px 0;
  font-size: 18px;
}

.upload-zone p {
  margin: 0;
  color: var(--muted);
}

.upload-thumb {
  max-width: 220px;
  max-height: 150px;
  margin-top: 12px;
  border-radius: 16px;
  object-fit: cover;
  box-shadow: var(--shadow);
}

.project-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.stack-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 14px 0;
}

.stack-tag {
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.empty-state {
  padding: 44px 22px;
  border: 1px dashed var(--line);
  border-radius: 24px;
  background: var(--panel);
  text-align: center;
}

.empty-state h3 {
  margin: 12px 0 6px;
  font-family: var(--font-serif);
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.setting-row:last-child {
  border-bottom: 0;
}

.toast-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: grid;
  gap: 10px;
  z-index: 100;
}

.toast {
  min-width: 240px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  animation: toastIn 0.24s ease both;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.mobile-only {
  display: none;
}

.mobile-overlay {
  display: none;
}

@media (max-width: 1180px) {
  .grid.stats,
  .product-grid,
  .image-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .mobile-only {
    display: inline-grid;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(86vw, 320px);
    transform: translateX(-105%);
    transition: 0.25s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-overlay.show {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(21, 32, 27, 0.38);
    z-index: 19;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .search-box {
    width: 100%;
    order: 5;
  }

  .user-chip span {
    display: none;
  }

  .content-area {
    padding: 18px;
  }
}

@media (max-width: 680px) {
  .login-card {
    padding: 30px 22px;
    border-radius: 28px;
  }

  .grid.stats,
  .product-grid,
  .image-grid,
  .project-grid,
  .settings-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .toolbar input,
  .toolbar select,
  .toolbar button {
    width: 100%;
  }

  .hero-card {
    padding: 24px;
  }

  .card {
    padding: 18px;
  }

  .form-actions,
  .form-row.between {
    flex-direction: column;
    align-items: stretch;
  }

  .toast-root {
    left: 16px;
    right: 16px;
  }

  .toast {
    min-width: auto;
  }
}