:root {
  --primary-orange: #f57c00;
  --light-orange: #fff3e0;
  --text-dark: #333;
  --bg: #fff8f0;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-solid: #ffffff;
  --surface-soft: var(--light-orange);
  --ink: var(--text-dark);
  --muted: #7d6958;
  --line: #f1d8bd;
  --primary: var(--primary-orange);
  --primary-dark: #b85d00;
  --accent: #ffb74d;
  --danger: #d94a3a;
  --orange-deep: #6d3b00;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image:
    radial-gradient(circle at top left, rgba(245, 124, 0, 0.18), transparent 34rem),
    radial-gradient(circle at top right, rgba(255, 183, 77, 0.18), transparent 30rem);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: grid;
  grid-template-columns: 260px 1fr;
  letter-spacing: 0;
}

body.auth-page {
  background: var(--light-orange);
  display: block;
}

a {
  color: var(--primary-dark);
  text-decoration: none;
}

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

.sidebar {
  min-height: 100vh;
  background: linear-gradient(180deg, #5c3100 0%, #8a4b00 55%, #3a2100 100%);
  color: #f7fff9;
  padding: 24px;
  position: sticky;
  top: 0;
}

.sidebar-user {
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  display: grid;
  gap: 8px;
  margin-top: 28px;
  padding-top: 18px;
}

.sidebar-user span,
.sidebar-user small {
  display: block;
}

.sidebar-user small {
  color: #ffd7a3;
}

.sidebar-user form {
  margin: 4px 0 0;
}

.sidebar-user button {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
  padding: 9px 12px;
  width: 100%;
}

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

.brand-mark {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--orange-deep);
  font-weight: 800;
  overflow: hidden;
  position: relative;
}

.brand-mark img {
  background: #ffffff;
  display: block;
  height: 100%;
  object-fit: contain;
  padding: 3px;
  position: absolute;
  width: 100%;
}

.brand-mark img + span {
  opacity: 0;
}

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

.brand small {
  color: #ffd7a3;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav a {
  color: #fff0d8;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 700;
  transition: background 160ms ease, transform 160ms ease;
}

.nav a.active,
.nav a:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  transform: translateX(2px);
}

.main {
  padding: 32px;
}

.flash {
  background: #dbf4e7;
  border: 1px solid #afe4c9;
  color: #125f41;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-weight: 700;
}

.flash.error {
  background: #fff0ee;
  border-color: #efbeb8;
  color: var(--danger);
}

.notice {
  background: #fff9eb;
  border: 1px solid #f0d59a;
  border-radius: 8px;
  color: #6d4a00;
  font-weight: 700;
  margin-bottom: 18px;
  padding: 14px 16px;
}

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

.page-title p {
  color: var(--primary-dark);
  font-weight: 800;
  margin: 0 0 6px;
}

.page-title h1 {
  font-size: 40px;
  line-height: 1.1;
  margin: 0;
}

.button,
.actions a,
.actions button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.button:hover,
.actions a:hover,
.actions button:hover {
  transform: translateY(-1px);
}

.button.primary {
  background: linear-gradient(135deg, var(--primary), #ff9800);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(245, 124, 0, 0.24);
}

.button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metric,
.panel,
.form-panel,
.empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.metric {
  position: relative;
  overflow: hidden;
  padding: 20px;
}

.metric::after {
  background: linear-gradient(135deg, rgba(245, 124, 0, 0.2), rgba(255, 183, 77, 0.18));
  content: "";
  height: 70px;
  position: absolute;
  right: -24px;
  top: -24px;
  transform: rotate(20deg);
  width: 120px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-weight: 700;
  margin-bottom: 10px;
}

.metric strong {
  font-size: 32px;
}

.metric.warning {
  border-color: #f0d59a;
  background: #fff9eb;
}

.metric.danger {
  border-color: #f3b5ae;
  background: #fff3f1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  overflow: hidden;
}

.panel-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 18px 20px;
}

.panel-header h2 {
  font-size: 18px;
  margin: 0;
}

.list {
  display: grid;
}

.list-row {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
}

.list-row:last-child {
  border-bottom: 0;
}

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

.list-row span,
.list-row time,
.empty {
  color: var(--muted);
}

.empty {
  padding: 20px;
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
}

.bulk-bar {
  align-items: center;
  background: rgba(255, 255, 255, 0.7);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 14px 16px;
}

.check-label {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  gap: 9px;
  min-height: 40px;
}

.check-label input,
.select-cell input {
  accent-color: var(--primary);
  height: 18px;
  width: 18px;
}

.select-cell {
  text-align: center;
  width: 48px;
}

table {
  border-collapse: collapse;
  min-width: 860px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  background: #e8f5ee;
  border: 1px solid #c8e6d6;
  border-radius: 999px;
  color: var(--primary-dark);
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  padding: 5px 10px;
}

.badge.warning {
  background: #fff7df;
  border-color: #f0d59a;
  color: #8a5a00;
}

.badge.danger {
  background: #fff0ee;
  border-color: #efbeb8;
  color: var(--danger);
}

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

.actions form {
  margin: 0;
}

.actions button {
  color: var(--danger);
}

.form-panel {
  padding: 22px;
}

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

.form-panel h2 {
  font-size: 18px;
  margin: 0 0 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

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

label {
  color: var(--muted);
  display: grid;
  font-weight: 800;
  gap: 8px;
}

input,
select,
textarea {
  background: #fbfdfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 44px;
  padding: 10px 12px;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(245, 124, 0, 0.65);
  box-shadow: 0 0 0 4px rgba(245, 124, 0, 0.14);
  outline: none;
}

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

.upload-zone input {
  border-style: dashed;
  min-height: 64px;
}

.upload-zone span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.full {
  grid-column: 1 / -1;
}

.file-note {
  color: var(--muted);
  margin: 0;
}

.photo-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.photo-grid figure {
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  overflow: hidden;
}

.photo-grid img {
  aspect-ratio: 4 / 3;
  display: block;
  object-fit: cover;
  width: 100%;
}

.photo-grid figcaption {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  padding: 9px 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  max-width: 560px;
  padding: 34px;
}

.login-shell {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 420px;
  padding: 28px;
  width: 100%;
}

.login-brand {
  align-items: center;
  flex-direction: column;
  color: var(--ink);
  gap: 14px;
  margin-bottom: 24px;
  text-align: center;
}

.login-brand .brand-mark {
  height: 132px;
  width: 132px;
}

.login-brand .brand-mark img {
  padding: 6px;
}

.login-brand strong {
  font-size: 24px;
}

.login-brand small {
  color: var(--muted);
  font-size: 15px;
}

.login-panel h1 {
  font-size: 30px;
  margin: 0 0 20px;
}

.login-panel form {
  display: grid;
  gap: 16px;
}

.login-panel .button {
  width: 100%;
}

.compact table {
  min-width: 520px;
}

@media (max-width: 900px) {
  body {
    display: block;
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    min-height: auto;
    padding: 14px 14px 10px;
    position: static;
  }

  .brand {
    margin-bottom: 12px;
  }

  .brand-mark {
    height: 52px;
    width: 52px;
  }

  .nav {
    display: flex;
    gap: 8px;
    margin-inline: -4px;
    overflow-x: auto;
    padding: 2px 4px 10px;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav a {
    background: rgba(255, 255, 255, 0.08);
    flex: 0 0 auto;
    min-height: 44px;
    padding: 12px 14px;
  }

  .nav a:hover,
  .nav a.active {
    transform: none;
  }

  .sidebar-user {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    padding-top: 10px;
  }

  .sidebar-user form {
    margin: 0;
  }

  .sidebar-user button {
    min-height: 40px;
    width: auto;
  }

  .metrics-grid,
  .dashboard-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 18px 14px 92px;
  }

  .page-title {
    align-items: start;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
  }

  .page-title h1 {
    font-size: 30px;
  }

  .page-title .button {
    width: 100%;
  }

  .metric,
  .panel,
  .form-panel {
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.07);
  }

  .list-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .table-wrap {
    overflow: visible;
  }

  .bulk-bar {
    align-items: stretch;
    flex-direction: column;
    padding: 12px 14px;
  }

  .bulk-bar .button {
    width: 100%;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tr {
    border-bottom: 1px solid var(--line);
    padding: 14px;
  }

  tr:last-child {
    border-bottom: 0;
  }

  td {
    border-bottom: 0;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 7px 0;
  }

  td::before {
    color: var(--muted);
    content: attr(data-label);
    flex: 0 0 42%;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
  }

  .select-cell {
    align-items: center;
    display: flex;
    justify-content: flex-start;
    width: auto;
  }

  .select-cell::before {
    content: "Select";
  }

  td:empty {
    display: none;
  }

  .actions {
    justify-content: stretch;
    padding-top: 12px;
  }

  .actions::before {
    display: none;
  }

  .actions a,
  .actions form,
  .actions button {
    width: 100%;
  }

  .actions a,
  .actions button {
    min-height: 44px;
    text-align: center;
  }

  input,
  select,
  textarea,
  .button {
    min-height: 48px;
  }

  .form-panel {
    padding: 16px;
  }

  .form-actions {
    background: rgba(246, 248, 251, 0.92);
    border-top: 1px solid var(--line);
    bottom: 0;
    left: 0;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
    position: fixed;
    right: 0;
    z-index: 20;
  }

  .form-actions .button {
    width: 100%;
  }

  .photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .brand strong {
    font-size: 15px;
  }

  .brand small,
  .sidebar-user small {
    font-size: 12px;
  }

  .page-title h1 {
    font-size: 28px;
  }

  .metrics-grid {
    gap: 12px;
  }

  .metric {
    padding: 16px;
  }

  .metric strong {
    font-size: 28px;
  }

  td {
    display: grid;
    gap: 5px;
    justify-content: normal;
  }

  td::before {
    flex-basis: auto;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .actions a:only-child,
  .actions form:only-child {
    grid-column: 1 / -1;
  }

  .photo-grid {
    grid-template-columns: 1fr;
  }
}
