/*
 * Visual theme shared with the b:bot Poland dashboard.
 * Business layouts stay in style.css; this file only harmonizes foundations
 * and reusable presentation patterns.
 */

:root {
  --canvas: #fafafa;
  --surface: #ffffff;
  --ink: #1d1d1b;
  --muted: #676963;
  --line: #e8e8e3;
  --line-strong: #d8d9d3;
  --teal-pale: #e7f6f5;
  --lime-soft: #efffd7;
  --pink-soft: #fff0f7;
  --red-soft: #fff0ef;
  --orange-soft: #fff3e9;
  --yellow: #f6c945;
  --shadow: 0 18px 55px rgba(29, 29, 27, .08);
  --shadow-soft: 0 8px 28px rgba(29, 29, 27, .07);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --font-body: "Poppins", "Segoe UI", Arial, sans-serif;
  --font-display: "Sigmar", "Poppins", sans-serif;

  /* Legacy aliases used throughout the operational views. */
  --bg: var(--canvas);
  --paper: var(--surface);
  --black: var(--ink);
  --grey: #4f514d;
  --line-soft: rgba(29, 29, 27, .065);
  --soft: #f4f6f4;
  --panel-soft: #f7f8f6;
  --teal-soft: rgba(24, 155, 159, .10);
}

:root[data-theme="dark"] {
  --canvas: #0e1112;
  --surface: #171b1d;
  --ink: #f4f7f7;
  --muted: #aab3b7;
  --line: rgba(244, 247, 247, .16);
  --line-strong: rgba(244, 247, 247, .24);
  --teal-pale: rgba(38, 191, 195, .15);
  --lime-soft: rgba(200, 255, 105, .16);
  --pink-soft: rgba(255, 74, 169, .14);
  --red-soft: rgba(255, 107, 97, .13);
  --orange-soft: rgba(255, 154, 61, .14);
  --shadow-soft: 0 8px 28px rgba(0, 0, 0, .24);
  --soft: #111618;
  --panel-soft: #13191b;
  --line-soft: rgba(244, 247, 247, .08);
}

html {
  min-width: 320px;
  background: var(--canvas);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(190, 251, 98, .08), transparent 34%),
    linear-gradient(180deg, rgba(24, 155, 159, .035), transparent 320px),
    var(--canvas);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

:root[data-theme="dark"] body {
  background:
    linear-gradient(135deg, rgba(200, 255, 105, .045), transparent 34%),
    linear-gradient(180deg, rgba(38, 191, 195, .07), transparent 360px),
    var(--canvas);
}

button,
input,
select,
textarea {
  font-family: var(--font-body);
}

button,
[role="button"],
select,
input[type="checkbox"],
input[type="radio"] {
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: .58;
}

img,
svg {
  max-width: 100%;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--surface);
  background: var(--ink);
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 180ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid rgba(24, 155, 159, .38);
  outline-offset: 3px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--teal) !important;
  outline: 0;
  box-shadow: 0 0 0 3px rgba(24, 155, 159, .13) !important;
}

/* Shell and navigation */

.app-shell {
  grid-template-columns: 252px minmax(0, 1fr) 390px;
}

.sidebar,
.inspector {
  border-color: var(--line);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: 12px 0 48px rgba(29, 29, 27, .025);
}

.sidebar {
  padding: 18px 16px;
}

.brand-block {
  margin-bottom: 18px;
  padding: 12px;
  border-color: var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}

.brand-logo-img {
  border-radius: 14px;
  filter: drop-shadow(0 8px 14px rgba(24, 155, 159, .2));
  box-shadow: none;
}

.brand-logo-type span,
.brand-logo-type strong,
.login-brand span,
.login-brand strong {
  font-family: var(--font-display);
  font-weight: 400;
}

.nav-list {
  gap: 6px;
}

.nav-btn {
  min-height: 44px;
  padding: 9px 11px;
  border-color: transparent;
  border-radius: 12px;
  background: transparent;
  color: #51534e;
  font-size: 12px;
  font-weight: 750;
  transition: color 180ms ease, background 180ms ease, transform 180ms ease;
}

.nav-btn:hover {
  color: var(--teal-dark);
  background: var(--teal-pale);
  transform: translateX(2px);
}

.nav-btn.active,
:root[data-theme="dark"] .nav-btn.active {
  border-color: var(--lime);
  color: #1d1d1b;
  background: var(--lime);
  box-shadow: none;
}

.nav-btn span,
.nav-btn.active span,
:root[data-theme="dark"] .nav-btn.active span {
  border-radius: 9px;
  color: currentColor;
  background: rgba(255, 255, 255, .62);
}

.workspace {
  padding: 18px 20px 32px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 35;
  margin: 0 0 18px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}

.topbar-theme-toggle,
.role-context,
.search-wrap input,
.filters input,
.multi-filter-toggle,
.data-refresh .secondary-btn,
.logout-btn,
.mobile-filters-toggle {
  min-height: 42px;
  border-color: var(--line-strong);
  border-radius: 12px;
}

.search-wrap input::placeholder {
  color: color-mix(in srgb, var(--muted) 78%, transparent);
}

.multi-filter-menu {
  border-color: var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 20px 54px rgba(29, 29, 27, .16);
}

.multi-filter-option,
.multi-filter-clear {
  min-height: 40px;
  border-radius: 10px;
}

.multi-filter-option:hover,
.multi-filter-clear:hover {
  background: var(--teal-pale);
}

.active-filter-bar span,
.active-filter-bar button {
  min-height: 28px;
}

.preview-banner,
.readonly-badge,
.stock-source-bar,
.production-cadence-alert {
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
}

/* Page hierarchy, cards and reusable surfaces */

.view-head {
  min-height: 48px;
  margin-bottom: 16px;
  align-items: flex-end;
}

.view-head h2 {
  position: relative;
  font-size: 24px;
  font-weight: 800;
}

.view-head h2::after {
  content: "";
  display: block;
  width: 38px;
  height: 4px;
  margin-top: 7px;
  border-radius: 99px;
  background: var(--lime);
}

.view-head .muted {
  display: block;
  margin-top: 5px;
}

.panel,
.data-table,
.empty-state,
.detail-form,
.today-card,
.machine-card,
.completion-metric,
.kpi,
.action-tile,
.access-box,
.detail-section,
.excel-extra-fields,
.list-item {
  border-color: var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.panel,
.data-table,
.empty-state,
.detail-form {
  border-radius: var(--radius-lg);
}

.kpi,
.completion-metric,
.today-card,
.action-tile,
.access-box,
.detail-section,
.excel-extra-fields,
.machine-card,
.list-item {
  border-radius: var(--radius-md);
}

.panel-head h2,
.panel-head h3,
.today-card-head h3,
.detail-head h2 {
  font-weight: 800;
}

.kpi {
  min-height: 112px;
  padding: 16px 16px 14px 19px;
  overflow: hidden;
}

.kpi::before {
  width: 5px;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.kpi .label,
.completion-metric span,
.today-metric span {
  font-size: 10px;
  font-weight: 750;
}

.kpi .value,
.completion-metric b {
  font-size: 30px;
  font-weight: 800;
}

.today-card {
  border-left-width: 5px;
}

.today-metric,
.action-tile,
.access-box,
.detail-section,
.excel-extra-fields {
  background: var(--panel-soft);
  box-shadow: none;
}

.list-item,
.machine-card,
tbody tr,
[data-id][role="button"] {
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.list-item:hover,
.machine-card:hover {
  border-color: rgba(24, 155, 159, .38);
  box-shadow: 0 10px 24px rgba(24, 155, 159, .08);
}

/* Buttons and command controls */

.primary-btn,
.secondary-btn,
.secondary-link,
.wide-btn,
.wide-link,
.file-btn,
.mini-action-btn,
.doc-action-btn,
.convert-opportunity-btn {
  min-height: 42px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 800;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, border-color 180ms ease;
}

.primary-btn,
:root[data-theme="dark"] .primary-btn {
  border-color: var(--teal);
  color: #fff;
  background: var(--teal);
  box-shadow: 0 9px 18px rgba(24, 155, 159, .18);
}

.primary-btn:hover,
.wide-link:hover,
.mini-action-btn:hover,
.doc-action-btn:hover,
.convert-opportunity-btn:hover {
  filter: none;
  background: var(--teal-dark);
  transform: translateY(-1px);
}

.secondary-btn:hover,
.secondary-link:hover,
.wide-btn:hover,
.file-btn:hover,
.icon-btn:hover {
  border-color: var(--teal);
  background: var(--teal-pale);
  transform: translateY(-1px);
}

.icon-btn,
#closeDetail,
#closeNewDialog,
.photo-preview-controls button {
  min-width: 42px;
  min-height: 42px;
  border-radius: 12px;
}

.service-tabs button,
.segmented-control button,
.planning-month-controls button {
  min-height: 42px;
}

.service-tabs button.active,
.segmented-control button.active {
  color: #1d1d1b;
  background: var(--lime);
}

.sales-finance-page > .service-tabs {
  border-color: var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-soft);
}

.sales-finance-page > .service-tabs::before {
  border-radius: 10px;
  background: var(--lime);
  box-shadow: none;
}

.sales-finance-page > .service-tabs button.active,
.sales-finance-page > .service-tabs button.active:hover,
.sales-finance-page > .service-tabs button.active em {
  color: #1d1d1b;
}

.sales-finance-page > .service-tabs button.active em {
  background: rgba(255, 255, 255, .6);
}

/* Forms, filters and validation states */

label {
  gap: 6px;
  color: #555752;
  font-size: 10px;
  font-weight: 800;
}

:root[data-theme="dark"] label {
  color: var(--muted);
}

label input,
label select,
label textarea,
.ticket-toolbar select,
.planning-field-select select,
.route-settings-grid input,
.route-settings-grid select {
  min-height: 42px;
  padding: 9px 10px;
  border-color: var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  font-size: 11px;
}

label textarea {
  min-height: 86px;
}

label.is-empty input,
label.is-empty select,
label.is-empty textarea {
  border-color: rgba(249, 115, 22, .34);
  background: var(--orange-soft);
}

label.is-required-missing input,
label.is-required-missing select,
label.is-required-missing textarea {
  border-color: rgba(215, 48, 39, .52);
  background: var(--red-soft);
  box-shadow: 0 0 0 3px rgba(215, 48, 39, .08);
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

/* Tables and dense operational data */

.data-table,
.table-scroll,
.ticket-data-board,
.access-preview-table,
.reconditioning-panel .data-table {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

table {
  border-spacing: 0;
}

th,
td {
  padding: 11px 12px;
}

th {
  border-bottom-color: var(--line);
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 88%, var(--canvas));
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  font-size: 11px;
}

tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--canvas) 58%, transparent);
}

tr:hover td {
  background: var(--teal-pale);
}

/* Status, alerts, empty and loading states */

.status-pill,
.tag,
.missing-chip,
.notification-reasons span,
.v0-status-chip,
.production-validation-badge,
.factory-validation-pill {
  min-height: 24px;
  border-color: var(--line);
  font-size: 10px;
  font-weight: 800;
}

.status-pill::before {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.severity-danger,
.status-blocked,
.status-lost {
  color: var(--red);
}

.empty-state {
  min-height: 150px;
  padding: 24px;
  place-items: center;
  border-style: dashed;
  border-color: var(--line-strong);
  background: var(--panel-soft);
  text-align: center;
  box-shadow: none;
}

.empty-state h2 {
  margin: 0 0 6px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 400;
}

.empty-state p {
  max-width: 420px;
  margin: 0 auto;
}

body.is-loading .topbar::after {
  position: absolute;
  right: 12px;
  bottom: -1px;
  left: 12px;
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(90deg, transparent, var(--teal), var(--lime), transparent);
  background-size: 220% 100%;
  content: "";
  animation: theme-progress 1.2s linear infinite;
}

.active-filter-bar .busy::before,
.stock-source-bar.loading::before {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 2px solid var(--teal);
  border-right-color: transparent;
  border-radius: 50%;
  content: "";
  animation: theme-spin 650ms linear infinite;
}

.toast {
  max-width: min(520px, calc(100vw - 24px));
  min-height: 44px;
  padding: 11px 16px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 12px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .24);
  font-size: 12px;
}

dialog {
  border-color: var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

dialog::backdrop {
  background: rgba(13, 16, 17, .58);
  backdrop-filter: blur(3px);
}

.login-panel {
  padding: 28px;
  border-color: var(--line);
  border-top: 5px solid var(--lime);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 70px rgba(29, 29, 27, .13);
}

.login-panel h1 {
  font-size: 28px;
  font-weight: 800;
}

.login-panel input {
  min-height: 44px;
  border-color: var(--line-strong);
  border-radius: 10px;
}

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

@keyframes theme-progress {
  to { background-position: -220% 0; }
}

@media (max-width: 1500px) {
  .app-shell {
    grid-template-columns: 220px minmax(600px, 1fr);
  }
}

@media (max-width: 850px) {
  .workspace {
    padding: 12px;
  }

  .sidebar {
    padding: 10px 12px 0;
    background: var(--surface);
    box-shadow: none;
  }

  .brand-block {
    margin: 0;
    border-radius: 12px;
    box-shadow: none;
  }

  .topbar {
    top: 0;
    margin-bottom: 14px;
    padding: 8px;
  }

  .nav-btn {
    min-height: 40px;
    border: 1px solid var(--line);
    background: var(--surface);
  }

  .view-head {
    align-items: flex-start;
  }

  .view-head h2 {
    font-size: 21px;
  }
}

@media (max-width: 520px) {
  .topbar {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .view-head,
  .view-head > div {
    width: 100%;
  }

  .view-head .primary-btn,
  .view-head .secondary-btn,
  .view-head .secondary-link {
    width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  label.full {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  .skip-link,
  .sidebar,
  .topbar,
  .inspector,
  .toast {
    display: none !important;
  }

  .app-shell,
  body.single-workspace-mode .app-shell {
    display: block;
  }

  .workspace {
    max-height: none;
    padding: 0;
    overflow: visible;
  }
}
