/* ==========================================================================
   Printing Press Inventory — application shell + module styling
   Built on Bootstrap 5.2
   ========================================================================== */

:root {
	--ppi-bg:        #f1f4f9;
	--ppi-surface:   #ffffff;
	--ppi-border:    #e4e8ef;
	--ppi-ink:       #1f2937;
	--ppi-muted:     #6b7a90;
	--ppi-primary:   #2563eb;
	--ppi-primary-d: #1d4ed8;
	--ppi-dark:      #1b2434;
	--ppi-dark-2:    #232f42;
	--ppi-success:   #0f9d76;
	--ppi-danger:    #dc3545;
	--ppi-warning:   #d97706;
	--ppi-topbar-h:  56px;
	--ppi-sidebar-w: 232px;
	--ppi-radius:    8px;
}

body {
	background: var(--ppi-bg);
	color: var(--ppi-ink);
	font-size: 13.5px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	padding-top: var(--ppi-topbar-h);
}
body.bare { padding-top: 0; background: var(--ppi-dark); }

a { color: var(--ppi-primary); text-decoration: none; }
a:hover { color: var(--ppi-primary-d); text-decoration: underline; }
.req { color: var(--ppi-danger); }

/* ============================================================ top bar ==== */
.topbar {
	position: fixed;
	top: 0; left: 0; right: 0;
	height: var(--ppi-topbar-h);
	background: var(--ppi-dark);
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 14px;
	z-index: 1035;
	box-shadow: 0 1px 3px rgba(16, 24, 40, .18);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }

.sidebar-toggle {
	background: transparent;
	border: 0;
	color: #b9c3d3;
	font-size: 16px;
	padding: 6px 8px;
	border-radius: 6px;
	cursor: pointer;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.08); color: #fff; }

.brand { display: flex; align-items: center; gap: 9px; color: #fff; }
.brand:hover { color: #fff; text-decoration: none; }
.brand-mark {
	width: 30px; height: 30px;
	display: inline-flex; align-items: center; justify-content: center;
	background: var(--ppi-primary);
	border-radius: 7px;
	font-size: 14px;
}
.brand-text { font-size: 15px; font-weight: 600; letter-spacing: .2px; }

.topbar .today { color: #93a1b5; font-size: 12px; }

.user-button {
	display: flex; align-items: center; gap: 9px;
	background: rgba(255,255,255,.06);
	border: 0;
	color: #e6ebf3;
	padding: 5px 10px 5px 5px;
	border-radius: 30px;
	cursor: pointer;
}
.user-button:hover { background: rgba(255,255,255,.13); }
.avatar {
	width: 28px; height: 28px;
	display: inline-flex; align-items: center; justify-content: center;
	background: var(--ppi-primary);
	color: #fff;
	border-radius: 50%;
	font-size: 12.5px; font-weight: 600;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.user-name { font-size: 12.5px; font-weight: 600; }
.user-role { font-size: 10.5px; color: #93a1b5; }
.user-menu .dropdown-menu { font-size: 13px; }
.user-menu .dropdown-item .fa { width: 18px; }

/* ============================================================ sidebar ==== */
.layout { display: flex; align-items: flex-start; min-height: calc(100vh - var(--ppi-topbar-h)); }

.sidebar {
	width: var(--ppi-sidebar-w);
	flex: 0 0 var(--ppi-sidebar-w);
	background: var(--ppi-dark-2);
	min-height: calc(100vh - var(--ppi-topbar-h));
	padding: 14px 0 0;
	position: sticky;
	top: var(--ppi-topbar-h);
	align-self: stretch;
	display: flex;
	flex-direction: column;
}
.menu-label-text {
	color: #64748b;
	font-size: 10px;
	letter-spacing: 1.2px;
	text-transform: uppercase;
	padding: 0 18px 8px;
}

.nav-sidebar, .submenu { list-style: none; margin: 0; padding: 0; }
.nav-sidebar > li > a {
	display: flex; align-items: center; gap: 10px;
	padding: 9px 18px;
	color: #cbd5e1;
	font-size: 13px;
	border-left: 3px solid transparent;
}
.nav-sidebar > li > a:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.nav-sidebar > li.active > a { color: #fff; background: rgba(37, 99, 235, .18); border-left-color: var(--ppi-primary); }
.menu-icon { width: 17px; text-align: center; font-size: 13px; opacity: .9; }

.submenu { background: rgba(0,0,0,.16); }
.submenu > li > a {
	display: flex; align-items: center; gap: 10px;
	padding: 7px 18px 7px 30px;
	color: #94a3b8;
	font-size: 12.5px;
	border-left: 3px solid transparent;
}
.submenu > li > a:hover { color: #fff; text-decoration: none; }
.submenu > li.active > a { color: #fff; background: rgba(0,0,0,.25); border-left-color: var(--ppi-primary); }

.sidebar-foot {
	margin-top: auto;
	padding: 12px 18px;
	color: #5b6a80;
	font-size: 10.5px;
	border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-backdrop { display: none; }

/* ========================================================== main area ==== */
.main { flex: 1 1 auto; padding: 18px; min-width: 0; }

.content-section {
	background: var(--ppi-surface);
	border: 1px solid var(--ppi-border);
	border-radius: var(--ppi-radius);
	padding: 16px 18px;
	margin-bottom: 16px;
	box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.content-section > h4 {
	font-size: 15.5px;
	font-weight: 600;
	margin: 0 0 14px;
	padding-bottom: 11px;
	border-bottom: 1px solid #eef1f6;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	flex-wrap: wrap;
}
.page-actions { display: inline-flex; gap: 6px; margin-left: auto; }

/* ============================================================== tables === */
.table { font-size: 12.8px; margin-bottom: 0; }
.table > thead > tr > th {
	background: #f7f9fc;
	border-bottom: 1px solid var(--ppi-border);
	font-size: 10.5px;
	letter-spacing: .5px;
	text-transform: uppercase;
	color: #5b6674;
	font-weight: 600;
	white-space: nowrap;
	padding: 9px 8px;
}
.table > tbody > tr > td { padding: 8px; vertical-align: middle; }
.table > tfoot > tr > td { font-weight: 600; background: #f7f9fc; padding: 9px 8px; }
.table-striped > tbody > tr:nth-of-type(odd) > * { background-color: #fbfcfe; }
.table-hover > tbody > tr:hover > * { background-color: #f2f6fd; }

.text-right { text-align: right; }
.num { font-variant-numeric: tabular-nums; }
.row-low > td { background: #fff5f5 !important; }

.badge { font-weight: 500; font-size: 10.5px; padding: .32em .6em; border-radius: 4px; }
.badge-active   { background: #e7f7f1; color: #0f7a5c; }
.badge-inactive { background: #eef1f5; color: #6b7a90; }
.badge-low      { background: #fde8e8; color: #b91c1c; }
.badge-you      { background: #e6efff; color: #1d4ed8; }
.badge-default  { background: #eef1f5; color: #40506b; }

/* =============================================================== forms === */
.form-group { margin-bottom: 13px; }
.form-group > label { font-size: 12px; font-weight: 600; color: #47566b; margin-bottom: 4px; display: block; }
.form-control, .form-select { font-size: 13px; border-color: #dbe1ea; }
.form-control:focus, .form-select:focus {
	border-color: #93b4fb;
	box-shadow: 0 0 0 .18rem rgba(37, 99, 235, .12);
}
select.form-control {
	appearance: none;
	background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236b7a90' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
	background-repeat: no-repeat;
	background-position: right .6rem center;
	background-size: 14px 11px;
	padding-right: 2rem;
}
.has-danger .form-control, .has-danger .form-select { border-color: var(--ppi-danger); }
.field-error { color: var(--ppi-danger); font-size: 11.5px; display: block; margin-top: 4px; }
.form-check-label { font-size: 13px; }

.filter-bar {
	background: #f8fafc;
	border: 1px solid var(--ppi-border);
	border-radius: var(--ppi-radius);
	padding: 11px 13px;
	margin-bottom: 15px;
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 10px;
}
.filter-bar .form-group { margin-bottom: 0; }
.filter-bar .form-control, .filter-bar select { width: auto; min-width: 155px; }

.btn { font-size: 13px; border-radius: 6px; }
.btn-sm { font-size: 12px; padding: .29rem .62rem; }
.btn-primary { background: var(--ppi-primary); border-color: var(--ppi-primary); }
.btn-primary:hover { background: var(--ppi-primary-d); border-color: var(--ppi-primary-d); }

.modal-header { padding: 13px 18px; border-bottom: 1px solid #eef1f6; }
.modal-title { font-size: 15px; font-weight: 600; }
.modal-body { padding: 16px 18px; }
.modal-footer { padding: 11px 18px; border-top: 1px solid #eef1f6; }

/* =========================================================== line grid === */
#lineGrid { border: 1px solid var(--ppi-border); border-radius: var(--ppi-radius); }
#lineGrid .table { margin: 0; }
#lineGrid td { padding: 5px; }
#lineGrid .form-control { padding: 4px 7px; font-size: 12.5px; }
#lineGrid input[readonly] { background: #f3f5f9; font-weight: 600; }
/* keep the small lookup dropdowns wide enough to read, and the numeric
   columns wide enough for a real figure */
#lineGrid select.form-control { min-width: 92px; padding-right: 1.6rem; }
#lineGrid select.line-item { min-width: 215px; }
#lineGrid input[type="number"] { min-width: 74px; }
#lineGrid .line-amount { min-width: 92px; }
#lineGrid > .table > thead > tr > th { padding: 8px 5px; }
/* the GRN grid carries every column the Access form had, so it scrolls
   sideways rather than squeezing fields down to unreadable boxes */
#lineGrid.table-responsive { overflow-x: auto; }
.totals-box { text-align: right; font-size: 14px; padding-top: 12px; }
.totals-box strong { display: inline-block; min-width: 110px; color: var(--ppi-muted); font-weight: 600; }
.totals-box span { font-variant-numeric: tabular-nums; font-weight: 600; }

/* =============================================================== tiles === */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 14px; margin-bottom: 16px; }
.tile {
	background: var(--ppi-surface);
	border: 1px solid var(--ppi-border);
	border-radius: var(--ppi-radius);
	padding: 14px 16px;
	display: flex;
	align-items: center;
	gap: 13px;
	box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.tile-icon {
	width: 38px; height: 38px;
	flex: 0 0 38px;
	display: inline-flex; align-items: center; justify-content: center;
	border-radius: 9px;
	font-size: 15px;
	background: #eef2ff; color: var(--ppi-primary);
}
.tile.success .tile-icon { background: #e7f7f1; color: var(--ppi-success); }
.tile.danger  .tile-icon { background: #fde8e8; color: var(--ppi-danger); }
.tile.warning .tile-icon { background: #fef3e2; color: var(--ppi-warning); }
.tile-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--ppi-muted); }
.tile-value { font-size: 20px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile.danger .tile-value { color: var(--ppi-danger); }
.tile.success .tile-value { color: var(--ppi-success); }

/* ============================================================== login ==== */
.login-screen {
	min-height: 100vh;
	display: flex; align-items: center; justify-content: center;
	padding: 20px;
	background: linear-gradient(150deg, #1b2434 0%, #24344f 55%, #1d3a63 100%);
}
.login-card {
	width: 100%; max-width: 385px;
	background: #fff;
	border-radius: 12px;
	padding: 30px 30px 22px;
	box-shadow: 0 20px 45px rgba(0,0,0,.32);
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand > .fa {
	width: 50px; height: 50px;
	display: inline-flex; align-items: center; justify-content: center;
	background: var(--ppi-primary); color: #fff;
	border-radius: 12px; font-size: 21px;
	margin-bottom: 12px;
}
.login-brand h1 { font-size: 17px; font-weight: 600; margin: 0; }
.login-brand p { font-size: 12.5px; color: var(--ppi-muted); margin: 3px 0 0; }
.login-card .form-control { padding-left: 34px; height: 40px; }
.input-with-icon { position: relative; }
.input-with-icon > .fa {
	position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
	color: #9aa5b1; font-size: 13px; pointer-events: none;
}
.login-card .btn-primary { height: 40px; font-size: 13.5px; font-weight: 600; margin-top: 4px; }
.login-foot { text-align: center; font-size: 11px; color: #9aa5b1; margin: 18px 0 0; }

/* ============================================================== flash ==== */
.flash {
	position: fixed;
	top: calc(var(--ppi-topbar-h) + 12px); right: 18px;
	padding: 11px 16px;
	border-radius: 7px;
	color: #fff;
	font-size: 13px;
	z-index: 2000;
	display: none;
	box-shadow: 0 6px 18px rgba(16, 24, 40, .22);
	max-width: 360px;
}
.flash-success { background: var(--ppi-success); }
.flash-danger  { background: var(--ppi-danger); }

/* ============================================================= loader ==== */
.page-loader {
	position: fixed; inset: 0;
	background: rgba(241, 244, 249, .62);
	backdrop-filter: blur(1px);
	display: none;
	align-items: center; justify-content: center;
	z-index: 2050;
}
.page-loader.show { display: flex; }
.spinner {
	width: 34px; height: 34px;
	border: 3px solid rgba(37, 99, 235, .2);
	border-top-color: var(--ppi-primary);
	border-radius: 50%;
	animation: ppi-spin .7s linear infinite;
}
@keyframes ppi-spin { to { transform: rotate(360deg); } }

.btn .btn-spin {
	display: inline-block;
	width: 12px; height: 12px;
	border: 2px solid rgba(255,255,255,.45);
	border-top-color: #fff;
	border-radius: 50%;
	animation: ppi-spin .7s linear infinite;
	margin-right: 6px;
	vertical-align: -2px;
}

.empty-state { text-align: center; color: #93a1b5; padding: 30px 0; font-size: 13px; }
.empty-state .fa { font-size: 24px; display: block; margin-bottom: 8px; opacity: .55; }

/* ========================================================= datatables ==== */
.dataTables_wrapper .row:first-child { padding-bottom: 8px; }
.dataTables_wrapper .dataTables_filter input {
	border: 1px solid #dbe1ea; border-radius: 6px; padding: 3px 10px; font-size: 12.5px; min-width: 200px;
}
/* the length menu is a native select — leave room for its arrow */
.dataTables_wrapper .dataTables_length select {
	border: 1px solid #dbe1ea; border-radius: 6px; font-size: 12.5px;
	padding: 3px 1.8rem 3px 8px; width: auto; min-width: 68px;
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label { font-size: 12px; color: var(--ppi-muted); }
.dataTables_wrapper .pagination { margin: 8px 0 0; }
.dataTables_wrapper .page-link { font-size: 12.5px; padding: .28rem .58rem; }

/* ============================================================ responsive = */
@media (max-width: 991.98px) {
	.sidebar {
		position: fixed;
		top: var(--ppi-topbar-h); bottom: 0; left: 0;
		transform: translateX(-100%);
		transition: transform .2s ease;
		z-index: 1040;
		overflow-y: auto;
	}
	body.sidebar-open .sidebar { transform: translateX(0); }
	body.sidebar-open .sidebar-backdrop {
		display: block;
		position: fixed; inset: var(--ppi-topbar-h) 0 0 0;
		background: rgba(16, 24, 40, .42);
		z-index: 1039;
	}
	.main { padding: 14px; }
}

/* ============================================================== print ==== */
@media print {
	.topbar, .sidebar, .page-actions, .filter-bar, .btn, .page-loader,
	.dataTables_filter, .dataTables_length, .dataTables_paginate, .dataTables_info { display: none !important; }
	body { padding-top: 0; background: #fff; }
	.main { padding: 0; }
	.content-section { border: 0; box-shadow: none; padding: 0; }
	.table > thead > tr > th { background: #fff !important; }
}
