/* Apple-Inspired Design System for DQM */
:root {
    /* Theme A - Emerald Vitality: manufacturing green, gradient accents */
    --apple-blue: #118173;
    --apple-blue-hover: #0d6b5f;
    --link-blue: #0e6e62;
    --link-blue-dark: #3ad6ae;
    --primary-grad: linear-gradient(135deg, #118173, #2bb673);
    --primary-shadow: 0 4px 14px rgba(17, 129, 115, 0.32);
    --text-primary: #1d1d1f;
    --text-secondary: rgba(0, 0, 0, 0.56);
    --text-tertiary: rgba(0, 0, 0, 0.48);
    --bg-light: #f4f9f6;
    --bg-white: #ffffff;
    --bg-dark: #1d1d1f;
    --card-bg: #ffffff;
    --border: rgba(0, 0, 0, 0.08);
    --danger: #ff3b30;
    --success: #2bb673;
    --warning: #ff9500;
    --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-elevated: 3px 5px 30px rgba(0, 0, 0, 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-pill: 980px;
}

* {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background: var(--bg-light);
    color: var(--text-primary);
    margin: 0;
    font-size: 17px;
    line-height: 1.47;
    letter-spacing: -0.374px;
}

/* ═══════════════════════════════════════
   Navigation — Apple Glass Effect
   ═══════════════════════════════════════ */
.top-nav {
    background: rgba(10, 52, 40, 0.88);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    padding: 0 24px;
    height: 48px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.top-nav .brand {
    color: #ffffff;
    font-weight: 600;
    font-size: 21px;
    margin-right: 32px;
    letter-spacing: -0.4px;
    text-decoration: none;
}

.top-nav .nav-links { display: flex; gap: 0; align-items: center; }

.top-nav .nav-links .nav-item {
    position: relative;
}

.top-nav .nav-links .nav-item > a,
.top-nav .nav-links .nav-item > span {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    transition: all 0.3s ease;
    letter-spacing: -0.1px;
    cursor: pointer;
    display: inline-block;
    white-space: nowrap;
}

.top-nav .nav-links .nav-item > span.disabled {
    color: rgba(255, 255, 255, 0.35);
    cursor: default;
}

.top-nav .nav-links .nav-item:hover > a,
.top-nav .nav-links .nav-item:hover > span:not(.disabled) {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.top-nav .nav-links .nav-item > a.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
}

/* Dropdown menu */
.top-nav .nav-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-radius: 8px;
    padding: 6px 0;
    min-width: 200px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    z-index: 2000;
    padding-top: 10px;
}

/* Invisible bridge to prevent hover gap */
.top-nav .nav-dropdown::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
}

.top-nav .nav-item:hover > .nav-dropdown {
    display: block;
}

.top-nav .nav-dropdown a,
.top-nav .nav-dropdown span {
    display: block;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    transition: background 0.15s;
    white-space: nowrap;
}

.top-nav .nav-dropdown a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.top-nav .nav-dropdown span.disabled {
    color: rgba(255, 255, 255, 0.3);
    cursor: default;
}

.top-nav .nav-dropdown span.disabled:hover {
    background: none;
}

/* Right section */
.top-nav .nav-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.top-nav .nav-right .nav-item > span {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
}

/* ═══════════════════════════════════════
   Content & Layout
   ═══════════════════════════════════════ */
.content {
    max-width: 100%;
    margin: 0;
    padding: 32px 40px;
}

.page-title {
    font-size: 34px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 24px;
    line-height: 1.14;
    letter-spacing: -0.6px;
}

/* ═══════════════════════════════════════
   Cards — Clean, Borderless Apple Style
   ═══════════════════════════════════════ */
.qs-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    box-shadow: var(--shadow-card);
    border: none;
    margin-bottom: 24px;
}

.qs-card-header {
    background: var(--bg-light);
    border-bottom: none;
    padding: 14px 24px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    letter-spacing: -0.224px;
}

/* ═══════════════════════════════════════
   Buttons — Apple Blue Primary
   ═══════════════════════════════════════ */
.btn-accent {
    background: var(--apple-blue);
    color: #ffffff;
    border: none;
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    font-weight: 400;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: -0.224px;
}

.btn-accent:hover {
    background: var(--apple-blue-hover);
    color: #ffffff;
}

.btn-filter {
    padding: 6px 16px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-filter-primary {
    background: var(--apple-blue);
    color: #ffffff;
    border: none;
}

.btn-filter-primary:hover {
    background: var(--apple-blue-hover);
}

.btn-filter-secondary {
    background: none;
    color: var(--link-blue);
    border: 1px solid var(--link-blue);
}

.btn-filter-secondary:hover {
    background: rgba(17, 129, 115, 0.06);
}

/* ═══════════════════════════════════════
   Page Header "Add" Button — unified
   ═══════════════════════════════════════ */
.btn-new {
    background: var(--primary-grad);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: var(--primary-shadow);
    padding: 8px 20px;
    border-radius: var(--radius-pill);
    font-size: 14px;
    letter-spacing: -0.224px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: box-shadow 0.25s ease, transform 0.15s ease, filter 0.2s ease;
}

.btn-new:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(17, 129, 115, 0.42); filter: saturate(1.1); }
.btn-new:active { transform: scale(0.97); }
.btn-new:focus-visible { outline: 2px solid var(--apple-blue); outline-offset: 2px; }
.btn-new svg { width: 14px; height: 14px; fill: currentColor; }

.btn-new.btn-new-danger { background: var(--danger); }
.btn-new.btn-new-danger:hover { background: #e0352b; }

/* ═══════════════════════════════════════
   Filter Bar Controls — uniform 34px height
   ═══════════════════════════════════════ */
/* inline-block leaves baseline descent space under the control,
   pushing dropdowns out of line with the Filter/Clear buttons */
.td-filter .filter-dropdown,
.filter-row .filter-dropdown,
.filter-group .filter-dropdown {
    display: block;
}

.td-filter .filter-btn,
.filter-row .filter-btn,
.filter-panel .filter-trigger {
    height: 34px;
    padding: 6px 12px;
    line-height: 20px;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.td-filter .filter-btn:hover,
.filter-row .filter-btn:hover,
.filter-panel .filter-trigger:hover {
    border-color: rgba(0, 0, 0, 0.28);
}

.btn-filter-apply,
.btn-filter-clear {
    height: 34px;
    padding: 0 18px;
    box-sizing: border-box;
    font-size: 13px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s ease;
}

.btn-filter-apply {
    background: var(--primary-grad);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-filter-apply:hover { filter: saturate(1.15) brightness(1.05); }

.btn-filter-clear {
    background: none;
    color: var(--link-blue);
    border: 1px solid var(--link-blue);
}

.btn-filter-clear:hover { background: rgba(17, 129, 115, 0.06); }

/* ═══════════════════════════════════════
   Filter Row
   ═══════════════════════════════════════ */
.filter-row {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 16px 24px;
    box-shadow: var(--shadow-card);
    border: none;
    margin-bottom: 20px;
    display: flex;
    gap: 14px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-group { flex: 1; min-width: 120px; }

.filter-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.filter-group select,
.filter-group .filter-btn {
    width: 100%;
    height: 34px;
    box-sizing: border-box;
    padding: 6px 12px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-white);
    cursor: pointer;
    transition: border-color 0.2s;
}

.filter-group select:focus,
.filter-group .filter-btn:focus {
    border-color: var(--apple-blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(17, 129, 115, 0.15);
}

.filter-btn.has-selection {
    background: rgba(17, 129, 115, 0.06) !important;
    border-color: var(--apple-blue) !important;
    color: var(--apple-blue) !important;
}

.filter-menu {
    background: var(--bg-white) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--shadow-elevated) !important;
}

.filter-menu label:hover {
    background: rgba(17, 129, 115, 0.04) !important;
}

.filter-menu input[type=checkbox] {
    accent-color: var(--apple-blue);
}

/* ═══════════════════════════════════════
   Table — Clean Apple Data Grid
   ═══════════════════════════════════════ */
.qs-table-wrap {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.qs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    white-space: nowrap;
    letter-spacing: -0.12px;
    table-layout: auto;
}

.qs-table thead th {
    position: relative;
    user-select: none;
    padding: 10px 12px;
    background: var(--bg-dark);
    color: rgba(255, 255, 255, 0.92);
    font-weight: 500;
    font-size: 12px;
    letter-spacing: 0;
    text-transform: none;
}

.qs-table thead th.th-preseal {
    background: #1d1d1f;
    color: #ff9f0a;
}

.qs-table thead th.th-postseal {
    background: #1d1d1f;
    color: #30d158;
}

.qs-table tbody td {
    padding: 9px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
}

.qs-table tbody tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
}

.qs-table tbody tr:hover {
    background: rgba(17, 129, 115, 0.04);
}

.qs-table td.td-preseal {
    background: rgba(255, 159, 10, 0.04);
}

.qs-table tr:nth-child(even) td.td-preseal {
    background: rgba(255, 159, 10, 0.06);
}

.qs-table td.td-postseal {
    background: rgba(48, 209, 88, 0.04);
}

.qs-table tr:nth-child(even) td.td-postseal {
    background: rgba(48, 209, 88, 0.06);
}

.qs-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════
   Stats Bar
   ═══════════════════════════════════════ */
.stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    font-size: 14px;
}

.stats-bar .count {
    color: var(--text-secondary);
    letter-spacing: -0.224px;
}

.stats-bar .count strong {
    color: var(--apple-blue);
    font-weight: 600;
}

/* ═══════════════════════════════════════
   Pagination
   ═══════════════════════════════════════ */
.qs-pagination {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
    padding: 0 4px;
}

.qs-pagination button {
    padding: 6px 16px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: var(--radius-pill);
    background: var(--bg-white);
    font-size: 12px;
    cursor: pointer;
    color: var(--link-blue);
    transition: all 0.2s;
}

.qs-pagination button:hover {
    background: rgba(17, 129, 115, 0.06);
}

.qs-pagination button:disabled {
    color: var(--text-tertiary);
    cursor: default;
    background: transparent;
}

.qs-pagination input[type=range] {
    flex: 1;
    accent-color: var(--apple-blue);
}

/* ═══════════════════════════════════════
   Alerts — Subtle Apple Style
   ═══════════════════════════════════════ */
.alert-success {
    background: rgba(52, 199, 89, 0.1);
    border: 1px solid rgba(52, 199, 89, 0.3);
    color: #248a3d;
    border-radius: var(--radius-sm);
    font-size: 14px;
    letter-spacing: -0.224px;
}

.alert-danger {
    background: rgba(255, 59, 48, 0.08);
    border: 1px solid rgba(255, 59, 48, 0.25);
    color: #d70015;
    border-radius: var(--radius-sm);
    font-size: 14px;
    letter-spacing: -0.224px;
}

/* ═══════════════════════════════════════
   Forms
   ═══════════════════════════════════════ */
.form-control,
.form-select {
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px rgba(17, 129, 115, 0.15);
}

.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.12px;
}

/* ═══════════════════════════════════════
   Danger / Success Buttons
   ═══════════════════════════════════════ */
.btn-danger {
    background: var(--danger);
    border: none;
    color: #ffffff;
    border-radius: var(--radius-sm);
    font-size: 11px;
    padding: 3px 0;
    width: 40px;
    text-align: center;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-danger:hover { opacity: 0.85; }

.btn-success {
    background: var(--success);
    border: none;
    color: #ffffff;
    border-radius: var(--radius-sm);
    font-size: 11px;
    padding: 3px 0;
    width: 58px;
    text-align: center;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-success:hover { opacity: 0.85; }

/* ═══════════════════════════════════════
   Polish — motion & focus
   ═══════════════════════════════════════ */
/* opacity only — a transform here would make .content the containing
   block for position:fixed modals inside it, breaking their placement */
.content {
    animation: page-in 0.4s ease;
}

@keyframes page-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .content { animation: none; }
    * { transition-duration: 0.01ms !important; }
}

.btn-filter-apply:focus-visible,
.btn-filter-clear:focus-visible,
.filter-btn:focus-visible,
.filter-trigger:focus-visible {
    outline: 2px solid var(--apple-blue);
    outline-offset: 2px;
}

.qs-table thead th:first-child { border-radius: 0; }

/* Numbers in data tables read better tabular */
.qs-table tbody td { font-variant-numeric: tabular-nums; }

/* ═══════════════════════════════════════
   Column sizing (shared with /js/table-resize.js)
   ═══════════════════════════════════════ */
.qs-table td.wrap-col {
    white-space: normal !important;
    overflow-wrap: break-word;
    word-break: normal;
    vertical-align: top;
    line-height: 1.45;
    max-width: none;
}

/* during width measurement wrap columns must not wrap,
   otherwise their natural width reads tiny */
.qs-table.measuring td.wrap-col { white-space: nowrap !important; }

.col-resize-handle {
    position: absolute;
    right: -3px;
    top: 0;
    bottom: 0;
    width: 7px;
    cursor: col-resize;
    z-index: 10;
}

.col-resize-handle:hover,
.col-resize-handle.active { background: rgba(17, 129, 115, 0.7); }

/* headers that may wrap to keep their column narrow (pair with data-maxw) */
.qs-table thead th.th-wrap {
    white-space: normal;
    line-height: 1.3;
    vertical-align: middle;
}

/* ═══════════════════════════════════════
   Nav Search — Apple-style expanding panel
   ═══════════════════════════════════════ */
.nav-search-btn {
    background: none;
    border: none;
    /* match the nav-item > a/span: 6px top/bottom + same line-height */
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    color: rgba(255, 255, 255, 0.8);
    transition: all 0.3s ease;
    font-size: 14px;
    line-height: 1;
}

.nav-search-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.nav-search-btn svg { width: 15px; height: 15px; fill: currentColor; }

.nav-search-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1900;
    background: rgba(0, 0, 0, 0.4);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.nav-search-overlay.open { display: block; }

.nav-search-panel {
    background: rgba(22, 22, 23, 0.92);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    padding: 28px 0 34px;
    animation: nav-search-in 0.25s ease;
    max-height: 80vh;
    overflow-y: auto;
}

@keyframes nav-search-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .nav-search-panel { animation: none; }
}

.nav-search-inner { max-width: 680px; margin: 0 auto; padding: 0 24px; }

.nav-search-field {
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 10px;
}

.nav-search-field svg { width: 17px; height: 17px; fill: rgba(255, 255, 255, 0.6); flex-shrink: 0; }

.nav-search-field input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: #fff;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.nav-search-field input::placeholder { color: rgba(255, 255, 255, 0.4); }

.nav-search-results { margin-top: 20px; }

.nav-search-results .ns-title {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    text-transform: capitalize;
    letter-spacing: 0.2px;
    margin-bottom: 10px;
}

.nav-search-results .ns-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin: 0 -14px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.nav-search-results .ns-link:hover,
.nav-search-results .ns-link.sel { background: rgba(255, 255, 255, 0.08); color: #fff; }

.nav-search-results .ns-link:hover svg,
.nav-search-results .ns-link.sel svg { stroke: #fff; }

.nav-search-results .ns-link svg { width: 12px; height: 12px; fill: none; stroke: rgba(255, 255, 255, 0.35); flex-shrink: 0; transition: stroke 0.15s; }

.nav-search-results .ns-group {
    margin-left: auto;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
}

.nav-search-results .ns-empty { color: rgba(255, 255, 255, 0.5); font-size: 14px; padding: 8px 0; }
