:root {
  --bg: #f5f9fc;
  --panel: #ffffff;
  --text: #151515;
  --muted: #5f6d78;
  --line: #d8e6ef;
  --accent: #8fd3ff;
  --accent-dark: #176b95;
  --ink: #111111;
  --ink-soft: #17212b;
  --income: #2f7d46;
  --expense: #6b5f00;
  --result: #2b2b2b;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
}

.topbar {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--ink);
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 2px 10px rgba(17, 17, 17, 0.12);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand img {
  width: 48px;
  height: 34px;
  border-radius: 6px;
  background: #ffffff;
  object-fit: contain;
  padding: 3px;
}

h1,
h2 {
  margin: 0;
}

h1 {
  color: #ffffff;
  font-size: 20px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

h2 {
  margin-bottom: 16px;
  font-size: 18px;
}

.date-controls,
.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.date-controls {
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: center;
  max-width: 480px;
}

.month-control {
  display: grid;
  gap: 3px;
  padding: 6px 8px;
  border: 1px solid #2d5367;
  border-radius: 8px;
  background: var(--ink-soft);
}

.month-control > span,
.month-control small {
  color: #d9edf8;
  font-size: 11px;
  font-weight: 700;
}

.month-switch {
  display: grid;
  grid-template-columns: 34px minmax(120px, 1fr) 34px;
  gap: 6px;
  align-items: center;
}

.month-switch strong {
  color: #ffffff;
  font-size: 14px;
  text-align: center;
  text-transform: capitalize;
}

.nav-button {
  min-height: 28px;
  padding: 0;
}

#refreshData {
  min-height: 34px;
  min-width: 82px;
  padding: 0 12px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
}

.panel,
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(17, 17, 17, 0.06);
}

.panel {
  padding: 16px;
}

.form-panel {
  align-self: start;
}

.right-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.staff-panels {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  padding: 16px;
  border-top: 3px solid var(--accent);
}

.metric span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
}

.metric strong {
  font-size: 24px;
}

.split-metric {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.split-metric div {
  min-width: 0;
}

.split-metric small {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.split-metric strong {
  display: block;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.income strong {
  color: var(--income);
}

.expense strong {
  color: var(--expense);
}

.result strong {
  color: var(--result);
}

.vat strong {
  color: var(--accent-dark);
}

form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdff;
  color: var(--text);
  font: inherit;
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

button:hover {
  background: var(--accent-dark);
  color: #ffffff;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button.secondary {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
}

button.secondary:hover {
  background: #e8f5fc;
  color: var(--text);
}

.topbar button.secondary {
  border-color: #2d5367;
  background: #1c1c1c;
  color: #edf8ff;
}

.topbar button.secondary:hover {
  background: #23313d;
  color: #ffffff;
}

.topbar-link {
  color: #8fd3ff;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.topbar-link:hover {
  color: #ffffff;
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: #991b1b;
}

button.small {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 12px;
}

.button-row,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#cancelEdit {
  display: none;
}

.message {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
}

.message.ok {
  color: var(--income);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-heading span {
  color: var(--muted);
}

.entry-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(140px, 180px);
  gap: 12px;
  margin-bottom: 12px;
}

.log-filters {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(120px, 160px);
  gap: 12px;
  margin-bottom: 12px;
}

.logs-layout {
  padding: 16px;
}

.table-wrap {
  overflow-x: auto;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.pagination span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.compact td,
.compact th {
  padding: 8px;
}

.tag {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 999px;
  background: #e5f4ff;
  color: #145a7d;
  font-size: 12px;
  font-weight: 700;
}

.tag.expense-tag {
  background: #eef2f6;
  color: var(--expense);
}

.action-tag {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.action-CREATE {
  background: #dff8e8;
  color: #1f6b38;
}

.action-UPDATE {
  background: #e5f4ff;
  color: #145a7d;
}

.action-DELETE {
  background: #fde8e8;
  color: #8b1a1a;
}

.log-details td {
  padding: 0;
}

.snapshot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  background: #f8fbff;
  border-bottom: 1px solid var(--line);
}

.snapshot-grid section {
  min-width: 0;
  padding: 12px;
}

.snapshot-grid section + section {
  border-left: 1px solid var(--line);
}

.snapshot-grid h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.snapshot-table td {
  padding: 4px 6px;
  border-bottom: 0;
  font-size: 13px;
}

.snapshot-table td:first-child {
  width: 140px;
  color: var(--muted);
  font-weight: 700;
}

.changed-field td {
  background: #e5f4ff;
}

.empty-snapshot {
  margin: 0;
  color: var(--muted);
}

.breakdown {
  display: block;
}

.breakdown-table th,
.breakdown-table td {
  text-align: right;
  white-space: nowrap;
}

.breakdown-table th:first-child,
.breakdown-table td:first-child {
  text-align: left;
  white-space: normal;
}

.breakdown-section td {
  background: #101820;
  color: #eaf6ff;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.summary-row td {
  font-weight: 800;
}

.config-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.config-form button,
.config-form .message {
  grid-column: 1 / -1;
}

.config-panel {
  grid-column: 1 / -1;
}

.config-panel summary {
  cursor: pointer;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  list-style-position: inside;
}

.config-panel summary::marker {
  color: var(--accent);
}


.day-nav {
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  text-align: center;
}

.day-table {
  width: 100%;
  border-collapse: collapse;
}

.day-table td {
  padding: 5px 6px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.day-table td:last-child {
  text-align: right;
  font-weight: 700;
  white-space: nowrap;
}

.day-section-row td {
  background: #f0f7fc;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 4px 6px;
}

.day-total-row td {
  font-weight: 800;
  font-size: 14px;
}

.login-wrap {
  min-height: calc(100vh - 57px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 360px;
}

.login-card h2 {
  margin-bottom: 24px;
  font-size: 20px;
  color: var(--ink);
}

.login-card form {
  gap: 16px;
}

.login-card button[type="submit"] {
  width: 100%;
  margin-top: 4px;
}

.login-error {
  min-height: 20px;
  margin: 0;
  font-size: 13px;
  color: var(--danger);
  font-weight: 700;
}

@media (max-width: 980px) {
  .topbar,
  .layout {
    display: block;
  }

  .date-controls,
  .right-column {
    margin-top: 16px;
  }

  .panel,
  .right-column,
  .staff-panels {
    margin-bottom: 16px;
  }
}

@media (max-width: 640px) {
  .topbar,
  .layout {
    padding: 12px;
  }

  .date-controls,
  .field-row,
  .entry-filters,
  .log-filters,
  .metrics,
  .config-form,
  .staff-panels {
    grid-template-columns: 1fr;
  }

  .snapshot-grid {
    grid-template-columns: 1fr;
  }

  .snapshot-grid section + section {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .pagination {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 24px;
  }
}
