/* ============================================
   Follow-Up Tracker — Jira-Inspired Stylesheet
   ============================================ */

:root {
    /* Atlassian-inspired palette */
    --primary: #0052CC;
    --primary-light: #0065FF;
    --primary-dark: #003D99;
    --primary-subtle: #DEEBFF;
    --success: #36B37E;
    --success-subtle: #E3FCEF;
    --danger: #DE350B;
    --danger-subtle: #FFEBE6;
    --warning: #FF991F;
    --warning-subtle: #FFFAE6;
    --purple: #6554C0;
    --teal: #00B8D9;

    /* Neutrals */
    --N0: #FFFFFF;
    --N10: #FAFBFC;
    --N20: #F4F5F7;
    --N30: #EBECF0;
    --N40: #DFE1E6;
    --N50: #C1C7D0;
    --N60: #B3BAC5;
    --N80: #97A0AF;
    --N100: #7A869A;
    --N200: #6B778C;
    --N300: #5E6C84;
    --N400: #505F79;
    --N500: #42526E;
    --N600: #344563;
    --N700: #253858;
    --N800: #172B4D;
    --N900: #091E42;

    /* Semantic tokens */
    --bg: var(--N20);
    --surface: var(--N0);
    --border: var(--N40);
    --text: var(--N900);
    --text-secondary: var(--N200);
    --text-muted: var(--N100);
    --shadow-sm: 0 1px 2px rgba(9, 30, 66, 0.08);
    --shadow: 0 1px 3px rgba(9, 30, 66, 0.13), 0 0 1px rgba(9, 30, 66, 0.2);
    --shadow-lg: 0 8px 16px rgba(9, 30, 66, 0.15), 0 0 1px rgba(9, 30, 66, 0.31);
    --shadow-overlay: 0 4px 8px -2px rgba(9, 30, 66, 0.25), 0 0 1px rgba(9, 30, 66, 0.31);
    --radius: 3px;
    --radius-sm: 3px;
    --radius-md: 4px;
    --transition: all 0.14s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.4286;
    -webkit-font-smoothing: antialiased;
}

/* ---- Top Bar ---- */
.topbar {
    background: linear-gradient(135deg, #1A73E8 0%, #4A90D9 50%, #6BA3E8 100%);
    color: var(--N0);
    padding: 0 20px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(26, 115, 232, 0.3);
}

.app-title {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.003em;
}

.app-title .icon {
    font-size: 18px;
    opacity: 0.7;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: none;
    border-radius: var(--radius);
    background: var(--N20);
    color: var(--N500);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
    font-family: inherit;
    line-height: 20px;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    background: var(--N30);
    color: var(--N800);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(9, 30, 66, 0.15);
}

.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Add New Item — bold blue */
.btn-primary {
    background: var(--primary);
    color: var(--N0);
}

.btn-primary:hover {
    background: var(--primary-light);
    color: var(--N0);
    box-shadow: 0 3px 10px rgba(0, 82, 204, 0.35);
}

/* Add Column — teal */
#btn-add-column {
    background: #00B8D9;
    color: var(--N0);
}

#btn-add-column:hover {
    background: #00A3BF;
    color: var(--N0);
    box-shadow: 0 3px 10px rgba(0, 184, 217, 0.35);
}

/* Manage Columns — purple */
#btn-manage-columns {
    background: var(--purple);
    color: var(--N0);
}

#btn-manage-columns:hover {
    background: #5243AA;
    color: var(--N0);
    box-shadow: 0 3px 10px rgba(101, 84, 192, 0.35);
}

/* Clear Filters — warm amber/orange */
#btn-clear-filters {
    background: var(--warning);
    color: var(--N900);
}

#btn-clear-filters:hover {
    background: #FF8B00;
    color: var(--N900);
    box-shadow: 0 3px 10px rgba(255, 153, 31, 0.35);
}

/* Export to Excel — green */
.btn-success {
    background: var(--success);
    color: var(--N0);
}

.btn-success:hover {
    background: #2C9D6B;
    color: var(--N0);
    box-shadow: 0 3px 10px rgba(54, 179, 126, 0.35);
}

/* Delete Selected — red */
.btn-danger {
    background: var(--danger);
    color: var(--N0);
}

.btn-danger:hover {
    background: #BF2600;
    color: var(--N0);
    box-shadow: 0 3px 10px rgba(222, 53, 11, 0.35);
}

.btn-secondary {
    background: var(--N20);
    color: var(--N500);
}

.btn-secondary:hover {
    background: var(--N30);
}

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

.btn-xs {
    padding: 2px 8px;
    font-size: 11px;
    line-height: 18px;
}

/* Top-bar icon buttons */
.btn-icon {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--N0);
    transform: translateY(0);
    box-shadow: none;
}

/* Topbar — Customers button */
#btn-customer-mgmt {
    color: rgba(255, 255, 255, 0.8);
}

#btn-customer-mgmt:hover {
    background: rgba(0, 184, 217, 0.25);
    color: #79E2F2;
}

/* Topbar — Users button */
#btn-user-mgmt {
    color: rgba(255, 255, 255, 0.8);
}

#btn-user-mgmt:hover {
    background: rgba(101, 84, 192, 0.3);
    color: #C0B6F2;
}

.btn-inline-add {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius);
    background: var(--primary);
    color: var(--N0);
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.18s ease;
}

.btn-inline-add:hover {
    background: var(--primary-light);
    box-shadow: 0 2px 8px rgba(0, 82, 204, 0.3);
}

/* ---- Action Bar ---- */
.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--N30);
    flex-wrap: wrap;
    gap: 8px;
}

.action-bar-left,
.action-bar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* ---- Table ---- */
.table-container {
    padding: 0 20px;
    overflow-x: auto;
    overflow-y: visible;
    margin-top: 1px;
}

.tracker-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-size: 13px;
    min-width: 1200px;
    border: 1px solid var(--N30);
}

.tracker-table thead th {
    background: linear-gradient(180deg, #E8F0FE 0%, #D2E3FC 100%);
    padding: 11px 12px;
    text-align: left;
    font-weight: 700;
    font-size: 11px;
    color: #1A56DB;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid #90B8F8;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

/* Column resize handle */
.col-resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    cursor: col-resize;
    background: transparent;
    z-index: 10;
    transition: background 0.15s;
}

.col-resize-handle:hover,
.col-resize-handle.resizing {
    background: rgba(26, 86, 219, 0.15);
}

.tracker-table.resizing {
    cursor: col-resize;
    user-select: none;
}

/* Sortable column headers */
.tracker-table th.sortable {
    cursor: pointer;
    user-select: none;
    padding-right: 24px;
    transition: background 0.12s;
}

.tracker-table th.sortable:hover {
    background: linear-gradient(180deg, #D2E3FC 0%, #B8D4FA 100%);
    color: #0D47A1;
}

.tracker-table th.sortable .th-label {
    margin-right: 2px;
}

.tracker-table th.sortable .sort-icon {
    font-size: 10px;
    opacity: 0.4;
    vertical-align: middle;
    transition: opacity 0.12s;
    color: #5B8DEF;
}

.tracker-table th.sortable:hover .sort-icon {
    opacity: 0.8;
}

.tracker-table th.sort-active {
    background: linear-gradient(180deg, #C3D9FA 0%, #A8C8F7 100%);
    color: #0D47A1;
}

.tracker-table th.sort-active .sort-icon {
    opacity: 1;
    color: #0D47A1;
}

.tracker-table thead tr:first-child th:first-child {
    border-top-left-radius: var(--radius);
}

.tracker-table thead tr:first-child th:last-child {
    border-top-right-radius: var(--radius);
}

.tracker-table tbody td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--N30);
    vertical-align: top;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--N800);
}

.tracker-table tbody tr:hover {
    background: var(--N10);
}

.tracker-table tbody tr.selected {
    background: var(--primary-subtle);
}

/* Inline editing cells */
.cell-editable {
    cursor: pointer;
    border-radius: var(--radius);
    transition: var(--transition);
    min-height: 28px;
    position: relative;
}

.cell-editable:hover {
    background: var(--N20);
}

.cell-editable.editing {
    background: var(--N0);
    outline: 2px solid var(--primary);
    padding: 0;
}

.cell-editable .edit-input,
.cell-editable .edit-textarea,
.cell-editable .edit-select {
    width: 100%;
    padding: 6px 8px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    outline: none;
    resize: vertical;
    color: var(--text);
}

.cell-editable .edit-textarea {
    min-height: 60px;
}

/* Dated Action Log */
.cell-dated-log {
    min-width: 220px;
}

.dated-log-display {
    white-space: normal !important;
    display: block !important;
    overflow: visible !important;
    word-break: break-word;
}

.dated-log-entry {
    padding: 2px 0;
    line-height: 1.5;
    font-size: 13px;
}

.dated-log-entry+.dated-log-entry {
    border-top: 1px dashed var(--N30);
    margin-top: 2px;
    padding-top: 4px;
}

.dated-log-date {
    font-weight: 700;
    color: var(--primary);
    font-size: 11px;
    white-space: nowrap;
}

.dated-log-textarea {
    min-height: 100px !important;
}

.dated-log-editor {
    width: 100%;
}

/* Checkbox column */
.col-checkbox {
    width: 40px;
    text-align: center;
}

.row-checkbox {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* Serial number column */
.col-serial {
    width: 50px;
    text-align: center;
    color: var(--N200);
    font-weight: 600;
    font-size: 12px;
}

/* Status badge — Jira lozenge style */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0;
    padding: 2px 8px;
    border-radius: var(--radius);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 16px;
}

.status-blocked {
    background: var(--danger-subtle);
    color: var(--danger);
}

.status-inprogress {
    background: #DEEBFF;
    color: var(--primary);
}

.status-done {
    background: var(--success-subtle);
    color: #006644;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.status-dot.blocked {
    background: var(--danger);
}

.status-dot.inprogress {
    background: var(--primary);
}

.status-dot.done {
    background: var(--success);
}

/* Priority tags — Jira lozenge style */
.priority-tag {
    display: inline-flex;
    align-items: center;
    gap: 0;
    padding: 2px 8px;
    border-radius: var(--radius);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 16px;
}

.priority-high {
    background: var(--danger-subtle);
    color: var(--danger);
}

.priority-medium {
    background: var(--warning-subtle);
    color: #FF8B00;
}

.priority-low {
    background: var(--success-subtle);
    color: #006644;
}

.priority-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 5px;
}

.priority-dot.high {
    background: var(--danger);
}

.priority-dot.medium {
    background: var(--warning);
}

.priority-dot.low {
    background: var(--success);
}

/* Action buttons in table */
.row-actions {
    display: flex;
    gap: 4px;
    white-space: nowrap;
}

.btn-notify {
    background: var(--primary);
    color: var(--N0);
    border: none;
    padding: 4px 10px;
    border-radius: var(--radius);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
}

.btn-notify:hover {
    background: var(--primary-light);
    box-shadow: 0 2px 8px rgba(0, 82, 204, 0.3);
    transform: translateY(-1px);
}

.btn-notify.sent {
    background: var(--success);
}

.btn-notify.sent:hover {
    background: #2C9D6B;
    box-shadow: 0 2px 8px rgba(54, 179, 126, 0.3);
}

.btn-attach {
    background: var(--N600);
    color: var(--N0);
    border: none;
    padding: 4px 10px;
    border-radius: var(--radius);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s ease;
    position: relative;
}

.btn-attach:hover {
    background: var(--N500);
    box-shadow: 0 2px 8px rgba(52, 69, 99, 0.3);
    transform: translateY(-1px);
}

.attachment-count {
    background: var(--primary-light);
    color: var(--N0);
    font-size: 10px;
    padding: 0 5px;
    border-radius: 10px;
    margin-left: 4px;
    line-height: 16px;
    font-weight: 700;
}

.btn-delete-row {
    background: transparent;
    border: none;
    color: var(--N80);
    cursor: pointer;
    padding: 3px 6px;
    border-radius: var(--radius);
    font-size: 16px;
    transition: all 0.18s ease;
}

.btn-delete-row:hover {
    background: var(--danger-subtle);
    color: var(--danger);
    transform: translateY(-1px);
}

/* ---- Filter Row ---- */
.filter-row th {
    padding: 6px 8px !important;
    background: var(--N0) !important;
    border-bottom: 1px solid var(--N40) !important;
    color: var(--text) !important;
}

.filter-input {
    width: 100%;
    padding: 4px 8px;
    border: 2px solid var(--N40);
    border-radius: var(--radius);
    font-size: 12px;
    font-family: inherit;
    background: var(--N10);
    transition: var(--transition);
    color: var(--text);
}

.filter-input:focus {
    border-color: var(--primary);
    background: var(--N0);
    outline: none;
}

.filter-input.active {
    border-color: var(--primary);
    background: var(--primary-subtle);
}

/* Multi-select filter dropdown */
.filter-multiselect {
    position: relative;
}

.filter-ms-btn {
    width: 100%;
    padding: 4px 8px;
    border: 2px solid var(--N40);
    border-radius: var(--radius);
    font-size: 12px;
    background: var(--N10);
    cursor: pointer;
    text-align: left;
    color: var(--N200);
    transition: var(--transition);
    font-family: inherit;
}

.filter-ms-btn.active {
    border-color: var(--primary);
    background: var(--primary-subtle);
    color: var(--primary);
    font-weight: 600;
}

.filter-ms-dropdown {
    position: fixed;
    width: max-content;
    min-width: 160px;
    max-height: 250px;
    overflow-y: auto;
    background: var(--N0);
    border-radius: var(--radius);
    box-shadow: var(--shadow-overlay);
    z-index: 200;
    padding: 4px 0;
    display: none;
}

.filter-ms-dropdown.show {
    display: block;
}

.filter-ms-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--N800);
}

.filter-ms-option:hover {
    background: var(--N20);
}

.filter-ms-option input {
    accent-color: var(--primary);
}

/* ---- Pagination ---- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    color: var(--N200);
    font-size: 13px;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-size-select {
    padding: 4px 8px;
    border: 2px solid var(--N40);
    border-radius: var(--radius);
    font-size: 12px;
    font-family: inherit;
    background: var(--N0);
    color: var(--text);
}

#page-indicator {
    font-weight: 600;
    color: var(--N500);
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--N200);
}

.empty-state p {
    margin-top: 12px;
    font-size: 14px;
}

/* ---- Modals ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(9, 30, 66, 0.54);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

#modal-confirm.modal-overlay {
    z-index: 1100;
}

/* Child modals that open on top of management modals */
#modal-add-user.modal-overlay,
#modal-add-master.modal-overlay,
#modal-add-column.modal-overlay {
    z-index: 1050;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.15s ease;
}

.modal-sm {
    max-width: 440px;
}

.modal-xs {
    max-width: 360px;
}

.modal-lg {
    max-width: 800px;
}

@keyframes modalIn {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 500;
    color: var(--N800);
    letter-spacing: -0.01em;
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--N100);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    border-radius: var(--radius);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--N20);
    color: var(--N800);
}

.modal-body {
    padding: 0 24px 20px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--N30);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ---- Forms ---- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--N300);
}

.required {
    color: var(--danger);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid var(--N40);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.12s, background 0.12s;
    background: var(--N10);
    color: var(--text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    background: var(--N0);
    outline: none;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.select-with-add {
    display: flex;
    gap: 6px;
}

.select-with-add select {
    flex: 1;
}

.char-count {
    font-size: 11px;
    color: var(--N100);
    text-align: right;
    display: block;
    margin-top: 2px;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input {
    width: auto !important;
    accent-color: var(--primary);
}

/* ---- User Management ---- */
.user-mgmt-toolbar {
    margin-bottom: 16px;
}

.user-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.user-table th {
    background: var(--N20);
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--N300);
    border-bottom: 2px solid var(--N40);
}

.user-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--N30);
    color: var(--N800);
}

.user-table tr:hover {
    background: var(--N10);
}

.badge-active {
    padding: 2px 8px;
    border-radius: var(--radius);
    font-size: 11px;
    font-weight: 700;
    background: var(--success-subtle);
    color: #006644;
    text-transform: uppercase;
}

.badge-inactive {
    padding: 2px 8px;
    border-radius: var(--radius);
    font-size: 11px;
    font-weight: 700;
    background: var(--N30);
    color: var(--N200);
    text-transform: uppercase;
}

/* ---- Attachments ---- */
.attachment-upload-zone {
    border: 2px dashed var(--N40);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
    margin-bottom: 16px;
}

.attachment-upload-zone:hover,
.attachment-upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-subtle);
}

.upload-prompt p {
    margin-top: 8px;
    color: var(--N200);
    font-size: 14px;
}

.upload-prompt a {
    color: var(--primary);
    font-weight: 500;
}

.upload-hint {
    font-size: 12px !important;
    color: var(--N80) !important;
    margin-top: 4px !important;
}

.attachment-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.attachment-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--N10);
    border-radius: var(--radius);
    border: 1px solid var(--N30);
}

.attachment-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.attachment-info a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.attachment-info a:hover {
    text-decoration: underline;
}

.attachment-size {
    font-size: 11px;
    color: var(--N100);
}

.attachment-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.attachment-view {
    background: var(--primary);
    color: var(--N0);
    border: none;
    padding: 3px 10px;
    border-radius: var(--radius);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.attachment-view:hover {
    background: var(--primary-dark);
}

.attachment-remove {
    background: none;
    border: none;
    color: var(--N80);
    cursor: pointer;
    font-size: 18px;
    padding: 0 4px;
    transition: var(--transition);
}

.attachment-remove:hover {
    color: var(--danger);
}

/* ---- File Preview Modal ---- */
.modal-preview {
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-preview .modal-header {
    flex-shrink: 0;
}

.preview-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-body {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    background: var(--N20);
}

.preview-body img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: var(--radius);
}

.preview-body iframe {
    width: 100%;
    height: 75vh;
    border: none;
    border-radius: var(--radius);
}

.preview-not-supported {
    text-align: center;
    padding: 40px;
    color: var(--N200);
}

.preview-not-supported p {
    margin-top: 12px;
    font-size: 14px;
}

/* ---- Toasts ---- */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
}

.toast {
    padding: 12px 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-overlay);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.2s ease;
    min-width: 280px;
    max-width: 400px;
}

.toast-success {
    background: var(--success);
    color: var(--N0);
}

.toast-error {
    background: var(--danger);
    color: var(--N0);
}

.toast-info {
    background: var(--N700);
    color: var(--N0);
}

.toast .toast-undo {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: var(--N0);
    padding: 2px 10px;
    border-radius: var(--radius);
    font-size: 12px;
    cursor: pointer;
    margin-left: auto;
    font-weight: 600;
}

.toast .toast-undo:hover {
    background: rgba(255, 255, 255, 0.35);
}

@keyframes toastIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ---- Truncated text ---- */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

/* ---- Utility ---- */
.hidden {
    display: none !important;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .action-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .topbar {
        padding: 0 12px;
    }

    .table-container {
        padding: 0 8px;
    }

    .pagination {
        flex-direction: column;
        gap: 8px;
    }
}

/* ---- Scrollbar ---- */
.table-container::-webkit-scrollbar {
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: var(--N20);
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--N50);
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: var(--N80);
}

/* ---- Login Screen ---- */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--N20);
    padding: 20px;
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
    overflow: hidden;
    animation: modalIn 0.2s ease;
}

.login-header {
    background: var(--N0);
    color: var(--N800);
    padding: 32px 32px 8px;
    text-align: center;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: -0.01em;
}

.login-header p {
    font-size: 14px;
    color: var(--N200);
    margin-top: 4px;
}

.login-body {
    padding: 20px 32px 32px;
}

.login-body .form-group {
    margin-bottom: 16px;
}

.login-body .form-group label {
    font-weight: 600;
    font-size: 12px;
    color: var(--N300);
    margin-bottom: 4px;
}

.login-body .form-group input {
    padding: 10px 12px;
    font-size: 14px;
    border-radius: var(--radius);
}

.login-error {
    color: var(--danger);
    font-size: 13px;
    font-weight: 500;
    min-height: 20px;
    margin-bottom: 8px;
}

.btn-login-submit {
    width: 100%;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.18s ease;
}

.btn-login-submit:hover {
    background: var(--primary-light);
    box-shadow: 0 4px 12px rgba(0, 82, 204, 0.35);
    transform: translateY(-1px);
}

.auth-toggle {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: var(--N200);
}

.auth-toggle a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    transition: color 0.15s ease;
}

.auth-toggle a:hover {
    color: var(--primary-light);
    text-decoration: underline;
}

/* ---- User Label & Logout ---- */
.user-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-weight: 500;
    padding: 0 4px;
}

.btn-logout {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
}

.btn-logout:hover {
    background: rgba(222, 53, 11, 0.2);
    color: #FF8F73;
}

/* ---- Loading spinner ---- */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--N0);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}