:root {
  --ink: #24302f;
  --muted: #697775;
  --line: #dbe5df;
  --paper: #f7faf7;
  --panel: #ffffff;
  --accent: #2f7a78;
  --accent-soft: #d9eeee;
  --warm: #f2f7f4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, opacity 160ms ease;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(47, 122, 120, 0.34);
  outline-offset: 2px;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  padding: 24px;
  color: #f7fbf8;
  background: #1f3433;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 44px;
}

.mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  background: #f7fbf8;
  color: var(--ink);
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: rgba(247, 251, 248, 0.62);
  font-size: 13px;
}

nav {
  display: grid;
  gap: 8px;
}

nav a {
  padding: 12px 14px;
  color: rgba(247, 251, 248, 0.76);
  text-decoration: none;
  min-height: 44px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

nav a:hover,
nav a.is-active {
  background: rgba(247, 251, 248, 0.1);
  color: #f7fbf8;
}

main {
  margin-left: 248px;
  padding: 34px 40px 56px;
  background: var(--paper);
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #2f7a78;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: clamp(30px, 5vw, 52px);
  letter-spacing: 0;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 18px;
}

.form-card button,
.inline-form button,
.small-btn {
  min-height: 40px;
  padding: 0 16px;
  background: var(--accent);
  color: #f7fbf8;
  font-weight: 700;
}

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

.topbar button,
.ghost-main,
.danger-main {
  min-height: 40px;
  padding: 0 16px;
  background: var(--accent);
  color: #f7fbf8;
  font-weight: 700;
}

.ghost-main {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.danger-main {
  background: #b84f45;
}

.login-state {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  background: var(--warm);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.ghost-btn,
.danger-btn {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.danger-btn {
  border-color: #efc4bd;
  color: #b84f45;
}

.text-btn {
  margin-left: 8px;
  color: #b84f45;
  background: transparent;
  font-size: 12px;
}

.panel {
  display: none;
  margin-bottom: 28px;
  padding: 0 0 28px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.panel.is-active {
  display: block;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.helper {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.stat {
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
}

.stat strong,
.stat span {
  display: block;
}

.stat strong {
  font-size: 30px;
}

.stat span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 18px;
}

.dashboard-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  background: #fff;
}

.dashboard-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.dashboard-card-head h3 {
  font-size: 17px;
}

.dashboard-card-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.compact-list {
  display: grid;
  gap: 8px;
}

.compact-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  background: #fbfdfb;
  color: inherit;
  text-align: left;
}

.compact-item:hover {
  border-color: #9fcac7;
  background: #f2f7f4;
}

.compact-item.hot {
  border-color: #9fcac7;
  background: #eef8f7;
}

.compact-item strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-item span,
.empty-compact {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.empty-compact {
  padding: 18px;
  border: 1px dashed var(--line);
  background: #fbfdfb;
}

.board-list,
.finance-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.board-item,
.finance-board div {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  background: #fbfdfb;
}

.board-item strong,
.board-item span,
.finance-board strong,
.finance-board span {
  display: block;
}

.board-item strong,
.finance-board strong {
  color: var(--ink);
  font-size: 24px;
}

.board-item span,
.finance-board span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.list,
.album-list {
  display: grid;
  gap: 12px;
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  background: #fff;
}

.row > div {
  min-width: 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.stacked-actions {
  align-content: start;
  align-items: stretch;
  min-width: 210px;
}

.mini-label {
  display: grid;
  gap: 5px;
  min-width: 150px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.mini-label select,
.actions > select {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 12px;
}

.row strong,
.row span {
  display: block;
}

.row strong {
  font-size: 16px;
  overflow-wrap: anywhere;
}

.row span,
.meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  background: var(--accent-soft);
  color: #1e5f5d;
  font-size: 12px;
  font-weight: 700;
}

.form-card {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 30;
  display: none;
  align-content: start;
  gap: 14px;
  width: min(520px, calc(100vw - 36px));
  max-height: calc(100vh - 56px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 24px 80px rgba(45, 41, 38, 0.22);
  transform: translate(-50%, -50%);
}

.form-card.is-open {
  display: grid;
}

.form-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(45, 41, 38, 0.28);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.modal-close {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
}

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

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
}

.media-card {
  background: #fff;
  border: 1px solid var(--line);
  overflow: hidden;
}

.image-button,
.photo-preview {
  display: block;
  width: 100%;
  padding: 0;
  background: #fff;
  color: inherit;
  text-align: left;
}

.media-card img,
.photo-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: #fff;
}

.media-card div {
  padding: 14px;
}

.media-card .actions {
  margin-top: 12px;
  padding: 0;
  justify-content: flex-start;
}

.album-layout {
  display: block;
}

.album-card {
  padding: 20px 0 0;
  border: 1px solid var(--line);
  border-width: 1px 0 0;
  background: #fff;
}

.album-card header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  margin-bottom: 16px;
}

.album-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.photo-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.photo-tile {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}

.photo-tile.is-selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(216, 95, 85, 0.18);
}

.photo-tile-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
}

.photo-tile-bar span {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-tile .text-btn {
  margin-left: 0;
}

.empty-text {
  display: block;
  padding: 16px;
  border: 1px dashed var(--line);
  color: var(--muted);
}

.empty-list {
  display: grid;
  gap: 6px;
  padding: 26px;
  border: 1px dashed var(--line);
  background: #fbfdfb;
  color: var(--muted);
}

.empty-list strong {
  color: var(--ink);
  font-size: 15px;
}

.empty-list span {
  font-size: 13px;
  line-height: 1.55;
}

.inline-form {
  display: grid;
  grid-template-columns: 110px minmax(140px, 0.8fr) minmax(0, 1fr) 70px;
  gap: 8px;
  margin-top: 10px;
}

input[type="file"] {
  padding: 7px;
}

.dialog-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(45, 41, 38, 0.32);
}

.dialog-layer[hidden] {
  display: none;
}

.dialog-box {
  width: min(420px, 100%);
  padding: 24px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 24px 80px rgba(45, 41, 38, 0.22);
}

.dialog-box form,
.dialog-box label {
  width: 100%;
}

.dialog-text {
  margin: 12px 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.toast {
  position: fixed;
  left: 50%;
  top: 22px;
  z-index: 70;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  background: var(--ink);
  color: #f7fbf8;
  font-size: 13px;
  font-weight: 700;
  transform: translateX(-50%);
}

.preview-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(25, 22, 20, 0.82);
}

.preview-layer[hidden] {
  display: none;
}

.preview-shell {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 12px;
  width: min(1120px, 100%);
  max-height: 100%;
}

.preview-shell img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 120px);
  object-fit: contain;
  background: #fff;
}

.preview-shell p {
  margin: 0;
  color: #f7fbf8;
  font-size: 14px;
  font-weight: 700;
}

.preview-close {
  position: absolute;
  right: 0;
  top: 0;
  z-index: 1;
  min-height: 36px;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  transform: translateY(calc(-100% - 10px));
}

@media (max-width: 980px) {
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 15;
    width: auto;
    padding: 16px;
  }

  main {
    margin-left: 0;
    padding: 18px 14px 36px;
  }

  nav {
    display: flex;
    gap: 8px;
    margin: 0 -16px;
    overflow-x: auto;
    padding: 0 16px 4px;
    scroll-snap-type: x proximity;
  }

  nav a {
    flex: 0 0 auto;
    min-width: 96px;
    scroll-snap-align: start;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    flex-wrap: wrap;
  }

  .top-actions button,
  .top-actions .login-state {
    flex: 1 1 120px;
    justify-content: center;
  }

  .two-col,
  .album-layout,
  .album-columns,
  .stats,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .row,
  .album-card header {
    grid-template-columns: 1fr;
  }

  .actions {
    justify-content: flex-start;
  }

  .actions button,
  .actions select,
  .mini-label {
    width: 100%;
  }

  .stacked-actions {
    min-width: 0;
  }

  .form-card {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 24px);
    padding: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
