:root {
    --accent: #0078D4;
    --accent-strong: #0F6CBD;
    --bg: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f5f5f5;
    --muted: #69797E;
    --text: #1b1b1f;
    --text-secondary: #605e5c;
    --border: #e1e5e9;
    --border-light: #f3f2f1;
    --radius: 12px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-light: 0 1px 3px rgba(0, 0, 0, 0.08);
    --transition: all 0.2s ease;
}

body[data-theme="dark"] {
    --accent: #4CC2FF;
    --accent-strong: #0F6CBD;
    --bg: #1f1f23;
    --bg-secondary: #2d2d30;
    --bg-tertiary: #3c3c3c;
    --muted: #9ca3af;
    --text: #ffffff;
    --text-secondary: #d1d5db;
    --border: #404040;
    --border-light: #4a4a4a;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
}

/* Global Top Bar */
.global-bar {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    height: 48px;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.global-bar-content {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 16px;
    max-width: 100%;
}

.global-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.app-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.app-title i {
    color: var(--accent);
    font-size: 16px;
}

.app-context {
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
}

.global-bar-center {
    flex: 1;
    max-width: 600px;
    margin: 0 24px;
}

.search-container {
    position: relative;
    width: 100%;
}

.search-container i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
}

.search-input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    transition: var(--transition);
}

.search-input:focus {
    outline: 2px solid var(--accent);
    border-color: var(--accent);
}

.global-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.global-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    border-radius: 6px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.global-action-btn:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

.user-avatar img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

/* Command Bar */
.command-bar {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px;
}

.command-bar-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.command-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.command-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.command-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--accent);
}

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

.command-btn.primary:hover {
    background: var(--accent-strong);
}

.command-btn.overflow {
    min-width: 32px;
    justify-content: center;
}

/* Main Container */
.main-container {
    display: flex;
    min-height: calc(100vh - 96px);
}

/* Navigation Rail */
.nav-rail {
    width: 64px;
    background: var(--bg);
    border-right: 1px solid var(--border);
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.nav-rail:hover {
    width: 200px;
}

.nav-items {
    padding: 8px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
    position: relative;
}

.nav-item:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

.nav-item.active {
    background: var(--bg-secondary);
    color: var(--accent);
    border-right: 2px solid var(--accent);
}

.nav-item i {
    width: 20px;
    font-size: 16px;
    flex-shrink: 0;
}

.nav-item span {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nav-rail:hover .nav-item span {
    opacity: 1;
}

/* Tooltips */
.nav-item::before {
    content: attr(data-tooltip);
    position: absolute;
    left: 72px;
    background: var(--text);
    color: var(--bg);
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 1000;
}

.nav-rail:not(:hover) .nav-item:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 24px;
    overflow: auto;
}

/* Record Header */
.record-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.record-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.record-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.monogram {
    color: white;
    font-weight: 600;
    font-size: 16px;
}

.record-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
}

.record-subtitle {
    color: var(--text-secondary);
    font-size: 12px;
}

.record-kpis {
    display: flex;
    gap: 16px;
}

.kpi-chip {
    background: var(--bg-secondary);
    padding: 8px 12px;
    border-radius: 6px;
    text-align: center;
    min-width: 80px;
}

.kpi-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-top: 2px;
}

/* Tabs */
.tabs-container {
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.tabs {
    display: flex;
    gap: 24px;
}

.tab {
    padding: 12px 0;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--accent);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
}

/* Content Grid */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 320px;
    gap: 24px;
    align-items: start;
}

.content-section {
    min-width: 0;
}

/* Cards */
.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-light);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}

.card-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.card-body {
    padding: 20px;
}

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

.form-label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    transition: var(--transition);
}

.form-control:focus {
    outline: 2px solid var(--accent);
    border-color: var(--accent);
}

.form-control:read-only {
    background: var(--bg-tertiary);
}

/* Timeline Section */
.timeline-section {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-light);
    padding: 0;
}

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

.timeline-search {
    flex: 1;
    position: relative;
    max-width: 300px;
}

.timeline-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
}

.timeline-search input {
    width: 100%;
    padding: 6px 12px 6px 36px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    font-size: 12px;
}

.timeline-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg-secondary);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--accent);
    color: white;
}

.note-input {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}

.note-input textarea {
    width: 100%;
    min-height: 60px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    font-size: 12px;
    resize: vertical;
    font-family: inherit;
}

.note-actions {
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
}

.btn-primary {
    padding: 6px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

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

/* Timeline List */
.timeline-list {
    padding: 8px 0;
    max-height: 400px;
    overflow-y: auto;
}

.timeline-item {
    display: flex;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-light);
    transition: var(--transition);
}

.timeline-item:hover {
    background: var(--bg-secondary);
}

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

.timeline-icon {
    width: 32px;
    height: 32px;
    background: var(--bg-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: 12px;
    flex-shrink: 0;
}

.timeline-content {
    flex: 1;
    min-width: 0;
}

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

.timeline-title {
    font-weight: 500;
    color: var(--text);
    font-size: 12px;
}

.timeline-time {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.timeline-body {
    color: var(--text-secondary);
    font-size: 11px;
    margin-bottom: 4px;
    line-height: 1.4;
}

.timeline-footer {
    font-size: 11px;
    color: var(--muted);
}

/* Right Panel */
.right-panel {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-light);
    transition: all 0.3s ease;
    position: relative;
}

.right-panel.collapsed {
    width: 48px;
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    gap: 8px;
}

.panel-title {
    flex: 1;
    min-width: 0;
}

.panel-dropdown {
    border: none;
    background: none;
    color: var(--text);
    font-weight: 500;
    font-size: 12px;
    cursor: pointer;
    width: 100%;
}

.panel-filter {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.panel-toggle {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
    flex-shrink: 0;
}

.panel-toggle:hover {
    background: var(--bg-secondary);
}

.right-panel.collapsed .panel-toggle i {
    transform: rotate(180deg);
}

/* Queue List */
.queue-list {
    max-height: 400px;
    overflow-y: auto;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    transition: var(--transition);
}

.queue-item:hover {
    background: var(--bg-secondary);
}

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

.queue-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

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

.avatar-monogram {
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.queue-content {
    flex: 1;
    min-width: 0;
}

.queue-title {
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-subtitle {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-actions {
    flex-shrink: 0;
}

.queue-action {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
}

.queue-action:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

/* Footer */
.app-footer {
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding: 12px 24px;
    text-align: center;
}

.footer-content {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr 300px;
        gap: 16px;
    }
    
    .timeline-section {
        grid-row: span 2;
    }
}

@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }
    
    .nav-rail {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        overflow-x: auto;
        overflow-y: hidden;
    }
    
    .nav-items {
        display: flex;
        padding: 0;
    }
    
    .nav-item {
        flex-direction: column;
        padding: 12px;
        min-width: 64px;
        text-align: center;
    }
    
    .nav-item span {
        opacity: 1;
        font-size: 10px;
        margin-top: 4px;
    }
    
    .content-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .main-content {
        padding: 16px;
    }
    
    .global-bar-center {
        display: none;
    }
    
    .record-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .record-kpis {
        align-self: stretch;
        justify-content: space-between;
    }
    
    .command-bar-content {
        overflow-x: auto;
    }
    
    .right-panel {
        order: -1;
    }
}

@media (max-width: 480px) {
    .global-bar-content {
        padding: 0 12px;
    }
    
    .app-title span,
    .app-context {
        display: none;
    }
    
    .command-btn span {
        display: none;
    }
    
    .command-btn {
        min-width: 32px;
        padding: 6px;
        justify-content: center;
    }
    
    .main-content {
        padding: 12px;
    }
    
    .record-title {
        font-size: 18px;
    }
}

/* Dashboard Specific Styles */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.kpi-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow-light);
    transition: var(--transition);
}

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

.kpi-icon {
    width: 48px;
    height: 48px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 20px;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.kpi-label {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 4px;
}

.kpi-change {
    font-size: 12px;
    font-weight: 500;
}

.kpi-change.positive {
    color: #10b981;
}

.kpi-change.negative {
    color: #ef4444;
}

/* Chart Container */
.chart-container {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 32px;
    box-shadow: var(--shadow-light);
}

.chart-container h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    color: var(--text);
}

/* Table Styles */
.data-table {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-light);
}

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

.table-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--text);
}

.table-search {
    position: relative;
    max-width: 200px;
}

.table-search i {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 12px;
}

.table-search input {
    padding: 6px 8px 6px 24px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
    width: 100%;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 12px;
}

.table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody tr:hover {
    background: var(--bg-secondary);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Kanban Styles */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.kanban-column {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 16px;
    min-height: 500px;
}

.kanban-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
}

.kanban-title {
    font-weight: 600;
    color: var(--text);
}

.kanban-count {
    background: var(--muted);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.kanban-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.kanban-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-light);
}

.kanban-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.card-title {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    font-size: 14px;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.card-value {
    font-weight: 600;
    color: var(--accent);
    font-size: 14px;
    margin-bottom: 8px;
}

.card-progress {
    height: 4px;
    background: var(--border-light);
    border-radius: 2px;
    overflow: hidden;
}

.card-progress-bar {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s ease;
}

/* Settings Page */
.settings-section {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
    box-shadow: var(--shadow-light);
}

.settings-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
}

.settings-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--text);
}

.settings-body {
    padding: 24px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-info h4 {
    margin: 0 0 4px 0;
    font-size: 14px;
    color: var(--text);
}

.setting-info p {
    margin: 0;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 48px;
    height: 24px;
    background: var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.toggle-switch.active {
    background: var(--accent);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch.active::after {
    left: 26px;
}

/* Loading States */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-secondary);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top: 2px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 12px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus styles */
*:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}