:root {
  --main-bg: #191b22;
  --box-bg: #23242a;
  --accent: #6366f1;
  --accent2: #23242a;
  --border: #353743;
  --text: #f3f4fa;
  --btn-bg: #6366f1;
  --btn-bg-2: #292b34;
  --btn-text: #fff;
  --btn-border: #6366f1;
  --preview-bg: #15161a;
}
body {
  background: var(--main-bg);
  color: var(--text);
  font-family: 'Segoe UI', Arial, sans-serif;
  margin: 0;
  padding: 0;
}
.theme-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--box-bg);
  padding: 18px 4vw 12px 4vw;
  font-size: 1.1em;
  border-bottom: 1.5px solid var(--border);
}
.theme-select {
  font-size: 1em;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--box-bg);
  color: var(--text);
}
.tab-btn {
  background: var(--btn-bg-2);
  color: var(--text);
  border: none;
  border-bottom: 2.5px solid transparent;
  font-size: 1em;
  font-family: inherit;
  padding: 9px 18px;
  border-radius: 7px 7px 0 0;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border 0.15s;
}
.tab-btn.active {
  background: var(--box-bg);
  color: var(--accent);
  border-bottom: 2.5px solid var(--accent);
  font-weight: 600;
}
.custom-template-label {
  margin-left: 25px;
  font-size: 0.98em;
  color: #ccc;
  cursor: pointer;
  padding: 4px 16px;
  border-radius: 8px;
  border: 1px dotted var(--border);
  transition: color 0.2s, border 0.2s;
}
.custom-template-label:hover { color: var(--accent); border: 1px solid var(--accent); }
.main-flex {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 32px;
  max-width: 1380px;
  margin: 0 auto;
  padding-top: 18px;
}
.form-section {
  flex: 0 0 410px;
  min-width: 340px;
  background: var(--box-bg);
  border-radius: 16px;
  box-shadow: 0 4px 32px #0006;
  padding: 28px 26px 22px 26px;
  margin-bottom: 36px;
  max-width: 430px;
}
#generator-section { display: block; }
#preview-section { display: none; }
form fieldset {
  border: none;
  margin-bottom: 18px;
  padding: 0 0 10px 0;
}
form legend {
  font-weight: 500;
  color: var(--accent);
  font-size: 1.1em;
  margin-bottom: 8px;
  margin-top: 4px;
}
input[type="text"], input[type="date"], input[type="number"], textarea {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 7px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 1em;
  background: var(--box-bg);
  color: var(--text);
  transition: border-color 0.2s;
  box-sizing: border-box;
  resize: none;
  outline: none;
}
input[type="text"]:focus, input[type="date"]:focus, input[type="number"]:focus, textarea:focus {
  border-color: var(--accent);
}
textarea { min-height: 44px; max-width: 100%; }
#logo-preview { max-width: 92px; max-height: 52px; display: none; border-radius: 7px; margin: 4px 0 7px 0;}
.theme-btn {
  background: var(--btn-bg);
  color: var(--btn-text);
  border: none;
  padding: 8px 18px;
  border-radius: 9px;
  font-size: 1em;
  font-family: inherit;
  cursor: pointer;
  font-weight: 500;
  margin-right: 7px;
  margin-bottom: 3px;
  transition: background 0.15s, color 0.15s;
}
.theme-btn.secondary {
  background: var(--btn-bg-2);
  color: var(--accent);
  border: 1.5px solid var(--btn-border);
}
.theme-btn.main-btn {
  width: 100%;
  margin-top: 11px;
  font-size: 1.08em;
  font-weight: 700;
}
.theme-btn:hover, .theme-btn:focus {
  background: #373b71;
  color: #fff;
}
.theme-btn.secondary:hover, .theme-btn.secondary:focus {
  background: #353743;
  color: #a5b4fc;
}
.toggle-row {
  display: inline-block;
  margin-right: 16px;
  margin-bottom: 5px;
  color: #ccc;
}
#items { margin-bottom: 8px; }
.item-row {
  display: flex;
  gap: 6px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}
.item-name { flex: 2; }
.item-price, .item-qty, .item-status, .item-status-custom { flex: 1; }
.remove-item { background: #e53e3e; color: #fff; border: none; font-size: 1.22em; width: 32px; border-radius: 7px; }
.remove-item:hover { background: #b91c1c;}
.tax-row, .discount-row { margin-top: 8px; }
.manual-total-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
#manual-warning { color: #e53e3e; display: none; font-size: 0.95em; }
.preview-section {
  flex: 1 1 0;
  min-width: 340px;
  max-width: 650px;
  background: var(--preview-bg);
  border-radius: 18px;
  box-shadow: 0 4px 32px #0006;
  margin-bottom: 36px;
  margin-right: 25px;
  padding: 18px 18px 18px 18px;
  min-height: 740px;
  overflow-x: auto;
}
.invoice-preview {
  width: 100%;
  min-height: 600px;
  background: var(--box-bg);
  border-radius: 16px;
  box-shadow: 0 2px 12px #0003;
  padding: 26px 19px 29px 19px;
  box-sizing: border-box;
  overflow-x: auto;
  max-width: 100%;
  word-break: break-word;
  color: var(--text);
}
.invoice-preview * { box-sizing: border-box; }
@media (max-width: 1100px) {
  .main-flex { flex-direction: column; gap: 18px; }
  .form-section, .preview-section { margin-right: 0;}
  .preview-section { margin-bottom: 0;}
}
@media (max-width: 700px) {
  .main-flex { padding-top: 7px; }
  .form-section, .preview-section { padding: 11px 4px; border-radius: 0; box-shadow: none;}
  .preview-section { min-height: 400px; }
}
