@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=Fraunces:opsz,wght@9..144,500&display=swap");

:root {
  color-scheme: light;
  --bg: #f4f2ee;
  --bg-2: #efe7dc;
  --ink: #1a1a1a;
  --muted: #6f6b66;
  --accent: #e65f4a;
  --accent-2: #2a7f6f;
  --card: #ffffff;
  --border: rgba(0, 0, 0, 0.12);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #fdf8f1, #f0e7db 50%, #e7dfd3);
  color: var(--ink);
  min-height: 100vh;
  overflow-y: scroll;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(transparent 24px, rgba(0, 0, 0, 0.04) 25px),
    linear-gradient(90deg, transparent 24px, rgba(0, 0, 0, 0.04) 25px);
  background-size: 25px 25px;
  opacity: 0.3;
  pointer-events: none;
  z-index: 0;
}

.topbar {
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2rem;
  height: 96px;
  z-index: 2;
  gap: 2rem;
}

.brand {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.brand h1 {
  font-family: "Fraunces", serif;
  margin: 0;
  font-size: 1.6rem;
}

.brand p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.brand-mark {
  width: 178px;
  height: 178px;
  display: block;
  object-fit: contain;
  background: transparent;
  border-radius: 0;
}

.session {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.pill {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: #f7f1e8;
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.note-field {
  width: 100%;
  min-height: 44px;
  max-height: 72px;
  resize: none;
  overflow: auto;
}

.note-field:disabled {
  background: transparent;
  border-color: transparent;
  color: var(--ink);
  box-shadow: none;
}

.detail-meta .note-field:disabled {
  padding: 0;
  min-height: auto;
  height: auto;
}

main.layout {
  display: grid;
  gap: 2rem;
  padding: 2rem;
  z-index: 1;
  position: relative;
}

.login-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  background: var(--card);
  border-radius: 18px;
  padding: 2rem;
  box-shadow: var(--shadow);
}

.form-card,
.card {
  background: var(--card);
  border-radius: 18px;
  padding: 1.5rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  width: 100%;
  min-width: 0;
  overflow-x: auto;
}


.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.form-card {
  display: grid;
  gap: 1rem;
  min-width: 260px;
}

.form-card input,
.form-card textarea,
.form-stack input,
.form-stack textarea,
.form-row input,
.form-row textarea,
.form-grid input,
.form-grid textarea {
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
  background: #fffdf8;
}

.form-card button,
button {
  border: none;
  background: var(--accent);
  color: white;
  padding: 0.65rem 1.2rem;
  border-radius: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 8px 20px rgba(230, 95, 74, 0.35);
}

button:hover {
  transform: translateY(-1px);
}

button:disabled:hover {
  transform: none;
}

.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink);
  box-shadow: none;
}

.danger {
  background: #d64545;
}

.layout .app {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.nav.topnav {
  display: flex;
  flex: 1;
  gap: 1.2rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.nav.topnav button {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0.25rem 0.35rem;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 0;
}

.nav.topnav button:hover {
  transform: none;
  color: var(--ink);
}

.nav.topnav button.active {
  color: var(--ink);
  border-bottom: 2px solid var(--accent);
}

.content {
  display: grid;
  gap: 2rem;
  min-width: 0;
}

.panel {
  display: none;
  animation: fadeIn 0.4s ease;
  width: 100%;
  min-width: 0;
}

.panel.active {
  display: block;
}

.tab-header {
  display: inline-flex;
  gap: 0.5rem;
  padding: 0.4rem;
  background: #f6f1e7;
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 1rem;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink);
  padding: 0.45rem 0.9rem;
  border-radius: 12px;
  font-weight: 600;
  box-shadow: none;
}

.tab-btn.active {
  background: #fff6f1;
  border-color: var(--accent);
}

.tab-content {
  display: grid;
  gap: 1rem;
}

.tab-panel {
  display: none;
}

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


.dashboard-only {
  display: none;
}

#dashboard.active .dashboard-only {
  display: grid;
}

.panel-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.grid.two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.form-row input {
  flex: 1 1 160px;
}

.form-row select {
  flex: 1 1 160px;
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
  background: #fffdf8;
}

.form-stack {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

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

.form-grid label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 100%;
  table-layout: fixed;
}

#orders .detail-card table {
  table-layout: auto;
  min-width: 900px;
}

#orders .detail-card th,
#orders .detail-card td {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

#orders .detail-card {
  overflow-x: auto;
}

#orders .detail-card th:nth-child(7),
#orders .detail-card td:nth-child(7) {
  min-width: 140px;
}

th,
td {
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
}

#articles table th:nth-child(1),
#articles table td:nth-child(1) {
  width: 5%;
}

#articles table th:nth-child(3),
#articles table td:nth-child(3) {
  width: 22%;
}

#orders table th:nth-child(2),
#orders table td:nth-child(2) {
  width: 20%;
}

#orders table th:nth-child(7),
#orders table td:nth-child(7) {
  width: 6%;
}

#customers table th:nth-child(1),
#customers table td:nth-child(1) {
  width: 5%;
}

#customers table th:nth-child(9),
#customers table td:nth-child(9) {
  width: 20%;
}

tr.clickable {
  cursor: pointer;
}

tr.clickable.selected {
  background: #fff6f1;
}

.detail-row td {
  background: #fffdf8;
  border-bottom: none;
  padding: 0.8rem 0.8rem 1rem;
}

.detail-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0.6rem 1rem;
}

.detail-card.scroll {
  max-height: 38vh;
  overflow-y: auto;
}

.field-stack {
  display: grid;
  gap: 0.35rem;
}

.detail-form {
  grid-column: 1 / -1;
}

.detail-actions {
  display: none;
  justify-content: center;
  gap: 0.5rem;
  padding-top: 0.75rem;
}

.detail-row.editing .detail-actions {
  display: flex;
}

.modal .detail-actions {
  display: flex;
}

.detail-actions .order-detail-remove {
  display: inline-flex;
}

.detail-row .hint {
  display: none;
}

.detail-row.editing .hint {
  display: inline-block;
}

.detail-row.single-row .order-detail-remove {
  display: none !important;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.6rem;
  position: relative;
  z-index: 1;
}

.detail-toggle {
  position: relative;
  z-index: 2;
  pointer-events: auto;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
}

.detail-meta label {
  display: grid;
  gap: 0.2rem;
  min-width: 180px;
  flex: 0 0 180px;
}

.subtext {
  color: var(--muted);
  font-size: 0.8rem;
}

.hint {
  color: var(--muted);
  font-size: 0.8rem;
}

.hint.error {
  color: #d64545;
}

.detail-card table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}


.detail-card input,
.detail-card select,
.detail-card textarea {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fffdf8;
  font-size: 0.9rem;
}

.detail-card input[list],
.detail-form input[list],
.form-grid input[list] {
  padding-right: 1.6rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236f6b66' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 0.7rem;
}

.detail-card input:disabled,
.detail-card select:disabled {
  background: transparent;
  border-color: transparent;
}

.inline-input,
.inline-select {
  width: 100%;
  padding: 0.3rem 0.45rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fffdf8;
  font-size: 0.9rem;
}

.inline-input:disabled,
.inline-select:disabled {
  background: transparent;
  border-color: transparent;
  pointer-events: none;
}

.detail-card select:disabled,
.inline-select:disabled {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: none;
  padding-right: 0;
  color: var(--ink);
}

.icon-btn {
  padding: 0.25rem 0.5rem;
  border-radius: 10px;
  font-size: 0.8rem;
  line-height: 1;
  box-shadow: none;
}

.action-cell .icon-btn + .icon-btn {
  margin-left: 0.25rem;
}

tr.editing {
  background: #fff6f1;
}

.action-cell {
  width: 1%;
  white-space: nowrap;
}

.spacer-row td {
  height: 12px;
  border-bottom: none;
}

.status {
  position: fixed;
  left: 1.5rem;
  bottom: 1.5rem;
  min-height: 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  padding: 0.6rem 0.9rem;
  box-shadow: var(--shadow);
  z-index: 30;
}

.status:empty {
  display: none;
}

.note {
  color: var(--muted);
  font-size: 0.85rem;
}

.muted {
  color: var(--muted);
}

.log-row {
  cursor: pointer;
}

.log-detail {
  padding: 1rem;
}

.log-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.log-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.log-detail-grid h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.log-diff-list {
  margin: 0;
  padding-left: 1.1rem;
}

.log-diff-list li {
  margin-bottom: 0.35rem;
}

.quick-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: grid;
  place-items: center;
  z-index: 20;
}

.modal-content {
  background: #fff;
  border-radius: 18px;
  padding: 1.5rem;
  width: min(720px, 92vw);
  box-shadow: var(--shadow);
}

.modal-content.modal-wide {
  width: min(1080px, 96vw);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.modal-header h3 {
  margin: 0;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  grid-column: 1 / -1;
}

.hidden {
  display: none !important;
}

button[hidden] {
  display: none !important;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.ghost:disabled {
  background: #f4f1ea;
  border-color: #d6d0c8;
  color: #9a948c;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .layout .app {
    grid-template-columns: 1fr;
  }

  .nav {
    display: flex;
    flex-wrap: wrap;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
}
