/* ═══════════════════════════════════════════════
   APP SHELL — Login, Dashboard, Preview
   ═══════════════════════════════════════════════ */

:root {
  --sh-bg: #0d0d0d;
  --sh-surface: #161616;
  --sh-elevated: #1e1e1e;
  --sh-border: rgba(255,255,255,0.07);
  --sh-text: #d0d0d0;
  --sh-muted: #777;
  --sh-accent: #2aa198;
  --sh-accent2: #239089;
  --sh-danger: #dc322f;
  --sh-radius: 10px;
  --sidebar-w: 320px;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--sh-bg);
  color: var(--sh-text);
  height: 100vh;
  overflow: hidden;
}

/* ── Screens ── */
.screen { display: none; width: 100vw; height: 100vh; }
.screen.active { display: flex; }

/* ════════════════════════════════
   LOGIN
   ════════════════════════════════ */
#screen-login {
  align-items: center;
  justify-content: center;
  background: var(--sh-bg);
}

.login-card {
  width: 360px;
  background: var(--sh-surface);
  border: 1px solid var(--sh-border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  text-align: center;
}

.login-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(42,161,152,0.1);
  border: 1px solid rgba(42,161,152,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
}

.login-icon svg { width: 22px; height: 22px; fill: var(--sh-accent); }

.login-card h1 {
  font-family: 'Outfit', system-ui, sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.25rem;
}

.login-card .login-sub {
  font-size: 0.75rem;
  color: var(--sh-muted);
  margin-bottom: 1.75rem;
}

.login-card input {
  width: 100%;
  background: var(--sh-elevated);
  border: 1px solid var(--sh-border);
  color: #fff;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  margin-bottom: 0.75rem;
}

.login-card input:focus { border-color: var(--sh-accent); }

.login-card .login-btn {
  width: 100%;
  background: var(--sh-accent);
  color: #fff;
  border: none;
  padding: 0.7rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.login-card .login-btn:hover { background: var(--sh-accent2); }

.login-error {
  font-size: 0.75rem;
  color: var(--sh-danger);
  min-height: 1.2em;
  margin-top: 0.5rem;
}

/* ════════════════════════════════
   DASHBOARD
   ════════════════════════════════ */
#screen-dashboard { flex-direction: row; }

.dash-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sh-surface);
  border-right: 1px solid var(--sh-border);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.dash-sidebar-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--sh-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dash-sidebar-header h1 {
  font-family: 'Outfit', system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.dash-sidebar-header .btn-logout {
  background: none;
  border: 1px solid var(--sh-border);
  color: var(--sh-muted);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-size: 0.65rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.dash-sidebar-header .btn-logout:hover { border-color: var(--sh-danger); color: var(--sh-danger); }

.dash-sidebar-body { padding: 1.25rem; flex: 1; overflow-y: auto; }

.section-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sh-muted);
  margin-bottom: 0.6rem;
  margin-top: 1.25rem;
}

.section-label:first-child { margin-top: 0; }

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--sh-border);
  border-radius: var(--sh-radius);
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(255,255,255,0.015);
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--sh-accent);
  background: rgba(42,161,152,0.04);
}

.drop-zone.has-file { border-color: var(--sh-accent); border-style: solid; }

.drop-zone svg { width: 28px; height: 28px; fill: var(--sh-muted); margin-bottom: 0.5rem; }
.drop-zone.has-file svg { fill: var(--sh-accent); }

.drop-zone .drop-label {
  font-size: 0.8rem;
  color: var(--sh-muted);
  margin-bottom: 0.15rem;
}

.drop-zone .drop-hint {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.3);
}

.drop-zone .file-name {
  font-size: 0.75rem;
  color: var(--sh-accent);
  font-weight: 600;
  margin-top: 0.35rem;
  display: none;
}

.drop-zone.has-file .file-name { display: block; }
.drop-zone.has-file .drop-hint { display: none; }

/* Form */
.form-group { margin-bottom: 0.75rem; }
.form-group label { display: block; font-size: 0.7rem; color: var(--sh-muted); margin-bottom: 0.25rem; }
.form-group input {
  width: 100%;
  background: var(--sh-elevated);
  border: 1px solid var(--sh-border);
  color: #fff;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus { border-color: var(--sh-accent); }
.language-label { display: block; font-size: 0.7rem; color: var(--sh-muted); margin-bottom: 0.25rem; }
.language-switch {
  display: inline-flex;
  width: 100%;
  padding: 3px;
  border: 1px solid var(--sh-border);
  border-radius: 7px;
  background: var(--sh-elevated);
}
.language-option {
  flex: 1;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--sh-muted);
  padding: 0.4rem 0.5rem;
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}
.language-option:hover { color: var(--sh-text); }
.language-option.is-active {
  color: #fff;
  background: var(--sh-accent);
  box-shadow: 0 1px 5px rgba(0,0,0,0.25);
}
.language-option:focus-visible { outline: 2px solid var(--sh-accent); outline-offset: 1px; }

/* Main grid area */
.dash-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  overflow-y: auto;
}

.dashboard-actions {
  width: 100%;
  max-width: 900px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.dashboard-export-all {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  background: var(--sh-elevated);
  border: 1px solid var(--sh-border);
  color: var(--sh-text);
  padding: 0.7rem 1rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.dashboard-export-all:hover:not(:disabled) { border-color: var(--sh-accent); color: var(--sh-accent); }
.dashboard-export-all:disabled { cursor: not-allowed; opacity: 0.45; }
.dashboard-export-all svg { width: 14px; height: 14px; }
.dashboard-actions-hint { color: var(--sh-muted); font-size: 0.7rem; line-height: 1.4; text-align: right; }

@media (max-width: 760px) {
  .dashboard-actions { align-items: stretch; flex-direction: column; }
  .dashboard-export-all { width: 100%; }
  .dashboard-actions-hint { text-align: center; }
}

.grid-empty {
  text-align: center;
  color: var(--sh-muted);
  max-width: 300px;
}

.grid-empty svg { width: 48px; height: 48px; fill: rgba(255,255,255,0.08); margin-bottom: 1rem; }
.grid-empty p { font-size: 0.85rem; line-height: 1.5; }

/* Preview Grid */
#preview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  max-width: 900px;
  width: 100%;
}

#preview-grid:not(.has-content) { display: none; }
#preview-grid.has-content + .grid-empty { display: none; }

.grid-card {
  cursor: pointer;
  border-radius: var(--sh-radius);
  overflow: hidden;
  border: 1px solid var(--sh-border);
  background: var(--sh-surface);
  transition: all 0.2s;
}

.grid-card:hover {
  border-color: var(--sh-accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

.grid-preview {
  height: 280px;
  overflow: hidden;
  position: relative;
}

.grid-preview .report-content {
  transform: scale(0.3);
  transform-origin: top left;
  width: 333%;
  pointer-events: none;
}

.grid-preview.view-mobile .report-content {
  transform: scale(0.35);
  width: 285%;
}

.grid-label {
  padding: 0.65rem 0.85rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--sh-text);
  border-top: 1px solid var(--sh-border);
  text-align: center;
}

/* ════════════════════════════════
   PREVIEW SCREEN
   ════════════════════════════════ */
#screen-preview { flex-direction: row; }

.preview-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--sh-surface);
  border-right: 1px solid var(--sh-border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
}

.preview-sidebar .btn-back {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: 1px solid var(--sh-border);
  color: var(--sh-text);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: 1.5rem;
  transition: all 0.15s;
}

.preview-sidebar .btn-back:hover { border-color: var(--sh-accent); color: var(--sh-accent); }
.preview-sidebar .btn-back svg { width: 14px; height: 14px; fill: currentColor; }

.preview-variant-name {
  font-family: 'Outfit', system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.25rem;
}

.preview-variant-sub {
  font-size: 0.7rem;
  color: var(--sh-muted);
  margin-bottom: auto;
}

.preview-sidebar .btn-print {
  width: 100%;
  background: var(--sh-accent);
  color: #fff;
  border: none;
  padding: 0.7rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: background 0.15s;
}

.preview-sidebar .btn-print:hover { background: var(--sh-accent2); }
.preview-sidebar .btn-print:disabled {
  cursor: wait;
  opacity: 0.65;
}
.preview-sidebar .btn-print svg { width: 14px; height: 14px; fill: currentColor; }

.preview-instructions {
  font-size: 0.65rem;
  color: var(--sh-muted);
  line-height: 1.5;
  margin-top: 0.75rem;
  padding: 0.65rem;
  border: 1px dashed var(--sh-border);
  border-radius: 6px;
}
.preview-instructions strong { color: var(--sh-text); }

.preview-main {
  flex: 1;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem;
  background: #0a0a0a;
}

.preview-wrapper {
  width: 100%;
  transition: all 0.25s;
}

.preview-wrapper.view-pc {
  max-width: 820px;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

.preview-wrapper.view-mobile {
  max-width: 390px;
  height: 844px;
  border-radius: 28px;
  border: 6px solid #2a2a2a;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.04), 0 20px 60px rgba(0,0,0,0.6);
  margin: 0 auto;
}

.preview-wrapper.view-mobile::-webkit-scrollbar { width: 3px; }
.preview-wrapper.view-mobile::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* ════════════════════════════════
   PRINT OVERRIDES
   ════════════════════════════════ */
@media print {
  body { overflow: visible !important; background: none !important; height: auto !important; }
  .screen { display: none !important; }
  #screen-preview { display: flex !important; }
  .preview-sidebar { display: none !important; }
  .preview-main {
    padding: 0 !important;
    background: none !important;
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }
  .preview-wrapper {
    box-shadow: none !important;
    border: none !important;
    margin: 0 !important;
    height: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
    border-radius: 0 !important;
  }
}
