html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* ---------- Theme tokens ---------- */
:root {
  --ys-bg: #faf6f2;
  --ys-surface: #ffffff;
  --ys-border: #ece2d8;
  --ys-text: #3a2c28;
  --ys-text-muted: #8d7a70;
  --ys-primary: #d17a4a;
  --ys-primary-dark: #b5623a;
  --ys-ink: #1e1a17;
}

h1, h2, h3, .app-brand-text, .dash-title, .dash-card-header h2, .auth-card h1 {
  font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
}

body {
  background-color: var(--ys-bg);
  color: var(--ys-text);
}

/* ---------- Navbar ---------- */
.app-navbar {
  background: var(--ys-surface);
  border-bottom: 1px solid var(--ys-border);
  box-shadow: 0 2px 16px rgba(58, 44, 40, 0.05);
  position: sticky;
  top: 0;
  z-index: 1030;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.app-navbar::before {
  content: "";
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--ys-primary), #8a9a7e);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  color: var(--ys-text) !important;
}

.app-brand-mark {
  width: 4.75rem;
  height: 4.75rem;
  border-radius: 50%;
  object-fit: cover;
  background-color: #1c2949;
  flex-shrink: 0;
}

.app-brand-text {
  font-size: 1.05rem;
}

.app-nav .nav-link {
  color: var(--ys-text-muted);
  font-weight: 500;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  margin: 0 0.15rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.app-nav .nav-link:hover {
  color: var(--ys-primary-dark);
  background-color: rgba(109, 94, 252, 0.08);
}

.app-nav .nav-link.active {
  color: #fff;
  background-color: var(--ys-primary);
}

.app-nav .dropdown-menu {
  border: 1px solid var(--ys-border);
  border-radius: .8rem;
  box-shadow: 0 .75rem 2rem rgba(58, 44, 40, 0.12);
  padding: .4rem;
  margin-top: .4rem;
}

.app-nav .dropdown-item {
  border-radius: .5rem;
  padding: .5rem .8rem;
  font-weight: 500;
  color: var(--ys-text);
}

.app-nav .dropdown-item:hover,
.app-nav .dropdown-item:focus {
  background-color: rgba(209, 122, 74, 0.1);
  color: var(--ys-primary-dark);
}

.app-nav .dropdown-item.active {
  background-color: var(--ys-primary);
  color: #fff;
}

.app-user-menu .btn-outline-secondary {
  color: var(--ys-text-muted);
  border-color: var(--ys-border);
}

.app-user-menu .btn-outline-secondary:hover {
  color: var(--ys-primary-dark);
  border-color: var(--ys-primary);
  background-color: rgba(209, 122, 74, 0.08);
}

/* ---------- Dashboard header ---------- */
.dash-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.dash-title {
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.dash-subtitle {
  color: var(--ys-text-muted);
  margin-bottom: 0;
}

.dash-store-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ys-primary);
  text-decoration: none;
}

.dash-store-link:hover {
  color: var(--ys-primary-dark);
  text-decoration: underline;
}

.dash-store-link-muted {
  color: var(--ys-text-muted);
  font-weight: 500;
}

.dash-store-link-muted:hover {
  color: var(--ys-primary);
}

.dash-header-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* ---------- Tiles ---------- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.1rem;
  margin-bottom: 1.75rem;
}

.tile {
  background: var(--ys-surface);
  border: 1px solid var(--ys-border);
  border-radius: 1rem;
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  box-shadow: 0 2px 10px rgba(20, 20, 43, 0.03);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(20, 20, 43, 0.08);
}

.tile-icon {
  width: 2.75rem;
  height: 2.75rem;
  min-width: 2.75rem;
  border-radius: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile-icon svg {
  width: 1.4rem;
  height: 1.4rem;
}

.tile-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tile-label {
  font-size: 0.82rem;
  color: var(--ys-text-muted);
  font-weight: 500;
}

.tile-value {
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.3;
}

.tile-meta {
  font-size: 0.8rem;
  color: var(--ys-text-muted);
}

.tile-violet .tile-icon { background: rgba(109, 94, 252, 0.12); color: #6d5efc; }
.tile-teal .tile-icon   { background: rgba(20, 184, 166, 0.12); color: #0f9488; }
.tile-amber .tile-icon  { background: rgba(245, 158, 11, 0.14); color: #b45309; }
.tile-rose .tile-icon   { background: rgba(244, 63, 94, 0.12); color: #e11d48; }
.tile-blue .tile-icon   { background: rgba(37, 99, 235, 0.12); color: #2563eb; }

/* ---------- Dashboard cards ---------- */
.dash-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
}

.dash-card {
  background: var(--ys-surface);
  border: 1px solid var(--ys-border);
  border-radius: 1rem;
  padding: 1.25rem;
  box-shadow: 0 2px 10px rgba(20, 20, 43, 0.03);
}

/* Keep right-aligned currency values and row-action button groups from wrapping
   onto a second line when the table is a bit tight — .table-responsive already
   provides horizontal scroll, so nowrap here just moves overflow there instead
   of into an awkward mid-value/mid-button-group line break. */
.table td.text-end {
  white-space: nowrap;
}

.table td.text-end .btn {
  margin-left: .25rem;
}

.table td.text-end .btn:first-child {
  margin-left: 0;
}

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

.dash-card-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}

.dash-card-link {
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

.dash-table {
  margin-bottom: 0;
}

.dash-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ys-text-muted);
  border-top: none;
  font-weight: 600;
}

.dash-table td, .dash-table th {
  border-color: var(--ys-border);
  vertical-align: middle;
}

.status-pill {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-draft { background: rgba(107, 114, 128, 0.14); color: #374151; }
.status-ordered { background: rgba(245, 158, 11, 0.16); color: #b45309; }
.status-received { background: rgba(16, 185, 129, 0.16); color: #047857; }
.status-cancelled { background: rgba(244, 63, 94, 0.14); color: #be123c; }

/* ---------- Auth pages ---------- */
.auth-body {
  background: var(--ys-bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0;
  padding: 1.5rem;
}

.auth-wrap {
  width: 100%;
  max-width: 420px;
}

.auth-card {
  background: var(--ys-surface);
  border: 1px solid var(--ys-border);
  border-radius: 1rem;
  box-shadow: 0 10px 30px rgba(20, 20, 43, 0.08);
  padding: 2rem;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.auth-brand .app-brand-text {
  font-size: 1.1rem;
  color: var(--ys-text);
}

/* Scoped to .auth-card only — the rest of the app's .btn-primary stays Bootstrap
   blue (used in 52+ views); the login/register/reset pages are the one place
   worth bringing onto the brand accent since they're the first thing anyone sees. */
.auth-card .btn-primary {
  background-color: var(--ys-primary);
  border-color: var(--ys-primary);
}

.auth-card .btn-primary:hover,
.auth-card .btn-primary:focus {
  background-color: var(--ys-primary-dark);
  border-color: var(--ys-primary-dark);
}

.auth-card a {
  color: var(--ys-primary-dark);
}

.auth-card a:hover {
  color: var(--ys-primary);
}

.auth-card .form-check-input:checked {
  background-color: var(--ys-primary);
  border-color: var(--ys-primary);
}

/* ---------- Icon buttons (nav logout, table row actions, quick actions) ---------- */
.btn-icon {
  width: 14px;
  height: 14px;
  margin-right: .35rem;
  vertical-align: -2px;
}

/* ---------- User menu (navbar) ---------- */
.app-user-menu {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-user-email {
  font-size: 0.85rem;
  color: var(--ys-text-muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 575.98px) {
  .app-brand-text {
    display: none;
  }

  .app-user-email {
    display: none;
  }
}

/* ---------- Sales line-item table ---------- */

/* Without a floor, the flex row inside .batch-cell (thumbnail + search input)
   gets squeezed to near-zero width on narrow screens instead of the table
   properly overflowing into its .table-responsive scroll container — the product
   name search box was effectively invisible on mobile. */
#line-items-table {
  min-width: 720px;
}

.batch-search-input {
  min-width: 200px;
}