/* ProjectID - Main Stylesheet */

:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-secondary: #64748b;
    --color-success: #16a34a;
    --color-warning: #ca8a04;
    --color-danger: #dc2626;
    --color-bg: #f1f5f9;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 64px;
    --topbar-height: 56px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* App Shell & Sidebar */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-width);
    background: #1e293b;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    transition: width 0.25s ease;
    overflow: hidden;
}

.sidebar-collapsed .app-sidebar {
    width: var(--sidebar-collapsed-width);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    min-height: var(--topbar-height);
}

.sidebar-brand-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
    white-space: nowrap;
}

.sidebar-brand-link:hover { color: #fff; text-decoration: none; }
.sidebar-brand-link i { font-size: 1.5rem; color: var(--color-primary); }

.sidebar-toggle {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.25rem;
}

.sidebar-toggle:hover { color: #fff; }

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #94a3b8;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
    text-decoration: none;
}

.sidebar-link.active {
    background: rgba(37,99,235,0.15);
    color: #fff;
    border-left-color: var(--color-primary);
}

.sidebar-link i { font-size: 1.15rem; min-width: 1.25rem; text-align: center; }

.sidebar-collapsed .sidebar-link-text,
.sidebar-collapsed .sidebar-brand-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
    display: none;
}

/* Mini sidebar: keep icons + toggle visible */
.sidebar-collapsed .sidebar-brand {
    flex-direction: column;
    justify-content: center;
    padding: 0.75rem 0.5rem;
    gap: 0.5rem;
}

.sidebar-collapsed .sidebar-brand-link {
    justify-content: center;
    width: 100%;
}

.sidebar-collapsed .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.35rem;
}

.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 0.75rem 0.5rem;
    gap: 0;
}

.sidebar-collapsed .sidebar-link i {
    font-size: 1.25rem;
}

.sidebar-expand-topbar {
    display: none;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    cursor: pointer;
    padding: 0.35rem 0.6rem;
    font-size: 1.15rem;
    margin-right: 0.5rem;
}

.sidebar-collapsed .sidebar-expand-topbar {
    display: none !important;
}

.app-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.25s ease;
}

.sidebar-collapsed .app-content {
    margin-left: var(--sidebar-collapsed-width);
}

.app-topbar {
    display: flex;
    align-items: center;
    height: var(--topbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0 1.5rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-spacer { flex: 1; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
}

.sidebar-mobile-toggle {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    margin-right: 0.5rem;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 150;
}

.sidebar-overlay.hidden { display: none; }

.user-name { font-weight: 500; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-admin { background: #dbeafe; color: #1d4ed8; }
.badge-user { background: #f1f5f9; color: #475569; }
.badge-readonly { background: #fef3c7; color: #92400e; }

.license-badge {
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 600;
}

.license-normal { background: #dcfce7; color: #166534; }
.license-warning { background: #fef9c3; color: #854d0e; }
.license-expired { background: #fee2e2; color: #991b1b; }

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-active { background: #dcfce7; color: #166534; }
.status-pending { background: #fef9c3; color: #854d0e; }
.status-expired { background: #ffedd5; color: #c2410c; }
.status-banned { background: #fee2e2; color: #991b1b; }
.status-default { background: #f1f5f9; color: #475569; }

/* Main */
.app-main {
    padding: 1.5rem;
    flex: 1;
    overflow-x: hidden;
    max-width: 100%;
}

.app-main-guest {
    max-width: 1200px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 { font-size: 1.5rem; font-weight: 600; }
.page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-secondary); color: #fff; }
.btn-outline { background: transparent; border-color: var(--color-border); color: var(--color-text); }
.btn-outline:hover { background: var(--color-bg); }
.btn-danger { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.8125rem; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.action-btn:disabled,
.action-btn.disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.action-btn { padding: 0.2rem 0.45rem; }

.col-actions {
    white-space: nowrap;
    display: flex;
    gap: 0.25rem;
}

/* Flash messages */
.flash-messages { margin-bottom: 1rem; }
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}
.flash-success { background: #dcfce7; color: #166534; }
.flash-danger { background: #fee2e2; color: #991b1b; }
.flash-warning { background: #fef9c3; color: #854d0e; }
.flash-info { background: #dbeafe; color: #1e40af; }

/* Stats dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    text-align: center;
    border: 1px solid var(--color-border);
}

.stat-value { font-size: 2rem; font-weight: 700; }
.stat-label { font-size: 0.8125rem; color: var(--color-text-muted); margin-top: 0.25rem; }
.stat-active .stat-value { color: var(--color-success); }
.stat-trial .stat-value { color: var(--color-primary); }
.stat-warning .stat-value { color: var(--color-warning); }
.stat-expired .stat-value { color: #c2410c; }
.stat-banned .stat-value { color: var(--color-danger); }

/* Master-Detail Layout — Grid always 100%, detail as fixed right overlay drawer */
.master-detail {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: calc(100vh - var(--topbar-height) - 220px);
    min-height: 400px;
    overflow: visible;
}

.grid-panel {
    width: 100%;
    max-width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: min(420px, 90vw);
    height: 100%;
    z-index: 300;
    background: var(--color-surface);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-left: 1px solid var(--color-border);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    pointer-events: none;
}

.detail-panel.hidden {
    display: none !important;
}

.master-detail.detail-open .detail-panel {
    transform: translateX(0);
    pointer-events: auto;
    display: flex !important;
}

.detail-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 299;
    background: rgba(15, 23, 42, 0.4);
}

.master-detail.detail-open .detail-backdrop {
    display: block;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
    background: #f8fafc;
}

.detail-header h2 { font-size: 1rem; font-weight: 600; }

.detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.detail-actions {
    padding: 1rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: #f8fafc;
}

.detail-footer {
    padding: 1rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: #fff;
}

.detail-edit-form .detail-field-input {
    width: 100%;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.875rem;
}

.detail-edit-form textarea.detail-field-input {
    min-height: 60px;
    resize: vertical;
}

.detail-edit-form .detail-value-readonly {
    color: var(--color-muted, #64748b);
}

.field-validation {
    margin-top: 0.35rem;
    font-size: 0.8125rem;
    min-height: 1.25rem;
}

.field-validation.valid {
    color: #16a34a;
}

.field-validation.invalid {
    color: #dc2626;
}

/* 2-column detail layout */
.detail-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--color-border);
    align-items: start;
}

.detail-row:last-child { border-bottom: none; }
.detail-row:nth-child(even) { background: #fafbfc; }

.detail-label {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

.detail-value {
    font-size: 0.9375rem;
    word-break: break-word;
}

.detail-placeholder {
    color: var(--color-text-muted);
    text-align: center;
    padding: 2rem;
}

.detail-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.75rem 1rem;
    background: #f1f5f9;
    border-bottom: 1px solid var(--color-border);
}

/* Grid */
.grid-toolbar {
    margin-bottom: 0.5rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.search-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    width: 250px;
    font-size: 0.875rem;
}

.column-picker {
    position: relative;
}

.column-picker-menu {
    position: fixed;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 0;
    min-width: 200px;
    max-width: min(280px, calc(100vw - 16px));
    max-height: min(360px, calc(100vh - 16px));
    z-index: 300;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.column-picker-menu.show { display: flex; }

.column-picker-search {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.column-picker-search input {
    width: 100%;
    padding: 0.35rem 0.5rem;
    font-size: 0.8125rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
}

.column-picker-list {
    overflow-y: auto;
    padding: 0.5rem 0.75rem;
    flex: 1;
}

.column-picker-menu label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    font-size: 0.875rem;
    cursor: pointer;
}

.column-picker-menu label.hidden-by-search { display: none; }

.user-combobox {
    position: relative;
}

.user-combobox select {
    width: 100%;
}

.grid-wrapper {
    flex: 1;
    overflow: auto;
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--color-border);
}

.grid-section { margin-bottom: 1rem; }
.grid-section-title { font-size: 1rem; margin-bottom: 0.5rem; font-weight: 600; }

.data-grid [data-col].col-hidden {
    display: none !important;
}

.data-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-grid th {
    background: #f8fafc;
    padding: 0.625rem 0.75rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--color-border);
    position: sticky;
    top: 0;
    white-space: nowrap;
    z-index: 1;
}

.data-grid td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.grid-row { cursor: pointer; }
.grid-row:hover { background: #f8fafc; }
.grid-row.selected { background: #dbeafe; }

.data-grid td.editable { cursor: cell; }
.data-grid td.cell-schedule-warning { background: #fef9c3; }
.boq-status-done       { color: #16a34a; font-weight: 500; }
.boq-status-inprogress { color: #2563eb; font-weight: 500; }
.boq-status-notstarted { color: #6b7280; font-weight: 500; }
.boq-status-warning    { color: #d97706; font-weight: 500; }
.boq-status-overdue    { color: #dc2626; font-weight: 500; }
.boq-status-paused     { color: #dc2626; font-weight: 500; }
.import-row-conflict td { background: #fef9c3; }
.import-row-skipped td { background: #fee2e2; }
.import-wizard-step.hidden { display: none; }
.data-grid td.editing { padding: 0; background: #fff; }

.data-grid td.editing input,
.data-grid td.editing select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--color-primary);
    font-size: 0.875rem;
}

.empty-row td,
.empty-state {
    text-align: center;
    color: var(--color-text-muted);
    padding: 2rem;
}

.empty-state i { font-size: 2.5rem; display: block; margin-bottom: 0.5rem; opacity: 0.4; }

.readonly-date { color: var(--color-text-muted); font-style: italic; }

/* NS module — page, drawer, mini modals, cards */
.ns-context-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: var(--color-surface, #f8fafc);
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: 8px;
}
.ns-context-label { font-weight: 600; }
.ns-summary-cards .stat-card { text-align: left; }
.ns-summary-cards .stat-card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.ns-summary-cards .stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
.ns-summary-cards .stat-value.card-stat-pct { font-size: 1.25rem; }
.ns-summary-cards .stat-sub {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    line-height: 1.5;
}
#ns-summary-cards.stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.ns-summary-cards .card-stat-muted { color: #6b7280; }
.ns-summary-cards .stat-value.card-stat-muted { color: #6b7280; font-weight: 600; }
.ns-summary-cards .card-stat-danger { color: #dc2626; }
.ns-summary-cards .card-stat-success { color: #16a34a; }
.ns-summary-cards .card-stat-warn { color: #ca8a04; }
.ns-summary-cards .card-stat-primary { color: #2563eb; }
.ns-filter-select {
    min-width: 160px;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--color-surface);
}
.ns-grid td.cell-readonly {
    background: #f1f5f9;
    color: var(--color-text-muted);
}
.ns-grid td.cell-ln-pct { font-weight: 600; }
.form-field-hint {
    font-size: 0.8125rem;
    margin-top: 0.35rem;
}
.form-field-hint.error { color: #dc2626; }
.form-field-hint.warning { color: #b45309; }
.form-field-hint.hidden { display: none; }
.ns-detail-section { margin-bottom: 1rem; }
.ns-detail-section h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.ns-detail-section .detail-row { padding: 0.35rem 0; }
/* NS drawer (separate from Bootstrap .modal) */
.ns-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 349;
    background: rgba(15, 23, 42, 0.45);
}
.ns-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 640px;
    min-width: 420px;
    max-width: 92vw;
    height: 100%;
    z-index: 350;
    background: var(--color-surface, #fff);
    border-left: 1px solid var(--color-border);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s ease;
}
.ns-drawer.open { transform: translateX(0); }
.ns-drawer-resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    background: transparent;
    z-index: 10;
}
.ns-drawer-resize-handle:hover,
.ns-drawer-resize-handle.dragging {
    background: rgba(99, 102, 241, 0.3);
}
.ns-drawer-header {
    padding: 1rem 1rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
    background: #f8fafc;
}
.ns-drawer-close {
    float: right;
    padding: 0.15rem 0.35rem;
    color: var(--color-text-muted);
}
.ns-drawer-title {
    font-weight: 600;
    font-size: 0.9375rem;
    margin: 0 2rem 0.35rem 0;
    word-break: break-word;
}
.ns-drawer-id {
    font-family: ui-monospace, monospace;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}
.ns-drawer-meta {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    line-height: 1.6;
}
.ns-drawer-main-tabs {
    border-bottom: 1px solid var(--color-border);
    padding: 0 1rem;
}
.ns-drawer-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.ns-drawer-panel.hidden { display: none; }
.ns-drawer-sub-tabs { padding: 0.5rem 1rem 0; }
.ns-drawer-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
}
.ns-drawer-body {
    flex: 1;
    overflow: auto;
    padding: 0.5rem 1rem;
}
.ns-sub-grid { font-size: 0.8125rem; }
.ns-sub-grid td.editable { cursor: text; }
.ns-sub-grid td.editable:hover { background: #f1f5f9; }
.ns-sub-grid td.cell-readonly {
    background: #f1f5f9;
    color: var(--color-text-muted);
}
.ns-sub-grid .col-actions { white-space: nowrap; }
.ns-drawer-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.875rem;
    background: #fff;
}
.ns-drawer-footer.ns-footer-mismatch {
    background: #fef2f2;
    color: #b91c1c;
}
/* NS mini modals (above drawer, not Bootstrap .modal) */
.ns-mini-modal {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ns-mini-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
}
.ns-mini-modal-content {
    position: relative;
    z-index: 1;
    background: var(--color-surface, #fff);
    padding: 1.25rem;
    border-radius: 8px;
    width: min(720px, 94vw);
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.ns-mini-modal-content h3 { margin: 0 0 1rem; font-size: 1.0625rem; }
.ns-mini-modal-content.modal-lg { width: min(960px, 96vw); }
.ns-picker-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    align-items: center;
}
.ns-picker-table-wrap {
    max-height: 320px;
    overflow: auto;
    border: 1px solid var(--color-border);
    border-radius: 6px;
}
.ns-picker-table { width: 100%; font-size: 0.8125rem; }
.ns-picker-table th, .ns-picker-table td { padding: 0.35rem 0.5rem; border-bottom: 1px solid #e2e8f0; }
.ns-form-section {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
}
.ns-form-section h4 {
    font-size: 0.8125rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
}
.ns-form-section-last {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.ns-form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.ns-grid .col-actions .action-btn {
    opacity: 1;
    visibility: visible;
}
.ns-grid .col-actions .action-btn .bi {
    display: inline-block;
    opacity: 1;
    color: currentColor;
}
.ns-grid .col-actions .action-btn.btn-outline-primary {
    color: var(--color-primary, #2563eb);
    border-color: var(--color-primary, #2563eb);
    background-color: transparent;
}
.ns-grid .col-actions .action-btn.btn-outline-secondary {
    color: var(--color-secondary, #64748b);
    border-color: #ced4da;
    background-color: transparent;
}
.ns-grid .col-actions .action-btn.btn-outline-danger {
    color: var(--color-danger, #dc2626);
    border-color: var(--color-danger, #dc2626);
    background-color: transparent;
}
.ns-embedded-nsboq-table-wrap {
    max-height: 220px;
    overflow: auto;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    margin-top: 0.5rem;
}
.ns-embedded-nsboq-table {
    width: 100%;
    font-size: 0.8125rem;
}
.ns-embedded-nsboq-table th,
.ns-embedded-nsboq-table td {
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid #e2e8f0;
}
.ns-date-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-end;
}
.ns-date-row .form-group { flex: 1; min-width: 140px; margin-bottom: 0; }

/* Auth pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 3rem);
}

.auth-card {
    background: var(--color-surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--color-border);
}

.auth-card-wide { max-width: 520px; }

.auth-card h1 { text-align: center; color: var(--color-primary); }
.auth-subtitle { text-align: center; color: var(--color-text-muted); margin-bottom: 1.5rem; }
.auth-footer { text-align: center; margin-top: 1rem; font-size: 0.875rem; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.25rem; }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.875rem;
}

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

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.readonly-field { background: #f1f5f9; cursor: not-allowed; }

.form-error {
    color: var(--color-danger);
    font-size: 0.8125rem;
    margin-top: 0.25rem;
}

.user-preview {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-top: 0.75rem;
    font-size: 0.875rem;
}

.user-preview.hidden { display: none; }

.invite-status-badge {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 600;
}

.invite-status-member { background: #dbeafe; color: #1e40af; }
.invite-status-pending { background: #fef9c3; color: #854d0e; }
.invite-status-can { background: #dcfce7; color: #166534; }
.invite-status-blocked { background: #fee2e2; color: #991b1b; }

.trial-presets {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.trial-presets button.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 300;
}

.hidden { display: none !important; }

.modal.hidden { display: none; }

.modal-content {
    background: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.modal-content h3 { margin-bottom: 1rem; font-size: 1.125rem; }

.modal-content-wide {
    max-width: 640px;
    width: 95vw;
}

.modal-audit-log {
    max-width: min(960px, 95vw);
}

.audit-log-table .data-grid {
    font-size: 0.8125rem;
}

.audit-log-table .data-grid td,
.audit-log-table .data-grid th {
    white-space: nowrap;
}

.audit-log-table .data-grid td:nth-child(5),
.audit-log-table .data-grid td:nth-child(6) {
    white-space: normal;
    max-width: 200px;
    word-break: break-word;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }

/* Invitations */
.invitation-banner {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.invitation-banner h3 { font-size: 0.9375rem; margin-bottom: 0.5rem; }

.invitation-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    font-size: 0.875rem;
}

.invitation-item span { flex: 1; }

.filter-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-tab {
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface);
    cursor: pointer;
    font-size: 0.8125rem;
}

.filter-tab.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

/* Members table in detail */
.member-list { padding: 0; }

.member-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.5rem;
    align-items: center;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
}

.member-item:last-child { border-bottom: none; }

/* Toast notification (app-toast — tránh xung đột class .toast của Bootstrap) */
.app-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    color: #fff;
    font-size: 0.875rem;
    z-index: 600;
    opacity: 1;
    animation: slideIn 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.app-toast-success { background: var(--color-success); }
.app-toast-error { background: var(--color-danger); }
.app-toast-warning { background: var(--color-warning); }

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.loading-overlay.hidden { display: none; }

@keyframes slideIn {
    from { transform: translateY(1rem); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Settings */
.settings-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--color-border);
    max-width: 600px;
}

/* Help page */
.help-section { max-width: 720px; }
.help-section-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 1rem;
}
.help-block { max-width: 720px; }
.help-block-text {
    color: var(--color-text-muted);
    line-height: 1.6;
    margin-bottom: 1rem;
}
.help-video-wrap { margin-top: 0.5rem; }
.help-video-iframe {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: var(--radius);
    background: #000;
}

/* Help hub */
.help-hub {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1.5rem;
    min-height: 360px;
}
.help-hub-categories {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.help-hub-cat-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius);
    color: inherit;
    text-decoration: none;
}
.help-hub-cat-link:hover { background: var(--color-bg); }
.help-hub-cat-link.active {
    background: var(--color-primary);
    color: #fff;
}
.help-hub-cat-count {
    font-size: 0.75rem;
    opacity: 0.85;
    background: rgba(0,0,0,0.08);
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
}
.help-hub-cat-link.active .help-hub-cat-count { background: rgba(255,255,255,0.2); }
.help-hub-articles {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.help-hub-articles-title { font-size: 1.1rem; margin-bottom: 1rem; }
.help-articles-list { display: flex; flex-direction: column; gap: 0.5rem; }
.help-article-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: inherit;
    text-decoration: none;
}
.help-article-link:hover { border-color: var(--color-primary); background: var(--color-bg); }
.help-article-link-title { flex: 1; font-weight: 500; }
.help-article-link-badges { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.help-article-card { max-width: 820px; }
.help-markdown-body { max-width: 100%; }
.help-markdown-preview {
    min-height: 200px;
    max-height: 480px;
    overflow: auto;
    background: #fff;
    font-size: 0.875rem;
}
.help-md-textarea { font-family: ui-monospace, monospace; font-size: 0.875rem; }
.help-admin-panel.hidden { display: none; }
.modal-content.modal-xl { max-width: 960px; width: 95vw; }

@media (max-width: 768px) {
    .help-hub { grid-template-columns: 1fr; }
}

/* Export page */
.export-card { max-width: 720px; }
.export-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem 1rem;
}
.export-checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    margin: 0;
}

@media (max-width: 768px) {
    .app-sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

    .sidebar-mobile-open .app-sidebar {
        transform: translateX(0);
    }

    .app-content { margin-left: 0 !important; }

    .master-detail { height: auto; }
    .detail-panel {
        width: min(100vw, 420px);
    }
    .form-row { grid-template-columns: 1fr; }
    .detail-row { grid-template-columns: 1fr; }
    .search-input { width: 100%; }
}
