@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/inter-v20-latin_cyrillic-regular.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/inter-v20-latin_cyrillic-500.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/inter-v20-latin_cyrillic-600.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/inter-v20-latin_cyrillic-700.woff2") format("woff2");
}

:root {
  /* Core Brand: RoyalBlue (#4169E1) */
  --primary: #4169e1;
  --primary-hover: #3154c5;
  --primary-subtle: #e8eeff;
  --primary-surface: #f4f7ff;

  /* Semantic Zone 2: Codes & Queue (Indigo/Slate tone) */
  --codes-accent: #4f46e5;
  --codes-subtle: #ede9fe;
  --codes-surface: #ffffff;

  /* Semantic Zone 3: Receive/Download (Teal/Emerald tone) */
  --receive-accent: #0d9488;
  --receive-hover: #0f766e;
  --receive-subtle: #ccfbf1;
  --receive-surface: #f2fbf9;

  /* Base Neutral Tokens (Light Theme) */
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-variant: #f1f5f9;
  --surface-hover: #e2e8f0;
  --surface-elevated: #f8fafc;
  --text: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;

  /* Status Colors */
  --danger: #dc2626;
  --danger-subtle: #fee2e2;
  --success: #16a34a;
  --success-subtle: #dcfce7;

  /* Layout & Spacing */
  --radius-xl: 18px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --space-xs: 6px;
  --space-sm: 10px;
  --space-md: 16px;
  --space-lg: 22px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --primary: #4169e1;
  --primary-hover: #587ef0;
  --primary-subtle: #1e2d5c;
  --primary-surface: #121829;

  --codes-accent: #818cf8;
  --codes-subtle: #23254c;
  --codes-surface: #141822;

  --receive-accent: #14b8a6;
  --receive-hover: #2dd4bf;
  --receive-subtle: #133936;
  --receive-surface: #101e1f;

  --bg: #090c12;
  --surface: #141822;
  --surface-variant: #1d2331;
  --surface-hover: #283044;
  --surface-elevated: #191f2c;
  --text: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;

  --danger: #f87171;
  --danger-subtle: #35161b;
  --success: #4ade80;
  --success-subtle: #123120;
}

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

html,
body {
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Minimalist scrollbar (4.8) */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--surface-hover);
  border-radius: 3px;
}

.app-shell {
  max-width: 1260px;
  margin: 0 auto;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  min-height: 100vh;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
  background-color: var(--surface);
  padding: 14px var(--space-lg);
  border-radius: var(--radius-xl);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--text);
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background-color: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* Centralized UI Components: Segmented Nav & Buttons */
.ui-segmented {
  display: inline-flex;
  align-items: center;
  background-color: var(--surface-variant);
  padding: 4px;
  border-radius: var(--radius-md);
  gap: 3px;
}

.ui-segmented-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.ui-segmented-btn:hover {
  color: var(--text);
  background-color: var(--surface-hover);
}

.ui-segmented-btn.active {
  background-color: var(--primary);
  color: #ffffff;
}

.ui-icon-btn {
  background-color: var(--surface-variant);
  color: var(--text);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.ui-icon-btn:hover {
  background-color: var(--surface-hover);
}

/* Primary Buttons */
.ui-btn {
  background-color: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 13px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: background-color 0.15s ease, opacity 0.15s ease;
  width: 100%;
}

.ui-btn:hover:not(.disabled) {
  background-color: var(--primary-hover);
}

.ui-btn-receive {
  background-color: var(--receive-accent);
  color: #ffffff;
}

.ui-btn-receive:hover:not(.disabled) {
  background-color: var(--receive-hover);
}

.ui-btn.disabled {
  background-color: var(--surface-variant);
  color: var(--text-muted);
  pointer-events: none;
  cursor: default;
}

.ui-btn-ghost {
  background-color: var(--surface);
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.ui-btn-ghost:hover {
  background-color: var(--surface-hover);
  color: var(--text);
}

/* Main 3-Zone Workspace Grid */
.workspace-grid {
  display: grid;
  grid-template-columns: 1.08fr 1fr 1.02fr;
  gap: var(--space-md);
  align-items: stretch;
  flex: 1;
}

.workspace-grid[data-route="upload"] {
  grid-template-columns: minmax(0, 580px);
  justify-content: center;
}
.workspace-grid[data-route="upload"] #codes,
.workspace-grid[data-route="upload"] #download {
  display: none;
}

.workspace-grid[data-route="codes"] {
  grid-template-columns: minmax(0, 580px);
  justify-content: center;
}
.workspace-grid[data-route="codes"] #upload,
.workspace-grid[data-route="codes"] #download {
  display: none;
}

.workspace-grid[data-route="download"] {
  grid-template-columns: minmax(0, 580px);
  justify-content: center;
}
.workspace-grid[data-route="download"] #upload,
.workspace-grid[data-route="download"] #codes {
  display: none;
}

@media (max-width: 1024px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

/* Distinct Panel Surfaces so the user never gets lost */
.ui-panel {
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.panel-upload {
  background-color: var(--primary-surface);
}

.panel-codes {
  background-color: var(--codes-surface);
}

.panel-download {
  background-color: var(--receive-surface);
}

.panel-top {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 20px;
}

.step-badge-upload {
  background-color: var(--primary-subtle);
  color: var(--primary);
}

.step-badge-codes {
  background-color: var(--codes-subtle);
  color: var(--codes-accent);
}

.step-badge-download {
  background-color: var(--receive-subtle);
  color: var(--receive-accent);
}

.titles {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-upload .titles svg {
  color: var(--primary);
}
.panel-codes .titles svg {
  color: var(--codes-accent);
}
.panel-download .titles svg {
  color: var(--receive-accent);
}

.panel-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* 1. UPLOAD PANEL ELEMENTS */
#uploadBox {
  background-color: var(--surface);
  border-radius: var(--radius-lg);
  padding: 26px 18px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 180px;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

#uploadBox:hover,
body.lightened #uploadBox {
  background-color: var(--primary-subtle);
}

.upload-icon-circle {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background-color: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

#dragFiles {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
}

.upload-cta-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--primary-subtle);
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  margin-top: 2px;
}

#uploadBox:hover .upload-cta-pill {
  background-color: var(--primary);
  color: #ffffff;
}

.drag-subtext {
  font-size: 12px;
  color: var(--text-muted);
}

#uploader {
  display: none;
}

/* Group Checkbox Row */
#sameCode {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background-color: var(--surface);
  padding: 10px 14px;
  border-radius: var(--radius-md);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.checkbox {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background-color: var(--surface-variant);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  color: transparent;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.checkbox[checked="1"] {
  background-color: var(--primary);
  color: #ffffff;
}

#groupFilesText {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

/* Expiration Selector */
.field-block {
  margin-top: auto;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.radioWrap {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background-color: var(--surface);
  padding: 4px;
  border-radius: var(--radius-md);
  gap: 4px;
}

.radios {
  text-align: center;
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.radios:hover {
  color: var(--text);
  background-color: var(--surface-variant);
}

.radios.selected {
  background-color: var(--primary);
  color: #ffffff;
}

/* 2. CODES & UPLOAD QUEUE PANEL */
#codesTable {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

#nowUploadingWrap {
  background-color: var(--surface-variant);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.uploading-status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  gap: 8px;
}

#nowUploading {
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#uploadProgress {
  height: 26px;
  background-color: var(--surface);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#uploadProgressInner {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background-color: var(--primary);
  opacity: 0.22;
  transition: width 0.15s linear;
}

#uploadProgressText {
  position: relative;
  z-index: 1;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-mono);
}

#table {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 270px;
  overflow-y: auto;
  flex: 1;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.5;
  background-color: var(--surface-variant);
  border-radius: var(--radius-md);
  margin: auto 0;
}

.wrapCell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background-color: var(--surface-variant);
  padding: 11px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.wrapCell:hover {
  background-color: var(--primary-subtle);
}

.wrapCell.error {
  background-color: var(--danger-subtle);
  color: var(--danger);
  cursor: default;
}

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

.wrapCell.error .fileNameCell {
  color: var(--danger);
}

.codeCell {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  background-color: var(--primary);
  color: #ffffff;
  padding: 5px 12px;
  border-radius: 6px;
  flex-shrink: 0;
}

.wrapCell.error .codeCell {
  background-color: var(--danger);
  color: #ffffff;
}

/* 3. DOWNLOAD PANEL ELEMENTS */
#codeInput {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 4px 0;
}

.codeLetter {
  height: 64px;
  width: 100%;
  background-color: var(--surface);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  text-transform: uppercase;
  outline: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.codeLetter:focus {
  background-color: var(--receive-subtle);
  color: var(--receive-accent);
}

.codeLetter.filled {
  background-color: var(--receive-subtle);
  color: var(--receive-accent);
}

.codeLetter.wrong {
  background-color: var(--danger-subtle);
  color: var(--danger);
}

#fileStats {
  background-color: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.stat-value {
  font-weight: 600;
  color: var(--text);
  text-align: right;
  word-break: break-all;
}

.inline-message {
  display: none;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
}

.inline-message.shown {
  display: block;
}

.inline-message.error {
  background-color: var(--danger-subtle);
  color: var(--danger);
}

/* How It Works Compact Strip (Bottom Guide) */
.info-strip {
  background-color: var(--surface);
  border-radius: var(--radius-xl);
  padding: 14px var(--space-lg);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-md);
}

.info-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.info-step-num {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background-color: var(--primary-subtle);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.info-step-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Centralized Toast Notification */
#copySuccess {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 20px);
  background-color: var(--primary);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
}

#copySuccess.shown {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Footer */
#footer {
  padding: 12px var(--space-lg);
  background-color: var(--surface);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
