/**
 * Sonji Factory Operations - Modern Design System & Stylesheet
 */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-subtle: #dbeafe;
    --primary-text: #1e40af;

    --sidebar-bg: #eca35f;
    --sidebar-border: #d68b45;
    --sidebar-hover: #f2b87d;
    --sidebar-text: #0a0a0a;
    --sidebar-text-active: #000000;
    --sidebar-accent: #c2410c;
    --sidebar-active-bg: rgba(255, 255, 255, 0.5);
    --sidebar-heading: #0a0a0a;
    --sidebar-icon: #7a3f10;
    --sidebar-footer-bg: #e3924a;
    --sidebar-muted: #5a3a1c;

    --body-bg: #f8fafc;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --card-radius: 14px;
    --card-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --card-shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);

    --text-heading: #0f172a;
    --text-body: #334155;
    --text-muted: #64748b;

    --status-success-bg: #ecfdf5;
    --status-success-text: #065f46;
    --status-success-border: #a7f3d0;

    --status-warning-bg: #fffbeb;
    --status-warning-text: #92400e;
    --status-warning-border: #fde68a;

    --status-danger-bg: #fef2f2;
    --status-danger-text: #991b1b;
    --status-danger-border: #fecaca;

    --status-info-bg: #f0f9ff;
    --status-info-text: #075985;
    --status-info-border: #bae6fd;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--body-bg);
    color: var(--text-body);
    font-size: 0.94rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* App Shell Layout */
.app-shell {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: 270px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1040;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    padding: 20px 20px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-heading);
}

.sidebar-brand img {
    height: 38px;
    width: auto;
}

.sidebar-nav {
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.nav-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-heading);
    padding: 12px 12px 6px;
    margin: 0;
}

.nav-group-toggle {
    background: transparent;
    border: none;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    color: var(--sidebar-heading);
    font-size: 0.76rem;
    font-weight: 800;
    border-radius: 9px;
    cursor: pointer;
    transition: all 0.18s ease;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    /* A group is a header band; its screens below are plain, indented lines. */
    background: rgba(0, 0, 0, 0.08);
}

.nav-group:not(.is-collapsed) > .nav-group-toggle {
    background: rgba(0, 0, 0, 0.14);
}

.nav-group-toggle .group-label {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.nav-group-toggle .group-icon {
    font-size: 1.15rem;
    color: var(--sidebar-icon);
    transition: color 0.18s ease;
}

/* A group row hovers like a screen link: soft background, dark text, accent icon. */
.nav-group-toggle:hover,
.nav-group-toggle:focus-visible {
    color: var(--text-heading);
    background: var(--sidebar-hover);
    outline: none;
}

.nav-group-toggle:hover .group-icon,
.nav-group-toggle:focus-visible .group-icon,
.nav-group:not(.is-collapsed) > .nav-group-toggle .group-icon {
    color: var(--sidebar-accent);
}

.nav-group-toggle .group-chevron {
    transition: transform 0.2s ease;
    font-size: 0.75rem;
}

.nav-group.is-collapsed .group-chevron {
    transform: rotate(-90deg);
}

.nav-group.is-collapsed .nav-group-items {
    display: none;
}

.nav-group-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 4px 0 8px 10px;
    padding-left: 4px;
    border-left: 2px solid rgba(0, 0, 0, 0.25);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 500;
    border-radius: 9px;
    transition: all 0.18s ease;
}

.sidebar-link i {
    font-size: 1.05rem;
    color: var(--sidebar-icon);
    transition: color 0.18s ease;
}

.sidebar-link:hover {
    color: var(--text-heading);
    background: var(--sidebar-hover);
}

.sidebar-link:hover i {
    color: var(--sidebar-accent);
}

.sidebar-link.active {
    color: var(--sidebar-text-active);
    background: var(--sidebar-active-bg);
    border-left: 3px solid var(--sidebar-accent);
}

.sidebar-link.active i {
    color: var(--sidebar-accent);
}

.sidebar-link .badge {
    margin-left: auto;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--sidebar-border);
    background: var(--sidebar-footer-bg);
}

.user-profile-chip {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-heading);
    text-decoration: none;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.74rem;
    color: #1f1f1f;
}

/* Sidebar Collapsed State */
.app-shell.sidebar-collapsed .sidebar {
    width: 0;
    padding: 0;
    border-right: none;
    transform: translateX(-100%);
}

.sidebar-toggle {
    background: #ffffff;
    border: 1px solid var(--card-border);
    color: var(--text-heading);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: all 0.15s ease;
}

.sidebar-toggle:hover {
    background: #f1f5f9;
    color: var(--primary);
}

/* Main Content Area */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
}

/* The sign-in page's brand panel is the sidebar's orange too, with dark text. */
.login-brand-panel { background: linear-gradient(145deg, var(--sidebar-bg) 0%, var(--sidebar-footer-bg) 100%); border-right: 1px solid var(--sidebar-border); color: var(--sidebar-text); }
.login-brand-panel h2 { color: #000000; }
.login-brand-panel .login-muted { color: var(--sidebar-muted); }
.login-brand-panel .login-panel-foot { border-top: 1px solid var(--sidebar-border); }
/* The form side is a light tint of the same orange; the fields and the demo box stay white. */
.login-form-panel { background: color-mix(in srgb, var(--sidebar-bg) 20%, #ffffff); }

/* The page footer is the same colour as the sidebar and the top bar. */
.app-footer {
    background: var(--sidebar-bg);
    border-top: 1px solid var(--sidebar-border);
    color: var(--sidebar-muted);
}
.app-footer .text-success { color: #14532d !important; }

/* Top Navigation Bar */
.top-navbar {
    height: 64px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--sidebar-border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.breadcrumb-nav {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.86rem;
    color: var(--text-muted);
}

.breadcrumb-nav a {
    color: var(--sidebar-muted);
    text-decoration: none;
}

.breadcrumb-nav a:hover {
    color: var(--primary);
}

.breadcrumb-nav .separator {
    color: #cbd5e1;
}

.breadcrumb-nav .current {
    color: var(--text-heading);
    font-weight: 600;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.quick-search {
    position: relative;
    width: 280px;
}

.quick-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}

.quick-search input {
    width: 100%;
    height: 38px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    padding-left: 36px;
    padding-right: 12px;
    font-size: 0.86rem;
    background: #f8fafc;
    transition: all 0.15s ease;
}

.quick-search input:focus {
    background: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    outline: none;
}

.main-content {
    flex: 1;
    padding: 24px;
}

/* Modern Card System */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    margin-bottom: 24px;
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--card-shadow-lg);
}

.card-header {
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    padding: 16px 20px;
    font-weight: 700;
    color: var(--text-heading);
    border-top-left-radius: var(--card-radius) !important;
    border-top-right-radius: var(--card-radius) !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h4, .card-header h5, .card-header h6 {
    margin: 0;
    font-weight: 700;
    color: var(--text-heading);
}

.card-body {
    padding: 20px;
}

/* Stat & KPI Cards */
.stat-card {
    display: flex;
    align-items: center;
    padding: 20px;
    border-radius: var(--card-radius);
    background: #ffffff;
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
    gap: 16px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-lg);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-icon.primary {
    background: #eff6ff;
    color: #2563eb;
}

.stat-icon.success {
    background: #ecfdf5;
    color: #059669;
}

.stat-icon.warning {
    background: #fffbeb;
    color: #d97706;
}

.stat-icon.danger {
    background: #fef2f2;
    color: #dc2626;
}

.stat-icon.info {
    background: #f0f9ff;
    color: #0284c7;
}

.stat-details {
    flex: 1;
}

.stat-title {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text-heading);
    line-height: 1.1;
}

.stat-trend {
    font-size: 0.78rem;
    font-weight: 600;
    margin-top: 4px;
}

.stat-trend.positive { color: #059669; }
.stat-trend.neutral { color: #64748b; }

/* Buttons */
.btn {
    font-weight: 600;
    border-radius: 10px;
    padding: 8px 16px;
    font-size: 0.88rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.15s ease;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 1px 2px 0 rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.3);
}

.btn-light {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: var(--text-body);
}

.btn-light:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

/* Modern Tables */
.table-responsive {
    border-radius: 10px;
    overflow-x: auto;
}

.table {
    margin-bottom: 0;
    vertical-align: middle;
}

.table thead th {
    background: #e9eef5;
    color: #334155;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 7px 6px;
    border: 1px solid #d3dbe6;
    border-bottom: 2px solid #b6c2d2;
    white-space: nowrap;
}

.table tbody td {
    padding: 6px;
    color: var(--text-body);
    font-size: 0.8rem;
    line-height: 1.25;
    border: 1px solid #dfe5ee;
    background: #fff;
}

/* A grid, so every row reads as its own row: lines between rows and columns, light bands, clear hover. */
.table thead th:first-child, .table tbody td:first-child { border-left: 0; }
.table thead th:last-child, .table tbody td:last-child { border-right: 0; }
.table tbody tr:nth-child(even) > td { background: #f4f7fb; }
.table-hover tbody tr:hover > td { background: #e3edff; }


/* Badges */
.badge {
    padding: 5px 10px;
    font-weight: 700;
    font-size: 0.74rem;
    border-radius: 6px;
    letter-spacing: 0.02em;
}

.badge-status-available { background: var(--status-success-bg); color: var(--status-success-text); border: 1px solid var(--status-success-border); }
.badge-status-running { background: var(--primary-subtle); color: var(--primary-text); border: 1px solid #bfdbfe; }
.badge-status-idle { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.badge-status-maintenance { background: var(--status-warning-bg); color: var(--status-warning-text); border: 1px solid var(--status-warning-border); }
.badge-status-breakdown { background: var(--status-danger-bg); color: var(--status-danger-text); border: 1px solid var(--status-danger-border); }
.badge-status-setup { background: var(--status-info-bg); color: var(--status-info-text); border: 1px solid var(--status-info-border); }

/* Priority Badges */
.badge-priority-normal { background: #f1f5f9; color: #475569; }
.badge-priority-urgent { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.badge-priority-critical { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* Progress bar */
.progress {
    height: 8px;
    border-radius: 999px;
    background-color: #f1f5f9;
    overflow: hidden;
}

.progress-bar {
    border-radius: 999px;
    background: linear-gradient(90deg, #3b82f6, #2563eb);
}

/* Machine Fleet Grid */
.machine-fleet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
}

.machine-card-unit {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 14px 10px;
    text-align: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
}

.machine-card-unit:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow);
    border-color: #93c5fd;
}

.machine-unit-code {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-heading);
    letter-spacing: -0.02em;
}

.machine-unit-type {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.machine-unit-badge {
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 999px;
    font-weight: 700;
    display: inline-block;
}

/* Operator Window Execution Cards */
.operator-work-card {
    border-left: 4px solid var(--primary);
    transition: all 0.2s ease;
}

.operator-work-card.in-progress {
    border-left-color: #10b981;
    background: #fafffc;
}

.operator-work-card.paused {
    border-left-color: #f59e0b;
}

/* Action Button Groups */
.action-btn-group {
    display: flex;
    gap: 6px;
    align-items: center;
}

.action-btn-group .btn {
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 0.85rem;
    border-radius: 8px;
}

/* Forms styling */
.form-label {
    font-weight: 600;
    font-size: 0.86rem;
    color: var(--text-heading);
    margin-bottom: 6px;
}

.form-control, .form-select {
    border-radius: 9px;
    border: 1px solid #cbd5e1;
    padding: 8px 14px;
    font-size: 0.9rem;
    transition: all 0.15s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    outline: none;
}

/* Modal styling */
.modal-content {
    border-radius: 16px;
    border: none;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.modal-header {
    border-bottom: 1px solid #f1f5f9;
    padding: 18px 24px;
}

.modal-footer {
    border-top: 1px solid #f1f5f9;
    padding: 16px 24px;
}

/* Print styles for Job Cards */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }
    .sidebar, .top-navbar, .no-print {
        display: none !important;
    }
    .main-wrapper, .main-content {
        padding: 0 !important;
        margin: 0 !important;
    }
    .print-card {
        border: 1px solid #000000 !important;
        box-shadow: none !important;
    }
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
    }

    .app-shell:not(.sidebar-collapsed) .sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.6);
        backdrop-filter: blur(2px);
        z-index: 1030;
        display: none;
    }

    .app-shell:not(.sidebar-collapsed) .sidebar-backdrop {
        display: block;
    }
}

/* Tom Select lists that are attached to <body> (used by selects inside modals) must sit above
   the Bootstrap modal (z-index 1055), otherwise they open behind it and look broken. */
body > .ts-dropdown {
    z-index: 2000;
}

/* A wide table keeps its Action column pinned to the right edge while the other columns scroll sideways. */
.table .sticky-action { position: sticky; right: 0; z-index: 2; box-shadow: -6px 0 8px -6px rgba(15, 23, 42, .18); }
.table thead .sticky-action { z-index: 3; }

/* Machine Roster: operators shown as small people chips inside the machine rows */
.roster-ops { display: flex; flex-wrap: wrap; gap: 5px; }
.roster-op { display: flex; align-items: center; gap: 6px; padding: 2px 8px 2px 3px; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; min-width: 0; }
.roster-avatar { width: 20px; height: 20px; border-radius: 6px; background: linear-gradient(135deg, #3b82f6, #1d4ed8); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: .6rem; font-weight: 700; flex-shrink: 0; }
.roster-op-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.roster-op-name { font-weight: 600; font-size: .78rem; color: #0f172a; white-space: nowrap; }
.roster-op-note { font-size: .66rem; color: #64748b; white-space: nowrap; }
.roster-op-cover { border-color: #bae6fd; background: #f0f9ff; }
.roster-op-cover .roster-avatar { background: linear-gradient(135deg, #0ea5e9, #0369a1); }
.roster-op-leave { border-style: dashed; border-color: #fcd34d; background: #fffbeb; }
.roster-op-leave .roster-avatar { background: #f59e0b; }
.roster-op-leave .roster-op-name { color: #92400e; }
.roster-op-free { border-color: #bbf7d0; background: #f0fdf4; }
.roster-op-free .roster-avatar { background: linear-gradient(135deg, #22c55e, #15803d); }
.table.roster-table tbody tr.roster-section > td { background: #e2e8f0; font-weight: 700; font-size: .74rem; color: #334155; text-transform: uppercase; letter-spacing: .04em; padding-top: 6px; padding-bottom: 6px; }
.action-btn-group .roster-change-btn { width: auto; height: auto; padding: 2px 8px; font-size: .74rem; font-weight: 600; white-space: nowrap; }

/* Every table in the app is compact by default (the one size). Extras for what sits inside the cells: */
.table tbody td .small, .table tbody td.small { font-size: .78rem; }
.table .badge { font-size: .68rem; padding: 3px 6px; }
.table .action-btn-group { gap: 3px; }
.table .action-btn-group .btn { width: 25px; height: 25px; font-size: .75rem; }
.table .progress { height: 5px !important; }
.list-search { position: relative; }
.list-pagination .pagination { --bs-pagination-padding-x: .6rem; --bs-pagination-padding-y: .2rem; --bs-pagination-font-size: .8rem; }

/* No transitions while the page is first drawn (the class is removed by main.js after the first frame). */
.preload *, .preload *::before, .preload *::after { transition: none !important; }

/* Dashboard blocks: a titled card with big clickable numbers */
.dash-block { --tone: #2563eb; background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 1px 2px rgba(15, 23, 42, .05); overflow: hidden; }
.dash-block.dash-tone-success { --tone: #059669; }
.dash-block.dash-tone-info { --tone: #0891b2; }
.dash-block.dash-tone-warning { --tone: #d97706; }
.dash-block.dash-tone-secondary { --tone: #475569; }
.dash-block-head { display: flex; align-items: center; gap: 8px; padding: 9px 16px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; border-left: 4px solid var(--tone); font-weight: 700; font-size: .86rem; color: #0f172a; }
.dash-block-head i { color: var(--tone); }
.dash-block-note { margin-left: auto; font-weight: 500; font-size: .74rem; color: #64748b; }
.dash-tile { --tile: #2563eb; display: block; height: 100%; padding: 14px 16px; text-decoration: none; color: inherit; }
.dash-tile.dash-tone-success { --tile: #059669; } .dash-tile.dash-tone-info { --tile: #0891b2; } .dash-tile.dash-tone-warning { --tile: #d97706; }
.dash-tile.dash-tone-danger { --tile: #dc2626; } .dash-tile.dash-tone-secondary { --tile: #475569; }
a.dash-tile:hover { background: #f1f5f9; }
.dash-tile-label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #64748b; }
.dash-tile-value { font-size: 1.9rem; font-weight: 800; line-height: 1.15; color: var(--tile); }
.dash-tile-sub { font-size: .74rem; color: #64748b; margin-top: 2px; }
.dash-col-sep { border-left: 1px solid #e2e8f0; }
/* A dashboard column: a header, the area's numbers as equal-height lines, and a link to its screen pinned to the bottom. */
.dash-cols .dash-block { display: flex; flex-direction: column; background: #f4f6fa; }
.dash-cols .dash-block-head { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; align-items: center; padding: 11px 14px 10px; background: color-mix(in srgb, var(--tone) 7%, #ffffff); border-left: 4px solid var(--tone); min-height: 64px; }
.dash-cols .dash-head-icon { grid-row: 1 / span 2; width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--tone) 16%, #ffffff); }
.dash-cols .dash-head-icon i { font-size: 1rem; color: var(--tone); }
.dash-cols .dash-head-title { font-size: .92rem; font-weight: 800; color: #0f172a; line-height: 1.2; }
.dash-cols .dash-block-note { grid-column: 2; margin: 0; padding: 0; width: auto; font-size: .72rem; font-weight: 500; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-row { --tile: #2563eb; display: flex; align-items: center; gap: 10px; height: 64px; margin: 8px 10px 0; padding: 0 14px 0 14px; text-decoration: none; color: inherit; background: #ffffff; border: 1px solid #e2e8f0; border-left: 4px solid var(--tile); border-radius: 10px; box-shadow: 0 1px 2px rgba(15, 23, 42, .06); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.dash-row:has(+ .dash-foot), .dash-row:last-child { margin-bottom: 10px; }
.dash-row.dash-tone-success { --tile: #059669; } .dash-row.dash-tone-info { --tile: #0891b2; } .dash-row.dash-tone-warning { --tile: #d97706; }
.dash-row.dash-tone-danger { --tile: #dc2626; } .dash-row.dash-tone-secondary { --tile: #475569; }
a.dash-row:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(15, 23, 42, .12); border-color: #cbd5e1; border-left-color: var(--tile); }
.dash-row-total { border-left-width: 6px; }
.dash-row-total .dash-row-label { color: #0f172a; }
.dash-row-total .dash-row-value { font-size: 1.85rem; }
.dash-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.dash-row-label { display: flex; align-items: center; gap: 8px; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: #475569; line-height: 1.25; }
.dash-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tile); flex-shrink: 0; }
.dash-share { display: flex; align-items: center; gap: 8px; }
.dash-bar { flex: 1; height: 5px; border-radius: 3px; background: #e2e8f0; overflow: hidden; }
.dash-bar span { display: block; height: 100%; border-radius: 3px; background: var(--tile); }
.dash-pct { font-size: .68rem; font-weight: 600; color: #64748b; min-width: 28px; text-align: right; }
.dash-row-value { font-size: 1.6rem; font-weight: 800; line-height: 1; color: var(--tile); text-align: right; }
.dash-go { font-size: .75rem; color: #94a3b8; transition: transform .15s ease, color .15s ease; }
a.dash-row:hover .dash-go { color: var(--tile); transform: translateX(2px); }
.dash-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid #e2e8f0; background: #f8fafc; font-size: .76rem; font-weight: 700; color: var(--tone); text-decoration: none; }
.dash-foot:hover { background: #f1f5f9; }
.dash-foot i { transition: transform .15s ease; }
.dash-foot:hover i { transform: translateX(3px); }
@media (max-width: 767.98px) { .dash-col-sep { border-left: 0; border-top: 1px solid #e2e8f0; } }

a.machine-card-unit { display: block; color: inherit; text-decoration: none; }

/* =====================================================================
   Phones and tablets
   ===================================================================== */

/* Tablet (576-991px): a table keeps its place and drops the columns marked data-priority="low". */
@media (min-width: 576px) and (max-width: 991.98px) {
    .table-responsive > table.table th[data-priority="low"],
    .table-responsive > table.table td[data-priority="low"] { display: none; }
}

/* Touch: bigger targets on tablets and phones. */
@media (max-width: 991.98px) {
    .btn:not(.btn-sm):not(.btn-close) { min-height: 40px; }
    .btn.btn-sm { min-height: 34px; }
    .table .action-btn-group .btn { width: 34px; height: 34px; font-size: .9rem; }
    .form-control, .form-select { min-height: 40px; }
}

/* Phone (under 576px) */
@media (max-width: 575.98px) {
    .main-content { padding: 14px 12px; }

    /* Page header: the title, then the buttons across the full width. */
    .container-fluid > .d-flex.flex-wrap.justify-content-between.gap-3.mb-4 > .d-flex,
    .container-fluid > .d-flex.flex-wrap.justify-content-between.gap-3.mb-4 > form { width: 100%; }
    .container-fluid > .d-flex.flex-wrap.justify-content-between.gap-3.mb-4 .d-flex > .btn,
    .container-fluid > .d-flex.flex-wrap.justify-content-between.gap-3.mb-4 > .btn { flex: 1 1 auto; }
    .container-fluid > .d-flex.flex-wrap.justify-content-between.gap-3.mb-4 > .btn { width: 100%; }

    /* Search boxes use the whole width. */
    .quick-search, .list-search { width: 100% !important; }

    /* Every table becomes a list of cards: one card a row, "LABEL  value" lines, the Action buttons last. */
    .table-responsive > table.table:not(.no-cards) { display: block; border: 0; }
    .table-responsive > table.table:not(.no-cards) thead,
    .table-responsive > table.table:not(.no-cards) tfoot { display: none; }
    .table-responsive > table.table:not(.no-cards) tbody { display: block; padding: 8px 10px; }
    .table-responsive > table.table:not(.no-cards) tbody tr {
        display: flex; flex-direction: column; margin-bottom: 10px; padding: 6px 12px; background: #fff;
        border: 1px solid #d3dbe6; border-radius: 12px; box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
    }
    .table-responsive > table.table:not(.no-cards) tbody td {
        display: block; overflow: hidden; max-width: none !important; width: auto !important;
        padding: 7px 0; border: 0; border-bottom: 1px solid #eef2f7; background: transparent !important;
        text-align: right; font-size: .85rem; word-break: break-word;
    }
    .table-responsive > table.table:not(.no-cards) tbody td:last-child { border-bottom: 0; }
    .table-responsive > table.table:not(.no-cards) tbody td[data-label]::before {
        content: attr(data-label); float: left; width: 38%; padding-right: 10px; text-align: left;
        font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #64748b; padding-top: 2px;
    }
    .table-responsive > table.table:not(.no-cards) tbody td[data-label=""]::before { display: none; }
    /* An empty "#" / index cell is not worth a line. */
    .table-responsive > table.table:not(.no-cards) tbody td:empty { display: none; }

    /* A cell with a form control: the label sits above it, full width. */
    .table-responsive > table.table:not(.no-cards) tbody td[data-field] { display: block; text-align: left; }
    .table-responsive > table.table:not(.no-cards) tbody td[data-field]::before { display: block; float: none; width: auto; margin-bottom: 4px; }
    /* Row numbers and ids add nothing to a card. */
    .table-responsive > table.table:not(.no-cards) tbody td[data-label="#"],
    .table-responsive > table.table:not(.no-cards) tbody td[data-label="S.No"],
    .table-responsive > table.table:not(.no-cards) tbody td[data-label="S.NO"],
    .table-responsive > table.table:not(.no-cards) tbody td[data-label="Srl No"],
    .table-responsive > table.table:not(.no-cards) tbody td[data-label="ID"] { display: none; }

    /* The pinned Action column is just the last line of the card. */
    .table-responsive > table.table:not(.no-cards) tbody td.sticky-action {
        order: 99; position: static; box-shadow: none; display: flex; justify-content: flex-end; border-top: 1px solid #e2e8f0; margin-top: 4px; padding-top: 10px;
    }
    .table-responsive > table.table:not(.no-cards) tbody td.sticky-action::before { display: none; }
    .table-responsive > table.table:not(.no-cards) tbody td.sticky-action .action-btn-group,
    .table-responsive > table.table:not(.no-cards) tbody td.sticky-action .d-flex { flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

    /* Rows that say "no records" / section titles span the card. */
    .table-responsive > table.table:not(.no-cards) tbody td[colspan] { display: block; text-align: center; }
    .table-responsive > table.table:not(.no-cards) tbody tr:has(> td[colspan]) { border-style: dashed; box-shadow: none; }
    .table-responsive { overflow-x: visible; }

    /* Popups use the whole screen, with their body scrolling and the buttons kept at the bottom. */
    .modal-dialog { margin: 0; max-width: 100%; min-height: 100%; }
    .modal-content { min-height: 100vh; border: 0; border-radius: 0; }
    .modal-dialog-scrollable .modal-content { max-height: 100vh; }
    .modal-body { flex: 1 1 auto; overflow-y: auto; }
    .modal-footer { position: sticky; bottom: 0; background: #fff; z-index: 2; }

    /* Cards and blocks use less padding; pagination stacks. */
    .card-body { padding: 12px; }
    .list-pagination { justify-content: center !important; text-align: center; }
    .dash-tile { padding: 12px 14px; }
}

/* The roster's "Change" button is a labelled button, not a square icon button, on every screen size. */
.table .action-btn-group .btn.roster-change-btn { width: auto; height: auto; min-height: 0; padding: 3px 10px; font-size: .78rem; }
@media (max-width: 991.98px) {
    .table .action-btn-group .btn.roster-change-btn { min-height: 34px; padding: 4px 12px; }
}
