/* =====================================================================
   Stitching Department Management System — design system
   Light theme · white cards · light-grey canvas · professional blue
   ===================================================================== */
:root {
    --primary: #2563eb;
    --primary-600: #1d4ed8;
    --primary-50: #eff4ff;
    --primary-100: #dbe6fe;
    --bg: #f3f5f9;
    --surface: #ffffff;
    --border: #e5e9f0;
    --text: #1e293b;
    --muted: #64748b;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0891b2;
    --violet: #7c3aed;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 2px 8px rgba(16, 24, 40, .04);
    --shadow-lg: 0 10px 30px rgba(16, 24, 40, .08);
    --sidebar-w: 248px;
    --sidebar-w-collapsed: 74px;
    --topbar-h: 64px;
    --bs-primary: #2563eb;
    --bs-primary-rgb: 37, 99, 235;
    --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14.5px; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); }
.text-muted { color: var(--muted) !important; }
.fw-600 { font-weight: 600; }
.small-caps { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
    position: fixed; inset: 0 auto 0 0; z-index: 1030; display: flex; flex-direction: column;
    transition: width .2s ease, transform .2s ease;
}
.sidebar .brand { height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.brand-logo { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), #4f46e5); color: #fff; display: grid; place-items: center; font-size: 16px; flex-shrink: 0; }
.brand-name { font-weight: 700; font-size: 16px; line-height: 1.1; white-space: nowrap; }
.brand-name small { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 12px 24px; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #94a3b8; font-weight: 600; padding: 14px 12px 6px; white-space: nowrap; }
.nav-link-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #475569;
    font-weight: 500; white-space: nowrap; margin-bottom: 2px;
}
.nav-link-item i { width: 20px; text-align: center; font-size: 15px; color: #94a3b8; }
.nav-link-item:hover { background: var(--primary-50); color: var(--primary); }
.nav-link-item:hover i { color: var(--primary); }
.nav-link-item.active { background: #1e293b; color: #fff; }
.nav-link-item.active i { color: #fff; }
.sidebar-footer { border-top: 1px solid var(--border); padding: 12px 16px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 600; flex-shrink: 0; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; transition: margin-left .2s ease; }
.topbar {
    height: var(--topbar-h); background: rgba(255,255,255,.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: 14px; padding: 0 24px;
}
.topbar .page-title { font-size: 18px; font-weight: 700; margin: 0; }
.topbar .crumbs { font-size: 12px; color: var(--muted); }
.content { padding: 24px; max-width: 1600px; }
.btn-icon { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid var(--border); background: #fff; color: #475569; }
.btn-icon:hover { background: var(--primary-50); color: var(--primary); }
.clock-chip { background: var(--primary-50); color: var(--primary); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; }

body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .sidebar .brand-name,
body.sidebar-collapsed .sidebar .nav-group,
body.sidebar-collapsed .sidebar .nav-text,
body.sidebar-collapsed .sidebar .sidebar-footer .user-meta { display: none; }
body.sidebar-collapsed .nav-link-item { justify-content: center; }
body.sidebar-collapsed .main { margin-left: var(--sidebar-w-collapsed); }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
    body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
    body.sidebar-open .sidebar .brand-name, body.sidebar-open .sidebar .nav-group, body.sidebar-open .sidebar .nav-text { display: block !important; }
    .main { margin-left: 0 !important; }
    .content { padding: 16px; }
    .topbar { padding: 0 14px; }
}
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) { body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 1025; } }

/* ---------- Cards ---------- */
.card { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--surface); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); padding: 14px 18px; font-weight: 600; }
.card-body { padding: 18px; }
.card-title-sm { font-size: 15px; font-weight: 700; margin: 0; }

.stat-card {
    position: relative; border-radius: var(--radius); padding: 18px 18px 16px; background: linear-gradient(180deg, #ffffff 0%, #f8faff 100%);
    border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; height: 100%;
}
.stat-card::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--accent, var(--primary)); opacity: .85; }
.stat-card .stat-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-bg, var(--primary-50)); color: var(--accent, var(--primary)); font-size: 17px; }
.stat-card .stat-label { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 12px; }
.stat-card .stat-value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.stat-card .stat-sub { font-size: 12px; color: var(--muted); }
.accent-blue { --accent: #2563eb; --accent-bg: #eff4ff; }
.accent-green { --accent: #16a34a; --accent-bg: #ecfdf3; }
.accent-orange { --accent: #ea580c; --accent-bg: #fff4ed; }
.accent-violet { --accent: #7c3aed; --accent-bg: #f4f0ff; }
.accent-cyan { --accent: #0891b2; --accent-bg: #ecfeff; }
.accent-red { --accent: #dc2626; --accent-bg: #fef2f2; }
.accent-amber { --accent: #d97706; --accent-bg: #fffbeb; }

.action-tile {
    display: block; border-radius: var(--radius); padding: 18px; border: 1.5px solid var(--tile-border, var(--border));
    background: var(--tile-bg, #fff); color: var(--text); height: 100%; transition: transform .12s ease, box-shadow .12s ease;
}
.action-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); color: var(--text); }
.action-tile .tile-icon { width: 40px; height: 40px; border-radius: 10px; background: #fff; display: grid; place-items: center; color: var(--tile-color, var(--primary)); box-shadow: var(--shadow); }
.action-tile .tile-title { font-weight: 700; margin-top: 12px; color: var(--tile-color, var(--primary)); }
.action-tile .tile-sub { font-size: 12.5px; color: var(--muted); }

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: 11px 12px; border-color: #eef1f6; vertical-align: middle; }
.table thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #f8fafc; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table-hover > tbody > tr:hover > * { background: #f8fbff; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
tr.row-clickable { cursor: pointer; }
.table tfoot td { font-weight: 700; background: #f8fafc; }

/* ---------- Badges ---------- */
.badge { font-weight: 600; padding: .42em .7em; border-radius: 999px; font-size: 11.5px; }
.badge-soft-success { background: #dcfce7; color: #15803d; }
.badge-soft-secondary { background: #eef2f6; color: #475569; }
.badge-soft-primary { background: #dbeafe; color: #1d4ed8; }
.badge-soft-warning { background: #fef3c7; color: #b45309; }
.badge-soft-danger { background: #fee2e2; color: #b91c1c; }
.badge-soft-info { background: #cffafe; color: #0e7490; }

/* Status switch in listings */
.status-toggle { display: inline-flex; align-items: center; gap: 8px; }
.status-toggle .form-check-input { width: 2.4em; height: 1.25em; cursor: pointer; margin: 0; }
.status-toggle .form-check-input:checked { background-color: var(--success); border-color: var(--success); }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: 13px; color: #334155; margin-bottom: 6px; }
.form-control, .form-select { border-radius: var(--radius-sm); border-color: #d9e0ea; padding: .6rem .8rem; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 .2rem rgba(37,99,235,.12); }
.form-control-lg { font-size: 1.15rem; font-weight: 600; }
.btn { border-radius: var(--radius-sm); font-weight: 600; padding: .55rem 1rem; }
.btn-lg { padding: .8rem 1.4rem; font-size: 1.02rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn-soft { background: var(--primary-50); color: var(--primary); border: 1px solid var(--primary-100); }
.btn-soft:hover { background: var(--primary-100); color: var(--primary-600); }
.invalid-feedback { font-size: 12.5px; }
.required::after { content: ' *'; color: var(--danger); }

/* Tom Select alignment */
.ts-wrapper.form-select, .ts-wrapper.form-control { padding: 0 !important; border: 0; }
.ts-control { border-radius: var(--radius-sm) !important; border-color: #d9e0ea !important; padding: .55rem .8rem !important; min-height: 42px; }
.ts-wrapper.focus .ts-control { border-color: var(--primary) !important; box-shadow: 0 0 0 .2rem rgba(37,99,235,.12) !important; }
.ts-dropdown { border-radius: 10px; box-shadow: var(--shadow-lg); }
.ts-wrapper.is-invalid .ts-control { border-color: var(--danger) !important; }

/* Choice cards (machine radios / operation checkboxes) */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.choice {
    position: relative; display: flex; align-items: flex-start; gap: 10px; border: 1.5px solid var(--border); border-radius: 12px;
    padding: 12px 14px; cursor: pointer; background: #fff; transition: border-color .12s, background .12s; user-select: none;
}
.choice:hover { border-color: #b8c8f5; }
.choice input { margin-top: 3px; flex-shrink: 0; width: 1.15em; height: 1.15em; }
.choice .choice-title { font-weight: 600; line-height: 1.2; }
.choice .choice-sub { font-size: 12px; color: var(--muted); }
.choice.selected { border-color: var(--primary); background: var(--primary-50); }
.choice.disabled { opacity: .5; cursor: not-allowed; background: #f8fafc; }

/* Step layout for assignment */
.step { display: flex; gap: 14px; }
.step-num { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-50); color: var(--primary); font-weight: 700; display: grid; place-items: center; flex-shrink: 0; font-size: 13px; }
.step.done .step-num { background: var(--success); color: #fff; }
.step-body { flex: 1; min-width: 0; padding-bottom: 18px; }
.step-title { font-weight: 700; margin-bottom: 8px; }
.info-pill { background: #f8fafc; border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; }
.info-pill .v { font-size: 20px; font-weight: 800; }
.info-pill .l { font-size: 12px; color: var(--muted); font-weight: 600; }

/* Lot grid */
.size-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.size-cell { border: 1px solid var(--border); border-radius: 10px; padding: 8px; background: #fbfcfe; }
.size-cell label { font-size: 12px; font-weight: 700; color: var(--muted); display: block; margin-bottom: 4px; }
.size-cell input { text-align: center; font-weight: 700; }
.article-block { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; background: #fff; margin-bottom: 14px; }

/* Progress */
.progress { height: 8px; border-radius: 999px; background: #edf1f7; }
.progress-bar { border-radius: 999px; }

/* Employee board tiles */
.emp-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.emp-tile { border-radius: 12px; padding: 12px 14px; color: #fff; min-height: 112px; display: flex; flex-direction: column; justify-content: space-between; box-shadow: var(--shadow); }
.emp-tile .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emp-tile .meta { font-size: 12px; opacity: .9; }
.emp-tile .bar { height: 5px; background: rgba(255,255,255,.35); border-radius: 99px; overflow: hidden; }
.emp-tile .bar > span { display: block; height: 100%; background: #fff; }
.emp-tile.good { background: #22a35a; }
.emp-tile.mid { background: #e0a21b; }
.emp-tile.low { background: #e04848; }
.emp-tile.idle { background: #94a3b8; }

/* Misc */
.empty-state { text-align: center; padding: 40px 16px; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar .search { max-width: 320px; }
.btn-group-presets .btn { padding: .45rem .8rem; }
.btn-group-presets .btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.timer-live { font-variant-numeric: tabular-nums; font-weight: 700; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--success); display: inline-block; animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(22,163,74,.6);} 70% { box-shadow: 0 0 0 8px rgba(22,163,74,0);} 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0);} }
.toast-container { z-index: 1090; }
.modal-content { border-radius: var(--radius); border: 0; box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--border); }
.modal-footer { border-top: 1px solid var(--border); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; }
.chart-box { position: relative; height: 290px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 14px 20px; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.sticky-actions { position: sticky; bottom: 0; background: rgba(243,245,249,.92); backdrop-filter: blur(6px); padding: 12px 0; z-index: 5; }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 10% 0%, #fde7ef 0%, transparent 60%), radial-gradient(900px 600px at 100% 100%, #dbe6fe 0%, transparent 60%), #f5f7fb; padding: 20px; }
.login-card { width: 100%; max-width: 420px; background: rgba(255,255,255,.9); backdrop-filter: blur(12px); border: 1px solid #fff; border-radius: 20px; box-shadow: var(--shadow-lg); padding: 34px; }

@media print {
    .sidebar, .topbar, .no-print, .toolbar { display: none !important; }
    .main { margin-left: 0 !important; }
    .card { box-shadow: none; }
}
