:root {
  --bg: #f3f4f6;
  --sidebar: #ffffff;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #059669;
  --error: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef2ff, #f8fafc);
}

.auth-card {
  width: min(420px, 100%);
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.12);
}

.auth-card .logo {
  margin-bottom: 20px;
}

.auth-card h1 {
  margin: 0 0 8px;
}

.auth-card p {
  margin: 0 0 18px;
  color: var(--muted);
}

.auth-card label {
  display: block;
  margin: 12px 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.auth-card input {
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font: inherit;
}

.auth-submit {
  width: 100%;
  margin: 18px 0 0;
  text-align: center;
}

.auth-error {
  min-height: 22px;
  margin-top: 12px !important;
  color: var(--error) !important;
  font-weight: 700;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 2rem 0;
  display: flex;
  flex-direction: column;
}

.logo {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
  margin-bottom: 2rem;
}

.demo-user {
  width: calc(100% - 40px);
  margin: 0 20px 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #eff6ff;
  font-size: 13px;
  font-weight: 700;
  color: #1e40af;
}

.demo-user div + div {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 600;
}

.demo-user .quota-warn,
.quota-warn {
  color: #b45309 !important;
}

.btn {
  display: block;
  width: calc(100% - 40px);
  margin: 0 20px 10px;
  padding: 14px 16px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: #f1f5f9;
  color: var(--text);
  border: 1px solid transparent;
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.file-label {
  cursor: pointer;
}

.settings-panel {
  width: calc(100% - 40px);
  margin: 0 20px 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
}

.settings-panel summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.settings-panel label {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.settings-panel input,
.settings-panel textarea {
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font: 12px "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: #fff;
}

.settings-panel textarea {
  resize: vertical;
}

.settings-panel .csv-import-label {
  display: block;
  margin-top: 6px;
  padding: 8px;
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  color: var(--accent);
  background: #fff;
  text-align: center;
  cursor: pointer;
}

.mini-btn {
  width: 100%;
  margin-top: 8px;
  padding: 9px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: var(--accent);
  font: 12px "Segoe UI", system-ui, sans-serif;
  font-weight: 800;
  cursor: pointer;
}

.btn-export.btn-word {
  background: #eff6ff;
  color: #1e40af;
}
.btn-export.btn-excel {
  background: #ecfdf5;
  color: #047857;
}
.btn-export.btn-td {
  background: #fff7ed;
  color: #9a3412;
}
.btn-export.btn-norm {
  background: #f5f3ff;
  color: #6d28d9;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid #cbd5e1;
}

.logout-btn {
  margin-top: 8px;
}

.btn-ghost:hover {
  background: #f1f5f9;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  color: #9ca3af;
  margin: 28px 20px 8px;
}

.main {
  flex: 1;
  padding: 30px;
  min-width: 0;
}

.title {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 700;
}

.status {
  margin: 0 0 20px;
  font-size: 15px;
  color: var(--muted);
}

.progress {
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  margin-bottom: 16px;
  overflow: hidden;
}

.progress.hidden {
  display: none;
}

.progress-bar {
  height: 100%;
  width: 40%;
  background: var(--accent);
  animation: indet 1s ease-in-out infinite;
}

@keyframes indet {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(350%);
  }
}

.content {
  display: flex;
  gap: 20px;
  align-items: stretch;
  min-height: 520px;
}

.preview-card {
  width: 520px;
  flex-shrink: 0;
}

.tabs-card {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 15px;
  overflow: hidden;
}

.preview-wrap {
  min-height: 480px;
  padding: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  overflow: auto;
}

.preview-placeholder {
  color: #9ca3af;
}

#previewImg {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 0.05s ease-out;
}

.hidden {
  display: none !important;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  justify-content: flex-end;
}

.drawer-panel {
  width: min(760px, 100%);
  height: 100%;
  overflow: auto;
  background: #fff;
  border-left: 1px solid var(--border);
  box-shadow: -24px 0 70px rgba(15, 23, 42, 0.18);
}

.drawer-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.drawer-head h2 {
  margin: 0;
}

.drawer-close {
  border: 0;
  background: transparent;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

#drawerContent {
  padding: 20px 22px 32px;
}

.drawer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.drawer-table th,
.drawer-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.drawer-table tbody tr {
  cursor: pointer;
}

.drawer-table tbody tr:hover {
  background: #f8fafc;
}

.drawer-table tbody tr.loading {
  opacity: 0.55;
  pointer-events: none;
}

.drawer-label {
  display: block;
  margin: 14px 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.drawer-label input,
.drawer-label textarea,
.admin-toolbar input,
.admin-toolbar select,
.admin-form input {
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font: 13px "Segoe UI", system-ui, sans-serif;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.chip {
  padding: 7px 10px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
  color: #1e40af;
  font: 12px "Segoe UI", system-ui, sans-serif;
  font-weight: 700;
  cursor: pointer;
}

.drawer-item {
  padding: 10px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}

.admin-toolbar,
.admin-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.import-label {
  display: block;
  text-align: center;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px 10px 0;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 10px 14px;
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  font-family: inherit;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent);
  background: #f8fafc;
}

.tab-panels {
  flex: 1;
  min-height: 400px;
}

.tab-panel {
  display: none;
  height: 100%;
  min-height: 400px;
}

.tab-panel.active {
  display: block;
}

.text-out {
  margin: 0;
  padding: 16px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 400px;
  max-height: 70vh;
  overflow: auto;
}

.text-tech {
  color: #1e40af;
  background: #fff;
}

.text-otk {
  color: #9a3412;
  background: #fff7ed;
}

.text-glossary {
  color: #0369a1;
  background: #f0f9ff;
  font-size: 13px;
}

.text-economics {
  color: #166534;
  background: #f0fdf4;
  font-size: 14px;
}

.text-logs {
  color: var(--muted);
  background: #f9fafb;
  font-size: 12px;
}

.tag-error {
  color: var(--error);
}

.tag-warning {
  color: #f59e0b;
}

.tag-critical {
  color: #b91c1c;
}

.tag-it6 {
  background: #fef3c7;
  color: #92400e;
}

.tag-dfr {
  color: #7c3aed;
}

@media (max-width: 1100px) {
  .content {
    flex-direction: column;
  }
  .preview-card {
    width: 100%;
  }
  .admin-toolbar,
  .admin-form {
    grid-template-columns: 1fr;
  }
}
