:root {
  --bg: #f5f7fb;
  --panel: #fff;
  --panel-soft: #f9fafc;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d9dee8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #15803d;
  --shadow: 0 10px 30px rgb(31 41 55 / 8%);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 12px;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 20px;
}

h2 {
  font-size: 15px;
}

h3 {
  font-size: 13px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 6px 10px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  background: var(--accent-hover);
}

button.secondary {
  background: #e5e7eb;
  color: var(--text);
}

button.secondary:hover {
  background: #d1d5db;
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: var(--danger-hover);
}

button.small {
  padding: 4px 7px;
  border-radius: 8px;
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px 7px;
  background: white;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 12%);
}

input[readonly] {
  background: #f3f4f6;
  color: #374151;
  cursor: default;
}

.copy-field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.copy-field-row button {
  height: 100%;
  min-height: 31px;
}

.copy-field-row button.copied,
.icon-copy-button.copied {
  color: var(--success);
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.input-copy-inside {
  position: relative;
}

.input-copy-inside input {
  padding-right: 42px;
}

.inside-copy-button {
  position: absolute;
  top: 50%;
  right: 4px;
  width: 28px;
  min-width: 28px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  transform: translateY(-50%);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1;
}

.inside-copy-button.copied {
  color: var(--success);
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.inside-copy-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.icon-copy-button {
  width: 28px;
  min-width: 28px;
  height: 28px;
  padding: 0;
  line-height: 1;
  font-size: 14px;
}

.icon-copy-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.calculated-with-copy {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px;
  align-items: center;
}

.ilp-copy-row .icon-copy-button {
  min-height: 31px;
}


textarea {
  min-height: 180px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.app {
  max-width: 1600px;
  margin: 0 auto;
}

body.local-currency-layout-enabled .app {
  max-width: 1800px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.language-toggle {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
}

#countryPanel {
  max-width: 800px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  margin-bottom: 10px;
}

.settings-panel {
  display: none;
}

.settings-panel.open {
  display: block;
}

.grid {
  display: grid;
  gap: 10px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.settings-grid {
  margin-top: 12px;
}

.import-export-grid {
  margin-top: 10px;
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.button-row-spaced {
  margin-top: 8px;
}

.field label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.status {
  display: none;
  margin-top: 10px;
  min-height: 20px;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--muted);
  font-weight: 600;
}

.status:not(:empty) {
  display: block;
}

.status.ok {
  color: var(--success);
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.status.error {
  color: var(--danger);
  background: #fef2f2;
  border-color: #fecaca;
}

.country-list,
.import-export {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}


#modelGroupsContainer {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(370px, 1fr));
  gap: 10px;
  align-items: start;
}

body.local-currency-layout-enabled #modelGroupsContainer {
  grid-template-columns: repeat(auto-fit, minmax(590px, 1fr));
}

.model-group {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  min-width: 0;
}

.model-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.model-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.model-name-field,
.anchor-price-eur-field.full-width {
  grid-column: 1 / -1;
}

.checkbox-field input[type="checkbox"] {
  width: auto;
  min-width: 18px;
  height: 18px;
}

.trim-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 330px;
  background: white;
}

.trim-table-local-currency {
  min-width: 540px;
}

.trim-table-standard th:nth-child(1),
.trim-table-standard td:nth-child(1) {
  width: 33%;
}

.trim-table-standard th:nth-child(2),
.trim-table-standard td:nth-child(2) {
  width: 23%;
}

.trim-table-standard th:nth-child(3),
.trim-table-standard td:nth-child(3) {
  width: 17%;
}

.trim-table-standard th:nth-child(4),
.trim-table-standard td:nth-child(4) {
  width: 27%;
}

.trim-table-local-currency th:nth-child(1),
.trim-table-local-currency td:nth-child(1) {
  width: 26%;
}

.trim-table-local-currency th:nth-child(2),
.trim-table-local-currency td:nth-child(2) {
  width: 23%;
}

.trim-table-local-currency th:nth-child(3),
.trim-table-local-currency td:nth-child(3) {
  width: 19%;
}

.trim-table-local-currency th:nth-child(4),
.trim-table-local-currency td:nth-child(4) {
  width: 13%;
}

.trim-table-local-currency th:nth-child(5),
.trim-table-local-currency td:nth-child(5) {
  width: 19%;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 5px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  text-align: center;
}

tr:last-child td {
  border-bottom: 0;
}

td.numeric {
  text-align: right;
}

.calculated {
  display: block;
  width: 100%;
  border-radius: 10px;
  padding: 5px 7px;
  background: #f3f4f6;
  color: #374151;
  min-height: 30px;
  text-align: right;
  border: 1px solid transparent;
}

.calculated.negative {
  color: #b91c1c;
  background: #fef2f2;
  border-color: #fecaca;
  font-weight: 700;
}


.empty-state {
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.hint a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.hint a:hover {
  text-decoration: underline;
}


.warning {
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 10px;
  margin-top: 10px;
  font-size: 13px;
}

@media (min-width: 430px) {
  .model-fields {
	grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  body {
	padding: 10px;
  }

  .topbar {
	align-items: flex-start;
	flex-direction: column;
  }

  .topbar-actions {
	justify-content: flex-start;
  }

  .grid-3,
  .grid-4,
  #modelGroupsContainer {
    grid-template-columns: 1fr;
  }
  
  table,
  .trim-table-local-currency {
    min-width: 330px;
  }
}