/* ============================================
   TEN IT Communications Tool — Styles
   Brand colour: #462055 (Palace Purple)
   ============================================ */

:root {
    --ten-purple: #462055;
    --ten-purple-light: #5a2d6a;
    --ten-purple-dark: #2a1433;
    --ten-purple-lighter: #f3edf5;
    --ten-purple-bg: #f9f6fa;
    --ten-gold: #c8a84e;
    --ten-gold-light: #e8d9a0;
    --ten-gold-dark: #a68b3a;
    --white: #ffffff;
    --text: #2d2d2d;
    --text-light: #6b6b6b;
    --text-muted: #999999;
    --border: #e8e0ec;
    --border-light: #f0eaf2;
    --success: #107c10;
    --success-bg: #e6f4ea;
    --warning: #ff8c00;
    --warning-bg: #fff4e5;
    --danger: #d13438;
    --danger-bg: #fde7e9;
    --info: #0078d4;
    --info-bg: #e8f0fe;
    --heading-color: #462055;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 2px 12px rgba(70, 32, 85, 0.08);
    --shadow-lg: 0 8px 30px rgba(70, 32, 85, 0.12);
    --transition: all 0.2s ease;
}

[data-theme="dark"] {
    --heading-color: #e0e0e0;
    --ten-purple-lighter: #2a1a33;
    --ten-purple-bg: #1e1225;
    --white: #1e1e1e;
    --text: #e0e0e0;
    --text-light: #a0a0a0;
    --text-muted: #707070;
    --border: #3a2d42;
    --border-light: #2e2336;
    --success-bg: #1a2e1a;
    --warning-bg: #2e2510;
    --danger-bg: #2e1518;
    --info-bg: #152030;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] body {
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(200, 168, 78, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(200, 168, 78, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(90, 45, 106, 0.2) 0%, transparent 70%),
        linear-gradient(135deg, #1a0a20 0%, #2a1433 30%, #462055 60%, #2a1433 100%);
    background-attachment: fixed;
    color: var(--text);
}

[data-theme="dark"] .sidebar {
    background: 
        linear-gradient(180deg, rgba(62, 28, 80, 0.97), rgba(40, 16, 54, 0.98)),
        url('../Images/HeaderGold.jpg') center/cover no-repeat;
    border-right-color: var(--ten-gold);
}

[data-theme="dark"] .topbar {
    background: rgba(30, 20, 37, 0.85);
    backdrop-filter: blur(10px);
    border-bottom-color: rgba(200, 168, 78, 0.15);
}

[data-theme="dark"] .content-area {
    background: transparent;
}

[data-theme="dark"] .template-card {
    background: rgba(30, 25, 35, 0.7);
    border-color: rgba(200, 168, 78, 0.15);
    backdrop-filter: blur(10px);
}

[data-theme="dark"] .template-card:hover {
    border-color: var(--ten-gold);
    background: rgba(40, 30, 50, 0.8);
}

[data-theme="dark"] .template-card.create-new {
    background: rgba(26, 18, 32, 0.6);
    border-color: rgba(200, 168, 78, 0.2);
    border-style: dashed;
}

[data-theme="dark"] .settings-section {
    background: rgba(30, 25, 35, 0.7);
    backdrop-filter: blur(10px);
}

[data-theme="dark"] .settings-section h3 {
    color: #ffffff;
    border-bottom-color: rgba(200, 168, 78, 0.4);
}

[data-theme="dark"] .settings-row {
    border-bottom-color: #2e2336;
}

[data-theme="dark"] .editor-container {
    background: rgba(30, 25, 35, 0.8);
    backdrop-filter: blur(10px);
}

[data-theme="dark"] .editor-fields input,
[data-theme="dark"] .editor-fields select {
    background: #2a2a2a;
    color: var(--text);
    border-color: #3a2d42;
}

[data-theme="dark"] .editor-fields input[readonly] {
    background: #1e1e1e;
    color: #a0a0a0;
}

[data-theme="dark"] .editor-toolbar {
    background: #252025;
    border-color: #3a2d42;
}

[data-theme="dark"] .toolbar-btn {
    color: var(--text);
}

[data-theme="dark"] .toolbar-select {
    background: #2a2a2a;
    color: var(--text);
    border-color: #3a2d42;
}

[data-theme="dark"] #email-body {
    background: #2a2a2a;
    color: var(--text);
}

[data-theme="dark"] #email-body .detail-box {
    background: #1e1e1e;
    border-color: #3a2d42;
}

[data-theme="dark"] #email-body .detail-row {
    border-bottom-color: #2e2336;
}

[data-theme="dark"] #email-body .detail-label {
    color: #a090b0;
}

[data-theme="dark"] #email-body a {
    color: var(--ten-gold);
}

[data-theme="dark"] .editor-body {
    background: #2a2a2a;
    color: var(--text);
}

[data-theme="dark"] .editor-body:focus {
    background: #2e2e2e;
}

[data-theme="dark"] .editor-body .detail-box {
    background: #1e1e1e;
    border-left-color: var(--ten-gold);
}

[data-theme="dark"] .editor-body .detail-label {
    color: var(--ten-gold);
}

[data-theme="dark"] .editor-body .detail-value:focus {
    border-color: var(--ten-gold);
    background: rgba(200, 168, 78, 0.1);
}

[data-theme="dark"] .editor-actions {
    background: #1e1425;
    border-top-color: #2e2336;
}

[data-theme="dark"] .attachments-bar {
    background: #1e1425;
    border-bottom-color: #2e2336;
}

[data-theme="dark"] .attachment-chip {
    background: #2a2a2a;
    border-color: #3a2d42;
    color: var(--text);
}

[data-theme="dark"] .attachment-chip:hover {
    background: #352535;
    border-color: var(--ten-gold);
}

[data-theme="dark"] .history-table {
    background: rgba(30, 25, 35, 0.7);
    backdrop-filter: blur(10px);
}

[data-theme="dark"] .history-table th {
    background: #2a1a33;
}

[data-theme="dark"] .history-table td {
    border-bottom-color: #2e2336;
}

[data-theme="dark"] .history-table tbody tr:hover td {
    background: #252025;
}

[data-theme="dark"] .incident-card {
    background: rgba(30, 25, 35, 0.7);
    backdrop-filter: blur(10px);
}

[data-theme="dark"] .incident-card-header {
    background: #252025;
    border-bottom-color: #2e2336;
}

[data-theme="dark"] .incident-card-actions {
    background: #252025;
    border-top-color: #2e2336;
}

[data-theme="dark"] .incident-stat-card {
    background: rgba(30, 25, 35, 0.7);
    backdrop-filter: blur(10px);
}

[data-theme="dark"] .modal {
    background: rgba(30, 25, 35, 0.95);
    backdrop-filter: blur(20px);
}

[data-theme="dark"] .modal-header {
    border-bottom-color: #2e2336;
}

[data-theme="dark"] .modal-footer {
    border-top-color: #2e2336;
}

[data-theme="dark"] .modal-body input,
[data-theme="dark"] .modal-body textarea,
[data-theme="dark"] .modal-body select {
    background: #2a2a2a;
    color: var(--text);
    border-color: #3a2d42;
}

[data-theme="dark"] .empty-state {
    color: var(--text-light);
}

[data-theme="dark"] .btn-primary {
    color: #ffffff;
}

[data-theme="dark"] .btn-danger {
    color: #ffffff;
}

[data-theme="dark"] .btn-success {
    color: #ffffff;
}

[data-theme="dark"] .btn-ghost {
    color: var(--text);
    border-color: #3a2d42;
}

[data-theme="dark"] .btn-ghost:hover {
    background: #252025;
}

[data-theme="dark"] .btn-secondary {
    background: #2a2a2a;
    color: #ffffff;
    border-color: #3a2d42;
}

[data-theme="dark"] .autocomplete-dropdown {
    background: #1e1e1e;
    border-color: #3a2d42;
}

[data-theme="dark"] .autocomplete-item:hover,
[data-theme="dark"] .autocomplete-item.active {
    background: #2a1a33;
}

[data-theme="dark"] .sidebar-nav li {
    color: #ffffff;
    opacity: 0.9;
}

[data-theme="dark"] .sidebar-nav li:hover {
    background: rgba(255,255,255,0.1);
    opacity: 1;
    color: #ffffff;
}

[data-theme="dark"] .sidebar-nav li.active {
    color: #ffffff;
    opacity: 1;
}

[data-theme="dark"] .sidebar-subtitle {
    color: #ffffff;
    opacity: 0.65;
}

[data-theme="dark"] .template-card h3,
[data-theme="dark"] .template-card .card-name {
    color: #ffffff;
}

[data-theme="dark"] .topbar h1 {
    color: #ffffff;
}

[data-theme="dark"] .template-card p,
[data-theme="dark"] .template-card .card-desc {
    color: #a0a0a0;
}

[data-theme="dark"] .template-card.create-new .card-icon {
    color: #c0b0d0;
}

[data-theme="dark"] .user-info .user-name {
    color: #e0d0e8;
}

[data-theme="dark"] .user-info .user-email {
    color: #a090b0;
}

[data-theme="dark"] .incident-severity-select {
    background: #2a2a2a;
    color: var(--text);
    border-color: #3a2d42;
}

[data-theme="dark"] .signin-card {
    background: #1e1e1e;
}

[data-theme="dark"] .preview-frame {
    background: #1e1e1e;
}

[data-theme="dark"] .preview-body {
    background: #2a2a2a;
    color: var(--text);
}

[data-theme="dark"] .preview-frame .detail-box,
[data-theme="dark"] .preview-body .detail-box {
    background: #1e1e1e !important;
    border-color: #3a2d42 !important;
}

[data-theme="dark"] .preview-frame .detail-label,
[data-theme="dark"] .preview-body .detail-label {
    color: var(--ten-gold) !important;
}

[data-theme="dark"] .preview-footer {
    background: #1e1425 !important;
}

[data-theme="dark"] .preview-footer-text {
    color: #a090b0 !important;
}

[data-theme="dark"] .preview-footer-company {
    color: var(--ten-purple-light) !important;
}

[data-theme="dark"] .toast {
    background: #2a2a2a;
    color: var(--text);
}

/* Theme toggle switch */
.theme-toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.theme-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #ccc;
    border-radius: 26px;
    transition: 0.3s;
}

.theme-toggle-slider::before {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
}

.theme-toggle input:checked + .theme-toggle-slider {
    background: var(--ten-purple);
}

.theme-toggle input:checked + .theme-toggle-slider::before {
    transform: translateX(22px);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f3f7;
    color: var(--text);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* ============================================
   LAYOUT
   ============================================ */

.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
    width: var(--sidebar-width);
    background: 
        linear-gradient(180deg, rgba(70, 32, 85, 0.92), rgba(42, 20, 51, 0.95)),
        url('../Images/HeaderGold.jpg') center/cover no-repeat;
    color: var(--white);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 10;
    border-right: 3px solid var(--ten-gold);
}

.sidebar-logo {
    padding: 24px 24px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo img {
    height: 36px;
    filter: brightness(0) invert(1);
}

.sidebar-subtitle {
    padding: 8px 24px 20px;
    font-size: 0.7rem;
    opacity: 0.5;
    text-transform: uppercase;
    letter-spacing: 2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-nav {
    list-style: none;
    padding: 16px 0;
    flex: 1;
}

.sidebar-nav li {
    padding: 12px 24px;
    font-size: 0.88rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0.7;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.sidebar-nav li:hover {
    background: rgba(255, 255, 255, 0.08);
    opacity: 0.9;
}

.sidebar-nav li.active {
    background: rgba(255, 255, 255, 0.12);
    opacity: 1;
    border-left-color: var(--ten-gold);
}

.sidebar-nav li .nav-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.sidebar-user {
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
}

.sidebar-user .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user .user-info {
    overflow: hidden;
}

.sidebar-user .user-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .user-email {
    font-size: 0.72rem;
    opacity: 0.6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    height: var(--topbar-height);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 0 var(--ten-gold);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    flex-shrink: 0;
}

/* PWA safe area — pushes content below Dynamic Island / notch on iPhone */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
    }
    .sidebar {
        padding-top: env(safe-area-inset-top);
    }
}

.topbar h1 {
    font-size: 1.25rem;
    color: var(--ten-purple);
    font-weight: 600;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--ten-purple);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--ten-purple-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(70, 32, 85, 0.3);
}

.btn-secondary {
    background: var(--white);
    color: var(--ten-purple);
    border: 2px solid var(--ten-purple);
}

.btn-secondary:hover {
    background: var(--ten-purple-lighter);
}

.btn-ghost {
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #b52d30;
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-success:hover {
    background: #0d6a0d;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 12px 28px;
    font-size: 1rem;
}

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

/* ============================================
   TEMPLATE CARDS (Dashboard)
   ============================================ */

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.template-card {
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 18px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.template-card:hover {
    border-color: var(--ten-gold);
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(200,168,78,0.15);
}

.template-card .card-icon {
    font-size: 2.2rem;
    margin-bottom: 10px;
}

.template-card .card-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--ten-purple);
    margin-bottom: 4px;
}

.template-card .card-desc {
    font-size: 0.75rem;
    color: var(--text-light);
}

.template-card.create-new {
    border: 2px dashed var(--ten-purple);
    background: var(--ten-purple-lighter);
}

.template-card.create-new .card-icon {
    font-size: 2.8rem;
    color: var(--ten-purple);
}

.template-card.create-new:hover {
    background: #ebe0ef;
}

/* ============================================
   EMAIL EDITOR
   ============================================ */

.editor-container {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.editor-fields {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.editor-field {
    display: flex;
    align-items: center;
    margin: 8px 0;
}

.editor-field label {
    width: 70px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-light);
    flex-shrink: 0;
}

.editor-field input,
.editor-field select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-family: inherit;
    color: var(--text);
    transition: var(--transition);
}

.editor-field input:focus,
.editor-field select:focus {
    outline: none;
    border-color: var(--ten-purple);
    box-shadow: 0 0 0 3px rgba(70, 32, 85, 0.1);
}

.editor-field input.readonly {
    background: #f8f6fa;
    color: var(--text-light);
    cursor: default;
}

.editor-toolbar {
    background: #faf8fb;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar-btn {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 0.8rem;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.toolbar-btn:hover {
    background: var(--ten-purple-lighter);
    border-color: var(--ten-purple);
}

.toolbar-btn.active {
    background: var(--ten-purple);
    color: var(--white);
    border-color: var(--ten-purple);
}

.toolbar-select {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.78rem;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    max-width: 130px;
}

.toolbar-select-sm {
    max-width: 60px;
}

.toolbar-select:focus {
    outline: none;
    border-color: var(--ten-purple);
}

.toolbar-color-wrap {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding-bottom: 2px !important;
}

.toolbar-color-input {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 6px;
    padding: 0;
    border: none;
    cursor: pointer;
    opacity: 0;
}

.toolbar-color-bar {
    display: block;
    width: 100%;
    height: 3px;
    background: #2d2d2d;
    border-radius: 1px;
    margin-top: 1px;
    pointer-events: none;
}

.toolbar-highlight-bar {
    background: #ffe066;
}

.toolbar-sub, .toolbar-sup {
    font-size: 0.72rem;
    padding: 5px 6px;
}

.toolbar-sep {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 4px;
}

.attachments-bar {
    background: #f8f6fa;
    border-bottom: 1px solid var(--border);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.attachments-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ten-purple);
    white-space: nowrap;
}

.attachments-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 3px 10px;
    font-size: 0.75rem;
    transition: var(--transition);
}

.attachment-chip:hover {
    border-color: var(--ten-gold);
    background: #fffdf5;
}

.attachment-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-weight: 500;
}

.attachment-size {
    color: var(--text-light);
    font-size: 0.7rem;
}

.attachment-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
    transition: var(--transition);
}

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

.editor-body {
    min-height: 300px;
    max-height: calc(100vh - 420px);
    overflow-y: auto;
    padding: 24px;
    outline: none;
    font-size: 0.92rem;
    line-height: 1.7;
    color: var(--text);
}

.editor-body:focus {
    background: #fefefe;
}

.editor-body p {
    margin-bottom: 12px;
}

.editor-body .detail-box {
    background: #f8f6fa;
    border-left: 4px solid var(--ten-purple);
    padding: 8px 18px;
    margin: 16px 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.88rem;
    width: 100%;
    border-collapse: collapse;
}

.editor-body .detail-row td {
    padding: 4px 0;
    vertical-align: middle;
}

.editor-body .detail-label {
    font-weight: 600;
    width: 140px;
    color: var(--ten-purple);
    white-space: nowrap;
    cursor: default;
    user-select: none;
    padding-right: 12px !important;
}

.editor-body .detail-value {
    padding: 2px 6px !important;
    border-radius: 3px;
    border: 1px solid transparent;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
    width: 100%;
}

.editor-body .detail-value:focus {
    border-color: var(--ten-gold);
    background: rgba(200, 168, 78, 0.07);
    outline: none;
}

.editor-actions {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #faf8fb;
}

.editor-actions-left {
    display: flex;
    gap: 10px;
}

.editor-actions-right {
    display: flex;
    gap: 10px;
}

/* ============================================
   EMAIL PREVIEW
   ============================================ */

.preview-frame {
    max-width: 650px;
    margin: 0 auto;
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.preview-header-image {
    line-height: 0;
    font-size: 0;
}

.preview-header-image img {
    display: block;
    width: 100%;
    height: auto;
}

.preview-gold-line {
    height: 3px;
    background: var(--ten-gold);
}

.preview-gold-divider {
    height: 1px;
    margin: 0 28px;
    background: linear-gradient(to right, var(--ten-gold), var(--ten-gold-light), var(--ten-gold));
}

.preview-bottom-bar {
    height: 6px;
    background: var(--ten-purple);
}

.preview-type-banner {
    padding: 12px 24px;
    font-weight: 700;
    font-size: 0.85rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.preview-type-banner.maintenance { background: var(--warning-bg); color: #e65100; }
.preview-type-banner.outage { background: var(--danger-bg); color: var(--danger); }
.preview-type-banner.resolved { background: var(--success-bg); color: var(--success); }
.preview-type-banner.security { background: var(--danger-bg); color: var(--danger); }
.preview-type-banner.new-system { background: var(--info-bg); color: var(--info); }
.preview-type-banner.policy { background: var(--ten-purple-lighter); color: var(--ten-purple); }
.preview-type-banner.welcome { background: var(--ten-purple-lighter); color: var(--ten-purple); }
.preview-type-banner.general { background: var(--info-bg); color: var(--info); }

.preview-body {
    padding: 28px 28px;
    font-size: 0.92rem;
    line-height: 1.7;
    color: #333;
}

.preview-footer {
    background: #faf8fb;
    padding: 20px 28px;
    text-align: center;
    font-size: 0.72rem;
    color: #999;
    line-height: 1.6;
}

/* ============================================
   CREATE TEMPLATE MODAL
   ============================================ */

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--white);
    border-radius: var(--radius);
    width: 560px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h2 {
    font-size: 1.15rem;
    color: var(--ten-purple);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px;
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 24px;
}

.modal-body .form-group {
    margin-bottom: 18px;
}

.modal-body .form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 6px;
}

.modal-body .form-group input,
.modal-body .form-group select,
.modal-body .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-family: inherit;
    color: var(--text);
    transition: var(--transition);
}

.modal-body .form-group input:focus,
.modal-body .form-group select:focus,
.modal-body .form-group textarea:focus {
    outline: none;
    border-color: var(--ten-purple);
    box-shadow: 0 0 0 3px rgba(70, 32, 85, 0.1);
}

.modal-body .form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.colour-picker-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.colour-swatch {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: var(--transition);
}

.colour-swatch:hover {
    transform: scale(1.15);
}

.colour-swatch.selected {
    border-color: var(--text);
    box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--text);
}

.edit-tpl-body-editor {
    width: 100%;
    min-height: 180px;
    max-height: 300px;
    overflow-y: auto;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-family: inherit;
    color: var(--text);
    line-height: 1.7;
    outline: none;
    transition: var(--transition);
}

.edit-tpl-body-editor:focus {
    border-color: var(--ten-purple);
    box-shadow: 0 0 0 3px rgba(70, 32, 85, 0.1);
}

.edit-tpl-body-editor .detail-box {
    background: #f8f6fa;
    border-left: 4px solid var(--ten-purple);
    padding: 10px 14px;
    margin: 10px 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.85rem;
}

.template-card .card-actions {
    margin-top: 8px;
    display: flex;
    gap: 6px;
    justify-content: center;
}

.template-card .card-edited-badge {
    display: inline-block;
    font-size: 0.65rem;
    background: var(--ten-gold-light);
    color: var(--ten-gold-dark);
    padding: 1px 8px;
    border-radius: 10px;
    margin-top: 4px;
    font-weight: 600;
}

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

/* ============================================
   AUTOCOMPLETE DROPDOWN
   ============================================ */

.autocomplete-wrap {
    position: relative;
}

.autocomplete-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 80px;
    right: 0;
    z-index: 100;
    background: var(--white);
    border: 1px solid var(--border);
    border-top: 2px solid var(--ten-purple);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 260px;
    overflow-y: auto;
}

.autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.1s ease;
}

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

.autocomplete-item:hover,
.autocomplete-item.active {
    background: var(--ten-purple-lighter);
}

.ac-main {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ac-name {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text);
}

.ac-email {
    font-size: 0.78rem;
    color: var(--text-light);
    margin-top: 1px;
}

.ac-tag {
    font-size: 0.62rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.ac-tag.ac-frequent {
    background: var(--ten-gold-light);
    color: var(--ten-gold-dark);
}

.ac-tag.ac-directory {
    background: var(--ten-purple-lighter);
    color: var(--ten-purple);
}

/* ============================================
   SENT HISTORY
   ============================================ */

.history-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.history-table th,
.history-table td {
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.88rem;
}

.history-table th {
    background: var(--ten-purple-lighter);
    font-weight: 600;
    color: var(--ten-purple);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-table tbody tr {
    transition: all 0.15s ease;
}

.history-table tbody tr:hover td {
    background: #f5f0fa;
}

.history-table tbody tr:hover td:first-child {
    box-shadow: inset 3px 0 0 var(--ten-gold);
}

.history-table .status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge.sent {
    background: var(--success-bg);
    color: var(--success);
}

.status-badge.draft {
    background: var(--warning-bg);
    color: var(--warning);
}

.status-badge.failed {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ============================================
   ACTIVE INCIDENTS
   ============================================ */

.incident-stat-card {
    flex: 1;
    background: var(--white);
    border-radius: var(--radius);
    padding: 18px 24px;
    box-shadow: var(--shadow);
    text-align: center;
    border-top: 3px solid var(--border);
}

.incident-stat-card.incident-stat-active {
    border-top-color: var(--danger);
}

.incident-stat-card.incident-stat-resolved {
    border-top-color: var(--success);
}

.incident-stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--ten-purple);
    line-height: 1;
}

.incident-stat-label {
    font-size: 0.78rem;
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.incident-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.incident-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border-left: 4px solid var(--danger);
    transition: var(--transition);
}

.incident-card.resolved {
    border-left-color: var(--success);
    opacity: 0.85;
}

.incident-card.investigating {
    border-left-color: #ff8c00;
}

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

.incident-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #faf8fb;
    border-bottom: 1px solid var(--border-light);
}

.incident-card-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.incident-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.incident-status-dot.active {
    background: var(--danger);
    box-shadow: 0 0 6px rgba(209, 52, 56, 0.5);
    animation: pulse-dot 1.5s infinite;
}

.incident-status-dot.investigating {
    background: #ff8c00;
    box-shadow: 0 0 6px rgba(255, 140, 0, 0.5);
    animation: pulse-dot 1.5s infinite;
}

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

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

.incident-status-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.incident-status-badge.active {
    background: var(--danger-bg);
    color: var(--danger);
}

.incident-status-badge.investigating {
    background: var(--warning-bg);
    color: #e65100;
}

.incident-status-badge.resolved {
    background: var(--success-bg);
    color: var(--success);
}

.incident-card-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 24px;
    padding: 14px 20px;
    font-size: 0.82rem;
}

.incident-meta-item {
    color: var(--text-light);
}

.incident-meta-label {
    font-weight: 600;
    color: var(--text);
}

.incident-card-timer-row {
    padding: 0 20px 14px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.incident-timer {
    background: linear-gradient(135deg, #462055, #5a2d6a);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    min-width: 160px;
}

.incident-timer.resolved {
    background: linear-gradient(135deg, #0a6b2a, #107c10);
}

.incident-timer.overdue {
    background: linear-gradient(135deg, #b91c1c, #d13438);
    animation: timer-pulse 1s infinite;
}

@keyframes timer-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(209, 52, 56, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(209, 52, 56, 0); }
}

.incident-timer-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8;
    margin-bottom: 2px;
}

.incident-timer-value {
    font-size: 1.3rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
}

.incident-countdown {
    background: linear-gradient(135deg, #c8a84e, #a68b3a);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    min-width: 160px;
}

.incident-countdown.urgent {
    background: linear-gradient(135deg, #e67e00, #ff8c00);
}

.incident-countdown.overdue {
    background: linear-gradient(135deg, #b91c1c, #d13438);
    animation: timer-pulse 1s infinite;
}

.incident-countdown-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8;
    margin-bottom: 2px;
}

.incident-countdown-value {
    font-size: 1.3rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
}

.incident-timer-warning {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--danger);
    background: var(--danger-bg);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.incident-card-timeline {
    padding: 0 20px 14px;
}

.incident-timeline-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.incident-timeline-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 0.78rem;
    color: var(--text-light);
    border-left: 2px solid var(--border);
    margin-left: 4px;
    padding-left: 12px;
}

.incident-timeline-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ten-purple);
    flex-shrink: 0;
}

.incident-timeline-time {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    min-width: 90px;
}

.incident-timeline-tag {
    font-size: 0.68rem;
    font-weight: 700;
    background: var(--ten-purple-lighter);
    color: var(--ten-purple);
    padding: 1px 8px;
    border-radius: 8px;
    white-space: nowrap;
}

.incident-timeline-subject {
    color: var(--text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.incident-severity-badge {
    display: inline-block;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 10px;
    letter-spacing: 0.5px;
}

.incident-severity-select {
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-family: inherit;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    background: var(--white);
}

.incident-severity-select:focus {
    outline: none;
    border-color: var(--ten-purple);
}

.incident-card-actions {
    padding: 12px 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 8px;
    background: #faf8fb;
}

/* ============================================
   NOTIFICATIONS / TOASTS
   ============================================ */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.88rem;
    min-width: 300px;
    animation: slideIn 0.3s ease;
    border-left: 4px solid var(--ten-purple);
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

.toast-icon { font-size: 1.2rem; }
.toast-message { flex: 1; }
.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-light);
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* ============================================
   SIGN-IN SCREEN
   ============================================ */

.signin-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(200, 168, 78, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(200, 168, 78, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(90, 45, 106, 0.3) 0%, transparent 70%),
        linear-gradient(135deg, #1a0a20 0%, #2a1433 30%, #462055 60%, #2a1433 100%);
    position: relative;
    overflow: hidden;
}

.signin-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('../Images/HeaderGold.jpg') center/cover no-repeat;
    opacity: 0.08;
    animation: subtlePulse 8s ease-in-out infinite;
}

@keyframes subtlePulse {
    0%, 100% { opacity: 0.08; }
    50% { opacity: 0.12; }
}

.signin-screen::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        linear-gradient(45deg, transparent 45%, rgba(200, 168, 78, 0.03) 50%, transparent 55%),
        linear-gradient(-45deg, transparent 45%, rgba(200, 168, 78, 0.03) 50%, transparent 55%);
    background-size: 60px 60px;
    animation: shimmer 20s linear infinite;
}

@keyframes shimmer {
    0% { background-position: 0 0, 0 0; }
    100% { background-position: 600px 600px, -600px 600px; }
}

.signin-card {
    background: linear-gradient(145deg, rgba(30, 20, 37, 0.95), rgba(20, 12, 25, 0.98));
    border-radius: 20px;
    padding: 60px 50px;
    text-align: center;
    box-shadow: 
        0 25px 80px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(200, 168, 78, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    max-width: 480px;
    width: 100%;
    position: relative;
    z-index: 1;
    border-top: 4px solid var(--ten-gold);
    backdrop-filter: blur(20px);
}

.signin-card::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 4px;
    background: linear-gradient(90deg, transparent, var(--ten-gold), transparent);
}

.signin-card img {
    height: 60px;
    margin-bottom: 20px;
    filter: brightness(0) invert(1);
}

.signin-card h1 {
    font-size: 1.8rem;
    color: #ffffff;
    margin-bottom: 8px;
    font-weight: 300;
    letter-spacing: 1px;
}

.signin-card h1 span {
    color: var(--ten-gold);
    font-weight: 600;
}

.signin-card p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.95rem;
    margin-bottom: 36px;
    line-height: 1.7;
}

.signin-card .btn {
    width: 100%;
    justify-content: center;
    padding: 18px 32px;
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--ten-gold), #a68b3a);
    border: none;
    color: #1a0a20;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(200, 168, 78, 0.3);
    transition: all 0.3s ease;
    text-transform: none;
    letter-spacing: 0.5px;
}

.signin-card .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(200, 168, 78, 0.4);
    background: linear-gradient(135deg, #d4b85e, var(--ten-gold));
}

.signin-card .btn:active {
    transform: translateY(0);
}

.signin-card .btn-secondary {
    background: transparent;
    border: 2px solid rgba(200, 168, 78, 0.4);
    color: var(--ten-gold);
    box-shadow: none;
}

.signin-card .btn-secondary:hover {
    background: rgba(200, 168, 78, 0.1);
    border-color: var(--ten-gold);
    box-shadow: 0 8px 30px rgba(200, 168, 78, 0.15);
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text);
}

.empty-state p {
    font-size: 0.88rem;
}

/* ============================================
   LOADING SPINNER
   ============================================ */

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--white);
    animation: spin 0.8s ease infinite;
}

.spinner.dark {
    border-color: rgba(70, 32, 85, 0.2);
    border-top-color: var(--ten-purple);
}

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

/* ============================================
   SETTINGS PAGE
   ============================================ */

.settings-section {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.settings-section h3 {
    font-size: 1rem;
    color: var(--ten-purple);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--ten-gold-light);
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.settings-row:last-child {
    border-bottom: none;
}

.settings-row .setting-label {
    font-weight: 600;
    font-size: 0.88rem;
}

.settings-row .setting-desc {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 2px;
}

.settings-row .setting-value {
    font-size: 0.88rem;
    color: var(--text-light);
}

/* ============================================
   MOBILE NAVIGATION
   ============================================ */

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    color: var(--text);
    border-radius: var(--radius-sm);
}

.mobile-menu-btn:hover {
    background: var(--ten-purple-lighter);
}

.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-nav-overlay.active {
    display: block;
    opacity: 1;
}

.mobile-nav {
    display: none;
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    background: linear-gradient(180deg, var(--ten-purple), var(--ten-purple-dark));
    z-index: 101;
    flex-direction: column;
    transition: left 0.3s ease;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
}

.mobile-nav.active {
    left: 0;
}

.mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-nav-header img {
    height: 32px;
    filter: brightness(0) invert(1);
}

.mobile-nav-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    padding: 4px 10px;
    opacity: 0.7;
}

.mobile-nav-close:hover {
    opacity: 1;
}

.mobile-nav-list {
    list-style: none;
    padding: 16px 0;
    flex: 1;
    overflow-y: auto;
}

.mobile-nav-list li {
    padding: 14px 24px;
    color: white;
    font-size: 0.95rem;
    cursor: pointer;
    opacity: 0.8;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.mobile-nav-list li:hover {
    background: rgba(255, 255, 255, 0.1);
    opacity: 1;
}

.mobile-nav-list li.active {
    background: rgba(255, 255, 255, 0.15);
    opacity: 1;
    border-left-color: var(--ten-gold);
}

.mobile-nav-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .mobile-nav {
    background: linear-gradient(180deg, rgba(26, 18, 32, 0.98), rgba(15, 10, 18, 0.99));
}

[data-theme="dark"] .mobile-menu-btn {
    color: var(--text);
}

[data-theme="dark"] .mobile-menu-btn:hover {
    background: rgba(200, 168, 78, 0.1);
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* Tablet */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 220px;
    }
    
    .templates-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
    
    .editor-layout {
        flex-direction: column;
    }
    
    .editor-fields, .editor-preview {
        width: 100%;
        max-width: none;
    }
    
    .editor-preview {
        max-height: 500px;
        overflow-y: auto;
    }
}

/* Mobile */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
        --topbar-height: 56px;
    }
    
    body {
        overflow: auto;
        height: auto;
    }
    
    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }
    
    /* Hide sidebar on mobile */
    .sidebar {
        display: none;
    }
    
    /* Show mobile nav elements */
    .mobile-menu-btn {
        display: block;
    }
    
    .mobile-nav {
        display: flex;
    }
    
    .topbar-signout {
        display: none !important;
    }
    
    /* Mobile navigation in topbar */
    .topbar {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 16px;
        gap: 12px;
    }
    
    .topbar h1 {
        font-size: 1.1rem;
        flex: 1;
    }
    
    .topbar-actions {
        order: 3;
        width: 100%;
        justify-content: space-between;
        padding-top: 12px;
        border-top: 1px solid var(--border-light);
    }
    
    /* Content area */
    .content-area {
        padding: 16px;
        margin-left: 0;
    }
    
    /* Templates grid */
    .templates-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .template-card {
        padding: 16px 12px;
    }
    
    .template-card .template-icon {
        font-size: 1.8rem;
    }
    
    .template-card h3 {
        font-size: 0.85rem;
    }
    
    .template-card p {
        font-size: 0.7rem;
    }
    
    /* Editor */
    .editor-container {
        padding: 16px;
    }
    
    .editor-layout {
        flex-direction: column;
        gap: 20px;
    }
    
    .editor-fields, .editor-preview {
        width: 100%;
        padding: 16px;
    }
    
    .editor-fields .form-group label {
        font-size: 0.8rem;
    }
    
    .editor-fields input,
    .editor-fields select,
    .editor-fields textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
    }
    
    .editor-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .editor-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* History table */
    .history-table {
        display: block;
        overflow-x: auto;
        font-size: 0.8rem;
    }
    
    .history-table th,
    .history-table td {
        padding: 10px 8px;
        white-space: nowrap;
    }
    
    /* Incident cards */
    .incident-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .incident-card-actions {
        flex-wrap: wrap;
    }
    
    .incident-card-actions .btn {
        flex: 1;
        min-width: 120px;
        justify-content: center;
    }
    
    /* Stats grid */
    .incident-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    /* Modal */
    .modal {
        width: 95%;
        max-width: none;
        margin: 10px;
        max-height: 90vh;
    }
    
    .modal-body {
        padding: 16px;
    }
    
    .modal-footer {
        flex-direction: column;
        gap: 10px;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
    
    /* Sign-in card */
    .signin-card {
        margin: 20px;
        padding: 40px 24px;
    }
    
    .signin-card h1 {
        font-size: 1.4rem;
    }
    
    /* Reports */
    .reports-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-container {
        height: 250px;
    }
    
    /* Buttons */
    .btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }
    
    .btn-lg {
        padding: 14px 20px;
    }
    
    /* Toast notifications */
    .toast-container {
        left: 10px;
        right: 10px;
        top: auto;
        bottom: 20px;
    }
    
    .toast {
        min-width: auto;
        width: 100%;
    }
}

/* ============================================
   INLINE IMAGE RESIZE (editor)
   ============================================ */

.img-resize-wrapper {
    display: table;
    position: relative;
    line-height: 0;
    margin: 8px 0;
    max-width: 100%;
}

.img-resize-wrapper img {
    display: block;
    outline: 2px solid var(--ten-gold);
    outline-offset: 1px;
    border-radius: 4px;
    cursor: default;
    user-select: none;
}

.img-resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--ten-gold);
    border: 2px solid #fff;
    border-radius: 2px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.35);
    z-index: 10;
}
.img-resize-handle.nw { top: -5px;  left: -5px;  cursor: nw-resize; }
.img-resize-handle.ne { top: -5px;  right: -5px; cursor: ne-resize; }
.img-resize-handle.sw { bottom: -5px; left: -5px;  cursor: sw-resize; }
.img-resize-handle.se { bottom: -5px; right: -5px; cursor: se-resize; }

.img-resize-toolbar {
    position: absolute;
    top: -34px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    background: #2d0e40;
    border: 1px solid var(--ten-gold);
    border-radius: 6px;
    padding: 3px 6px;
    white-space: nowrap;
    z-index: 20;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.img-resize-toolbar button {
    background: transparent;
    border: none;
    color: #e0d0f0;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    cursor: pointer;
    letter-spacing: 0.3px;
    transition: background 0.15s;
}
.img-resize-toolbar button:hover { background: rgba(200,168,78,0.25); color: var(--ten-gold); }
.img-resize-toolbar .img-tb-del { color: #f87171; }
.img-resize-toolbar .img-tb-del:hover { background: rgba(248,113,113,0.15); }

/* Small mobile */
@media (max-width: 480px) {
    .templates-grid {
        grid-template-columns: 1fr;
    }
    
    .incident-stats {
        grid-template-columns: 1fr;
    }
    
    .topbar h1 {
        font-size: 1rem;
    }
    
    .signin-card {
        padding: 32px 20px;
    }
    
    .signin-card img {
        height: 48px;
    }
    
    .signin-card h1 {
        font-size: 1.2rem;
    }
    
    .signin-card p {
        font-size: 0.85rem;
    }
}
