:root {
  --bg: #f7f5ef;
  --surface: #ffffff;
  --ink: #14231c;
  --ink-soft: #5b6b60;
  --line: #dce6dd;
  --green: #16a34a;
  --green-dark: #0f7a38;
  --rust: #c2410c;
  --rust-bg: #fdecd8;
  --negative-bg: #fbe4e1;
  --negative: #b42318;

  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

/* Author styles like `display: flex` on .modal-backdrop/.login-screen would
   otherwise override the browser's default [hidden] { display: none } rule,
   since they share the same specificity. This keeps hidden always winning. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

h1 {
  font-size: 1.6rem;
  font-weight: 600;
  margin: 0.1rem 0 0;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0 0 1.25rem;
}

.store-mark {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0.9rem 0 0.3rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 1px;
}

button {
  font-family: inherit;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--green);
  color: #fff;
  border: 1px solid var(--green);
  padding: 0.6rem 1.1rem;
  font-weight: 500;
}
.btn-primary:hover {
  background: var(--green-dark);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 0.55rem 1rem;
}
.btn-ghost:hover {
  border-color: var(--ink-soft);
}
.btn-ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
  margin-top: 1.25rem;
}

.error-text {
  color: var(--negative);
  font-size: 0.85rem;
  margin: 0.6rem 0 0;
}

/* ---------- Dashboard shell ---------- */

.dashboard-screen {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

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

.topbar-user {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.date-range-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.date-range-toolbar label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.date-range-toolbar input[type="date"] {
  font-family: var(--font-body);
}

.summary-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin: 0 0 1.5rem;
}

.summary-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.2rem;
}

.summary-tile .value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  display: block;
}

.summary-tile .label {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.search-input {
  flex: 1;
  max-width: 360px;
}

/* ---------- Table ---------- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-soft);
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--line);
}

tbody td {
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

.tag {
  display: inline-block;
  margin-left: 0.5rem;
  font-size: 0.7rem;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.05rem 0.4rem;
}

.tag-manual {
  border-color: var(--green);
  color: var(--green-dark);
}

.row-actions {
  display: flex;
  gap: 0.5rem;
  white-space: nowrap;
}

.btn-edit {
  font-size: 0.82rem;
  padding: 0.4rem 0.75rem;
}

.btn-save {
  background: transparent;
  border: 1px solid var(--line);
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.btn-save:not(:disabled) {
  border-color: var(--green);
  color: var(--green-dark);
}

.btn-save:not(:disabled):hover {
  background: var(--green);
  color: #fff;
}

.btn-save:disabled {
  cursor: default;
  opacity: 0.5;
}

.empty-state {
  padding: 2rem;
  text-align: center;
  color: var(--ink-soft);
}

/* ---------- Pagination ---------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.25rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(33, 38, 31, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  /* Must sit above styles.css's sticky .site-header (z-index: 50), which
     admin.html now includes for the shared manager nav. */
  z-index: 200;
}

.admin-modal {
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 6px;
  padding: 1.75rem;
}

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

.form-col {
  flex: 1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .dashboard-screen {
    padding: 1.25rem 1rem 3rem;
  }
  .table-wrap {
    overflow-x: auto;
  }
  table {
    min-width: 640px;
  }
  .form-row {
    flex-direction: column;
    gap: 0;
  }
}

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.tab-btn {
  padding: 0.55rem 1.1rem;
}

/* ---------- Billing-owned-field note ---------- */

.billing-note {
  margin-bottom: 0.75rem;
}

/* ---------- Toolbar extras ---------- */

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

.checkbox-label input {
  width: auto;
}

.bulk-bar {
  align-items: center;
  background: var(--rust-bg);
  border: 1px solid var(--rust);
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
}

.bulk-bar select {
  width: auto;
  max-width: 220px;
}

/* ---------- Image thumbnail ---------- */

.thumb {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  border: 1px solid var(--line);
  object-fit: cover;
  display: block;
}

.thumb-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  border: 1px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  font-size: 0.65rem;
  text-align: center;
}

.image-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ---------- Active toggle switch ---------- */

.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex: none;
}

.switch-input {
  width: 100% !important;
  height: 100%;
  margin: 0;
  appearance: none;
  background: var(--line);
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.switch-input:checked {
  background: var(--green);
}

.switch-input::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.15s;
}

.switch-input:checked::before {
  left: 18px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
