/* =============================================
   OPERATIONAL EXCELLENCE - MAIN STYLES
   ============================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    color: #333;
    background: #f4f5f7;
}

a { color: #1a6ba0; text-decoration: none; }
a:hover { text-decoration: underline; }

/* =============================================
   LAYOUT
   ============================================= */

.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1a3a5c;
    color: white;
    padding: 0 20px;
    height: 52px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo { font-size: 22px; }
.header-title { font-size: 16px; font-weight: 600; letter-spacing: 0.3px; }

.header-right { display: flex; align-items: center; gap: 12px; }
.header-user { font-size: 13px; display: flex; align-items: center; gap: 8px; }

.role-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.role-badge.admin { background: #e8a200; color: #fff; }
.role-badge.user  { background: #4caf7d; color: #fff; }

.btn-logout {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.35);
    color: white;
    padding: 5px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}
.btn-logout:hover { background: rgba(255,255,255,0.25); }

.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* =============================================
   SIDE NAV
   ============================================= */

.nav-wrapper {
    display: flex;
    flex-shrink: 0;
    align-items: stretch;
}

.nav-toggle-btn {
    width: 14px;
    min-width: 14px;
    background: #e8edf3;
    border: none;
    border-right: 1px solid #dde1e7;
    cursor: pointer;
    color: #666;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
    padding: 0;
}
.nav-toggle-btn:hover { background: #c8d3e0; color: #1a3a5c; }

.nav-wrapper.nav-collapsed .side-nav {
    width: 0;
    overflow: hidden;
    border-right: none;
}

.side-nav {
    width: 330px;
    background: #fff;
    border-right: 1px solid #dde1e7;
    overflow-y: auto;
    flex-shrink: 0;
    transition: width 0.2s ease;
}

.nav-header {
    padding: 12px 16px 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #888;
    border-bottom: 1px solid #eee;
}
.nav-header-collapsible {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    padding-right: 14px;
}
.nav-header-collapsible:hover { background: #f5f7fa; }
.nav-section-arrow { font-size: 11px; color: #aaa; }

.nav-super-region-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    cursor: pointer;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #1a3a5c;
    background: #edf1f7;
    border-left: 3px solid transparent;
    transition: background 0.15s;
    user-select: none;
}
.nav-super-region-header:hover { background: #e2e8f2; }
.nav-super-region-header.expanded { border-left-color: #1a6ba0; }

.nav-region-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px 8px 22px;
    cursor: pointer;
    font-weight: 600;
    color: #2c3e50;
    transition: background 0.15s;
    border-left: 3px solid transparent;
}
.nav-region-header:hover { background: #f0f4f8; }
.nav-region-header.active {
    background: #e8f0fe;
    border-left-color: #1a6ba0;
    color: #1a6ba0;
}

.expand-icon { font-size: 10px; color: #888; width: 12px; }

.nav-branch {
    padding: 6px 14px 6px 40px;
    cursor: pointer;
    color: #1a6ba0;
    font-size: 13px;
    transition: background 0.15s;
    border-left: 3px solid transparent;
}
.nav-branch:hover { background: #f0f4f8; }
.nav-branch.active {
    background: #dbeafe;
    border-left-color: #1a6ba0;
    font-weight: 600;
}

/* =============================================
   MAIN CONTENT
   ============================================= */

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px 24px 16px;
    display: flex;
    flex-direction: column;
}

/* =============================================
   LOGIN PAGE
   ============================================= */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a3a5c 0%, #2563a8 100%);
}

.login-card {
    background: white;
    border-radius: 10px;
    padding: 40px;
    width: 380px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    text-align: center;
}

.login-logo { font-size: 48px; margin-bottom: 12px; }
.login-card h2 { color: #1a3a5c; font-size: 20px; margin-bottom: 6px; }
.login-subtitle { color: #888; font-size: 13px; margin-bottom: 24px; }

.form-group { text-align: left; margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #555; }
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.2s;
}
.form-control:focus { outline: none; border-color: #1a6ba0; box-shadow: 0 0 0 3px rgba(26,107,160,0.1); }

.alert-error {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #b91c1c;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 13px;
    margin-bottom: 14px;
}

.btn-login {
    width: 100%;
    padding: 10px;
    background: #1a6ba0;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 20px;
}
.btn-login:hover { background: #145a88; }

.login-hint {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    padding: 12px;
    font-size: 12px;
    color: #666;
    text-align: left;
}
.login-hint p { margin-bottom: 3px; }

/* =============================================
   HOME PAGE
   ============================================= */

.page-home h2 { color: #1a3a5c; margin-bottom: 8px; }
.page-home p { color: #666; margin-bottom: 24px; }

.summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    max-width: 800px;
}

.summary-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border-top: 4px solid #1a6ba0;
}
.summary-card.warn { border-top-color: #e8a200; }
.summary-number { font-size: 32px; font-weight: 700; color: #1a3a5c; }
.summary-label { font-size: 12px; color: #888; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

/* =============================================
   REGION VIEW / CHART
   ============================================= */

.region-page h2 { color: #1a3a5c; font-size: 22px; margin-bottom: 16px; }
.section-title { color: #1a6ba0; font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.section-desc { color: #666; font-size: 13px; line-height: 1.6; margin-bottom: 20px; max-width: 700px; }

.report-chart {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow: hidden;
    max-width: 750px;
}

.chart-header {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    font-weight: 700;
    font-size: 13px;
    color: #444;
}

.chart-row {
    display: flex;
    align-items: center;
    padding: 6px 16px;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}
.chart-row:hover { background: #f8fafc; }
.chart-row:last-child { border-bottom: none; }

.col-branch { width: 280px; font-size: 13px; flex-shrink: 0; }
.col-branch a { color: #1a6ba0; }

.col-bar { flex: 1; padding: 0 12px; }
.col-count { width: 150px; text-align: right; font-size: 13px; flex-shrink: 0; }

.chart-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px;
    color: #666;
    font-size: 13px;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #c5d8e8;
    border-top-color: #1a6ba0;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.bar-container { height: 18px; }
.bar-bg {
    height: 100%;
    background: #c5d8e8;
    border-radius: 2px;
    overflow: hidden;
    min-width: 4px;
}
.bar-processed {
    height: 100%;
    background: #1a6ba0;
    transition: width 0.3s;
}

/* =============================================
   BRANCH REPORT TYPES PAGE
   ============================================= */

.branch-page h2 { color: #1a3a5c; font-size: 22px; margin-bottom: 6px; }
.branch-subtitle { color: #666; margin-bottom: 20px; }

.report-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 14px;
}

.report-type-card {
    background: white;
    border-radius: 8px;
    padding: 18px 20px;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid #e2e8f0;
    border-left: 4px solid #1a6ba0;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: all 0.2s;
}
.report-type-card:hover {
    box-shadow: 0 4px 12px rgba(26,107,160,0.15);
    border-left-color: #0f5080;
    transform: translateY(-1px);
}
.report-type-card.has-unprocessed:hover {
    box-shadow: 0 4px 12px rgba(26,107,160,0.15);
}

.report-type-icon { font-size: 24px; flex-shrink: 0; }
.report-type-body { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.report-type-name { font-weight: 600; color: #1a3a5c; font-size: 14px; }
.report-type-meta { display: flex; align-items: center; gap: 8px; }
.report-type-count { font-size: 12px; color: #888; }
.report-type-unprocessed {
    font-size: 11px;
    font-weight: 600;
    color: #991b1b;
    background: #fee2e2;
    border-radius: 10px;
    padding: 3px 9px;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.report-type-all-processed {
    font-size: 12px;
    font-weight: 600;
    color: #15803d;
    flex-shrink: 0;
}
.report-type-arrow { color: #1a6ba0; font-size: 16px; flex-shrink: 0; }

/* =============================================
   REPORT LIST PAGE
   ============================================= */

.report-list-page h2 { color: #1a3a5c; font-size: 22px; margin-bottom: 6px; }

.report-list-table-wrapper {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow: hidden;
    margin-top: 16px;
}

.report-list-table {
    width: 100%;
    border-collapse: collapse;
}
.report-list-table thead { background: #1a3a5c; color: white; }
.report-list-table th {
    padding: 11px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.report-list-table td {
    padding: 10px 16px;
    font-size: 13px;
    border-bottom: 1px solid #f0f0f0;
}
.report-list-row {
    cursor: pointer;
    transition: background 0.15s;
}
.report-list-row:hover { background: #f0f7ff; }
.report-list-row:last-child td { border-bottom: none; }

.report-list-table th.sortable-th { cursor: pointer; user-select: none; }
.report-list-table th.sortable-th:hover { background: #254d7a; }
.report-list-table th.sorted { background: #2d6099; }
.report-list-table thead tr.filter-row th { background: #f0f4f8; padding: 4px 6px; }
.report-list-table td.comment-cell { white-space: normal; word-break: break-word; max-width: 300px; }

/* =============================================
   ROW-LEVEL COMMENTS (ReportGrid)
   ============================================= */
.comment-col-header { white-space: nowrap; min-width: 180px; }
.row-comment-cell   { vertical-align: top; padding: 6px 8px !important; }
.row-comment-display {
    min-height: 36px;
    min-width: 180px;
    max-width: 320px;
    padding: 4px 6px;
    border: 1px dashed #ccd7e0;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    white-space: pre-wrap;
    word-break: break-word;
    color: #333;
}
.row-comment-display:hover { border-color: #2d6099; background: #f0f7ff; }
.row-comment-placeholder   { color: #aaa; font-style: italic; }
.row-comment-text          { display: block; white-space: pre-wrap; word-break: break-word; }
.row-comment-timestamp     { display: block; margin-top: 3px; font-size: 10px; color: #888; font-style: italic; }
.row-comment-input  {
    width: 100%;
    min-width: 180px;
    max-width: 320px;
    min-height: 48px;
    resize: vertical;
    font-size: 12px;
    padding: 4px 6px;
    border: 1px solid #2d6099;
    border-radius: 4px;
    background: #fff;
    box-sizing: border-box;
    white-space: pre-wrap;
    word-break: break-word;
}
.row-comment-actions { display: flex; gap: 6px; margin-top: 4px; }
.btn-comment-save   { font-size: 11px; padding: 2px 10px; background: #2d6099; color: #fff; border: none; border-radius: 3px; cursor: pointer; }
.btn-comment-save:hover   { background: #1a3a5c; }
.btn-comment-cancel { font-size: 11px; padding: 2px 10px; background: #e0e5ea; color: #333; border: none; border-radius: 3px; cursor: pointer; }
.btn-comment-cancel:hover { background: #c8d0d8; }

/* =============================================
   REPORT GRID PAGE
   ============================================= */

.report-grid-page h2 { color: #1a3a5c; font-size: 20px; margin-bottom: 4px; }

.report-grid-header,
.report-list-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.btn-back {
    background: #f0f4f8;
    border: 1px solid #d1d5db;
    color: #444;
    padding: 7px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    transition: background 0.2s;
}
.btn-back:hover { background: #e2e8f0; }

.data-grid-wrapper {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 220px);
}

.data-grid {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
}
.data-grid thead { background: #1a3a5c; color: white; position: sticky; top: 0; }
.data-grid th {
    padding: 11px 14px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}
.data-grid td {
    padding: 8px 14px;
    font-size: 13px;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
}
.data-grid tbody tr:nth-child(even) { background: #f8fafc; }
.data-grid tbody tr:hover { background: #e8f4fd; }

/* Grid toolbar (filter toggle + clear) */
.grid-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.btn-toggle-filters {
    background: #f0f4f8;
    border: 1px solid #d1d5db;
    color: #444;
    padding: 5px 14px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
}
.btn-toggle-filters:hover { background: #e2e8f0; }
.btn-toggle-filters.active {
    background: #1a3a5c;
    color: white;
    border-color: #1a3a5c;
}
.btn-download-excel {
    background: #166534;
    border: 1px solid #14532d;
    color: white;
    padding: 5px 14px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    margin-left: auto;
}
.btn-download-excel:hover { background: #15803d; }
.btn-download-excel:disabled { background: #6b7280; border-color: #6b7280; cursor: default; }

.btn-share-report {
    background: #1a6ba0;
    border: 1px solid #145a88;
    color: white;
    padding: 5px 14px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
}
.btn-share-report:hover { background: #145a88; }

.btn-popout {
    background: #374151;
    border: 1px solid #1f2937;
    color: white;
    padding: 5px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    white-space: nowrap;
}
.btn-popout:hover { background: #1f2937; text-decoration: none; color: white; }

.btn-popout-inline {
    margin-left: 6px;
    font-size: 11px;
    color: #6b7280;
    text-decoration: none;
    padding: 1px 4px;
    border-radius: 3px;
    border: 1px solid #d1d5db;
    vertical-align: middle;
    white-space: nowrap;
}
.btn-popout-inline:hover { color: #1a3a5c; border-color: #1a3a5c; text-decoration: none; }

.main-content-fullscreen {
    padding: 16px 20px;
}
.data-grid th.sortable-th {
    cursor: pointer;
    user-select: none;
}
.data-grid th.sortable-th:hover { background: #254d7a; }
.data-grid th.sorted { background: #2d6099; }

/* Filter row */
.data-grid thead tr.filter-row th {
    background: #f0f4f8;
    padding: 4px 6px;
}
.col-filter {
    width: 100%;
    padding: 4px 6px;
    font-size: 12px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    color: #333;
    background: white;
    box-sizing: border-box;
    min-width: 60px;
}
.col-filter:focus {
    outline: none;
    border-color: #1a3a5c;
}

/* Totals row in data grid (e.g. Unconfirmed Pick Ticket, Profit Exception) */
.grid-total-row td {
    background: #f0f4f8;
    border-top: 2px solid #cbd5e0;
    font-weight: 600;
    color: #1a3a5c;
    position: sticky;
    bottom: 0;
    z-index: 1;
}
.data-grid tbody tr.grid-total-row:hover td { background: #f0f4f8; }

.grid-subtotal-row td {
    background: #dce6f1;
    border-top: 1px solid #a0b4cc;
    font-weight: 600;
    color: #1a3a5c;
}
.data-grid tbody tr.grid-subtotal-row:hover td { background: #ccd8ea; }

.group-header-row td {
    background: #1a3a5c;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    padding: 6px 10px;
    letter-spacing: 0.03em;
}
.data-grid tbody tr.group-header-row:hover td { background: #1a3a5c; }

.super-header-row th {
    background: #e8f0fa;
    color: #1a3a5c;
    font-weight: 700;
    font-size: 12px;
    padding: 4px 10px;
    border-bottom: 1px solid #cbd5e0;
    text-align: left;
}
/* Stock Status - Loc column highlight */
.data-grid td.loc-col-highlight { background-color: #dbeafe !important; }
.data-grid th.loc-col-highlight { background-color: #2563eb !important; }
.data-grid tbody tr:hover td.loc-col-highlight { background-color: #bfdbfe !important; }
.super-header-row th.loc-super-header { background: #93c5fd !important; color: #1e3a5f; text-align: center !important; font-size: 13px; }
/* Stock Status - DXP column highlight */
.data-grid td.dxp-col-highlight { background-color: #fef9c3 !important; }
.data-grid th.dxp-col-highlight { background-color: #d97706 !important; }
.data-grid tbody tr:hover td.dxp-col-highlight { background-color: #fde68a !important; }
.super-header-row th.dxp-super-header { background: #fcd34d !important; color: #1a3a5c; text-align: center !important; font-size: 13px; }
/* Stock Status - Order column highlight */
.data-grid td.order-col-highlight { background-color: #dcfce7 !important; }
.data-grid th.order-col-highlight { background-color: #15803d !important; }
.data-grid tbody tr:hover td.order-col-highlight { background-color: #bbf7d0 !important; }
.super-header-row th.order-super-header { background: #86efac !important; color: #14532d; text-align: center !important; font-size: 13px; }
/* Orders Invoiced Summary - first column green */
.data-grid td.ois-first-col { background-color: #dcfce7 !important; }
.data-grid th.ois-first-col { background-color: #15803d !important; }
.data-grid tbody tr:hover td.ois-first-col { background-color: #bbf7d0 !important; }

/* Invoice Register - low MAC GP rows (< 23%) */
.data-grid tbody tr.ir-low-margin td { color: #b91c1c; }

.grid-footer-note-row td { background: #fff; }
.data-grid tbody tr.grid-footer-note-row:hover td { background: #fff; }
.grid-footer-note-cell {
    color: #c0392b;
    font-weight: 600;
    font-size: 12px;
    padding: 6px 10px;
    white-space: nowrap;
}

/* Footer clear button */
.grid-footer {
    padding: 8px 14px;
    font-size: 12px;
    color: #888;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 0 0 8px 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.btn-clear-filters {
    background: none;
    border: 1px solid #ccc;
    color: #555;
    padding: 2px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}
.btn-clear-filters:hover { background: #fee2e2; border-color: #f87171; color: #b91c1c; }

/* =============================================
   SHARED COMPONENTS
   ============================================= */

.breadcrumb {
    font-size: 13px;
    color: #888;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.breadcrumb a { color: #1a6ba0; }
.breadcrumb span { color: #bbb; }

.status-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.status-badge.processed { background: #d1fae5; color: #065f46; }
.status-badge.unprocessed { background: #fee2e2; color: #991b1b; }
button.status-badge {
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: opacity 0.15s, transform 0.1s;
}
button.status-badge:hover { opacity: 0.8; transform: scale(1.05); }

/* Confirmation Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-dialog {
    background: #fff;
    border-radius: 10px;
    padding: 28px 32px;
    min-width: 320px;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.modal-title {
    margin: 0 0 12px;
    font-size: 17px;
    font-weight: 700;
    color: #1a3a5c;
}
.modal-body {
    margin: 0 0 24px;
    font-size: 14px;
    color: #333;
    line-height: 1.5;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.btn-modal-cancel {
    padding: 7px 18px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #444;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-modal-cancel:hover { background: #e2e8f0; }
.btn-modal-confirm {
    padding: 7px 18px;
    border-radius: 6px;
    border: none;
    background: #1a3a5c;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-modal-confirm:hover { background: #14304f; }
.btn-modal-confirm:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}
.modal-note {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 16px;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    resize: vertical;
    font-family: inherit;
    color: #333;
}
.modal-note:focus {
    outline: none;
    border-color: #1a3a5c;
    box-shadow: 0 0 0 2px rgba(26,58,92,0.15);
}

.share-modal { min-width: 380px; max-width: 480px; }
.modal-share-subtitle {
    font-size: 13px;
    color: #555;
    margin: -6px 0 16px;
    font-style: italic;
}
.modal-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #444;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.modal-label-hint {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: #888;
    font-size: 11px;
}
.modal-share-input {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 14px;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    color: #333;
}
.modal-share-input:focus {
    outline: none;
    border-color: #1a3a5c;
    box-shadow: 0 0 0 2px rgba(26,58,92,0.15);
}
.share-error {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #b91c1c;
    padding: 7px 10px;
    border-radius: 5px;
    font-size: 13px;
    margin-bottom: 12px;
}
.share-success {
    background: #dcfce7;
    border: 1px solid #86efac;
    color: #15803d;
    padding: 7px 10px;
    border-radius: 5px;
    font-size: 13px;
    margin-bottom: 12px;
}

.no-data {
    text-align: center;
    color: #888;
    padding: 40px;
    background: white;
    border-radius: 8px;
    margin-top: 16px;
}

/* =============================================
   BLAZOR ERROR UI
   ============================================= */

#blazor-error-ui {
    background: #fff3cd;
    bottom: 0;
    box-shadow: 0 -2px 6px rgba(0,0,0,0.1);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* =============================================
   NAV - INACTIVE REGIONS (ADMIN VIEW)
   ============================================= */

.nav-region-inactive .nav-region-header {
    opacity: 0.5;
    font-style: italic;
}

.nav-inactive-badge {
    margin-left: auto;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    background: #e74c3c;
    color: white;
    padding: 1px 5px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

.nav-favorites-empty {
    padding: 7px 16px 10px;
    font-size: 12px;
    color: #bbb;
    font-style: italic;
}

.nav-admin-section {
    margin-top: 12px;
    border-top: 1px solid #eee;
}

/* ── Favorites section ── */
.nav-favorites-header {
    color: #92400e !important;
    background: #fffbeb !important;
    border-bottom: 1px solid #fde68a;
}

.nav-item-with-star {
    display: flex !important;
    align-items: center;
    padding-right: 4px !important;
}
.nav-item-label {
    flex: 1;
    overflow: hidden;
    word-break: break-word;
    cursor: pointer;
}
.nav-star {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #bbb;
    padding: 0 4px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}
.nav-item-with-star:hover .nav-star { opacity: 1; }
.nav-star.starred { opacity: 1; color: #f59e0b; }
.nav-star:hover { color: #f59e0b; }

.nav-favorite-item {
    display: flex !important;
    align-items: center;
    padding-right: 4px !important;
}
.nav-fav-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    font-size: 13px;
}
.nav-fav-remove {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    color: #bbb;
    padding: 0 4px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    border-radius: 3px;
}
.nav-favorite-item:hover .nav-fav-remove { opacity: 1; }
.nav-fav-remove:hover { color: #ef4444; background: #fee2e2; }

.nav-admin-link {
    padding: 8px 14px;
    cursor: pointer;
    color: #7b4f12;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.15s;
    border-left: 3px solid transparent;
}
.nav-admin-link:hover { background: #fef9f0; }
.nav-admin-link.active {
    background: #fdf3d0;
    border-left-color: #c88a00;
    color: #8a5e00;
}

/* =============================================
   ADMIN REGIONS PAGE
   ============================================= */

.admin-regions-page {
    max-width: 100%;
}

.admin-regions-page h2 {
    margin-bottom: 6px;
    color: #1a3a5c;
}

.admin-regions-page .section-desc {
    color: #666;
    margin-bottom: 20px;
    font-size: 13px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.admin-table th {
    background: #f0f4f8;
    padding: 10px 14px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #555;
    border-bottom: 1px solid #dde1e7;
    white-space: nowrap;
}

.admin-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
    white-space: nowrap;
}

.admin-table tr:last-child td { border-bottom: none; }

.admin-table tr.row-inactive td {
    opacity: 0.6;
    background: #fafafa;
}

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-active {
    background: #d4edda;
    color: #155724;
}

.badge-inactive {
    background: #f8d7da;
    color: #721c24;
}

.btn-toggle {
    padding: 5px 14px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
}

.btn-deactivate {
    background: #f8d7da;
    color: #721c24;
}
.btn-deactivate:hover { background: #f5c6cb; }

.btn-activate {
    background: #d4edda;
    color: #155724;
}
.btn-activate:hover { background: #c3e6cb; }

/* Admin table row interactions */
.admin-region-row { cursor: pointer; }
.admin-region-row:hover td { background: #f8faff; }
.expand-col { width: 28px; text-align: center; color: #888; font-size: 11px; }

.admin-branch-row td { background: #f9fafb; border-bottom: 1px solid #eee; }
.admin-branch-row:last-child td { border-bottom: 1px solid #dde1e7; }

.branch-indent {
    padding-left: 28px !important;
    color: #555;
    font-size: 13px;
}

.branch-id-cell {
    font-size: 12px;
    font-family: monospace;
    color: #888;
    white-space: nowrap;
}

.report-assign-count {
    font-size: 12px;
    color: #155724;
    background: #d4edda;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}
.report-assign-count.partial {
    color: #856404;
    background: #fff3cd;
}

.btn-configure {
    padding: 4px 12px;
    border: 1px solid #1a6ba0;
    border-radius: 4px;
    background: #fff;
    color: #1a6ba0;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.btn-configure:hover { background: #1a6ba0; color: #fff; }

/* Admin search filter */
.admin-search {
    width: 100%;
    max-width: 360px;
    padding: 7px 12px;
    border: 1px solid #cdd2da;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 14px;
    display: block;
}

/* Branch active count chip */
.branch-count {
    font-size: 12px;
    color: #1a3a5c;
    background: #e8f0fb;
    padding: 2px 9px;
    border-radius: 10px;
    font-weight: 600;
}

/* Warning / error badges */
.warn-badge {
    display: inline-block;
    margin-left: 10px;
    background: #fff3cd;
    color: #856404;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}

.sql-error-detail {
    margin-top: 8px;
    padding: 8px 12px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    font-size: 12px;
    color: #664d03;
    word-break: break-word;
}

.btn-retry-sql {
    margin-left: 10px;
    padding: 3px 12px;
    background: #fff;
    border: 1px solid #856404;
    color: #856404;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-retry-sql:hover { background: #fff3cd; }
.btn-retry-loading { opacity: 0.6; cursor: not-allowed; }

/* Admin toolbar (search + clear overrides) */
.admin-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.admin-toolbar .admin-search { margin-bottom: 0; }
.btn-clear-overrides {
    padding: 6px 14px;
    background: #fff;
    border: 1px solid #adb5bd;
    color: #495057;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}
.btn-clear-overrides:hover { background: #f8f9fa; border-color: #6c757d; }
.clear-confirm-text {
    font-size: 13px;
    color: #842029;
    font-weight: 500;
    white-space: nowrap;
}
.btn-danger {
    padding: 6px 14px;
    background: #dc3545;
    border: none;
    color: #fff;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.btn-danger:hover { background: #bb2d3b; }
.btn-danger:disabled { opacity: 0.65; cursor: not-allowed; }
.btn-cancel {
    padding: 6px 14px;
    background: #fff;
    border: 1px solid #adb5bd;
    color: #495057;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.btn-cancel:hover { background: #f8f9fa; }

/* Per-branch toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 22px;
    transition: background 0.2s;
}
.toggle-slider::before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: #1a6ba0; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* =============================================
   ADMIN BRANCH REPORTS PAGE
   ============================================= */

.admin-branch-reports-page {
    max-width: 780px;
}

.admin-branch-reports-page h2 {
    margin-bottom: 6px;
    color: #1a3a5c;
}

.admin-branch-reports-page .section-desc {
    color: #666;
    margin-bottom: 20px;
    font-size: 13px;
}

.report-assign-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.report-assign-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, opacity 0.15s;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.report-assign-card.assigned {
    border-color: #28a745;
    background: #f0fdf4;
}

.report-assign-card.unassigned {
    border-color: #dee2e6;
    background: #f9fafb;
    opacity: 0.65;
}

.report-assign-card:hover { opacity: 1; border-color: #1a6ba0; }

.report-assign-check { font-size: 18px; flex-shrink: 0; }
.check-on { color: #28a745; }
.check-off { color: #adb5bd; }

.report-assign-name {
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
    flex: 1;
}

.report-assign-status {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #888;
}

.report-assign-card.assigned .report-assign-status { color: #28a745; }

.admin-actions {
    display: flex;
    gap: 10px;
}

.btn-assign-all {
    padding: 7px 18px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    background: #d4edda;
    color: #155724;
    transition: background 0.15s;
}
.btn-assign-all:hover { background: #c3e6cb; }

/* ── Schedule Admin Page ─────────────────────────────────── */
.schedule-admin-page {
    padding: 24px 0;
    max-width: 1400px;
}
.schedule-admin-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}
.schedule-admin-header h2 { margin: 0 0 4px; font-size: 20px; color: #1a3a5c; }
.schedule-admin-subtitle { margin: 0; font-size: 13px; color: #666; }

.schedule-info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    color: #1e3a5f;
    margin-bottom: 20px;
    line-height: 1.6;
}
.schedule-info-box code {
    background: #dbeafe;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
}

.schedule-table-wrapper {
    overflow-x: auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.schedule-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.schedule-table th {
    background: #1a3a5c;
    color: white;
    padding: 10px 8px;
    text-align: left;
    white-space: nowrap;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.schedule-table td {
    padding: 9px 8px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}
.schedule-row:last-child td { border-bottom: none; }
.schedule-row:hover { background: #f8fafc; }
.schedule-row-disabled { opacity: 1; }

.schedule-report-name { font-weight: 600; color: #1a3a5c; white-space: nowrap; }
.schedule-proc-name   { font-family: 'Consolas', monospace; font-size: 11.5px; color: #555; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.schedule-last-run    { white-space: nowrap; color: #555; font-size: 12px; }
.schedule-na          { color: #aaa; }
.schedule-time-cell   { display: flex; align-items: center; gap: 4px; }
.schedule-time-sep    { font-weight: bold; color: #555; }

.schedule-select {
    padding: 4px 6px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 12px;
    background: white;
    color: #333;
    cursor: pointer;
}
.schedule-select:focus { outline: none; border-color: #1a3a5c; }
.schedule-select-day  { min-width: 0; width: auto; }
.schedule-select-time { width: 54px; }

/* CSS Toggle Switch */
.schedule-toggle-cell { text-align: center; }
.schedule-toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    cursor: pointer;
}
.schedule-toggle input { opacity: 0; width: 0; height: 0; }
.schedule-toggle-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #cbd5e1;
    border-radius: 22px;
    transition: 0.2s;
}
.schedule-toggle input:checked + .schedule-toggle-slider { background: #1a3a5c; }
.schedule-toggle-slider::before {
    content: "";
    position: absolute;
    height: 16px; width: 16px;
    left: 3px; bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.schedule-toggle input:checked + .schedule-toggle-slider::before {
    transform: translateX(18px);
}

/* Status badges */
.schedule-status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.schedule-status-badge.status-success  { background: #d1fae5; color: #065f46; }
.schedule-status-badge.status-failed   { background: #fee2e2; color: #991b1b; }
.schedule-status-badge.status-never    { background: #f3f4f6; color: #6b7280; }
.schedule-error-hint {
    cursor: help;
    margin-left: 4px;
    font-size: 13px;
}

/* Save button & confirm */
.btn-save-row {
    padding: 5px 14px;
    border: none;
    border-radius: 4px;
    background: #1a3a5c;
    color: white;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
.btn-save-row:hover { background: #14304f; }
.btn-save-row:disabled {
    background: #c0c8d0;
    color: #8a929a;
    cursor: default;
}
.schedule-saved-confirm {
    color: #065f46;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}
.btn-run-now {
    padding: 5px 12px;
    border: none;
    border-radius: 4px;
    background: #166534;
    color: white;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
    margin-left: 6px;
}
.btn-run-now:hover { background: #14532d; }
.schedule-running {
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
    margin-left: 6px;
    white-space: nowrap;
}
.schedule-run-result {
    font-size: 12px;
    font-weight: 700;
    margin-left: 6px;
    white-space: nowrap;
}
.run-ok   { color: #065f46; }
.run-warn { color: #92400e; }
.schedule-action-cell { white-space: nowrap; }

/* Expand/collapse toggle */
.schedule-expand-col { width: 28px; padding: 0 4px !important; text-align: center; }
.btn-expand {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    color: #6b7280;
    padding: 2px 4px;
    line-height: 1;
}
.btn-expand:hover { color: #1a3a5c; }

/* Branch detail row */
.schedule-branch-detail-row td {
    background: #f0f4f8;
    padding: 10px 16px 14px 40px !important;
    border-bottom: 2px solid #d1d9e0;
}
.schedule-param-section {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    align-items: flex-end;
    padding: 8px 0 12px;
    border-bottom: 1px solid #d1d9e0;
    margin-bottom: 10px;
}
.schedule-param-label {
    display: flex;
    flex-direction: column;
    font-size: 11px;
    font-weight: 600;
    color: #4b5563;
    gap: 3px;
}
.schedule-param-input {
    font-size: 12px;
    padding: 4px 7px;
    border: 1px solid #b8c5d1;
    border-radius: 4px;
    background: #fff;
    color: #1e293b;
    width: 180px;
}
.schedule-param-input-wide {
    width: 360px;
}
.schedule-branch-loading {
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
}
.schedule-branch-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.schedule-branch-table th {
    background: #dce4ed;
    color: #374151;
    font-weight: 600;
    padding: 5px 10px;
    text-align: left;
    border-bottom: 1px solid #b8c5d1;
}
.schedule-branch-table td {
    padding: 4px 10px;
    border-bottom: 1px solid #e2e8f0;
    color: #374151;
}
.schedule-branch-table tr:last-child td { border-bottom: none; }
.schedule-branch-id { color: #9ca3af; font-size: 11px; }
.schedule-branch-message { color: #6b7280; max-width: 400px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.schedule-status-badge.status-partial { background: #fef3c7; color: #92400e; }

.btn-unassign-all {
    padding: 7px 18px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    background: #f8d7da;
    color: #721c24;
    transition: background 0.15s;
}
.btn-unassign-all:hover { background: #f5c6cb; }

/* =============================================
   DASHBOARD PAGE
   ============================================= */

.dashboard-launch-page {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.dashboard-launch-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    width: 420px;
    padding: 48px 40px;
    background: #fff;
    border: 2px solid #dde1e7;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    text-decoration: none;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
    cursor: pointer;
}

.dashboard-launch-card:hover {
    border-color: #1a6ba0;
    box-shadow: 0 8px 28px rgba(26,107,160,0.18);
    transform: translateY(-3px);
    text-decoration: none;
}

.dashboard-launch-icon {
    font-size: 56px;
    line-height: 1;
}

.dashboard-launch-name {
    font-size: 16px;
    font-weight: 700;
    color: #1a3a5c;
    text-align: center;
}

.dashboard-launch-hint {
    font-size: 12px;
    color: #1a6ba0;
    font-weight: 500;
}
