/* Candengo — Apple glass design system */

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

:root {
  --bg:            #08080f;
  --glass:         rgba(255,255,255,0.06);
  --glass-hover:   rgba(255,255,255,0.09);
  --glass-border:  rgba(255,255,255,0.10);
  --glass-high:    rgba(255,255,255,0.13);
  --blur:          blur(24px) saturate(160%);
  --accent:        #0a84ff;
  --accent-glow:   rgba(10,132,255,0.35);
  --accent-hover:  #3fa0ff;
  --danger:        #ff453a;
  --danger-glow:   rgba(255,69,58,0.3);
  --success:       #30d158;
  --warning:       #ffd60a;
  --text:          rgba(255,255,255,0.90);
  --text-secondary:rgba(255,255,255,0.50);
  --text-tertiary: rgba(255,255,255,0.30);
  --radius:        16px;
  --radius-sm:     10px;
  --radius-xs:     7px;
  --sidebar-w:     228px;
  --transition:    0.18s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 60% at 15% 40%, rgba(10,132,255,0.07) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 85% 15%, rgba(120,60,255,0.05) 0%, transparent 55%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

/* ── Glass card ── */
.glass {
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.08);
}
.glass-sm {
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
}

/* ── Layout ── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: rgba(255,255,255,0.03);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  padding: 28px 14px 20px;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 28px;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 16px;
}
.sidebar-logo-mark {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent) 0%, #6030ff 100%);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: white;
  flex-shrink: 0;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.sidebar-logo-text { line-height: 1.2; }
.sidebar-logo-name { font-size: 15px; font-weight: 700; color: var(--text); }
.sidebar-logo-sub  { font-size: 11px; color: var(--text-secondary); }

.nav-section { font-size: 11px; font-weight: 600; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.08em; padding: 12px 10px 6px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); text-decoration: none;
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: all var(--transition); margin-bottom: 2px;
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--glass-hover); color: var(--text); }
.nav-item.active {
  background: rgba(10,132,255,0.12);
  color: var(--accent);
  border-color: rgba(10,132,255,0.2);
}
.nav-icon { width: 18px; text-align: center; font-size: 15px; opacity: 0.8; }

.sidebar-spacer { flex: 1; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border-top: 1px solid var(--glass-border); padding-top: 16px; margin-top: 8px;
}
.sidebar-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #6030ff);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white; flex-shrink: 0;
}
.sidebar-username { font-size: 13px; font-weight: 600; color: var(--text); }
.sidebar-role { font-size: 11px; color: var(--text-secondary); }
.logout-btn {
  margin-left: auto; background: none; border: none;
  color: var(--text-secondary); cursor: pointer; font-size: 16px;
  padding: 4px; border-radius: 6px; transition: color var(--transition);
}
.logout-btn:hover { color: var(--danger); }

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 36px 40px;
  max-width: calc(100vw - var(--sidebar-w));
}

.page-header { margin-bottom: 28px; }
.page-title { font-size: 26px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }

/* ── Inputs ── */
input, select, textarea {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text); padding: 11px 14px;
  font-size: 14px; font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
input::placeholder { color: var(--text-tertiary); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10,132,255,0.18);
}
select option { background: #1a1a2e; }
label { font-size: 13px; font-weight: 600; color: var(--text-secondary); display: block; margin-bottom: 6px; }
.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer;
  border: none; transition: all var(--transition); text-decoration: none;
}
.btn-primary {
  background: var(--accent); color: white;
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-ghost {
  background: var(--glass); border: 1px solid var(--glass-border);
  color: var(--text);
}
.btn-ghost:hover { background: var(--glass-hover); }
.btn-danger {
  background: rgba(255,69,58,0.15); border: 1px solid rgba(255,69,58,0.3);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(255,69,58,0.25); box-shadow: 0 4px 16px var(--danger-glow); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-green  { color: var(--success); background: rgba(48,209,88,0.12); border: 1px solid rgba(48,209,88,0.25); }
.badge-red    { color: var(--danger); background: rgba(255,69,58,0.12); border: 1px solid rgba(255,69,58,0.25); }
.badge-blue   { color: var(--accent); background: rgba(10,132,255,0.12); border: 1px solid rgba(10,132,255,0.25); }
.badge-yellow { color: var(--warning); background: rgba(255,214,10,0.12); border: 1px solid rgba(255,214,10,0.25); }

/* ── Stat cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { padding: 20px 22px; }
.stat-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); margin: 6px 0 4px; }
.stat-sub   { font-size: 12px; color: var(--text-secondary); }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  font-size: 11px; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.07em;
  padding: 10px 16px; text-align: left;
  border-bottom: 1px solid var(--glass-border);
}
td { padding: 13px 16px; font-size: 14px; border-bottom: 1px solid rgba(255,255,255,0.04); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }
.td-muted { color: var(--text-secondary); font-size: 13px; }

/* ── Toggle switch ── */
.toggle-wrap { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.toggle-wrap:last-child { border-bottom: none; }
.toggle-info .toggle-title { font-size: 14px; font-weight: 600; }
.toggle-info .toggle-desc  { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.toggle {
  position: relative; width: 48px; height: 28px; flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; border-radius: 14px;
  background: rgba(255,255,255,0.15); cursor: pointer;
  transition: background var(--transition);
  border: 1px solid var(--glass-border);
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 20px; height: 20px; border-radius: 50%;
  background: white; top: 3px; left: 3px;
  transition: transform var(--transition);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.toggle input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Upload zone ── */
.upload-zone {
  border: 2px dashed var(--glass-border); border-radius: var(--radius);
  padding: 40px; text-align: center; cursor: pointer;
  transition: all var(--transition); background: rgba(255,255,255,0.02);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(10,132,255,0.05);
}
.upload-icon { font-size: 36px; opacity: 0.5; margin-bottom: 12px; }
.upload-text { font-size: 15px; font-weight: 600; }
.upload-sub  { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px); z-index: 200;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity var(--transition);
}
.modal-backdrop.open { opacity: 1; pointer-events: all; }
.modal { padding: 28px; max-width: 480px; width: 90%; }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.modal-body  { font-size: 14px; color: var(--text-secondary); margin-bottom: 24px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; min-width: 240px;
  animation: slideIn 0.2s ease;
  background: var(--glass-high); backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-info    { border-left: 3px solid var(--accent); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Misc ── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title  { font-size: 16px; font-weight: 700; }
.empty-state    { text-align: center; padding: 48px 24px; color: var(--text-secondary); }
.empty-icon     { font-size: 40px; opacity: 0.35; margin-bottom: 12px; }
.code-block     { font-family: "SF Mono", "Fira Code", monospace; font-size: 13px;
  background: rgba(0,0,0,0.35); border: 1px solid var(--glass-border);
  border-radius: var(--radius-xs); padding: 10px 14px; word-break: break-all; }
.copy-row       { display: flex; gap: 8px; align-items: stretch; }
.copy-row .code-block { flex: 1; }
hr { border: none; border-top: 1px solid var(--glass-border); margin: 24px 0; }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; }
.mt-16{ margin-top: 16px; }.mt-24{ margin-top: 24px; }

/* ── Login page ── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card { width: 100%; max-width: 400px; padding: 40px 36px; }
.login-logo  { text-align: center; margin-bottom: 32px; }
.login-mark  {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--accent), #6030ff);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800; color: white;
  box-shadow: 0 8px 28px var(--accent-glow);
}
.login-title { font-size: 24px; font-weight: 700; }
.login-sub   { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.login-error { color: var(--danger); font-size: 13px; margin-bottom: 16px; min-height: 20px; }
.login-btn   { width: 100%; padding: 13px; font-size: 15px; margin-top: 8px; border-radius: var(--radius-sm); }

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Login page (body class) ── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.login-card { width: 100%; max-width: 400px; padding: 40px 36px; }
.login-logo  { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.login-subtitle { font-size: 13px; color: var(--text-secondary); margin-bottom: 28px; }
.login-footer   { font-size: 12px; color: var(--text-tertiary); text-align: center; margin-top: 24px; }
.form-error { font-size: 13px; color: var(--danger); padding: 8px 12px;
  background: rgba(255,69,58,0.1); border-radius: var(--radius-xs); margin-bottom: 12px; }

/* ── Logo atoms ── */
.logo-mark { font-size: 24px; line-height: 1; }
.logo-name { font-size: 17px; font-weight: 700; }

/* ── Nav list ── */
.nav-list { list-style: none; padding: 0; margin: 0 0 auto; }
.nav-item a {
  display: block; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: all var(--transition); margin-bottom: 2px;
  border: 1px solid transparent;
}
.nav-item a:hover { background: var(--glass-hover); color: var(--text); }
.nav-item.active a {
  background: rgba(10,132,255,0.12); color: var(--accent);
  border-color: rgba(10,132,255,0.2);
}

/* ── Sidebar footer ── */
.sidebar-footer {
  display: flex; align-items: center; gap: 10px;
  padding-top: 16px; margin-top: 8px;
  border-top: 1px solid var(--glass-border);
}
.username-badge { font-size: 13px; font-weight: 600; color: var(--text-secondary); flex: 1; }

/* ── Page header ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }

/* ── Card / Section ── */
.card { border-radius: var(--radius); }
.section { padding: 24px; margin-bottom: 20px; }
.section-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.section-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }

/* ── Info table (key–value) ── */
.info-table { width: 100%; border-collapse: collapse; }
.info-table td { padding: 9px 12px; font-size: 14px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.info-table tr:last-child td { border-bottom: none; }
.info-label { color: var(--text-secondary); font-weight: 600; font-size: 13px; width: 40%; }

/* ── Data table ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  font-size: 11px; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.07em;
  padding: 10px 16px; text-align: left;
  border-bottom: 1px solid var(--glass-border);
}
.data-table td { padding: 13px 16px; font-size: 14px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.empty-row { text-align: center; color: var(--text-secondary); padding: 32px !important; }
.error-row { color: var(--danger) !important; }
.action-cell { text-align: right; white-space: nowrap; }

/* ── Status text ── */
.status-ok { color: var(--success); }

/* ── Badge (default style, no dot) ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
  color: var(--accent); background: rgba(10,132,255,0.12);
  border: 1px solid rgba(10,132,255,0.25);
}

/* ── Upload progress ── */
.upload-progress { margin-top: 16px; }
.progress-bar { height: 6px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.4s ease; width: 0%; }
.upload-hint { font-size: 12px; color: var(--text-tertiary); margin-top: 6px; }
.upload-link { color: var(--accent); text-decoration: underline; cursor: pointer; }
.upload-zone.uploading { opacity: 0.5; pointer-events: none; }

/* ── Button secondary ── */
.btn-secondary {
  background: rgba(255,255,255,0.08); border: 1px solid var(--glass-border);
  color: var(--text);
}
.btn-secondary:hover { background: var(--glass-high); }

/* ── Button full-width ── */
.btn-full { width: 100%; justify-content: center; }

/* ── Input group (input + button side by side) ── */
.input-group { display: flex; gap: 8px; align-items: stretch; }
.input-group input { flex: 1; }
.input-mono { font-family: "SF Mono","Fira Code",monospace; font-size: 13px; }

/* ── Toggle (settings style) ── */
.toggle-label { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.toggle-label span { font-size: 14px; font-weight: 500; }
.toggle { position: relative; display: inline-block; width: 48px; height: 28px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0; border-radius: 14px; cursor: pointer;
  background: rgba(255,255,255,0.15); border: 1px solid var(--glass-border);
  transition: background var(--transition);
}
.toggle-track::before {
  content: ''; position: absolute;
  width: 20px; height: 20px; border-radius: 50%;
  background: white; top: 3px; left: 3px;
  transition: transform var(--transition);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.toggle input:checked + .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-track::before { transform: translateX(20px); }

/* ── Field / label hints ── */
.field-hint { font-size: 12px; color: var(--text-tertiary); margin-top: 5px; }
.label-hint { font-size: 12px; font-weight: 400; color: var(--text-tertiary); margin-left: 6px; }

/* ── Settings form ── */
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 24px; }
.settings-status { font-size: 13px; flex: 1; padding: 8px 12px; border-radius: var(--radius-xs); }
.settings-status-ok  { color: var(--success); background: rgba(48,209,88,0.1); }
.settings-status-err { color: var(--danger);  background: rgba(255,69,58,0.1); }

/* ── Modal overlay (replaces .modal-backdrop) ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px); z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.modal { padding: 28px; max-width: 480px; width: 90%; }
.modal-title  { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.modal-body   { font-size: 14px; color: var(--text-secondary); margin-bottom: 24px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Key display ── */
.key-display {
  font-family: "SF Mono","Fira Code",monospace; font-size: 13px;
  padding: 12px 16px; border-radius: var(--radius-sm); word-break: break-all;
  margin-bottom: 20px; user-select: all; color: var(--success);
}
.key-id { font-family: "SF Mono","Fira Code",monospace; font-size: 12px; color: var(--text-secondary); }

/* ── Toast (JS-driven, replaces toast-container class) ── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 400;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; min-width: 240px;
  background: var(--glass-high); backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  opacity: 0; transform: translateX(16px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: all;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-info    { border-left: 3px solid var(--accent); }
.toast-icon { font-size: 15px; flex-shrink: 0; }
.toast-msg  { flex: 1; }
