:root {
  --navy: #0b1f33;
  --navy-2: #153c5a;
  --blue: #1f4e78;
  --line: #9fc5d8;
  --row-blue: #bfe3f1;
  --row-light: #f7fbff;
  --soft-blue: #d9eaf7;
  --text: #1f2933;
  --muted: #6b7b88;
  --paper: #ffffff;
  --red-bg: #fce4e4;
  --red: #9c0006;
  --gold-bg: #fff2cc;
  --gold: #7f6000;
  --green-bg: #e2f0d9;
  --green: #375623;
  --shadow: 0 18px 50px rgba(11, 31, 51, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: #e8f3f9;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: block;
}

.sidebar {
  background: var(--navy);
  color: #fff;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 4px solid #5f9ec0;
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: var(--soft-blue);
  color: var(--navy);
  display: grid;
  place-items: center;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.15;
}

.brand p {
  margin: 3px 0 0;
  color: #bdd4e4;
  font-size: 13px;
}

.nav-list {
  display: flex;
  gap: 7px;
  flex: 1;
  overflow-x: auto;
  padding: 2px 0;
}

.nav-button {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: #e9f4fb;
  text-align: center;
  border-radius: 8px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  white-space: nowrap;
  min-width: max-content;
}

.nav-button:hover,
.nav-button.active {
  background: #17476b;
  border-color: #5f9ec0;
}

.nav-count {
  color: #123047;
  background: var(--soft-blue);
  min-width: 28px;
  border-radius: 999px;
  text-align: center;
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 700;
}

.save-panel {
  margin-left: auto;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.save-panel p {
  margin: 0;
  color: #d4e5f0;
  font-size: 13px;
  white-space: nowrap;
}

.secondary-button,
.file-button,
.primary-button,
.danger-button {
  border: 0;
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 700;
}

.secondary-button,
.file-button {
  background: #e9f4fb;
  color: var(--navy);
  text-align: center;
}

.primary-button {
  background: var(--blue);
  color: #fff;
}

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

.file-button input {
  display: none;
}

.main-panel {
  min-width: 0;
  padding: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  font-size: 12px;
}

.topbar h2 {
  margin: 0;
  font-size: 26px;
  color: var(--navy);
}

.top-actions,
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 260px));
  gap: 12px;
  margin-bottom: 12px;
}

.summary-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 8px 24px rgba(11, 31, 51, 0.08);
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-card strong {
  display: block;
  color: var(--navy);
  font-size: 22px;
  margin-top: 3px;
}

.content-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 560px;
  overflow: hidden;
}

.table-toolbar {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--soft-blue);
}

.search-input {
  width: min(360px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text);
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 230px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1280px;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--navy);
  color: #fff;
  border: 1px solid var(--line);
  text-align: left;
  padding: 9px;
  font-size: 13px;
  white-space: nowrap;
}

td {
  border: 1px solid var(--line);
  padding: 4px;
  background: var(--row-light);
  vertical-align: middle;
}

tbody tr:nth-child(odd) td {
  background: var(--row-blue);
}

.readonly-row td {
  background: var(--row-light);
}

.cell-input,
.cell-select {
  width: 100%;
  min-width: 110px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--text);
  min-height: 32px;
}

.cell-input:focus,
.cell-select:focus {
  outline: 2px solid #5f9ec0;
  background: #fff;
}

.number-input {
  min-width: 78px;
}

.notes-input {
  min-width: 300px;
}

.date-input {
  min-width: 130px;
}

td[data-field="item"],
th[data-field="item"] {
  min-width: 290px;
}

td[data-field="notes"],
th[data-field="notes"] {
  min-width: 320px;
}

td[data-field="customerName"],
th[data-field="customerName"],
td[data-field="belongsTo"],
th[data-field="belongsTo"] {
  min-width: 190px;
}

td[data-field="phone"],
th[data-field="phone"] {
  min-width: 145px;
}

td[data-field="status"],
th[data-field="status"] {
  min-width: 155px;
}

td[data-field="supplier"],
th[data-field="supplier"] {
  min-width: 175px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-weight: 800;
  font-size: 12px;
  white-space: nowrap;
}

.status-need,
.need-add {
  background: var(--red-bg);
  color: var(--red);
}

.status-ordered {
  background: var(--gold-bg);
  color: var(--gold);
}

.status-received {
  background: var(--soft-blue);
  color: var(--blue);
}

.status-done,
.need-ok {
  background: var(--green-bg);
  color: var(--green);
}

.cell-select.status-need,
.cell-select.status-ordered,
.cell-select.status-received,
.cell-select.status-done,
.cell-select.priority-urgent {
  border-color: rgba(11, 31, 51, 0.18);
  font-weight: 800;
}

.cell-select.status-need {
  background: var(--red-bg);
  color: var(--red);
}

.cell-select.status-ordered {
  background: var(--gold-bg);
  color: var(--gold);
}

.cell-select.status-received {
  background: var(--soft-blue);
  color: var(--blue);
}

.cell-select.status-done {
  background: var(--green-bg);
  color: var(--green);
}

.cell-select.priority-urgent {
  background: #f4cccc;
  color: var(--red);
}

.type-customer {
  background: var(--green-bg);
  color: var(--green);
}

.type-store {
  background: var(--soft-blue);
  color: var(--blue);
}

.row-actions {
  min-width: 150px;
  white-space: nowrap;
}

.icon-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  border-radius: 6px;
  padding: 6px 9px;
  font-weight: 700;
  margin-right: 5px;
}

.empty-state {
  padding: 44px;
  color: var(--muted);
  text-align: center;
}

.auth-panel {
  max-width: 430px;
  margin: 42px auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.auth-panel h3 {
  margin: 0;
  padding: 14px 16px;
  background: var(--navy);
  color: #fff;
}

.auth-body {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.auth-body label {
  display: grid;
  gap: 6px;
  color: var(--navy);
  font-weight: 700;
}

.auth-body input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
}

.auth-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.guide {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 14px;
  padding: 18px;
}

.guide-card,
.list-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.guide-card h3,
.list-card h3 {
  margin: 0;
  background: var(--navy);
  color: #fff;
  padding: 11px 12px;
  font-size: 15px;
}

.guide-card p {
  margin: 0;
  padding: 13px;
  line-height: 1.45;
  background: var(--row-light);
}

.list-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 14px;
  padding: 18px;
}

.list-items {
  display: grid;
  gap: 8px;
  padding: 12px;
  max-height: 310px;
  overflow: auto;
}

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.list-row input {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
}

.add-list-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: var(--soft-blue);
}

.add-list-row input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
}

@media (max-width: 920px) {
  .sidebar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    min-width: 0;
  }

  .save-panel {
    margin-left: 0;
    flex-wrap: wrap;
  }

  .summary-strip,
  .guide,
  .list-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
