:root {
    --bg: #050816;
    --surface: rgba(13, 23, 42, 0.86);
    --surface-border: rgba(148, 163, 184, 0.14);
    --surface-hover: rgba(59, 130, 246, 0.15);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --accent: #38bdf8;
    --accent-strong: #0ea5e9;
    --danger: #f87171;
    --success: #34d399;
    --warning: #facc15;
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --transition: all 0.18s ease;
}

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

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: radial-gradient(circle at top, rgba(8, 47, 73, 0.5), rgba(15, 23, 42, 0.9) 40%, #030712);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top Bar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    background: rgba(3, 7, 18, 0.92);
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
    backdrop-filter: blur(16px);
}

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

.brand-badge {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    background: linear-gradient(140deg, rgba(56, 189, 248, 0.45), rgba(14, 165, 233, 0.18));
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    letter-spacing: 0.16em;
}

.brand-text h1 {
    font-size: 20px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 600;
}

.brand-text p {
    font-size: 11px;
    color: var(--text-secondary);
    letter-spacing: 0.08em;
    margin-top: 4px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 24px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.75);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.status-pill .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-secondary);
}

.status-pill.online .dot {
    background: var(--success);
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5);
    animation: pulse 2.4s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.45); }
    70% { box-shadow: 0 0 0 10px rgba(52, 211, 153, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.dispatcher-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

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

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.18);
    transition: var(--transition);
    border-radius: 13px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--text-secondary);
    transition: var(--transition);
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.5), rgba(14, 165, 233, 0.5));
    border-color: rgba(56, 189, 248, 0.45);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
    background: var(--accent);
}

.toggle-switch input:disabled + .toggle-slider {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Tabs Nav */
.tabs-nav {
    background: rgba(3, 7, 18, 0.82);
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.tabs {
    display: flex;
    gap: 2px;
    padding: 0 28px;
    overflow-x: auto;
}

.tab-btn {
    padding: 14px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(59, 130, 246, 0.08);
}

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

.controls-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 28px;
    background: rgba(15, 23, 42, 0.45);
    border-top: 1px solid rgba(148, 163, 184, 0.08);
    flex-wrap: wrap;
}

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

.field-group-inline label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    white-space: nowrap;
}

.field-group-inline input {
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text-primary);
    transition: var(--transition);
    font-size: 13px;
    min-width: 180px;
}

.field-group-inline input:focus {
    outline: none;
    border-color: rgba(56, 189, 248, 0.45);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16);
}

/* Buttons */
.btn {
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(15, 23, 42, 0.65);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn:hover:not(:disabled) {
    border-color: rgba(56, 189, 248, 0.4);
    background: var(--surface-hover);
    color: var(--accent);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.92), rgba(14, 165, 233, 0.92));
    border-color: transparent;
    color: #041023;
    font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(14, 165, 233, 0.28);
}

.btn-small {
    padding: 6px 12px;
    font-size: 11px;
}

/* Main Content */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    padding: 24px 28px;
    overflow: hidden;
}

.zone-container {
    display: none;
}

.zone-container.active {
    display: block;
}

/* Channel Cards Grid */
.channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    padding: 4px;
}

.channel-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 2px solid var(--surface-border);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.channel-card:hover {
    border-color: rgba(56, 189, 248, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.channel-card.active {
    border-color: var(--accent);
    background: rgba(56, 189, 248, 0.08);
}

.channel-card.transmitting {
    border-color: var(--success);
    background: rgba(52, 211, 153, 0.12);
    animation: glow 1.5s ease-in-out infinite;
}

.channel-card.busy {
    border-color: var(--warning);
    background: rgba(250, 204, 21, 0.08);
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 20px rgba(52, 211, 153, 0.3); }
    50% { box-shadow: 0 0 30px rgba(52, 211, 153, 0.5); }
}

.channel-header {
    text-align: center;
}

.channel-name {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.channel-frequency {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.1em;
}

.channel-status {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    font-size: 11px;
}

.status-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.status-item .label {
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.status-item .value {
    color: var(--text-primary);
    font-weight: 600;
}

.channel-ptt {
    width: 100%;
    padding: 14px;
    background: rgba(248, 113, 113, 0.18);
    border: 2px solid rgba(248, 113, 113, 0.35);
    border-radius: var(--radius-md);
    color: var(--danger);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: var(--transition);
}

.channel-ptt:hover:not(:disabled) {
    background: rgba(248, 113, 113, 0.28);
    border-color: rgba(248, 113, 113, 0.55);
    transform: scale(1.02);
}

.channel-ptt:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.channel-ptt.transmitting {
    background: rgba(34, 197, 94, 0.22);
    border-color: rgba(34, 197, 94, 0.45);
    color: var(--success);
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--surface-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(12px);
}

.card-header {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 600;
}

.peer-count-badge {
    background: rgba(56, 189, 248, 0.2);
    color: var(--accent);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.card-body {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.peers-list {
    max-height: 200px;
    overflow-y: auto;
}

.peer-card {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: var(--radius-sm);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: var(--transition);
}

.peer-card.speaking {
    border-color: rgba(250, 204, 21, 0.5);
    background: rgba(250, 204, 21, 0.12);
}

.peer-card.transmitting {
    border-color: rgba(52, 211, 153, 0.5);
    background: rgba(52, 211, 153, 0.12);
}

.peer-card .peer-name {
    font-size: 12px;
    letter-spacing: 0.06em;
    font-weight: 500;
}

.peer-card .peer-id {
    font-size: 10px;
    color: var(--text-secondary);
}

.empty-state {
    color: var(--text-secondary);
    font-size: 12px;
    text-align: center;
    padding: 30px 8px;
}

.log-body {
    max-height: 250px;
    overflow-y: auto;
    padding-right: 6px;
}

.log-entry {
    font-family: 'Source Code Pro', monospace;
    font-size: 11px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.log-entry.success {
    color: var(--success);
}

.log-entry.warning {
    color: var(--warning);
}

.log-entry.error {
    color: var(--danger);
}

/* Responsive */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .sidebar {
        max-height: 400px;
    }
}

@media (max-width: 768px) {
    .topbar {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .header-controls {
        width: 100%;
        justify-content: space-between;
    }

    .controls-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .field-group-inline {
        flex-direction: column;
        align-items: stretch;
    }

    .field-group-inline input {
        min-width: 100%;
    }

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

/* Admin Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(3, 7, 18, 0.95);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    font-size: 18px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 32px;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

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

.modal-body {
    padding: 24px;
}

.admin-section {
    margin-bottom: 32px;
}

.admin-section h3 {
    font-size: 14px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--accent);
}

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

.form-group label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    transition: var(--transition);
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: rgba(56, 189, 248, 0.45);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16);
}

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

.channel-item {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: var(--radius-sm);
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.channel-item-info {
    flex: 1;
}

.channel-item-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.channel-item-details {
    font-size: 11px;
    color: var(--text-secondary);
}

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

.btn-danger {
    background: rgba(248, 113, 113, 0.18);
    border-color: rgba(248, 113, 113, 0.35);
    color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
    background: rgba(248, 113, 113, 0.28);
    border-color: rgba(248, 113, 113, 0.55);
}

/* Enhanced Channel Cards */
.channel-main {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.channel-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.channel-title h3 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--accent);
}

.alpha-tag {
    font-size: 10px;
    background: rgba(56, 189, 248, 0.18);
    color: var(--accent);
    padding: 4px 8px;
    border-radius: 6px;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.channel-rssi {
    display: flex;
    align-items: center;
}

.rssi-indicator {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text-secondary);
    transition: var(--transition);
}

.rssi-indicator.online {
    background: var(--success);
    box-shadow: 0 0 12px rgba(52, 211, 153, 0.6);
}

.rssi-indicator.transmitting {
    background: var(--warning);
    box-shadow: 0 0 12px rgba(250, 204, 21, 0.6);
    animation: pulse-rssi 0.8s infinite;
}

.rssi-indicator.offline {
    background: rgba(148, 163, 184, 0.4);
}

@keyframes pulse-rssi {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

.channel-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 0;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.channel-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.channel-freq {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 0.06em;
}

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

.channel-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
}

.status-indicator.online {
    background: var(--success);
}

.status-indicator.transmitting {
    background: var(--warning);
    animation: pulse-rssi 0.8s infinite;
}

.status-indicator.offline {
    background: rgba(148, 163, 184, 0.4);
}

.status-text {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
}

.status-text.online {
    color: var(--success);
}

.status-text.transmitting {
    color: var(--warning);
}

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

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    padding: 0;
}

.btn-icon .material-icons {
    font-size: 20px;
}

.btn-icon:hover:not(.disabled) {
    background: var(--surface-hover);
    border-color: rgba(56, 189, 248, 0.4);
    color: var(--accent);
    transform: translateY(-2px);
}

.btn-icon.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.mon-btn:hover:not(.disabled) {
    border-color: rgba(56, 189, 248, 0.5);
}

.ptt-btn {
    background: rgba(248, 113, 113, 0.18);
    border-color: rgba(248, 113, 113, 0.35);
    color: var(--danger);
}

.ptt-btn:hover:not(.disabled) {
    background: rgba(248, 113, 113, 0.28);
    border-color: rgba(248, 113, 113, 0.55);
}

.ptt-btn:active:not(.disabled) {
    background: rgba(52, 211, 153, 0.22);
    border-color: rgba(52, 211, 153, 0.45);
    color: var(--success);
}

.ltac-toggle {
    margin-left: auto;
}

.ltac-toggle:hover {
    transform: translateY(0) rotate(180deg);
}

/* L-TAC Container */
.ltac-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 2px solid rgba(148, 163, 184, 0.16);
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.ltac-container.collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    margin-top: 0;
    border-top: none;
}

.ltac-channel {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
}

.ltac-channel:hover {
    background: rgba(15, 23, 42, 0.75);
    border-color: rgba(56, 189, 248, 0.3);
    transform: translateX(4px);
}

.ltac-channel.active {
    background: rgba(56, 189, 248, 0.12);
    border-color: var(--accent);
}

.ltac-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.ltac-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ltac-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.ltac-freq {
    font-size: 11px;
    color: var(--accent);
    font-weight: 600;
}

.ltac-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ltac-controls {
    display: flex;
    gap: 6px;
}

.ltac-controls .btn-icon {
    width: 36px;
    height: 36px;
}

.ltac-controls .material-icons {
    font-size: 18px;
}
