/* ==========================================================================
   FloorPro Inventory & Job Manager — Design System & Styles
   High-density, space-optimized SaaS UI with horizontal ticker
   ========================================================================== */

:root {
	--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

	/* Color Tokens */
	--bg-app: #0d1117;
	--bg-surface: #161b22;
	--bg-subtle: #21262d;
	--bg-overlay: #1c2128;
	--bg-inset: #090d12;
	--border-subtle: #30363d;
	--border-bold: #484f58;

	--text-main: #f0f6fc;
	--text-muted: #8b949e;
	--text-faint: #6e7681;

	--brand: #2f81f7;
	--brand-hover: #388bfd;
	--brand-bg: rgba(56, 139, 253, 0.12);
	--brand-fg: #58a6ff;
	--brand-border: rgba(56, 139, 253, 0.35);

	--success: #238636;
	--success-hover: #2ea043;
	--success-bg: rgba(46, 160, 67, 0.15);
	--success-fg: #3fb950;
	--success-border: rgba(46, 160, 67, 0.35);

	--warning: #9e6a03;
	--warning-bg: rgba(187, 128, 9, 0.15);
	--warning-fg: #d29922;
	--warning-border: rgba(187, 128, 9, 0.35);

	--error: #da3633;
	--error-bg: rgba(248, 81, 73, 0.15);
	--error-fg: #f85149;
	--error-border: rgba(248, 81, 73, 0.35);

	--chip-pill: #1f2937;
	--radius-sm: 4px;
	--radius-md: 6px;
	--radius-lg: 8px;
	--radius-xl: 12px;
	--radius-full: 9999px;

	--shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
	--shadow-md: 0 4px 12px rgba(0,0,0,0.4);
	--shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}

* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

body {
	font-family: var(--font-sans);
	background-color: var(--bg-app);
	color: var(--text-main);
	line-height: 1.4;
	-webkit-font-smoothing: antialiased;
	min-height: 100vh;
	font-size: 13px;
}

button, input, select, textarea {
	font-family: inherit;
	font-size: inherit;
	color: inherit;
}

.tabular {
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum";
}

/* App Shell */
.app-shell {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	max-width: 1540px;
	margin: 0 auto;
	padding: 0.5rem 1rem 2rem;
}

/* Header */
.top-nav {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 0.5rem 0.75rem;
	background: var(--bg-surface);
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-lg);
	margin-bottom: 0.5rem;
	box-shadow: var(--shadow-sm);
}

.brand-section {
	display: flex;
	align-items: center;
	gap: 0.6rem;
}

.logo-badge {
	width: 28px;
	height: 28px;
	border-radius: var(--radius-md);
	background: linear-gradient(135deg, #1f6feb 0%, #238636 100%);
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	font-weight: 800;
	font-size: 0.85rem;
	box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.brand-title {
	font-size: 1.05rem;
	font-weight: 700;
	color: var(--text-main);
	letter-spacing: -0.01em;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.brand-tag {
	font-size: 0.68rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	padding: 0.15rem 0.45rem;
	background: var(--bg-subtle);
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-full);
	color: var(--brand-fg);
}

.tab-nav {
	display: flex;
	align-items: center;
	background: var(--bg-inset);
	padding: 0.2rem;
	border-radius: var(--radius-md);
	border: 1px solid var(--border-subtle);
	gap: 0.2rem;
}

.tab-btn {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.35rem 0.75rem;
	border: none;
	border-radius: var(--radius-sm);
	background: transparent;
	color: var(--text-muted);
	font-size: 0.82rem;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.15s ease;
	white-space: nowrap;
}

.tab-btn:hover {
	color: var(--text-main);
	background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
	color: #fff;
	background: var(--bg-subtle);
	font-weight: 600;
	box-shadow: var(--shadow-sm);
}

.tab-badge {
	font-size: 0.7rem;
	padding: 0.1rem 0.4rem;
	border-radius: var(--radius-full);
	background: var(--brand-bg);
	color: var(--brand-fg);
	font-weight: 700;
}

.header-actions {
	display: flex;
	align-items: center;
	gap: 0.4rem;
}

/* ==========================================================================
   HORIZONTAL STATS TICKER (Space-Saving Top Bar)
   ========================================================================== */
.ticker-container {
	position: relative;
	background: var(--bg-surface);
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-md);
	margin-bottom: 0.65rem;
	padding: 0.25rem 0.5rem;
	display: flex;
	align-items: center;
	gap: 0.4rem;
	box-shadow: var(--shadow-sm);
}

.ticker-scroll-area {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	overflow-x: auto;
	scroll-behavior: smooth;
	padding: 0.15rem 0;
	flex: 1;
	scrollbar-width: thin;
	scrollbar-color: var(--border-subtle) transparent;
}

.ticker-scroll-area::-webkit-scrollbar {
	height: 3px;
}
.ticker-scroll-area::-webkit-scrollbar-thumb {
	background: var(--border-bold);
	border-radius: 4px;
}

.ticker-pill {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	padding: 0.25rem 0.65rem;
	border-radius: var(--radius-full);
	background: var(--bg-subtle);
	border: 1px solid var(--border-subtle);
	font-size: 0.8rem;
	color: var(--text-main);
	cursor: pointer;
	white-space: nowrap;
	transition: all 0.15s ease;
	user-select: none;
}

.ticker-pill:hover {
	background: var(--bg-overlay);
	border-color: var(--border-bold);
	transform: translateY(-1px);
}

.ticker-pill.active-filter {
	background: var(--brand-bg);
	border-color: var(--brand);
	color: var(--brand-fg);
}

.ticker-pill-icon {
	font-size: 0.9rem;
	line-height: 1;
}

.ticker-pill-label {
	color: var(--text-muted);
	font-size: 0.75rem;
	font-weight: 500;
	text-transform: uppercase;
	letter-spacing: 0.02em;
}

.ticker-pill-val {
	font-weight: 700;
	font-size: 0.85rem;
}

.ticker-pill-val.on-hand {
	color: #e6edf3;
}
.ticker-pill-val.designated {
	color: var(--brand-fg);
}
.ticker-pill-val.net-good {
	color: var(--success-fg);
}
.ticker-pill-val.net-bad {
	color: var(--error-fg);
}
.ticker-pill-val.alert-count {
	color: var(--warning-fg);
}

.ticker-divider {
	width: 1px;
	height: 16px;
	background: var(--border-subtle);
	margin: 0 0.1rem;
	flex-shrink: 0;
}

.ticker-nav-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	border-radius: var(--radius-sm);
	background: var(--bg-subtle);
	border: 1px solid var(--border-subtle);
	color: var(--text-muted);
	cursor: pointer;
	flex-shrink: 0;
	font-size: 0.75rem;
}
.ticker-nav-btn:hover {
	color: var(--text-main);
	background: var(--bg-overlay);
}

/* ==========================================================================
   TOOLBAR
   ========================================================================== */
.toolbar-card {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	background: var(--bg-surface);
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-md);
	padding: 0.4rem 0.65rem;
	margin-bottom: 0.65rem;
}

.toolbar-left, .toolbar-right {
	display: flex;
	align-items: center;
	gap: 0.45rem;
	flex-wrap: wrap;
}

.search-wrapper {
	position: relative;
	min-width: 240px;
	max-width: 380px;
	flex: 1;
}

.search-icon {
	position: absolute;
	left: 0.6rem;
	top: 50%;
	transform: translateY(-50%);
	width: 14px;
	height: 14px;
	color: var(--text-faint);
	pointer-events: none;
}

.search-input {
	width: 100%;
	padding: 0.35rem 0.6rem 0.35rem 1.9rem;
	background: var(--bg-inset);
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-md);
	color: var(--text-main);
	font-size: 0.82rem;
	outline: none;
	transition: border-color 0.15s ease;
}

.search-input:focus {
	border-color: var(--brand);
	box-shadow: 0 0 0 2px var(--brand-bg);
}

.filter-select {
	padding: 0.35rem 0.65rem;
	background: var(--bg-inset);
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-md);
	color: var(--text-main);
	font-size: 0.8rem;
	outline: none;
	cursor: pointer;
}

.filter-select:focus {
	border-color: var(--brand);
}

.view-toggle-btn {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	padding: 0.3rem 0.55rem;
	background: var(--bg-subtle);
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-md);
	color: var(--text-muted);
	font-size: 0.78rem;
	cursor: pointer;
	transition: all 0.15s ease;
}

.view-toggle-btn.active, .view-toggle-btn:hover {
	color: var(--text-main);
	background: var(--bg-overlay);
	border-color: var(--border-bold);
}

/* ==========================================================================
   BUTTONS & UI ELEMENTS
   ========================================================================== */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.35rem;
	padding: 0.35rem 0.75rem;
	border-radius: var(--radius-md);
	font-size: 0.8rem;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.15s ease;
	border: 1px solid transparent;
	text-decoration: none;
	white-space: nowrap;
}

.btn-primary {
	background: var(--brand);
	color: #fff;
}
.btn-primary:hover {
	background: var(--brand-hover);
}

.btn-success {
	background: var(--success);
	color: #fff;
}
.btn-success:hover {
	background: var(--success-hover);
}

.btn-secondary {
	background: var(--bg-subtle);
	border-color: var(--border-subtle);
	color: var(--text-main);
}
.btn-secondary:hover {
	background: var(--bg-overlay);
	border-color: var(--border-bold);
}

.btn-danger {
	background: var(--error-bg);
	border-color: var(--error-border);
	color: var(--error-fg);
}
.btn-danger:hover {
	background: rgba(248, 81, 73, 0.25);
}

.btn-sm {
	padding: 0.2rem 0.45rem;
	font-size: 0.75rem;
}

/* ==========================================================================
   DATA TABLE (High Density & Sticky Headers)
   ========================================================================== */
.table-card {
	background: var(--bg-surface);
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-sm);
	overflow: hidden;
}

.table-responsive {
	overflow-x: auto;
	max-height: calc(100vh - 190px);
	position: relative;
}

.data-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.82rem;
	text-align: left;
}

.data-table thead th {
	position: sticky;
	top: 0;
	z-index: 10;
	background: #191f28;
	color: var(--text-muted);
	font-weight: 600;
	font-size: 0.72rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	padding: 0.45rem 0.65rem;
	border-bottom: 1px solid var(--border-bold);
	white-space: nowrap;
}

.data-table tbody tr {
	border-bottom: 1px solid var(--border-subtle);
	transition: background 0.1s ease;
}

.data-table tbody tr:hover {
	background: rgba(255, 255, 255, 0.025);
}

.data-table tbody tr.row-danger {
	background: rgba(248, 81, 73, 0.06);
}

.data-table tbody td {
	padding: 0.4rem 0.65rem;
	vertical-align: middle;
}

/* Dense mode */
.data-table.dense tbody td {
	padding: 0.22rem 0.5rem;
	font-size: 0.78rem;
}
.data-table.dense thead th {
	padding: 0.35rem 0.5rem;
	font-size: 0.68rem;
}

/* Color Dot */
.color-dot {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	display: inline-block;
	flex-shrink: 0;
	border: 1px solid rgba(255,255,255,0.2);
	box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.item-name-cell {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-weight: 600;
	color: var(--text-main);
}

.category-tag {
	display: inline-block;
	padding: 0.1rem 0.4rem;
	border-radius: var(--radius-sm);
	background: var(--bg-subtle);
	border: 1px solid var(--border-subtle);
	color: var(--text-muted);
	font-size: 0.7rem;
	font-weight: 500;
}

/* Stepper Box Controls (+ and -) */
.qty-stepper {
	display: inline-flex;
	align-items: center;
	background: var(--bg-inset);
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-md);
	overflow: hidden;
	box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}

.step-btn {
	width: 24px;
	height: 24px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--bg-subtle);
	border: none;
	color: var(--text-main);
	font-weight: 700;
	font-size: 0.9rem;
	cursor: pointer;
	transition: background 0.1s ease;
	user-select: none;
}

.step-btn:hover:not(:disabled) {
	background: var(--bg-overlay);
	color: var(--brand-fg);
}

.step-btn:disabled {
	opacity: 0.35;
	cursor: not-allowed;
}

.qty-input {
	width: 44px;
	height: 24px;
	text-align: center;
	background: transparent;
	border: none;
	border-left: 1px solid var(--border-subtle);
	border-right: 1px solid var(--border-subtle);
	color: var(--text-main);
	font-weight: 700;
	font-size: 0.85rem;
	outline: none;
}

.qty-input:focus {
	background: var(--bg-overlay);
}

/* Status Badges */
.status-badge {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	padding: 0.15rem 0.45rem;
	border-radius: var(--radius-full);
	font-size: 0.7rem;
	font-weight: 600;
}

.status-badge.badge-success {
	background: var(--success-bg);
	border: 1px solid var(--success-border);
	color: var(--success-fg);
}

.status-badge.badge-warning {
	background: var(--warning-bg);
	border: 1px solid var(--warning-border);
	color: var(--warning-fg);
}

.status-badge.badge-danger {
	background: var(--error-bg);
	border: 1px solid var(--error-border);
	color: var(--error-fg);
}

.status-badge.badge-muted {
	background: var(--bg-subtle);
	border: 1px solid var(--border-subtle);
	color: var(--text-muted);
}

/* ==========================================================================
   CUSTOMER JOBS CARDS & VIEWS
   ========================================================================== */
.scan-fab { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 900; min-height: 52px; padding: 0 1.6rem; border-radius: 999px; border: 0; background: #e5484d; color: #fff; font-weight: 700; font-size: 1rem; box-shadow: 0 6px 20px rgba(0,0,0,.35); cursor: pointer; }
.scanner-overlay { position: fixed; inset: 0; z-index: 2000; background: #000; display: flex; flex-direction: column; }
.scanner-view { position: relative; flex: 1; overflow: hidden; }
.scanner-video { width: 100%; height: 100%; object-fit: cover; }
.scanner-frame { position: absolute; top: 50%; left: 50%; width: min(65vw, 280px); aspect-ratio: 1; transform: translate(-50%, -50%); border: 3px solid #e5484d; border-radius: 12px; box-shadow: 0 0 0 9999px rgba(0,0,0,.45); }
.scanner-frame.ok { border-color: #3fb950; }
.scanner-panel { padding: 1rem; background: #111; color: #fff; text-align: center; }
.scanner-title { font-weight: 700; font-size: 1.05rem; margin: 0 0 .4rem; }
.scanner-msg { margin: 0 0 .6rem; }
.scanner-msg.ok { color: #3fb950; }
.scanner-msg.bad { color: #ff7b72; }
.scanner-cancel { min-height: 48px; width: 100%; max-width: 320px; }
.jobs-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
	gap: 0.75rem;
}

.job-card {
	background: var(--bg-surface);
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-lg);
	padding: 0.85rem;
	display: flex;
	flex-direction: column;
	gap: 0.65rem;
	box-shadow: var(--shadow-sm);
	transition: border-color 0.15s ease;
}

.job-card:hover {
	border-color: var(--border-bold);
}

.job-card-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 0.5rem;
}

.job-title-block h3 {
	font-size: 0.95rem;
	font-weight: 700;
	color: var(--text-main);
}

.job-title-block p {
	font-size: 0.75rem;
	color: var(--text-muted);
}

.job-allocations-list {
	background: var(--bg-inset);
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-md);
	padding: 0.5rem;
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
}

.allocation-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	font-size: 0.8rem;
	padding: 0.2rem 0.3rem;
	border-radius: var(--radius-sm);
	background: var(--bg-subtle);
}

/* ==========================================================================
   MATRIX TAB
   ========================================================================== */
.matrix-container {
	background: var(--bg-surface);
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-md);
	overflow-x: auto;
	max-height: calc(100vh - 190px);
}

.matrix-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.8rem;
}

.matrix-table th, .matrix-table td {
	padding: 0.35rem 0.55rem;
	border: 1px solid var(--border-subtle);
	text-align: center;
}

.matrix-table th.sticky-col, .matrix-table td.sticky-col {
	position: sticky;
	left: 0;
	background: #191f28;
	z-index: 5;
	text-align: left;
}

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.75);
	backdrop-filter: blur(4px);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 999;
	padding: 1rem;
}

.modal-dialog {
	background: var(--bg-surface);
	border: 1px solid var(--border-bold);
	border-radius: var(--radius-xl);
	width: 100%;
	max-width: 540px;
	box-shadow: var(--shadow-lg);
	overflow: hidden;
	animation: modalIn 0.15s ease-out;
}

@keyframes modalIn {
	from { opacity: 0; transform: scale(0.96) translateY(6px); }
	to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.75rem 1rem;
	border-bottom: 1px solid var(--border-subtle);
	background: var(--bg-overlay);
}

.modal-header h3 {
	font-size: 0.95rem;
	font-weight: 700;
}

.modal-close-btn {
	background: transparent;
	border: none;
	color: var(--text-muted);
	font-size: 1.1rem;
	cursor: pointer;
}

.modal-body {
	padding: 1rem;
	max-height: 75vh;
	overflow-y: auto;
}

.modal-footer {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 0.5rem;
	padding: 0.75rem 1rem;
	border-top: 1px solid var(--border-subtle);
	background: var(--bg-overlay);
}

.form-group {
	margin-bottom: 0.75rem;
}

.form-label {
	display: block;
	font-size: 0.75rem;
	font-weight: 600;
	color: var(--text-muted);
	margin-bottom: 0.25rem;
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

.form-input, .form-select, .form-textarea {
	width: 100%;
	padding: 0.4rem 0.6rem;
	background: var(--bg-inset);
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-md);
	color: var(--text-main);
	font-size: 0.82rem;
	outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
	border-color: var(--brand);
}

/* Utilities */
.alert-strip {
	padding: 0.5rem 0.75rem;
	border-radius: var(--radius-md);
	background: var(--error-bg);
	border: 1px solid var(--error-border);
	color: var(--error-fg);
	font-size: 0.8rem;
	margin-bottom: 0.65rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

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