:root {
    --primary-color: #22c55e;
    --primary-hover: #16a34a;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --error-color: #ef4444;
    --success-color: #22c55e;
    --sidebar-width: 260px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-md: 12px;
    --radius-lg: 16px;
    --mention-bg: #312e81;
    --mention-text: #e0e7ff;
}

.dark-mode {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);
    --mention-bg: #3730a3;
    --mention-text: #e0e7ff;
}

.dark-mode body {
    background-color: var(--bg-color);
    color: var(--text-main);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Login Page Styles */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-icon {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 16px;
    background: #f0fdf4;
    width: 64px;
    height: 64px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 8px;
}

.input-wrapper {
    position: relative;
}

.input-wrapper i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.input-wrapper input {
    width: 100%;
    padding: 12px 14px 12px 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all 0.2s;
    outline: none;
}

.input-wrapper input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-size: 1rem;
    gap: 8px;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-block {
    width: 100%;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-error {
    background-color: #fef2f2;
    color: var(--error-color);
    border: 1px solid #fee2e2;
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Layout Styles */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.logo-text {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-main);
}

.sidebar-menu {
    flex: 1;
    padding: 16px;
}

.menu-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 12px;
    margin-top: 24px;
    letter-spacing: 0.05em;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-muted);
    border-radius: var(--radius-md);
    transition: all 0.2s;
    font-weight: 500;
    margin-bottom: 4px;
}

.menu-item:hover {
    background-color: #f1f5f9;
    color: var(--text-main);
}

.menu-item.active {
    background-color: #f0fdf4;
    color: var(--primary-color);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: #e2e8f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--text-main);
}

.user-details {
    flex: 1;
    overflow: hidden;
}

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

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px;
}

.page-header {
    margin-bottom: 32px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.page-title h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-title p {
    color: var(--text-muted);
    margin-top: 4px;
}

/* Container Styles */
.container-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    transition: box-shadow 0.2s;
}

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

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-title {
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-info h3 {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-info span {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Orders Table / Screenshot Style */
.orders-page {
    background-color: var(--bg-color);
    color: var(--text-main);
    padding: 0;
    border-radius: var(--radius-lg);
    min-height: auto;
}

.orders-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.orders-header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 25px;
    border-radius: 12px 12px 0 0;
    display: grid;
    grid-template-columns: 2fr 0.5fr 1fr 1fr 1.5fr 1.5fr 1.2fr;
    gap: 15px;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    align-items: center;
}

.orders-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.order-row {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 18px 25px;
    display: grid;
    grid-template-columns: 2fr 0.5fr 1fr 1fr 1.5fr 1.5fr 1.2fr;
    gap: 15px;
    align-items: center;
    transition: transform 0.2s, background-color 0.2s;
    box-shadow: var(--shadow-sm);
}

.order-row:hover {
    background-color: #ffffff;
    transform: scale(1.005);
    box-shadow: var(--shadow-md);
}

.order-title {
    font-weight: 600;
    font-size: 1rem;
}

/* Status Badges */
.status-badge {
    padding: 6px 16px;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    display: inline-flex;
    justify-content: center;
    width: fit-content;
    min-width: 100px;
}

.status-offen   { background-color: #f59e0b; color: white; }
.status-arbeit  { background-color: #3b82f6; color: white; }
.status-erledigt{ background-color: #22c55e; color: white; }
/* Numeric status codes */
.status-100  { background-color: #94a3b8; color: white; }
.status-200  { background-color: #60a5fa; color: white; }
.status-300  { background-color: #818cf8; color: white; }
.status-400  { background-color: #22c55e; color: white; }
.status-500  { background-color: #f59e0b; color: white; }
.status-600  { background-color: #10b981; color: white; }
.status-1000 { background-color: #6366f1; color: white; }
.status-1100 { background-color: #ef4444; color: white; }

/* Priority Badges */
.prio-badge {
    padding: 6px 16px;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    display: inline-flex;
    justify-content: center;
    width: fit-content;
    min-width: 100px;
}

.prio-niedrig { background-color: #4b5563; color: white; }
.prio-normal { background-color: #06b6d4; color: white; }
.prio-hoch { background-color: #ef4444; color: white; }

.user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
}

.user-cell i {
    color: var(--primary-color);
}

.deadline-cell {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--card-bg);
    color: var(--text-main);
    padding: 30px;
    border-radius: 20px;
    width: 100%;
    max-width: 600px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

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

.close-modal {
    background: none;
    border: none;
    color: #64748b;
    font-size: 1.5rem;
    cursor: pointer;
}

.order-form .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.order-form .form-group-full {
    grid-column: span 2;
}

.order-form select, 
.order-form textarea, 
.order-form input {
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    margin-top: 5px;
}

.order-form textarea {
    height: 80px;
    resize: vertical;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-archive {
    background-color: #ffffff;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.btn-back {
    background-color: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

/* Order Details Specifics */
.order-details-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    align-items: start;
}

/* Logbook Premium Cards */
.logbook-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 24px;
    margin-top: 20px;
}

.logbook-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    position: relative;
}

.logbook-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.logbook-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.logbook-card-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    margin: 0;
}

.logbook-card-content {
    background: #f1f5f9;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.logbook-timeline {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    margin-bottom: 10px;
}

.logbook-timeline::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 40px;
    right: 40px;
    height: 2px;
    background: transparent;
    border-top: 2px dashed #94a3b8;
    z-index: 1;
}

.logbook-timeline-car {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: #f1f5f9;
    padding: 0 10px;
    color: #94a3b8;
    z-index: 2;
    font-size: 0.9rem;
}

.logbook-point {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 3;
    background: #f1f5f9;
    padding: 0 5px;
}

.logbook-point .label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
}

.logbook-point .dot {
    width: 12px;
    height: 12px;
    background: #94a3b8;
    border-radius: 50%;
}

.logbook-point .time {
    font-size: 0.85rem;
    font-weight: 700;
    color: #64748b;
}

.logbook-distance {
    font-size: 1.5rem;
    font-weight: 800;
    color: #64748b;
    margin-top: 5px;
}

/* Premium Buttons */
.btn-primary-premium {
    background: linear-gradient(135deg, var(--primary-color) 0%, #16a34a 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.3);
    text-decoration: none;
}

.btn-primary-premium:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(34, 197, 94, 0.4);
    filter: brightness(1.1);
}

.btn-primary-premium:active {
    transform: translateY(-1px);
}

.details-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.detail-section-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.detail-section-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: #f8fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    color: var(--text-main);
}

.detail-section-header i {
    margin-right: 8px;
    color: var(--primary-color);
}

.detail-section-content {
    padding: 20px;
}

/* Sidebar Actions */
.sidebar-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    position: sticky;
    top: 24px;
}

.sidebar-title-btn {
    width: 100%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 12px;
    font-weight: 800;
    margin-bottom: 20px;
    font-size: 1.1rem;
    cursor: default;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.action-buttons-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.action-btn-outline {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    background: transparent;
    font-weight: 600;
    transition: all 0.2s;
    text-align: left;
    cursor: pointer;
}

.action-btn-outline i {
    font-size: 1.1rem;
}

/* Action Button Colors (Light Mode Adaptions) */
.btn-finish { border: 1px solid #22c55e; color: #16a34a; }
.btn-finish:hover { background: #f0fdf4; }

.btn-status { border: 1px solid #f59e0b; color: #d97706; }
.btn-status:hover { background: #fffbeb; }

.btn-edit { border: 1px solid #3b82f6; color: #2563eb; }
.btn-edit:hover { background: #eff6ff; }

.btn-prio { border: 1px solid #64748b; color: #475569; }
.btn-prio:hover { background: #f8fafc; }

.btn-deadline { border: 1px solid #a855f7; color: #9333ea; }
.btn-deadline:hover { background: #faf5ff; }

.btn-assign { border: 1px solid #ec4899; color: #db2777; }
.btn-assign:hover { background: #fdf2f8; }

.btn-move { border: 1px solid #6366f1; color: #4f46e5; }
.btn-move:hover { background: #eef2ff; }

.btn-delete { border: 1px solid #ef4444; color: #dc2626; }
.btn-delete:hover { background: #fef2f2; }

/* Redesigned Comments */
.comment-feed {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.comment-item {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.comment-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--primary-color);
    flex-shrink: 0;
    border: 2px solid var(--border-color);
    overflow: hidden;
}

.comment-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.comment-content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.comment-author {
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.95rem;
}

.comment-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.comment-text {
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.5;
    margin-bottom: 0;
}

/* @Mentions highlighting */
.mention {
    background-color: var(--mention-bg);
    color: var(--mention-text);
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9em;
    display: inline-block;
}

/* Order Log optimization */
.log-list {
    max-height: 250px;
    overflow-y: auto;
    padding-right: 8px;
}

.log-list::-webkit-scrollbar {
    width: 6px;
}

.log-list::-webkit-scrollbar-track {
    background: transparent;
}

.log-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

/* Info Grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.info-item label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.info-item span {
    font-weight: 600;
    color: var(--text-main);
}

/* Responsive Layout & Mobile Optimization */
.mobile-header {
    display: none;
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 20px;
    align-items: center;
    justify-content: space-between;
}

.mobile-header h2 {
    font-size: 1.1rem;
    font-weight: 800;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-main);
    cursor: pointer;
    padding: 5px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
    z-index: 90;
}

.hide-on-pc {
    display: none;
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        visibility: hidden;
        pointer-events: none;
        transition: transform 0.3s ease, visibility 0.3s;
        box-shadow: 10px 0 30px rgba(0,0,0,0.1);
        z-index: 1001;
    }

    .sidebar.open {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
    }

    .sidebar.open + .sidebar-overlay {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 15px;
        overflow-x: hidden;
        max-width: 100vw;
        box-sizing: border-box;
    }

    .mobile-header {
        display: flex;
    }
    
    .hide-on-pc {
        display: block;
    }

    .order-details-grid {
        grid-template-columns: 1fr;
    }
    
    .sidebar-panel {
        position: static;
    }

    .container-grid {
        grid-template-columns: 1fr;
    }

    .order-row {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        align-items: center;
    }
    
    .order-row > div:nth-child(1) { width: 100%; } /* Title full width */
    .order-row > div:nth-child(2) { font-size: 0.9rem; margin-right: auto; } /* ID */

    .orders-header {
        display: none;
    }

    .order-row > *:nth-child(n+5) {
        display: none;
    }

    /* Fix: Containers being too wide or overflowing */
    .orders-top-bar {
        flex-direction: column;
        gap: 15px;
        align-items: stretch !important;
    }

    .orders-top-bar > div {
        flex-direction: column;
        width: 100%;
    }

    .orders-top-bar button, .orders-top-bar a {
        width: 100%;
        justify-content: center;
    }

    .field-service-container {
        padding: 0 !important; /* Remove extra internal padding on mobile to match dashboard */
        max-width: 100% !important;
    }

    .modal-content {
        width: 95%;
        padding: 20px;
        margin: 10px;
    }

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

    /* --- Mobile: Order Details --- */
    .order-details-grid {
        overflow-x: hidden;
    }

    .detail-section-card,
    .sidebar-panel,
    .card {
        max-width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }

    /* --- Mobile: Calendar --- */
    .calendar-component {
        max-width: 100%;
        overflow: hidden;
    }

    .calendar-body {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .calendar-grid {
        min-width: 600px;
    }

    .calendar-component .day {
        min-height: 80px !important;
        padding: 4px !important;
    }

    .calendar-component .day-name {
        font-size: 0.8rem !important;
        padding: 4px 2px !important;
    }

    /* --- Mobile: Notes (Sidebar → Popup) --- */
    .notes-container {
        display: block;
        height: auto;
    }

    .notes-sidebar {
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 0;
    }

    .notes-editor {
        display: none !important;
    }

    /* --- Mobile: Logbook Grid --- */
    .logbook-grid {
        grid-template-columns: 1fr;
    }

    /* --- Mobile: Mail Layout --- */
    .mail-grid {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        gap: 0 !important;
    }

    .mail-sidebar-list-container {
        height: auto !important;
        flex-direction: column !important;
    }

    .mail-nav-sidebar {
        display: none !important; /* Hidden – replaced by mobile icon bar */
    }

    .mail-content-container {
        display: none !important; /* Hidden – replaced by popup */
    }

    .mail-mobile-nav {
        display: flex !important;
    }

    .mail-list-view {
        min-height: 400px;
    }
}

/* ===== Mobile Mail: Icon Nav Bar ===== */
.mail-mobile-nav {
    display: none; /* shown only on mobile via media query */
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 10px 15px;
    margin-bottom: 16px;
    gap: 8px;
    justify-content: space-around;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.mail-mobile-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 16px;
    border-radius: 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    flex: 1;
    justify-content: center;
}

.mail-mobile-nav-btn span {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mail-mobile-nav-btn:hover,
.mail-mobile-nav-btn.active {
    background: #f0fdf4;
    color: var(--primary-color);
}

/* ===== Mobile Mail: Read Popup ===== */
#mail-read-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    z-index: 10000;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

#mail-read-modal .mail-modal-card {
    background: var(--card-bg);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUpModal 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUpModal {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

#mail-read-modal .mail-modal-header {
    padding: 20px 20px 15px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

#mail-read-modal .mail-modal-header h3 {
    flex: 1;
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mail-modal-meta-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

.mail-modal-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
}

.mail-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.mail-modal-actions {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
}


/* Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: ";
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
}

input:checked + .slider {
  background-color: var(--primary-color);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--primary-color);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Mention Popup */
.mention-list-popup {
  position: absolute;
  bottom: 100%;
  left: 0;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  width: 200px;
  max-height: 200px;
  overflow-y: auto;
  display: none;
  z-index: 100;
}

.mention-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
}

.mention-item:hover {
  background: #f1f5f9;
  color: var(--primary-color);
}

/* --- Toast Notification System --- */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    width: 100%;
    max-width: 450px;
    padding: 0 20px;
}

.toast {
    background: var(--card-bg);
    color: var(--text-main);
    padding: 16px 20px;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    display: flex;
    align-items: center;
    gap: 15px;
    pointer-events: auto;
    animation: toastSlideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1), toastFadeOut 0.3s forwards;
    animation-delay: 0s, 3.7s;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.toast::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: currentColor;
    opacity: 0.3;
    animation: toastProgress 3.7s linear forwards;
}

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

@keyframes toastFadeOut {
    to { opacity: 0; transform: translateY(-20px); scale: 0.95; }
}

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

.toast-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.toast-success { border-left: 4px solid #22c55e; color: #166534; }
.toast-success .toast-icon { background: #dcfce7; color: #166534; }

.toast-error { border-left: 4px solid #ef4444; color: #991b1b; }
.toast-error .toast-icon { background: #fee2e2; color: #991b1b; }

.toast-info { border-left: 4px solid #3b82f6; color: #1e40af; }
.toast-info .toast-icon { background: #dbeafe; color: #1e40af; }

.toast-warning { border-left: 4px solid #f59e0b; color: #92400e; }
.toast-warning .toast-icon { background: #fef3c7; color: #92400e; }

.toast-message {
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.4;
}

/* --- Custom Confirm Modal --- */
#custom-confirm-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    z-index: 10001;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.confirm-card {
    background: var(--card-bg);
    border-radius: 24px;
    width: 100%;
    max-width: 400px;
    padding: 32px;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    border: 1px solid var(--border-color);
    text-align: center;
    animation: modalScaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalScaleUp {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.confirm-icon {
    width: 64px;
    height: 64px;
    background: #fffbeb;
    color: #f59e0b;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin: 0 auto 24px;
}

.confirm-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 12px;
}

.confirm-text {
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 32px;
}

.confirm-actions {
    display: flex;
    gap: 12px;
}

.confirm-actions button {
    flex: 1;
    padding: 14px;
    border-radius: 14px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-confirm-no {
    background: #f1f5f9;
    color: #64748b;
}

.btn-confirm-no:hover {
    background: #e2e8f0;
    color: #475569;
}

.btn-confirm-yes {
    background: var(--primary-color);
    color: white;
}

.btn-confirm-yes:hover {
    background: var(--primary-hover);
    box-shadow: 0 8px 15px -3px rgba(34, 197, 94, 0.3);
}

.btn-confirm-danger {
    background: #ef4444;
    color: white;
}

.btn-confirm-danger:hover {
    background: #dc2626;
    box-shadow: 0 8px 15px -3px rgba(239, 68, 68, 0.3);
}

