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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f5f5f5;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: #1a1a2e;
    color: #fff;
    padding: 16px 24px;
    display: flex;
    align-items: baseline;
    gap: 12px;
}

header h1 {
    font-size: 20px;
    font-weight: 600;
}

header .subtitle {
    font-size: 14px;
    color: #8888aa;
}

.header-nav {
    margin-left: auto;
    display: flex;
    gap: 4px;
}

.nav-link {
    color: #aaa;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.15s;
}

.nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.nav-link.active {
    color: #fff;
    background: rgba(255,255,255,0.15);
}

.search-bar {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 10px 24px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-bar input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
}

.search-bar input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.search-bar button {
    padding: 8px 16px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    color: #333;
}

.search-bar button:hover {
    background: #f0f0f0;
}

.search-clear {
    color: #999 !important;
    border-color: transparent !important;
}

nav#breadcrumbs {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    font-size: 14px;
}

.breadcrumb-link {
    color: #2563eb;
    cursor: pointer;
    text-decoration: none;
}

.breadcrumb-link:hover {
    text-decoration: underline;
}

.breadcrumb-sep {
    color: #999;
    margin: 0 2px;
}

.breadcrumb-current {
    color: #333;
    font-weight: 500;
}

.loading {
    text-align: center;
    padding: 60px;
    color: #999;
    font-size: 16px;
}

.empty-state {
    text-align: center;
    padding: 60px;
    color: #999;
    font-size: 15px;
}

.file-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.file-table thead th {
    text-align: left;
    padding: 10px 16px;
    border-bottom: 2px solid #e0e0e0;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #666;
    position: sticky;
    top: 0;
    background: #fff;
    user-select: none;
}

.file-table thead th.sortable {
    cursor: pointer;
}

.file-table thead th.sortable:hover {
    color: #333;
}

.file-table thead th.sortable::after {
    content: "";
    display: inline-block;
    margin-left: 6px;
    width: 0;
    height: 0;
    vertical-align: middle;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 4px solid #ccc;
    border-top: none;
}

.file-table thead th.sort-active::after {
    border-bottom-color: #333;
}

.file-table thead th.sort-desc::after {
    border-bottom: none;
    border-top: 4px solid #333;
}

.file-table tbody tr {
    border-bottom: 1px solid #f0f0f0;
    cursor: default;
}

.file-table tbody tr.clickable {
    cursor: pointer;
}

.file-table tbody tr.clickable:hover {
    background: #f8f9ff;
}

.file-table tbody td {
    padding: 8px 16px;
    font-size: 14px;
    vertical-align: middle;
}

.col-name {
    width: 40%;
}

.col-size {
    width: 12%;
}

.col-modified {
    width: 18%;
}

.col-count {
    width: 12%;
    text-align: right;
}

td.col-count {
    text-align: right;
}

th.col-count {
    text-align: right;
}

.col-actions {
    width: 18%;
    text-align: center;
}

.icon {
    display: inline-block;
    width: 20px;
    margin-right: 8px;
    text-align: center;
    font-size: 16px;
    vertical-align: middle;
}

.file-name {
    vertical-align: middle;
}

.drive-label {
    color: #888;
    font-size: 12px;
    margin-left: 8px;
}

.btn-mark {
    padding: 4px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 12px;
    color: #333;
    transition: all 0.15s;
}

.btn-mark:hover {
    background: #f0f0f0;
    border-color: #bbb;
}

.btn-mark.marked {
    background: #059669;
    color: #fff;
    border-color: #059669;
}

.btn-mark.marked:hover {
    background: #047857;
}

.btn-mark.uploaded {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
    text-decoration: none;
    display: inline-block;
}

.btn-mark.uploaded:hover {
    background: #1d4ed8;
}

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

.btn-reindex {
    padding: 4px 10px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 12px;
    margin-left: 4px;
    color: #6b7280;
}

.btn-reindex:hover {
    background: #f0f0f0;
    border-color: #bbb;
    color: #374151;
}

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

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.status-badge.uploaded {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-badge.queued {
    background: #d1fae5;
    color: #065f46;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 24px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
}

.page-btn {
    padding: 6px 16px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    color: #333;
}

.page-btn:hover:not(:disabled) {
    background: #f0f0f0;
}

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

#page-info {
    font-size: 13px;
    color: #666;
}

.col-path {
    width: 35%;
    font-size: 12px;
}

.folder-link {
    color: #2563eb;
    text-decoration: none;
}

.folder-link:hover {
    text-decoration: underline;
}

/* Machines view */

.machines-toolbar {
    padding: 16px 24px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-action {
    padding: 8px 16px;
    border: 1px solid #2563eb;
    border-radius: 4px;
    background: #2563eb;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}

.btn-action:hover {
    background: #1d4ed8;
}

.btn-danger {
    padding: 4px 10px;
    border: 1px solid #dc2626;
    border-radius: 4px;
    background: #fff;
    color: #dc2626;
    cursor: pointer;
    font-size: 12px;
}

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

.reg-code-display {
    padding: 12px 24px;
    background: #f0fdf4;
    border-bottom: 1px solid #bbf7d0;
    font-size: 14px;
    display: flex;
    gap: 16px;
    align-items: center;
}

.reg-code-display strong {
    font-size: 24px;
    letter-spacing: 4px;
    font-family: monospace;
}

.reg-code-expiry {
    color: #666;
    font-size: 12px;
}

.auth-gate {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.auth-gate-box {
    background: #fff;
    padding: 40px 48px;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.auth-gate-box h2 {
    margin-bottom: 8px;
    color: #1a1a2e;
}

.auth-gate-box p {
    margin-bottom: 16px;
    color: #666;
}

.auth-gate-box input {
    padding: 10px 14px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 14px;
    width: 100%;
    margin-bottom: 12px;
}

.auth-gate-box input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
    outline: none;
}

.auth-gate-box button {
    padding: 10px 24px;
    border: 1px solid #2563eb;
    border-radius: 4px;
    background: #2563eb;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    width: 100%;
}

.auth-gate-box button:hover {
    background: #1d4ed8;
}

.auth-error {
    color: #dc2626;
    font-size: 13px;
    margin-top: 8px;
}

.status-active {
    color: #059669;
    font-weight: 500;
}

.status-revoked {
    color: #dc2626;
    font-weight: 500;
}

.hostname-badge {
    display: inline-block;
    padding: 1px 6px;
    background: #e0e7ff;
    color: #3730a3;
    border-radius: 3px;
    font-size: 11px;
    margin-left: 6px;
    vertical-align: middle;
}

footer {
    background: #fff;
    border-top: 1px solid #e0e0e0;
    padding: 10px 24px;
    font-size: 13px;
    color: #666;
}

/* File Viewer Modal */

.file-viewer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

.file-viewer-toolbar {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    background: #1a1a2e;
    color: #fff;
    gap: 12px;
    flex-shrink: 0;
}

.viewer-title {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.viewer-nav-btn {
    padding: 6px 16px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
}

.viewer-nav-btn:hover:not(:disabled) {
    background: rgba(255,255,255,0.15);
}

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

.viewer-close-btn {
    padding: 6px 12px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    margin-left: 8px;
}

.viewer-close-btn:hover {
    background: rgba(255,255,255,0.15);
}

.viewer-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #888;
    font-size: 16px;
}

.viewer-frame {
    flex: 1;
    border: none;
    background: #222;
}
