/* =========================
   Ochno Brand Tokens
   ========================= */
@import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap");

:root {
  /* Brand palette (from Ochno Brand Board) */
  --ochno-black-1: #0f0f0f;
  --ochno-black-2: #181919;
  --ochno-black-3: #212323;

  --ochno-gray: #a7a3a3;
  --ochno-nature: #f3f3f2;
  --white: #ffffff;

  --ochno-orange: #f4981c;
  --ochno-dark-orange: #a93d00;

  /* Layout tokens */
  --radius: 14px;
  --sidebar-w: 260px;
  --topbar-h: 64px;

  /* Sales forecast grid tokens */
  --sf-cell-w: 50px;        /* width of each sub-cell */
  --sf-article-w: 280px;    /* width of Article column */
  --sf-head-row-h: 32px;    /* sticky header row height */
  --sf-side-w: 340px;       /* right pane width */

  /* Light theme (MAIN content) */
  --main-bg: var(--ochno-nature);
  --main-panel: #ffffff;
  --main-panel-2: #fbfbfb;

  --main-text: #111;
  --main-muted: rgba(44, 44, 44, 0.6);
  --main-muted-2: rgba(44, 44, 44, 0.40); /* <-- was white-ish; fix for light UI */

  --main-border: rgba(0, 0, 0, 0.12);
  --main-border-2: rgba(0, 0, 0, 0.18);

  --main-shadow: 0 12px 28px rgba(0,0,0,0.10);

  /* Dark theme (SIDEBAR + TOPBAR only) */
  --nav-bg: var(--ochno-black-2);
  --nav-panel: var(--ochno-black-3);

  --nav-text: #ffffff;
  --nav-muted: rgba(255, 255, 255, 0.72);
  --nav-muted-2: rgba(255, 255, 255, 0.55);

  --nav-border: rgba(255, 255, 255, 0.10);
  --nav-border-2: rgba(255, 255, 255, 0.16);

  --nav-shadow: 0 10px 30px rgba(0,0,0,0.35);

  color-scheme: light;
}

/* =========================
   Base
   ========================= */
* { box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;   /* IMPORTANT: page never scrolls */
  margin: 0;
  font-family: "Open Sans", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--main-bg);
  color: var(--main-text);
}

a { color: inherit; text-decoration: none; }

/* IMPORTANT FIX:
   .small should NOT force a color (it made header labels nearly invisible on light backgrounds).
   Use .muted (or .small.muted) to color text, not .small alone. */
.small { font-size: 12px; }
.small.muted { color: var(--main-muted); }
.muted { color: var(--main-muted); }

hr.sep {
  border: none;
  height: 1px;
  background: var(--main-border);
  margin: 18px 0;
}

/* =========================
   Layout
   ========================= */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---- Sidebar (dark only) ---- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--nav-bg);
  border-right: 1px solid var(--nav-border);
  padding: 18px 16px;
  color: var(--nav-text);
  color-scheme: dark;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border: 1px solid var(--nav-border);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.02);
}

.brand-badge {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--ochno-orange), var(--ochno-dark-orange));
  box-shadow: 0 10px 20px rgba(244,152,28,0.18);
}

.brand-title {
  font-weight: 700;
  letter-spacing: 0.3px;
}

.nav {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--nav-text);
  border: 1px solid transparent;
}

.nav a:hover {
  background: rgba(255,255,255,0.04);
  border-color: var(--nav-border);
}

.nav a.active {
  background: rgba(244,152,28,0.12);
  border-color: rgba(244,152,28,0.32);
}

.nav .tag {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--nav-border);
  color: var(--nav-muted);
}

/* ---- Content ---- */
.content {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ---- Topbar (dark only) ---- */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: rgba(15,15,15,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--nav-border);
  color: var(--nav-text);
  color-scheme: dark;
}

/* ---- Main page area (light) ---- */
.page {
  padding: 18px;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;

  background:
    radial-gradient(1200px 700px at 10% 0%, rgba(244,152,28,0.12), transparent 55%),
    var(--main-bg);
}

.page-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

h1 {
  margin: 0;
  font-size: 22px;
  color: var(--main-text);
}

.page-subtitle {
  margin: 6px 0 0;
  color: var(--main-muted);
  font-size: 13px;
}

/* =========================
   Components (Light)
   ========================= */
.card {
  background: var(--main-panel);
  border: 1px solid var(--main-border);
  border-radius: var(--radius);
  box-shadow: var(--main-shadow);
}

.card-header {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--main-border);
}

.card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--main-text);
}

.card-body { padding: 14px; }

.row-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Buttons (Light) */
.btn {
  border: 1px solid var(--main-border-2);
  background: #ffffff;
  color: var(--main-text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 6px 14px rgba(0,0,0,0.06);
}

.btn:hover { background: #fafafa; }

.btn-primary {
  border-color: rgba(244,152,28,0.55);
  background: rgba(244,152,28,0.20);
}

.btn-primary:hover { background: rgba(244,152,28,0.28); }

.btn-danger {
  border-color: rgba(220, 38, 38, 0.35);
  background: rgba(220, 38, 38, 0.10);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

/* =========================
   Forms (Light)
   ========================= */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

label {
  font-size: 12px;
  color: var(--main-muted);
}

.input, .select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--main-border);
  background: #ffffff;
  color: var(--main-text);
  outline: none;
}

.input:focus, .select:focus {
  border-color: rgba(244,152,28,0.55);
  box-shadow: 0 0 0 3px rgba(244,152,28,0.18);
}

/* Select dropdown fixes (Light main) */
.select {
  appearance: auto;
  -webkit-appearance: auto;
  -moz-appearance: auto;
}

.select option {
  background-color: #ffffff;
  color: var(--main-text);
}

/* Sidebar/topbar (dark) */
.sidebar .select option,
.topbar .select option {
  background-color: var(--nav-panel);
  color: var(--nav-text);
}

/* =========================
   Topbar user block (dark)
   ========================= */
.userbox {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--nav-border);
  background: rgba(255,255,255,0.03);
  border-radius: 999px;
  color: var(--nav-text);
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: rgba(244,152,28,0.22);
  border: 1px solid rgba(244,152,28,0.25);
}

/* =========================
   Generic data grid (shared)
   ========================= */
.data-grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  table-layout: fixed;
}

.data-grid th,
.data-grid td {
  border-bottom: 1px solid var(--main-border);
  border-right: 1px solid var(--main-border);
  vertical-align: middle;
  background: #fff;
}

.data-grid th {
  background: #fbfbfb;
  color: var(--main-muted);
  font-weight: 700;
  text-align: left;
  padding: 8px 10px;
}

.data-grid td {
  padding: 0;
  height: 34px;
}

.data-grid tr:last-child td { border-bottom: none; }
.data-grid th:last-child,
.data-grid td:last-child { border-right: none; }

/* Sticky header row */
.data-grid thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #fbfbfb;
}

/* Sticky first column */
.data-grid th:first-child,
.data-grid td:first-child {
  position: sticky;
  left: 0;
}

.data-grid thead th:first-child { z-index: 7; }
.data-grid tbody td:first-child {
  z-index: 6;
  background: #fff;
}

.data-grid th:first-child,
.data-grid td:first-child {
  box-shadow: 2px 0 0 rgba(0,0,0,0.06);
}

/* Cell input */
.cell-input {
  width: 100%;
  border: 0;
  border-radius: 0;
  padding: 6px 8px;
  outline: none;
  background: transparent;
  color: var(--main-text);
  box-shadow: none;
}

.cell-input:focus {
  background: #fff;
  box-shadow: inset 0 0 0 2px rgba(244,152,28,0.95);
}

.cell-input[disabled],
.cell-input.is-readonly {
  background: #f6f6f6;
  color: rgba(0,0,0,0.55);
}

.cell-input.is-dirty {
  background: rgba(244, 152, 28, 0.14);
  box-shadow: inset 0 0 0 2px rgba(244, 152, 28, 0.55);
}

/* Publish disabled state */
.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* =========================
   Scroll containers (shared)
   ========================= */
.sf-table-wrap,
.data-table-wrap {
  flex: 1;
  min-height: 0;
  min-width: 0;

  width: 100%;
  overflow: auto;

  border: 1px solid var(--main-border);
  border-radius: var(--radius);
  background: #fff;
  position: relative;
}

.sf-table-wrap::after,
.data-table-wrap::after {
  content: "";
  position: sticky;
  left: 0;
  bottom: 0;
  display: block;
  height: 1px;
  width: 100%;
  background: var(--main-border);
  z-index: 5;
}

/* =========================
   Sales forecast workspace + header toolbar
   ========================= */
.sf-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sf-side-w);
  gap: 14px;
  align-items: stretch;

  flex: 1;
  min-height: 0;
  overflow: hidden;
}

@media (max-width: 1200px) {
  .sf-workspace {
    grid-template-columns: 1fr;
  }
}

.sf-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.sf-card-body {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Right pane stays docked */
.sf-side {
  height: 100%;
  overflow: auto;
}

/* Header layout: title + controls */
.sf-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.sf-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}

.sf-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.sf-control-group {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Checkbox/radio label styling */
.sf-control-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  line-height: 1;
  margin: 0;
  color: var(--main-text); /* explicit, to ensure visible */
  font-size: 12px;
}

.sf-control-label .muted {
  color: var(--main-muted);
}

.sf-control-label input[type="checkbox"],
.sf-control-label input[type="radio"] {
  transform: translateY(1px);
  cursor: pointer;
}

.sf-select {
  height: 32px;
  padding: 6px 10px;
  border-radius: 10px;
}

@media (max-width: 900px) {
  .sf-header-title {
    flex: 1 1 100%;
  }
}

/* =========================
   Sales forecast grid table
   ========================= */
.sf-grid {
  width: max-content;
  min-width: 100%;
  table-layout: fixed;
  font-size: 12px;
}

.sf-grid thead th {
  height: var(--sf-head-row-h);
  padding-top: 0;
  padding-bottom: 0;
  vertical-align: middle;
}

.sf-grid thead tr:nth-child(1) th {
  position: sticky;
  top: 0;
  z-index: 6;
  background: #fbfbfb;
}

.sf-grid thead tr:nth-child(2) th {
  position: sticky;
  top: var(--sf-head-row-h);
  z-index: 6;
  background: #fbfbfb;
}

.sf-grid thead tr:nth-child(1) th.sf-sticky-left,
.sf-grid thead tr:nth-child(2) th.sf-sticky-left {
  z-index: 8;
}

.sf-article-col {
  min-width: var(--sf-article-w);
  width: var(--sf-article-w);
  max-width: calc(var(--sf-article-w) + 80px);
}

.sf-article .sf-sku {
  font-weight: 700;
  color: var(--main-text);
}

.sf-article .sf-desc {
  font-size: 12px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sf-month { text-align: center; }
.sf-sub { text-align: center; font-weight: 700; font-size: 12px; }

.sf-cell {
  width: var(--sf-cell-w);
  min-width: var(--sf-cell-w);
  max-width: var(--sf-cell-w);
}

.sf-input {
  text-align: right;
  height: 28px;
  padding: 4px 6px;
}

.cell-input.is-readonly {
  text-align: center;
}

/* =========================
   SKU grid
   ========================= */
.sku-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sku-card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
}

.sku-table-wrap { flex: 1; }

.sku-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* Column sizing */
.sku-col-article { width: 160px; }
.sku-col-desc { width: 340px; }
.sku-col-manufacturer { width: 220px; }
.sku-col-note { width: 320px; }
.sku-col-int { width: 140px; }
.sku-col-coo { width: 120px; }

/* Fortnox manager */
.fn-manager {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
  align-items: start;
}

.fn-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.fn-right {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.fn-sync {
  grid-column: 1 / -1;
  margin-top: 14px;
}

.fn-progress {
  height: 12px;
  border-radius: 999px;
  background: rgba(0,0,0,0.06);
  overflow: hidden;
}

.fn-progress-bar {
  height: 100%;
  width: 0%;
  background: rgba(245, 158, 11, 0.85);
  transition: width 120ms linear;
}

.fn-console {
  margin-top: 12px;
  height: 260px;
  overflow: auto;
  background: #0b0f14;
  color: #dbe6f3;
  border-radius: 12px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.35;
  white-space: pre-wrap;
  border: 1px solid rgba(255,255,255,0.08);
}
