:root {
  --bg: #f7f6f3;
  --card: #ffffff;
  --border: #e2e0da;
  --text: #2b2a27;
  --muted: #746f66;
  --accent: #8a5a3b;
  --accent-hover: #6f4730;
  --accent-soft: #f1e8e1;
  --error-bg: #fbeceb;
  --error-text: #7a2b25;
  --navbar-bg: #211f1c;
  --navbar-text: #f3ede6;
  --navbar-muted: #b9ab9c;
  --shadow: 0 1px 2px rgba(43, 42, 39, 0.05), 0 6px 16px rgba(43, 42, 39, 0.06);
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
}

/* Navbar */

.navbar {
  background: var(--navbar-bg);
  color: var(--navbar-text);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

.navbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-height: 64px;
  flex-wrap: wrap;
}

.navbar-brand {
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  padding: 0.5rem 0;
}

.navbar-brand span {
  font-weight: 400;
  font-size: 0.68rem;
  color: var(--navbar-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.navbar-links {
  display: flex;
  gap: 0.2rem;
  flex: 1;
}

.navbar-links a {
  color: var(--navbar-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

.navbar-links a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
}

.navbar-links a.active {
  color: #fff;
  background: var(--accent);
}

.navbar-toggle {
  display: none;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  border-radius: 6px;
  padding: 0.35rem 0.65rem;
  font-size: 1.1rem;
  cursor: pointer;
  margin-left: auto;
}

.navbar-logout {
  margin: 0;
}

.navbar-logout button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: var(--navbar-muted);
}

.navbar-logout button:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.07);
}

@media (max-width: 760px) {
  .navbar-toggle { display: inline-block; }
  .navbar-links {
    display: none;
    width: 100%;
    flex-direction: column;
    order: 3;
    padding-top: 0.4rem;
    padding-bottom: 0.6rem;
  }
  .navbar-links.open { display: flex; }
  .navbar-logout { order: 2; }
}

/* Page shell */

.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

h1 {
  font-size: 1.6rem;
  margin-bottom: 0.25rem;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.15rem;
}

.subtitle {
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.page-header {
  margin-bottom: 1.5rem;
}

/* Hero (dashboard) */

.hero {
  padding: 1.75rem 0 0.5rem;
}

.hero h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.hero .subtitle {
  font-size: 1.05rem;
  max-width: 620px;
  margin-bottom: 0;
}

/* Quick links */

.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.9rem;
  margin: 1.5rem 0 2rem;
}

.quick-link {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.quick-link:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.quick-link-icon { font-size: 1.4rem; }
.quick-link-label { font-weight: 600; }
.quick-link-hint { color: var(--muted); font-size: 0.8rem; }

/* Cards & forms */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.flash {
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid #eecfcc;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.field {
  margin-bottom: 1.1rem;
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

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

.row {
  display: flex;
  gap: 1rem;
}

.row .field {
  flex: 1;
}

input[type="text"],
input[type="number"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(138, 90, 59, 0.15);
}

textarea {
  resize: vertical;
  min-height: 4.5rem;
}

button, .btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.65rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s ease, transform 0.05s ease;
}

button:hover, .btn:hover {
  background: var(--accent-hover);
}

button:active, .btn:active {
  transform: translateY(1px);
}

button:disabled, .btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn.secondary:hover {
  background: var(--accent-soft);
}

.btn.small {
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
}

.extra-attr-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
  align-items: center;
}

.extra-attr-row input { flex: 1; }

.extra-attr-row .remove-attr {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
}

.actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.color-block {
  margin-bottom: 1.5rem;
}

.color-block h3 {
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.image-strip {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.image-strip img {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

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

th {
  color: var(--muted);
  font-weight: 600;
}

tbody tr:hover {
  background: var(--accent-soft);
}

.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover {
  color: var(--accent);
}

.sort-chip {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  margin: 0.1rem 0.2rem 0.1rem 0;
}

.sort-chip:hover {
  background: var(--accent);
  color: #fff;
}

.sort-arrow {
  font-size: 0.7em;
}

.badge {
  display: inline-block;
  background: #e7f3ea;
  color: #2b6a3f;
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.meta-list {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.meta-list li { margin-bottom: 0.2rem; }

/* Loading overlay */

.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 16, 0.55);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-overlay.active { display: flex; }

.loading-box {
  background: var(--card);
  border-radius: 12px;
  padding: 2rem 2.4rem;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  max-width: 320px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#loading-message {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
}

/* Login page */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #211f1c 0%, #3a3128 45%, #8a5a3b 100%);
  padding: 1.5rem;
}

.login-card {
  background: var(--card);
  border-radius: 14px;
  padding: 2.5rem 2.25rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.login-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-brand h1 {
  font-size: 1.35rem;
  margin: 0 0 0.25rem;
}

.login-brand p {
  color: var(--muted);
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.login-card button[type="submit"] {
  width: 100%;
  margin-top: 0.5rem;
}
