:root {
  --bg-dark: #0f172a;
  --bg-sidebar: #1e293b;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --border-color: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif; background: var(--bg-dark); color: var(--text-primary); min-height: 100vh; overflow-x: hidden; }

.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: 260px; background: var(--bg-sidebar); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; padding: 20px; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.logo-icon { font-size: 28px; }
.brand h2 { font-size: 20px; font-weight: 700; letter-spacing: 1px; }
.badge-online { font-size: 11px; color: var(--success); font-weight: 600; }

.nav-menu { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 10px; background: none; border: none; color: var(--text-secondary); padding: 10px 14px; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; text-align: left; transition: all 0.2s; }
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.nav-item.active { background: var(--accent); color: white; }

.disk-usage-widget { background: rgba(0,0,0,0.2); padding: 14px; border-radius: 8px; border: 1px solid var(--border-color); font-size: 13px; }
.disk-info { display: flex; justify-content: space-between; margin-bottom: 8px; }
.progress-bar-bg { width: 100%; height: 6px; background: #334155; border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--accent); transition: width 0.3s; }

/* Main Content */
.main-content { flex: 1; display: flex; flex-direction: column; background: var(--bg-dark); overflow-y: auto; }
.top-bar { display: flex; justify-content: space-between; align-items: center; padding: 16px 28px; border-bottom: 1px solid var(--border-color); background: #131d31; gap: 20px; }
.search-box { display: flex; align-items: center; background: #1e293b; border: 1px solid var(--border-color); border-radius: 8px; padding: 8px 14px; flex: 1; max-width: 500px; gap: 8px; }
.search-box input { background: none; border: none; outline: none; color: white; width: 100%; font-size: 14px; }
.top-actions { display: flex; gap: 10px; }

/* Buttons */
.btn { padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; transition: all 0.2s; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: #334155; color: white; }
.btn-secondary:hover { background: #475569; }
.btn-outline { background: transparent; border: 1px solid var(--accent); color: var(--accent); }
.btn-outline:hover { background: var(--accent); color: white; }
.btn-sm { padding: 4px 8px; font-size: 12px; }
.btn-block { width: 100%; }

/* Drop zone */
.drop-zone { border: 2px dashed var(--border-color); margin: 24px 28px 0; border-radius: 12px; padding: 32px; text-align: center; transition: all 0.3s; background: rgba(30, 41, 59, 0.4); }
.drop-zone.dragover { border-color: var(--accent); background: rgba(59, 130, 246, 0.1); }
.drop-zone-content h3 { font-size: 16px; margin: 10px 0 6px; }
.drop-zone-content p { color: var(--text-secondary); font-size: 13px; margin-bottom: 16px; }
.upload-icon { font-size: 40px; }

/* Content panels */
.content-body { padding: 24px 28px; }
.view-panel { display: none; }
.view-panel.active { display: block; }
.view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.file-count { font-size: 13px; color: var(--text-secondary); background: #1e293b; padding: 4px 10px; border-radius: 20px; }

/* Files Table */
.table-container { background: var(--bg-card); border-radius: 10px; border: 1px solid var(--border-color); overflow-x: auto; }
.files-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
.files-table th { padding: 12px 16px; border-bottom: 1px solid var(--border-color); color: var(--text-secondary); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.files-table td { padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.files-table tr:hover { background: rgba(255,255,255,0.02); }

.status-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.status-active { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.status-revoked { background: rgba(239, 68, 68, 0.2); color: var(--danger); }

.action-buttons { display: flex; gap: 6px; }

/* Metrics */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.metric-card { background: var(--bg-card); border: 1px solid var(--border-color); padding: 20px; border-radius: 10px; }
.metric-label { font-size: 13px; color: var(--text-secondary); display: block; margin-bottom: 8px; }
.metric-value { font-size: 24px; font-weight: 700; color: white; }

.health-details { background: var(--bg-card); border: 1px solid var(--border-color); padding: 20px; border-radius: 10px; font-family: monospace; font-size: 13px; line-height: 1.6; }

/* Settings */
.settings-card { background: var(--bg-card); border: 1px solid var(--border-color); padding: 24px; border-radius: 10px; max-width: 600px; display: flex; flex-direction: column; gap: 16px; }
.setting-item { display: flex; flex-direction: column; gap: 6px; }
.setting-item label { font-size: 13px; color: var(--text-secondary); }
.input-readonly { background: #0f172a; border: 1px solid var(--border-color); padding: 8px 12px; border-radius: 6px; color: #f8fafc; font-size: 14px; outline: none; }

/* Modals */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 1000; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal.show { display: flex; }
.modal-dialog { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; width: 90%; max-width: 480px; box-shadow: 0 20px 40px rgba(0,0,0,0.6); overflow: hidden; }
.modal-lg { max-width: 720px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border-color); }
.modal-close { background: none; border: none; color: var(--text-secondary); font-size: 24px; cursor: pointer; }
.modal-body { padding: 20px; }

.text-center { text-align: center; }
.qr-url-text { font-family: monospace; font-size: 13px; word-break: break-all; margin: 16px 0; color: var(--accent); }

.form-group { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; color: var(--text-secondary); }
.form-group input, .form-group select, .form-group textarea { background: #0f172a; border: 1px solid var(--border-color); padding: 10px 12px; border-radius: 6px; color: white; font-size: 14px; outline: none; }
.token-result-box { margin-top: 16px; padding: 16px; background: #0f172a; border-radius: 8px; border: 1px solid var(--border-color); font-size: 13px; }
.token-result-box textarea { width: 100%; margin: 8px 0; font-family: monospace; }

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 15px;
  }
  
  .brand {
    margin-bottom: 15px;
  }
  
  .nav-menu {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .nav-item {
    flex: 1 1 auto;
    text-align: center;
    justify-content: center;
    padding: 8px 12px;
  }
  
  .disk-usage-widget {
    margin-top: 15px;
  }

  .top-bar {
    flex-direction: column;
    padding: 15px;
    gap: 12px;
  }
  
  .search-box {
    width: 100%;
    max-width: none;
  }
  
  .top-actions {
    width: 100%;
    justify-content: space-between;
  }
  
  .top-actions .btn {
    flex: 1;
  }

  .drop-zone {
    margin: 15px 15px 0;
    padding: 20px;
  }

  .content-body {
    padding: 15px;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }
  
  .action-buttons {
    flex-direction: column;
  }
  
  .modal-dialog {
    width: 95%;
    margin: 10px;
  }
}

/* Hide old menus explicitly if mobile overflow happens */
@media (max-width: 768px) {
  .nav-menu {
    flex-wrap: wrap;
    justify-content: center;
    padding: 10px;
    gap: 5px;
  }
  .nav-item {
    font-size: 12px;
    padding: 6px 10px;
  }
}
