/* =============================================================
   Suntech Zip Decoder — terminal-industrial style
   ============================================================= */

:root {
  /* Surfaces (warm graphite) */
  --s-0: #07090b;     /* deepest */
  --s-1: #0d1013;     /* base bg */
  --s-2: #13171b;     /* panel */
  --s-3: #1b2026;     /* raised */
  --s-4: #242a31;     /* border */
  --s-5: #3a424b;     /* muted border */

  /* Text */
  --t-0: #f0ede5;     /* foreground */
  --t-1: #c7c3b5;     /* body */
  --t-2: #8c8778;     /* meta */
  --t-3: #5a5648;     /* muted */
  --t-4: #403c30;     /* very muted */

  /* Accents */
  --a-phosphor: #59d185;   /* primary: phosphor green */
  --a-phosphor-dim: #2d7a4f;
  --a-amber: #f0b340;      /* secondary: amber */
  --a-amber-dim: #8c6120;
  --a-red: #ec5e5e;        /* error */
  --a-cyan: #64c9d9;       /* info */

  /* Typography */
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, 'Menlo', monospace;
  --font-sans: 'IBM Plex Sans', -apple-system, 'Helvetica Neue', sans-serif;
  --font-cond: 'IBM Plex Sans Condensed', var(--font-sans);

  /* Sizing */
  --radius: 3px;
  --radius-lg: 5px;
  --border-w: 1px;

  /* Motion */
  --ease: cubic-bezier(.2, .6, .3, 1);
  --dur: 180ms;
}

/* =============================================================
   Reset / defaults
   ============================================================= */

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  background: var(--s-1);
  color: var(--t-0);
  /* subtle scan-line / grain effect */
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(89, 209, 133, 0.04), transparent 60%),
    repeating-linear-gradient(
      0deg,
      transparent 0,
      transparent 3px,
      rgba(255, 255, 255, 0.008) 3px,
      rgba(255, 255, 255, 0.008) 4px
    );
  min-height: 100vh;
  overflow-x: hidden;
}

code, kbd, pre {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--s-0);
  color: var(--a-phosphor);
  padding: 1px 5px;
  border-radius: var(--radius);
}

kbd {
  color: var(--t-1);
  border: 1px solid var(--s-4);
  box-shadow: 0 1px 0 var(--s-4);
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
}

/* =============================================================
   Masthead
   ============================================================= */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: var(--border-w) solid var(--s-4);
  background: var(--s-0);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.wordmark {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
  user-select: none;
  display: flex;
  gap: 2px;
  align-items: baseline;
}

.wordmark__bracket {
  color: var(--t-3);
}
.wordmark__name {
  color: var(--a-phosphor);
}
.wordmark__sep {
  color: var(--t-3);
  margin: 0 2px;
}
.wordmark__tag {
  color: var(--t-1);
}

.masthead__meta {
  display: flex;
  gap: 10px;
  align-items: center;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--t-2);
  padding: 4px 10px;
  background: var(--s-2);
  border: var(--border-w) solid var(--s-4);
  border-radius: 100px;
}

.status-pill--privacy {
  color: var(--a-phosphor);
  border-color: var(--a-phosphor-dim);
  background: rgba(89, 209, 133, 0.06);
}

.status-pill__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--a-phosphor);
  box-shadow: 0 0 6px var(--a-phosphor);
  flex-shrink: 0;
}

.status-pill__dot--loading {
  background: var(--a-amber);
  box-shadow: 0 0 6px var(--a-amber);
  animation: pulse 1.2s var(--ease) infinite;
}

.status-pill--ready .status-pill__dot {
  background: var(--a-phosphor);
  box-shadow: 0 0 6px var(--a-phosphor);
  animation: none;
}

.status-pill--error .status-pill__dot {
  background: var(--a-red);
  box-shadow: 0 0 6px var(--a-red);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* =============================================================
   Main layout
   ============================================================= */

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 420px) 1fr;
  gap: 1px;
  background: var(--s-4);
  min-height: calc(100vh - 54px - 28px); /* minus masthead and statusbar */
}

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

.panel {
  background: var(--s-1);
  padding: 22px 24px 32px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel--inputs {
  background: var(--s-1);
}

.panel--results {
  background: var(--s-0);
  position: relative;
}

.panel__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: var(--border-w) solid var(--s-4);
}

.panel__label {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--a-phosphor);
}

.panel__hint {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--t-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* =============================================================
   Form fields
   ============================================================= */

.field {
  margin-bottom: 22px;
}

.field__label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--t-1);
  margin-bottom: 8px;
}

.field__label-aside {
  color: var(--t-3);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 6px;
  font-size: 11px;
}

.field__help {
  font-size: 12px;
  color: var(--t-2);
  margin: 8px 0 0;
  line-height: 1.55;
}

/* --- Select --- */

.select-wrap {
  position: relative;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 10px 36px 10px 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--s-2);
  color: var(--t-0);
  border: var(--border-w) solid var(--s-4);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease);
}

.select:focus {
  outline: none;
  border-color: var(--a-phosphor);
  box-shadow: 0 0 0 3px rgba(89, 209, 133, 0.12);
}

.select__chevron {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--t-2);
}

/* --- Dropzone --- */

.dropzone {
  position: relative;
  border: 1px dashed var(--s-5);
  background: var(--s-2);
  border-radius: var(--radius);
  padding: 18px 16px;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}

.dropzone:hover {
  border-color: var(--t-3);
  background: var(--s-3);
}

.dropzone--dragover {
  border-color: var(--a-phosphor);
  background: rgba(89, 209, 133, 0.06);
  border-style: solid;
}

.dropzone--loaded {
  border-color: var(--a-phosphor-dim);
  border-style: solid;
  background: rgba(89, 209, 133, 0.04);
}

.dropzone__input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone__content {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  pointer-events: none;
}

.dropzone__icon {
  color: var(--t-3);
  flex-shrink: 0;
  transition: color var(--dur) var(--ease);
}

.dropzone--loaded .dropzone__icon {
  color: var(--a-phosphor);
}

.dropzone__text {
  flex: 1;
  min-width: 0;
}

.dropzone__title {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--t-0);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropzone__subtitle {
  font-size: 11px;
  color: var(--t-3);
  font-family: var(--font-mono);
  margin-top: 2px;
  letter-spacing: 0.02em;
}

.dropzone--loaded .dropzone__subtitle {
  color: var(--a-phosphor);
}

.dropzone__clear {
  pointer-events: auto;
  background: transparent;
  border: 1px solid var(--s-5);
  color: var(--t-2);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  transition: all var(--dur) var(--ease);
  flex-shrink: 0;
}

.dropzone__clear:hover {
  color: var(--t-0);
  border-color: var(--a-red);
  background: rgba(236, 94, 94, 0.08);
}

/* --- Tabs --- */

.tab-group {
  display: flex;
  gap: 1px;
  background: var(--s-4);
  padding: 1px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  width: fit-content;
}

.tab {
  padding: 5px 14px;
  background: var(--s-2);
  border: none;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--t-2);
  border-radius: calc(var(--radius) - 1px);
  transition: all var(--dur) var(--ease);
}

.tab:hover:not(.tab--active) {
  color: var(--t-0);
  background: var(--s-3);
}

.tab--active {
  background: var(--s-0);
  color: var(--a-phosphor);
}

.tab-panel[hidden] {
  display: none;
}

.paste-input {
  width: 100%;
  min-height: 140px;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  background: var(--s-0);
  color: var(--a-phosphor);
  border: var(--border-w) solid var(--s-4);
  border-radius: var(--radius);
  resize: vertical;
  tab-size: 4;
}

.paste-input:focus {
  outline: none;
  border-color: var(--a-phosphor);
  box-shadow: 0 0 0 3px rgba(89, 209, 133, 0.12);
}

.paste-input::placeholder {
  color: var(--t-3);
}

/* =============================================================
   Actions
   ============================================================= */

.actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: transparent;
  color: var(--t-1);
  border: var(--border-w) solid var(--s-5);
  border-radius: var(--radius);
  transition: all var(--dur) var(--ease);
}

.btn:hover:not(:disabled) {
  border-color: var(--t-2);
  color: var(--t-0);
  background: var(--s-2);
}

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

.btn--primary {
  background: var(--a-phosphor);
  color: var(--s-0);
  border-color: var(--a-phosphor);
  font-weight: 600;
  flex: 1;
}

.btn--primary:hover:not(:disabled) {
  background: #6fe09a;
  border-color: #6fe09a;
  color: var(--s-0);
  box-shadow: 0 0 12px rgba(89, 209, 133, 0.35);
}

.btn--primary:disabled {
  background: var(--s-3);
  color: var(--t-3);
  border-color: var(--s-4);
}

.btn--ghost {
  background: transparent;
}

.btn__key {
  padding: 1px 6px;
  background: rgba(0, 0, 0, 0.2);
  color: inherit;
  border-radius: 2px;
  font-size: 10px;
  opacity: 0.7;
}

.btn--primary .btn__key {
  background: rgba(0, 0, 0, 0.15);
}

/* =============================================================
   Results
   ============================================================= */

.results-empty {
  text-align: center;
  padding: 80px 20px;
  margin: auto;
  max-width: 440px;
}

.results-empty__glyph {
  color: var(--t-4);
  margin-bottom: 24px;
}

.results-empty__title {
  font-family: var(--font-cond);
  font-size: 24px;
  font-weight: 500;
  margin: 0 0 12px;
  color: var(--t-1);
  letter-spacing: -0.01em;
}

.results-empty__body {
  color: var(--t-2);
  line-height: 1.65;
  font-size: 13px;
}

.results {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.stats {
  display: grid;
  grid-template-columns: auto auto 1fr 1fr;
  gap: 1px;
  background: var(--s-4);
  border: var(--border-w) solid var(--s-4);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}

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

.stat {
  padding: 12px 16px;
  background: var(--s-2);
  min-width: 0;
}

.stat__label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--t-2);
  margin-bottom: 4px;
}

.stat__value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  color: var(--a-phosphor);
  line-height: 1.1;
}

.stat__value--text {
  font-size: 13px;
  color: var(--t-0);
  font-weight: 400;
  word-break: break-word;
}

.stat__unit {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--t-3);
  margin-top: 2px;
  letter-spacing: 0.05em;
}

.download-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.download-row .btn--primary {
  flex: 0 0 auto;
}

.download-row__meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--t-2);
  letter-spacing: 0.04em;
}

.preview {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  border: var(--border-w) solid var(--s-4);
  border-radius: var(--radius);
  background: var(--s-1);
  overflow: hidden;
}

.preview__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 14px;
  border-bottom: var(--border-w) solid var(--s-4);
  background: var(--s-2);
}

.preview__title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--t-1);
}

.preview__note {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--t-3);
}

.preview__scroll {
  overflow: auto;
  min-height: 0;
  flex: 1;
  max-height: 60vh;
}

.preview__table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 11px;
}

.preview__table th,
.preview__table td {
  padding: 5px 10px;
  text-align: left;
  border-bottom: 1px solid var(--s-3);
  white-space: nowrap;
  vertical-align: top;
}

.preview__table th {
  position: sticky;
  top: 0;
  background: var(--s-2);
  color: var(--a-amber);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 10px;
  border-bottom: 1px solid var(--s-4);
  z-index: 1;
}

.preview__table tr:hover td {
  background: var(--s-2);
}

.preview__table td {
  color: var(--t-1);
}

.preview__table td:first-child {
  color: var(--t-3);
  font-size: 10px;
}

.preview__table .cell--report-alert {
  color: var(--a-amber);
}

.preview__table .cell--report-status {
  color: var(--a-phosphor);
}

.preview__table .cell--warn {
  color: var(--a-red);
}

/* =============================================================
   Error view
   ============================================================= */

.error {
  border: var(--border-w) solid var(--a-red);
  background: rgba(236, 94, 94, 0.05);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.error__header {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--a-red);
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}

.error__body {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--t-1);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* =============================================================
   Status bar
   ============================================================= */

.statusbar {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 20px;
  padding: 6px 24px;
  background: var(--s-0);
  border-top: var(--border-w) solid var(--s-4);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--t-2);
  letter-spacing: 0.04em;
  z-index: 10;
}

.statusbar__group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.statusbar__group--right {
  margin-left: auto;
}

.statusbar__key {
  color: var(--t-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.statusbar__val {
  color: var(--t-1);
}

/* =============================================================
   Reduced-motion
   ============================================================= */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print: hide nonessential chrome */
@media print {
  .masthead, .statusbar, .actions, .download-row, .dropzone, .tab-group { display: none; }
}
