/* ═══════════════════════════════════════════════════════
   Panel — Design System
   ═══════════════════════════════════════════════════════ */

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #fafbfc;
    --border: #e4e7ec;
    --border-strong: #d0d5dd;
    --text: #101828;
    --text-muted: #667085;
    --text-subtle: #98a2b3;

    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #eef2ff;

    --success: #10b981;
    --success-hover: #059669;
    --success-light: #ecfdf5;

    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-light: #fef2f2;

    --warning: #f59e0b;
    --warning-hover: #d97706;
    --warning-light: #fffbeb;

    --info: #06b6d4;
    --info-hover: #0891b2;

    --purple: #8b5cf6;
    --purple-hover: #7c3aed;
    --purple-light: #f5f3ff;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);

    --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    padding: 16px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

.app {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

/* ═══════════════════════════════════════════════════════
   Header
   ═══════════════════════════════════════════════════════ */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    min-width: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.avatar {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--primary) 0%, var(--purple) 100%);
    border-radius: 12px;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.header-info {
    min-width: 0;
    flex: 1;
}

.header-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
}

.header-user {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════
   Main
   ═══════════════════════════════════════════════════════ */
.app-main {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-xs);
    min-width: 0;
}

/* ═══════════════════════════════════════════════════════
   Menu Grid
   ═══════════════════════════════════════════════════════ */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    text-align: right;
    font-family: inherit;
    color: inherit;
    transition: all var(--transition);
    min-width: 0;
    position: relative;
    overflow: hidden;
}

.menu-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: currentColor;
    opacity: 0;
    transition: opacity var(--transition);
    pointer-events: none;
}

.menu-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.menu-item-blue:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.menu-item-green:hover { border-color: var(--success); background: var(--success-light); color: var(--success); }
.menu-item-purple:hover { border-color: var(--purple); background: var(--purple-light); color: var(--purple); }

.menu-item-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    border-radius: 12px;
    flex-shrink: 0;
    transition: all var(--transition);
    color: var(--text-muted);
}

.menu-item-blue:hover .menu-item-icon { background: var(--primary); color: #fff; }
.menu-item-green:hover .menu-item-icon { background: var(--success); color: #fff; }
.menu-item-purple:hover .menu-item-icon { background: var(--purple); color: #fff; }

.menu-item-body {
    min-width: 0;
    flex: 1;
}

.menu-item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    margin-bottom: 2px;
}

.menu-item:hover .menu-item-title { color: inherit; }

.menu-item-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════
   Page Head
   ═══════════════════════════════════════════════════════ */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    min-width: 0;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.page-sub {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.2;
    color: #fff;
    background: var(--text);
    border: 1.5px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
    user-select: none;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
    background: var(--primary);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}
.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--surface-2);
    border-color: var(--border-strong);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
    background: var(--surface-2);
    color: var(--text);
}

.btn-danger {
    background: var(--danger);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }

.btn-warning {
    background: var(--warning);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}
.btn-warning:hover:not(:disabled) { background: var(--warning-hover); }

.btn-success {
    background: var(--success);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}
.btn-success:hover:not(:disabled) { background: var(--success-hover); }

.btn-info {
    background: var(--info);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.25);
}
.btn-info:hover:not(:disabled) { background: var(--info-hover); }

.btn-block { width: 100%; }
.btn-lg { padding: 14px 24px; font-size: 14px; }
.btn-sm { padding: 8px 12px; font-size: 12.5px; }

/* Icon buttons */
.btn-icon {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

.btn-icon:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
    color: var(--text);
}

.btn-icon-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.btn-icon-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff;
}

.btn-icon-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
.btn-icon-danger:hover {
    background: var(--danger-hover);
    border-color: var(--danger-hover);
    color: #fff;
}

/* ═══════════════════════════════════════════════════════
   Forms
   ═══════════════════════════════════════════════════════ */
.form-group {
    margin-bottom: 18px;
    min-width: 0;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.form-required {
    color: var(--danger);
    font-weight: 700;
}

.form-help {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.5;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 140px;
    gap: 12px;
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea {
    width: 100%;
    padding: 11px 14px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    min-width: 0;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-subtle);
}

input:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

input[type="number"] {
    max-width: 100%;
    font-variant-numeric: tabular-nums;
}

textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.6;
}

.code-input {
    font-family: 'SF Mono', 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 12.5px;
    direction: ltr;
    text-align: left;
    line-height: 1.6;
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.inline-form input[type="number"] {
    max-width: 120px;
}

/* ═══════════════════════════════════════════════════════
   Tabs
   ═══════════════════════════════════════════════════════ */
.tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.tabs-sm .tab {
    padding: 8px 16px;
    font-size: 13px;
}

.tab {
    flex: 1;
    padding: 10px 16px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.tab:hover { color: var(--text); background: rgba(0, 0, 0, 0.03); }

.tab.active {
    color: var(--primary);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

/* ═══════════════════════════════════════════════════════
   Dropzone
   ═══════════════════════════════════════════════════════ */
.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 32px 20px;
    background: var(--surface-2);
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
    margin-bottom: 20px;
    overflow: hidden;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.dropzone.dragover {
    transform: scale(1.01);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.dropzone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.dropzone-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-radius: 16px;
    color: var(--primary);
    box-shadow: var(--shadow-xs);
    margin-bottom: 8px;
}

.dropzone-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.dropzone-desc {
    font-size: 13px;
    color: var(--text-muted);
}

.dropzone-hint {
    font-size: 12px;
    color: var(--text-subtle);
    margin-top: 4px;
}

.dropzone-file {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-pill {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-xs);
}

.file-pill > svg { color: var(--primary); flex-shrink: 0; }

.file-pill-info {
    flex: 1;
    min-width: 0;
    text-align: right;
}

.file-pill-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-pill-size {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.file-pill-remove {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

.file-pill-remove:hover {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
}

/* ═══════════════════════════════════════════════════════
   Upload Progress
   ═══════════════════════════════════════════════════════ */
.upload-progress {
    padding: 16px;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--purple-light) 100%);
    border: 1.5px solid var(--primary);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); max-height: 0; }
    to { opacity: 1; transform: translateY(0); max-height: 200px; }
}

.progress-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.progress-status {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.progress-spinner {
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.progress-status-text {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--primary-hover);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.progress-percent {
    font-size: 18px;
    font-weight: 800;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    flex-shrink: 0;
}

.progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--purple) 100%);
    border-radius: 999px;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.5);
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.4) 50%,
        transparent 100%);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--primary-hover);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.progress-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ═══════════════════════════════════════════════════════
   Files List
   ═══════════════════════════════════════════════════════ */
.files-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all var(--transition);
    min-width: 0;
}

.file-item:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.file-item.file-locked {
    background: var(--danger-light);
    border-color: #fecaca;
}

.file-item.file-locked:hover {
    border-color: var(--danger);
}

.file-item.file-locked::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--danger) 0%, #f87171 50%, var(--danger) 100%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    margin-bottom: 4px;
    word-break: break-all;
    flex-wrap: wrap;
}

.file-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

.file-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.file-meta .danger { color: var(--danger); font-weight: 600; }

.lock-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 10.5px;
    font-weight: 700;
    color: #fff;
    background: var(--danger);
    border-radius: 6px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

/* ═══════════════════════════════════════════════════════
   Stats
   ═══════════════════════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.stat {
    padding: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 0;
}

.stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
    word-break: break-word;
    font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════════
   Link Box
   ═══════════════════════════════════════════════════════ */
.link-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 8px 8px 14px;
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    min-width: 0;
}

.link-box code {
    flex: 1;
    min-width: 0;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    color: var(--text);
    direction: ltr;
    text-align: left;
    word-break: break-all;
    overflow-wrap: anywhere;
    line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════
   Action Grid
   ═══════════════════════════════════════════════════════ */
.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    padding-top: 20px;
    margin-top: 20px;
    border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════
   Lock Warning
   ═══════════════════════════════════════════════════════ */
.alert-lock {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    background: var(--danger-light);
    border: 1.5px solid #fecaca;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    animation: slideDown 0.3s ease;
}

.alert-lock-icon {
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
}

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

.alert-lock-title {
    font-size: 14px;
    font-weight: 700;
    color: #991b1b;
    margin-bottom: 6px;
}

.alert-lock-detail {
    font-size: 12.5px;
    color: #7f1d1d;
    line-height: 1.7;
    word-break: break-word;
}

.alert-lock-detail code {
    display: inline-block;
    padding: 1px 6px;
    background: #fff;
    border-radius: 4px;
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 11.5px;
    color: var(--danger);
    direction: ltr;
}

/* ═══════════════════════════════════════════════════════
   History
   ═══════════════════════════════════════════════════════ */
.history-box {
    background: #0d1117;
    border: 1px solid #21262d;
    border-radius: var(--radius);
    padding: 6px;
    max-height: 260px;
    overflow-y: auto;
    overflow-x: hidden;
}

.history-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    font-size: 12px;
    color: #e5e7eb;
    border-bottom: 1px solid #1f2937;
    border-radius: 6px;
}

.history-item:last-child { border-bottom: none; }
.history-item:hover { background: #161b22; }

.history-time {
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 11px;
    color: #9ca3af;
    direction: ltr;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-by {
    font-weight: 600;
    color: #60a5fa;
    white-space: nowrap;
}

.history-by.owner { color: #fbbf24; }
.history-by.reset { color: #a78bfa; }

.history-ip code {
    display: inline-block;
    padding: 2px 6px;
    background: #1f2937;
    color: #fbbf24;
    border-radius: 4px;
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 11px;
    direction: ltr;
}

/* ═══════════════════════════════════════════════════════
   Loader
   ═══════════════════════════════════════════════════════ */
.loader {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

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

.empty-state-icon {
    font-size: 40px;
    opacity: 0.4;
    margin-bottom: 12px;
}

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

.empty-state-desc {
    font-size: 13px;
}

/* ═══════════════════════════════════════════════════════
   Toast
   ═══════════════════════════════════════════════════════ */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    z-index: 9999;
    align-items: center;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 400px;
    width: 100%;
    padding: 12px 16px;
    background: var(--text);
    color: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-size: 13.5px;
    font-weight: 500;
    pointer-events: auto;
    animation: toastIn 0.3s ease;
    line-height: 1.4;
}

.toast.toast-success { background: var(--success); }
.toast.toast-error { background: var(--danger); }
.toast.toast-warning { background: var(--warning); }

.toast-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.toast-text {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    to { opacity: 0; transform: translateY(20px); }
}

/* ═══════════════════════════════════════════════════════
   Utilities
   ═══════════════════════════════════════════════════════ */
.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    body { padding: 10px; }
    .app { gap: 12px; }
    .app-main { padding: 18px; border-radius: 12px; }
    .app-header { padding: 10px 12px; }
    .avatar { width: 36px; height: 36px; font-size: 12px; }

    .menu-grid { grid-template-columns: 1fr; }
    .menu-item { padding: 14px; }

    .page-head { flex-direction: column; align-items: stretch; }
    .page-head .btn { width: 100%; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .action-grid { grid-template-columns: 1fr 1fr; }

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

    .file-item {
        flex-direction: column;
        align-items: stretch;
    }
    .file-item .btn { width: 100%; }

    .history-item {
        grid-template-columns: 1fr;
        gap: 4px;
        text-align: right;
    }
    .history-time { text-align: right; }

    .progress-percent { font-size: 16px; }
    .progress-meta { font-size: 11px; }

    .dropzone { min-height: 160px; padding: 24px 16px; }
    .dropzone-icon { width: 48px; height: 48px; }
    .dropzone-icon svg { width: 24px; height: 24px; }
    .dropzone-title { font-size: 14px; }

    .toast-container { bottom: 12px; left: 12px; right: 12px; }
}

@media (max-width: 400px) {
    .action-grid { grid-template-columns: 1fr; }
    .tabs { flex-direction: column; }
    .tab { width: 100%; }
}

/* ═══════════════════════════════════════════════════════
   Scrollbar
   ═══════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: #d0d5dd;
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
    background: #98a2b3;
    background-clip: padding-box;
}

.history-box::-webkit-scrollbar-thumb {
    background: #30363d;
    background-clip: padding-box;
}

::selection {
    background: rgba(99, 102, 241, 0.2);
    color: inherit;
}
/* ═══════════════════════════════════════════════════════
   Login Page
   ═══════════════════════════════════════════════════════ */
.login-page {
    width: 100%;
    max-width: 420px;
    margin: auto;
    animation: fadeInUp 0.4s ease;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

body:has(.login-page) {
    align-items: center;
    padding: 16px;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px 32px 32px;
    box-shadow: var(--shadow-md);
}

.login-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--purple) 100%);
    border-radius: 20px;
    color: #fff;
    box-shadow: 0 12px 32px rgba(99, 102, 241, 0.35);
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    color: var(--text);
    margin-bottom: 6px;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.login-subtitle {
    font-size: 13.5px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 28px;
    line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════
   Step Cards (system_check)
   ═══════════════════════════════════════════════════════ */
.step-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 14px;
    transition: all var(--transition);
}

.step-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.step-num {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.step-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.step-desc {
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 10px;
}

/* ═══════════════════════════════════════════════════════
   Code Box
   ═══════════════════════════════════════════════════════ */
.code-box {
    position: relative;
    background: #0d1117;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid #21262d;
}

.code-box pre {
    margin: 0;
    padding: 16px;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    line-height: 1.65;
    color: #c9d1d9;
    direction: ltr;
    text-align: left;
    overflow-x: auto;
    white-space: pre;
}

.code-copy {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: #c9d1d9;
    cursor: pointer;
    transition: all var(--transition);
    backdrop-filter: blur(10px);
}

.code-copy:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* ═══════════════════════════════════════════════════════
   Result Rows (system_check output)
   ═══════════════════════════════════════════════════════ */
.result-rows {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #fff;
    border-radius: var(--radius);
    padding: 6px;
    border: 1px solid var(--border);
}

.result-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--surface-2);
    min-width: 0;
}

.result-key {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
}

.result-val {
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    color: var(--text);
    direction: ltr;
    text-align: left;
    word-break: break-all;
    min-width: 0;
    flex: 1;
}

/* ═══════════════════════════════════════════════════════
   Info Note
   ═══════════════════════════════════════════════════════ */
.info-note {
    font-size: 12.5px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 16px;
    padding: 12px 14px;
    background: var(--primary-light);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius);
    line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════
   Empty State Icon Animation
   ═══════════════════════════════════════════════════════ */
.empty-state-icon {
    animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* ═══════════════════════════════════════════════════════
   Responsive for new pages
   ═══════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .login-card {
        padding: 28px 20px 24px;
    }
    .login-logo {
        width: 60px;
        height: 60px;
        border-radius: 16px;
    }
    .login-logo svg {
        width: 26px;
        height: 26px;
    }
    .login-title {
        font-size: 19px;
    }
    .step-card {
        padding: 14px;
    }
    .result-row {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }
    .result-key {
        font-size: 11px;
    }
}
/* ═══════════════════════════════════════════════════════
   Code Editor
   ═══════════════════════════════════════════════════════ */
.code-editor {
    width: 100%;
    min-height: 400px;
    padding: 16px;
    background: #0d1117;
    color: #c9d1d9;
    border: 1.5px solid #21262d;
    border-radius: var(--radius);
    font-family: 'SF Mono', 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 12.5px;
    line-height: 1.65;
    direction: ltr;
    text-align: left;
    resize: vertical;
    tab-size: 4;
    outline: none;
    transition: border-color var(--transition);
}

.code-editor:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.editor-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    background: var(--surface-2);
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
}
.dropzone-sm {
    min-height: 110px;
    padding: 20px 16px;
}

.dropzone-sm .dropzone-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 6px;
}

.dropzone-sm .dropzone-title {
    font-size: 13px;
}

.dropzone-sm .dropzone-desc {
    font-size: 12px;
}