:root {
  --bg-body: #2b4a3f;
  --text-main: #e6efea;
  --border-light: #5c7e72;
  --border-medium: #406457;
  --header-bg: #3d6254;
  --row-hover: #3a5c4e;
  --button-bg: #4a6b5d;
  --button-hover: #567e6c;
  --delete-color: #d98c8c;
  --delete-hover-bg: #5c4a4a;
  --accent-focus: #6b8b7a;
  --chip-bg: #3f6153;
  --autocomplete-bg: #345246;
  --add-color: #a3d0b1;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", "Roboto", system-ui, sans-serif;
  background: var(--bg-body);
  color: var(--text-main);
  padding: 8px 4px;
  transition: font-size 0.1s;
  font-size: 8px;
}

body.font-small { font-size: 6.5px; }
body.font-medium { font-size: 8px; }
body.font-large { font-size: 10px; }

.app {
  max-width: 100%;
  margin: 0 auto;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 6px;
}

.btn-group {
  display: flex;
  gap: 2px;
}

.btn {
  background: var(--button-bg);
  border: 1px solid var(--border-medium);
  padding: 3px 8px;
  font-size: inherit;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-main);
  border-radius: 0;
  line-height: 1.2;
  transition: background 0.15s;
}

.btn:hover {
  background: var(--button-hover);
}

.btn-small {
  padding: 2px 6px;
}

.spacer {
  flex: 1;
}

.table-wrapper {
  overflow-x: auto;
  margin: 8px 0;
  border: 1px solid var(--border-medium);
  background: var(--bg-body);
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  white-space: nowrap;
}

th,
td {
  border: 1px solid var(--border-light);
  padding: 4px 3px;
  text-align: left;
  vertical-align: middle;
  font-weight: normal;
}

th {
  background: var(--header-bg);
  font-weight: 500;
  text-align: center;
  font-size: 0.9em;
  color: var(--text-main);
}

th:nth-child(1) { width: 12%; }
th:nth-child(2) { width: 28%; }
th:nth-child(3) { width: 8%; }
th:nth-child(4) { width: 10%; }
th:nth-child(5) { width: 12%; }
th:nth-child(6) { width: 6%; }

td {
  background-color: transparent;
  color: var(--text-main);
}

tr:hover td {
  background-color: var(--row-hover);
}

input,
select {
  width: 100%;
  border: none;
  background: transparent;
  font-size: inherit;
  font-family: inherit;
  padding: 2px 1px;
  outline: none;
  box-shadow: none;
  color: var(--text-main);
}

input:focus,
select:focus {
  background: var(--accent-focus);
}

td:nth-child(3) input,
td:nth-child(4) input,
td:nth-child(5) {
  text-align: right;
}

.row-sum {
  text-align: right;
  font-weight: 500;
  padding-right: 6px;
}

.delete-btn {
  background: none;
  border: none;
  color: var(--delete-color);
  font-size: 1.4em;
  line-height: 1;
  cursor: pointer;
  width: 100%;
  text-align: center;
  padding: 0;
  font-weight: bold;
}

.delete-btn:hover {
  color: #e0a0a0;
  background: var(--delete-hover-bg);
}

tfoot td {
  background: var(--header-bg);
  border-top: 2px solid var(--border-medium);
  font-weight: 600;
  color: var(--text-main);
}

.total-label {
  text-align: right;
  padding-right: 8px;
}

.total-value {
  text-align: right;
  padding-right: 8px;
}

.add-row-btn {
  margin-top: 4px;
  padding: 5px 12px;
}

.settings-panel {
  margin-top: 12px;
  border-top: 1px dashed var(--border-medium);
  padding-top: 8px;
  display: none;
}

.settings-panel.visible {
  display: block;
}

.settings-layout {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.settings-column-left {
  min-width: 180px;
}

.settings-column-right {
  flex: 1;
}

.panel-title {
  font-weight: 600;
  margin: 6px 0 2px;
  font-size: 1.1em;
  color: #c0d6cc;
}

.item-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-bottom: 8px;
}

.chip {
  background: var(--chip-bg);
  border: 1px solid var(--border-light);
  padding: 2px 4px 2px 6px;
  font-size: 0.95em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-main);
}

.chip button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2em;
  line-height: 1;
  padding: 0 2px;
  font-weight: bold;
}

.chip .add-fav-btn {
  color: var(--add-color);
}

.chip .delete-fav-btn {
  color: var(--delete-color);
}

.chip button:hover {
  opacity: 0.8;
}

.input-row {
  display: flex;
  gap: 4px;
  margin: 6px 0;
}

.input-row input,
.input-row select {
  border: 1px solid var(--border-medium);
  background: var(--autocomplete-bg);
  padding: 4px;
  flex: 1;
  color: var(--text-main);
}

.input-row-favorites #newItemName { flex: 2; }
.input-row-favorites #newItemCategory { flex: 1.2; }
.input-row-favorites #newItemPrice { flex: 1; }
.input-row-favorites #addFavoriteBtn { flex: 0 0 auto; }

.small-note {
  color: #b9cfc4;
  font-size: 0.9em;
  margin: 2px 0;
}

.autocomplete-list {
  position: absolute;
  background: var(--autocomplete-bg);
  border: 1px solid var(--border-medium);
  max-height: 120px;
  overflow-y: auto;
  z-index: 100;
  list-style: none;
  box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.2);
}

.autocomplete-list li {
  padding: 3px 6px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.95em;
  color: var(--text-main);
}

.autocomplete-list li:hover {
  background: var(--button-hover);
}

::placeholder {
  color: #9fb7ab;
  opacity: 1;
}