:root {
  --ink: #17212b;
  --muted: #667085;
  --line: #d0d7de;
  --panel: #ffffff;
  --band: #eef6f8;
  --green: #1f6f55;
  --blue: #225f7a;
  --red: #a23b3b;
  --bg: #f3f5f7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font: 14px/1.4 "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: #174b5c;
  color: #fff;
}

h1, h2, p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 650;
}

.brandArea {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 320px;
}

.brandLogo {
  max-width: 160px;
  max-height: 48px;
  object-fit: contain;
  display: block;
}

.brandBadge {
  width: 54px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  border-radius: 8px;
  font-weight: 800;
  letter-spacing: .5px;
  color: #ffffff;
}

.topbar p {
  margin-top: 3px;
  color: #d7e8ee;
}

.status {
  min-width: 170px;
  text-align: right;
  color: #eaf5f8;
}

.topActions {
  display: flex;
  align-items: center;
  gap: 12px;
}

#backupBtn,
#refreshPriceBtn,
.uploadBtn {
  background: #ffffff;
  color: #174b5c;
  border-color: #ffffff;
}

.uploadBtn {
  height: 36px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #ffffff;
  border-radius: 4px;
  padding: 0 12px;
  cursor: pointer;
}

.uploadBtn input {
  display: none;
}

.layout {
  display: grid;
  grid-template-columns: 360px minmax(620px, 1fr);
  grid-template-rows: auto 1fr;
  gap: 14px;
  padding: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.entry {
  grid-row: span 2;
}

.stock {
  min-height: 420px;
}

.recent {
  min-height: 220px;
}

.journal {
  grid-column: 2;
  min-height: 260px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
}

.tab {
  height: 44px;
  border: 0;
  background: #f8fafc;
  font-weight: 650;
  cursor: pointer;
}

.tab.active[data-mode="in"] {
  background: #e4f4ec;
  color: var(--green);
}

.tab.active[data-mode="out"] {
  background: #f9e8e8;
  color: var(--red);
}

.form {
  display: grid;
  gap: 12px;
  padding: 16px;
}

label {
  display: grid;
  gap: 5px;
  font-weight: 600;
}

input,
select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 10px;
  font: inherit;
  background: #fff;
}

input:focus,
select:focus {
  outline: 2px solid #8ecae6;
  border-color: #3d8dae;
}

button {
  height: 36px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0 12px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

#submitBtn {
  background: var(--green);
  color: #fff;
}

.outMode #submitBtn {
  background: var(--red);
}

.lookup {
  margin: 0 16px 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--band);
  min-height: 74px;
}

.lookup strong {
  display: block;
  margin-bottom: 3px;
}

.muted {
  color: var(--muted);
}

.sectionHead {
  height: 54px;
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}

.sectionHead h2 {
  font-size: 17px;
}

.sectionHead input {
  width: min(460px, 55%);
}

.journalHead {
  height: auto;
  min-height: 62px;
  align-items: flex-start;
  padding-top: 12px;
  padding-bottom: 12px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.filters input,
.filters select {
  width: 150px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 8px;
  font: inherit;
  background: #fff;
}

.filters #journalSearch {
  width: 230px;
}

.tableWrap {
  overflow: auto;
  max-height: 520px;
}

.tableWrap.compact {
  max-height: 260px;
}

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

th, td {
  padding: 8px 9px;
  border-bottom: 1px solid #e6ebef;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #2f75b5;
  color: #fff;
  font-weight: 650;
  z-index: 1;
}

td:nth-child(2) {
  white-space: normal;
  min-width: 260px;
}

.qty {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.webLink {
  color: #0b63ce;
  text-decoration: none;
  font-weight: 650;
}

.logoutLink {
  color: #ffffff;
  font-weight: 650;
  text-decoration: none;
}

.installBox {
  width: min(460px, calc(100vw - 28px));
  margin: 60px auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.installBox h1 {
  color: #174b5c;
  margin-bottom: 12px;
}

.installBox a {
  color: #0b63ce;
  font-weight: 650;
}

.error {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid #e4a2a2;
  border-radius: 4px;
  background: #fff5f5;
  color: #9b2c2c;
}


.empty {
  color: var(--muted);
  padding: 18px;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .entry {
    grid-row: auto;
  }

  .journal {
    grid-column: auto;
  }
}


@media (max-width: 900px) {
  .topbar {
    height: auto;
    min-height: 92px;
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
  }
  .topActions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .brandLogo {
    max-width: 140px;
    max-height: 42px;
  }
}
