:root {
  --bg-base: #0a0e17;
  --bg-card: #111827;
  --bg-elevated: #1a2234;
  --primary: #10b981;
  --primary-glow: rgba(16, 185, 129, 0.35);
  --primary-dark: #059669;
  --cyan: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.3);
  --rose: #f43f5e;
  --amber: #f59e0b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: #10b981;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-main);
  min-height: 100vh;
  padding: 24px;
  background-image: 
    radial-gradient(at 0% 0%, rgba(6, 182, 212, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(16, 185, 129, 0.08) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(15, 23, 42, 0.6) 0px, transparent 50%);
  background-attachment: fixed;
}

.app-layout {
  max-width: 1100px;
  margin: 0 auto;
}

/* Header Card */
.header-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 24px;
  margin-bottom: 24px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
  flex-wrap: wrap;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px var(--primary-glow);
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand h1 span {
  color: var(--primary);
}

.subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Status Pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-online {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-offline {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.status-checking {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Main Grid */
.main-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 24px;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.card-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.badge {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  font-family: var(--font-mono);
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-cyan {
  background: rgba(6, 182, 212, 0.15);
  color: #38bdf8;
  border-color: rgba(6, 182, 212, 0.25);
}

/* Form Elements */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.input-text, .input-select {
  width: 100%;
  background: #0d131f;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  outline: none;
  transition: all 0.2s;
}

.input-text:focus, .input-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Scanner Platen */
.platen-wrapper {
  display: flex;
  justify-content: center;
  margin: 12px 0 14px;
}

.scanner-platen {
  width: 200px;
  height: 260px;
  border-radius: 20px;
  background: linear-gradient(180deg, #0d1424 0%, #080c14 100%);
  border: 2px solid rgba(255, 255, 255, 0.12);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: inset 0 2px 10px rgba(255, 255, 255, 0.05), 0 10px 25px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: all 0.3s;
}

.scanner-platen.scanning {
  border-color: #10b981;
  box-shadow: 0 0 30px var(--primary-glow), inset 0 0 20px var(--primary-glow);
}

.laser-beam {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #06b6d4, #10b981, #06b6d4, transparent);
  box-shadow: 0 0 15px #06b6d4, 0 0 25px #10b981;
  animation: laserScan 1.8s infinite alternate ease-in-out;
  z-index: 10;
}

@keyframes laserScan {
  0% { top: 2%; opacity: 0.8; }
  50% { opacity: 1; }
  100% { top: 96%; opacity: 0.8; }
}

.platen-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.scanned-image {
  max-width: 90%;
  max-height: 90%;
  border-radius: 12px;
  object-fit: contain;
  transition: transform 0.25s ease, filter 0.25s ease;
}

.quality-badge {
  position: absolute;
  bottom: 8px;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(16, 185, 129, 0.4);
  font-size: 0.7rem;
  color: #34d399;
  font-family: var(--font-mono);
  z-index: 12;
}

/* Custom Sizing & Tooling Bar */
.custom-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0a0e17;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.btn-group {
  display: flex;
  gap: 2px;
  background: var(--bg-card);
  padding: 2px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.btn-tool {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.15s;
}

.btn-tool:hover {
  color: var(--text-main);
}

.btn-tool.active {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

/* Status Banner */
.scan-status-banner {
  padding: 8px 14px;
  background: #0a0e17;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 18px;
}

/* Buttons */
.button-row {
  display: flex;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.btn-primary {
  flex: 1;
  padding: 12px 18px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  transform: translateY(-1px);
}

.btn-secondary {
  padding: 12px 16px;
  background: var(--bg-elevated);
  color: var(--text-main);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: #232e46;
}

.btn-save {
  width: 100%;
  padding: 12px 18px;
  background: linear-gradient(135deg, #06b6d4 0%, #0284c7 100%);
  color: white;
  box-shadow: 0 4px 14px var(--cyan-glow);
  font-size: 0.95rem;
}

.btn-save:hover:not(:disabled) {
  background: linear-gradient(135deg, #38bdf8 0%, #06b6d4 100%);
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-refresh {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-refresh:hover {
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Preview Info Box */
.preview-info-box {
  background: #0a0e17;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.8rem;
}

.info-item {
  display: flex;
  justify-content: space-between;
}

.info-label {
  color: var(--text-muted);
}

/* Toast Alert */
.toast-alert {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  border: 1px solid transparent;
}

.toast-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.toast-error {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border-color: rgba(244, 63, 94, 0.3);
}

/* Table */
.table-container {
  overflow-x: auto;
  margin-top: 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.data-table th {
  padding: 12px 14px;
  background: #0a0e17;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.table-empty {
  text-align: center;
  padding: 32px !important;
  color: var(--text-muted);
}

.table-thumb {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  object-fit: cover;
  background: #0a0e17;
  border: 1px solid var(--border);
}

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-delete:hover {
  color: #fb7185;
  border-color: rgba(244, 63, 94, 0.4);
}

/* Footer */
.app-footer {
  margin-top: 32px;
  text-align: center;
  font-size: 0.75rem;
  color: #64748b;
}

.app-footer code {
  color: var(--cyan);
  font-family: var(--font-mono);
}
