/*
 * NamiSanati design tokens and components.
 * All styling lives here: the Content Security Policy blocks inline styles.
 *
 * Palette: porcelain background, deep green for actions (the --ns-plum tokens), a single amber
 * accent borrowed from perfume oil, used only for the brand mark and the
 * active navigation marker.
 */

:root {
  --ns-bg: #f4f3f6;
  --ns-surface: #ffffff;
  --ns-ink: #231c27;
  --ns-muted: #6f6775;
  --ns-line: #e4e0e8;
  --ns-plum: #2a553f;
  --ns-plum-dark: #214430;
  --ns-plum-tint: #e8f1ec;
  --ns-amber: #b67a1e;
  --ns-amber-tint: #fbf3e4;
  --ns-radius: 10px;
  --ns-sidebar-width: 236px;
  /* One typeface everywhere: Avenir (static/css/fonts.css). --ns-serif keeps its name
     for the headings that use it. */
  --ns-sans: "Avenir", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --ns-serif: var(--ns-sans);

  --bs-body-bg: var(--ns-bg);
  --bs-body-color: var(--ns-ink);
  --bs-body-font-family: var(--ns-sans);
  --bs-body-font-size: 0.9375rem;
  --bs-secondary-color: var(--ns-muted);
  --bs-border-color: var(--ns-line);
  --bs-border-radius: 8px;
  --bs-link-color: var(--ns-plum);
  --bs-link-color-rgb: 42, 85, 63;
  --bs-link-hover-color: var(--ns-plum-dark);
  --bs-link-hover-color-rgb: 33, 68, 48;
  --bs-primary: var(--ns-plum);
  --bs-primary-rgb: 42, 85, 63;
  --bs-focus-ring-color: rgba(42, 85, 63, 0.25);
}

body {
  background: var(--ns-bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .ns-serif {
  font-family: var(--ns-serif);
  font-weight: 600;
  letter-spacing: 0.005em;
}

a {
  text-underline-offset: 0.18em;
}

.text-secondary {
  color: var(--ns-muted) !important;
}

/* --- Brand mark: an amber oil drop beside the wordmark --------------------- */

.ns-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--ns-serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ns-ink);
  text-decoration: none;
}

.ns-brand:hover {
  color: var(--ns-ink);
}

.ns-logo {
  display: block;
  height: 34px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
}

.ns-topbar .ns-logo {
  height: 28px;
}

.ns-brand-auth {
  justify-content: center;
}

.ns-brand-auth .ns-logo {
  height: 56px;
  max-width: 260px;
}

.ns-drop {
  width: 0.8rem;
  height: 0.8rem;
  background: var(--ns-amber);
  border-radius: 50% 0 50% 50%;
  transform: rotate(-45deg);
  flex: none;
}

/* --- Shell: sidebar + main -------------------------------------------------- */

.ns-shell {
  display: flex;
  min-height: 100vh;
}

.ns-sidebar {
  --bs-offcanvas-bg: var(--ns-surface);
  width: var(--ns-sidebar-width);
  background: var(--ns-surface);
  border-right: 1px solid var(--ns-line);
  display: flex;
  flex-direction: column;
}

@media (min-width: 992px) {
  /* Bootstrap makes offcanvas-lg transparent on wide screens; keep the sidebar white. */
  .ns-sidebar.offcanvas-lg {
    background-color: var(--ns-surface) !important;
  }

  .ns-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    flex: none;
  }
}

.ns-sidebar .offcanvas-header {
  padding: 1.25rem 1.25rem 0.5rem;
}

.ns-sidebar-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.75rem 1rem;
}

.ns-brand-row {
  padding: 1.5rem 1.25rem 1rem;
}

.ns-nav-group + .ns-nav-group {
  margin-top: 0.35rem;
}

.ns-nav-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ns-muted);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  user-select: none;
}

.ns-nav-label::-webkit-details-marker {
  display: none;
}

.ns-nav-label::after {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.ns-nav-group[open] > .ns-nav-label::after {
  transform: rotate(45deg);
}

.ns-nav-label:hover {
  color: var(--ns-ink);
  background: var(--ns-bg);
}

.ns-nav-items {
  padding-bottom: 0.4rem;
}

.ns-nav-link {
  position: relative;
  display: block;
  padding: 0.42rem 0.75rem;
  border-radius: 6px;
  color: var(--ns-ink);
  text-decoration: none;
}

.ns-nav-link:hover {
  background: var(--ns-bg);
  color: var(--ns-ink);
}

.ns-nav-link.active {
  background: var(--ns-plum-tint);
  color: var(--ns-plum);
  font-weight: 600;
}

.ns-nav-link.active::before {
  content: "";
  position: absolute;
  left: -0.75rem;
  top: 0.4rem;
  bottom: 0.4rem;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--ns-amber);
}

.ns-user {
  margin-top: auto;
  border-top: 1px solid var(--ns-line);
  padding: 1rem 0.75rem 0;
  font-size: 0.85rem;
}

.ns-user-name {
  font-weight: 600;
}

.ns-main {
  flex: 1;
  min-width: 0;
}

.ns-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--ns-surface);
  border-bottom: 1px solid var(--ns-line);
}

.ns-content {
  max-width: 1180px;
  padding: 2rem 2.25rem 3rem;
}

@media (max-width: 575.98px) {
  .ns-content {
    padding: 1.25rem 1rem 2rem;
  }
}

/* --- Page header ------------------------------------------------------------ */

.ns-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.ns-page-head h1 {
  font-size: 1.6rem;
  margin: 0;
}

.ns-page-head p {
  margin: 0.35rem 0 0;
  color: var(--ns-muted);
  max-width: 60ch;
}

/* --- Panels, tables, lists -------------------------------------------------- */

.ns-panel {
  background: var(--ns-surface);
  border: 1px solid var(--ns-line);
  border-radius: var(--ns-radius);
  box-shadow: 0 1px 2px rgba(35, 28, 39, 0.05), 0 2px 8px rgba(35, 28, 39, 0.04);
}

.ns-panel-body {
  padding: 1.5rem;
}

.ns-panel + .ns-panel,
.ns-section + .ns-section {
  margin-top: 1.5rem;
}

.ns-section-title {
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
}

.ns-table {
  margin: 0;
  --bs-table-bg: transparent;
  --bs-table-hover-bg: var(--ns-bg);
  font-variant-numeric: tabular-nums;
}

.ns-table thead th {
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--ns-muted);
  border-bottom-color: var(--ns-line);
  padding-top: 0.85rem;
  padding-bottom: 0.6rem;
  white-space: nowrap;
}

.ns-table td,
.ns-table th {
  padding-left: 1rem;
  padding-right: 1rem;
  border-color: var(--ns-line);
  vertical-align: middle;
}

.ns-table tbody tr:last-child td {
  border-bottom: 0;
}

.ns-num {
  text-align: right;
  white-space: nowrap;
}

.ns-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--ns-muted);
}

.ns-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.ns-filters .form-control,
.ns-filters .form-select {
  width: auto;
  min-width: 11rem;
}

/* --- Status marks ----------------------------------------------------------- */

.ns-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

.ns-status::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
}

.ns-status-ok { color: #2f7a4f; }
.ns-status-off { color: var(--ns-muted); }
.ns-status-warn { color: #9a5b00; }
.ns-status-info { color: var(--ns-plum); }

.ns-code {
  display: inline-block;
  min-width: 1.6rem;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--ns-line);
  border-radius: 5px;
  text-align: center;
  font-weight: 600;
  font-size: 0.85rem;
  background: var(--ns-bg);
}

/* --- Buttons ---------------------------------------------------------------- */
/* Clear at a glance, still quiet: solid plum for the main action, a visible
   outline for secondary ones, plum text for small inline actions. */

.btn {
  --bs-btn-font-weight: 600;
  --bs-btn-border-radius: 7px;
  --bs-btn-padding-y: 0.45rem;
  --bs-btn-padding-x: 1rem;
  letter-spacing: 0.01em;
}

.btn-sm {
  --bs-btn-padding-y: 0.3rem;
  --bs-btn-padding-x: 0.7rem;
}

.btn-primary {
  --bs-btn-bg: var(--ns-plum);
  --bs-btn-border-color: var(--ns-plum);
  --bs-btn-hover-bg: var(--ns-plum-dark);
  --bs-btn-hover-border-color: var(--ns-plum-dark);
  --bs-btn-active-bg: var(--ns-plum-dark);
  --bs-btn-active-border-color: var(--ns-plum-dark);
  --bs-btn-disabled-bg: var(--ns-plum);
  --bs-btn-disabled-border-color: var(--ns-plum);
  --bs-btn-focus-shadow-rgb: 42, 85, 63;
  box-shadow: 0 1px 2px rgba(35, 28, 39, 0.18);
}

.btn-outline-secondary {
  --bs-btn-color: var(--ns-plum);
  --bs-btn-bg: var(--ns-surface);
  --bs-btn-border-color: #a8c0b2;
  --bs-btn-hover-bg: var(--ns-plum-tint);
  --bs-btn-hover-color: var(--ns-plum-dark);
  --bs-btn-hover-border-color: var(--ns-plum);
  --bs-btn-active-bg: var(--ns-plum-tint);
  --bs-btn-active-color: var(--ns-plum-dark);
  --bs-btn-active-border-color: var(--ns-plum);
  --bs-btn-focus-shadow-rgb: 42, 85, 63;
}

.btn-outline-danger {
  --bs-btn-bg: var(--ns-surface);
  --bs-btn-color: #9b2c2c;
  --bs-btn-border-color: #d9a3a3;
  --bs-btn-hover-bg: #9b2c2c;
  --bs-btn-hover-border-color: #9b2c2c;
}

.btn-quiet {
  --bs-btn-color: var(--ns-plum);
  --bs-btn-hover-color: var(--ns-plum-dark);
  --bs-btn-hover-bg: var(--ns-plum-tint);
  --bs-btn-active-bg: var(--ns-plum-tint);
  --bs-btn-padding-x: 0.6rem;
  text-decoration: underline;
  text-decoration-color: rgba(42, 85, 63, 0.35);
  text-underline-offset: 3px;
}

.btn-quiet:hover {
  text-decoration-color: currentColor;
}

.btn:focus-visible {
  outline: 2px solid var(--ns-amber);
  outline-offset: 2px;
}

/* --- Forms ------------------------------------------------------------------ */

.form-label {
  font-weight: 500;
  margin-bottom: 0.3rem;
}

.form-control,
.form-select {
  border-color: #d3dbd6;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: #6e9a82;
  box-shadow: 0 0 0 0.2rem rgba(42, 85, 63, 0.15);
}

.form-check-input:checked {
  background-color: var(--ns-plum);
  border-color: var(--ns-plum);
}

.form-text {
  color: var(--ns-muted);
}

.ns-form {
  max-width: 34rem;
}

.ns-form-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1.5rem;
}

:focus-visible {
  outline: 2px solid var(--ns-plum);
  outline-offset: 2px;
}

/* --- Alerts and messages ---------------------------------------------------- */

.alert {
  border-radius: var(--ns-radius);
}

.ns-callout {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid #ecd9b5;
  background: var(--ns-amber-tint);
  border-radius: var(--ns-radius);
  margin-bottom: 1.5rem;
}

/* --- Home -------------------------------------------------------------------- */

.ns-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.75rem;
}

.ns-tile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 3.6rem;
  padding: 0.9rem 1.1rem;
  background: var(--ns-plum);
  border: 1px solid var(--ns-plum-dark);
  border-radius: var(--ns-radius);
  box-shadow: 0 1px 2px rgba(35, 28, 39, 0.10), 0 3px 10px rgba(35, 28, 39, 0.10);
  color: #ffffff;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

/* A small chevron so a tile reads as something to click. */
.ns-tile::after {
  content: "";
  flex: none;
  width: 0.45rem;
  height: 0.45rem;
  border-top: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.7;
}

.ns-tile:hover,
.ns-tile:focus-visible {
  background: var(--ns-plum-dark);
  border-color: var(--ns-plum-dark);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(42, 85, 63, 0.18), 0 8px 20px rgba(42, 85, 63, 0.20);
  transform: translateY(-1px);
}

.ns-tile:hover::after {
  opacity: 1;
}

.ns-tile:focus-visible {
  outline: 2px solid var(--ns-amber);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .ns-tile { transition: none; }
  .ns-tile:hover { transform: none; }
}

/* --- Sign-in ----------------------------------------------------------------- */

.ns-auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.ns-auth-card {
  width: 100%;
  max-width: 23rem;
}

.ns-auth-card .ns-brand {
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 2rem;
}

/* --- Small screens -------------------------------------------------------------- */

@media (max-width: 991.98px) {
  .ns-sidebar.offcanvas-lg {
    --bs-offcanvas-width: var(--ns-sidebar-width);
  }
}

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

/* --- Editable tables ----------------------------------------------------------- */

.ns-formset td,
.ns-offerings td {
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}

.ns-formset .form-control,
.ns-formset .form-select,
.ns-offerings .form-control {
  min-width: 6.5rem;
}

.ns-offerings input[name$="-price"],
.ns-formset input[name$="-price"],
.ns-formset input[name$="-price_offset"] {
  min-width: 9rem;
}

.ns-qty-input {
  width: 8rem;
  text-align: right;
}

.ns-qty-col {
  width: 11rem;
}

.ns-pin-panel {
  border-color: #c5d9cd;
  background: var(--ns-plum-tint);
}

/* --- Customers and imports ------------------------------------------------ */

.ns-search {
  display: flex;
  gap: .5rem;
  max-width: 640px;
  margin-bottom: 1.25rem;
}

.ns-search .form-control-lg {
  font-size: 1.05rem;
  border-radius: var(--ns-radius);
}

.ns-phone {
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  white-space: nowrap;
}

.ns-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}

.ns-stat {
  background: var(--ns-surface);
  border: 1px solid var(--ns-line);
  border-radius: var(--ns-radius);
  box-shadow: 0 1px 2px rgba(35, 28, 39, 0.05), 0 2px 8px rgba(35, 28, 39, 0.04);
  padding: .85rem 1rem;
}

.ns-stat-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ns-muted);
}

.ns-stat-value {
  font-family: var(--ns-serif);
  font-size: 1.45rem;
  font-variant-numeric: tabular-nums;
  margin-top: .15rem;
}

.ns-stat-value small {
  font-family: var(--ns-sans);
  font-size: .75rem;
  color: var(--ns-muted);
}

.ns-stat-text {
  font-size: 1.05rem;
}

.ns-dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .4rem 1.5rem;
  margin: 0;
}

.ns-dl dt {
  font-weight: 500;
  color: var(--ns-muted);
}

.ns-dl dd {
  margin: 0;
}

.ns-pos { color: #2f7a4f; }
.ns-neg { color: #9b2c2c; }

.ns-file {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .85em;
  word-break: break-all;
}

.ns-raw {
  font-size: .82rem;
  color: var(--ns-muted);
}

.ns-raw span {
  display: inline-block;
  margin-right: .75rem;
}

.ns-raw b {
  font-weight: 500;
  color: var(--ns-ink);
}

.ns-changes {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ns-changes li + li {
  margin-top: .3rem;
}

@media (max-width: 575.98px) {
  .ns-dl { grid-template-columns: 1fr; gap: .1rem; }
  .ns-dl dd { margin-bottom: .5rem; }
}

/* --- Sales ------------------------------------------------------------------ */

.ns-totals {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .35rem 1.5rem;
  max-width: 420px;
  margin: 0 0 0 auto;
}

.ns-totals dt { font-weight: 400; color: var(--ns-muted); }
.ns-totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.ns-total-label,
.ns-total-value {
  padding-top: .5rem;
  border-top: 1px solid var(--ns-line);
  color: var(--ns-ink) !important;
  font-weight: 600;
}

.ns-total-value {
  font-family: var(--ns-serif);
  font-size: 1.5rem;
}

.ns-total-value small { font-family: var(--ns-sans); font-size: .75rem; color: var(--ns-muted); }

.ns-warn { color: #9a5b00; }

.ns-tabs .nav-link { color: var(--ns-muted); }
.ns-tabs .nav-link.active { color: var(--ns-plum); font-weight: 500; }

.ns-more { margin-top: .25rem; }
.ns-more summary { cursor: pointer; color: var(--ns-plum); font-size: .9rem; margin-bottom: .25rem; }

.ns-callout-sm {
  background: var(--ns-amber-tint);
  border-radius: var(--ns-radius);
  padding: .5rem .75rem;
}

.ns-complete { border-color: var(--ns-plum); }

/* Quick sale */
.ns-quick-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.25rem;
  align-items: center;
  background: var(--ns-plum-tint);
  border-radius: var(--ns-radius);
  padding: .6rem 1rem;
  margin-bottom: 1rem;
}

.ns-quick-bar b { font-weight: 600; }

.ns-last {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  border: 1px solid #b9dcc6;
  background: #eef7f1;
  border-radius: var(--ns-radius);
  padding: .6rem 1rem;
  margin-bottom: 1rem;
}

.ns-danger-zone summary {
  cursor: pointer;
  color: #9b2c2c;
  font-weight: 500;
  list-style: revert;
}

@media print {
  .ns-sidebar, .ns-topbar, .d-print-none { display: none !important; }
  .ns-shell, .ns-main, .ns-content { display: block; margin: 0; padding: 0; }
  body { background: #fff; }
}

/* --- Reports ---------------------------------------------------------------- */

.ns-report-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1rem;
  border-bottom: 1px solid var(--ns-line);
  margin-bottom: 1rem;
}

.ns-report-tabs a {
  padding: .4rem 0;
  color: var(--ns-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.ns-report-tabs a.active {
  color: var(--ns-plum);
  border-bottom-color: var(--ns-amber);
  font-weight: 500;
}

.ns-report-filters .form-control { max-width: 150px; }
.ns-period { font-family: var(--ns-serif); font-size: 1.1rem; margin: 0 0 1rem; }

.ns-bar {
  display: block;
  width: 100%;
  height: 6px;
  margin-top: .3rem;
}

.ns-bar rect { fill: var(--ns-plum); opacity: .75; }
