:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --line: #d3dbe5;
  --line-soft: #e7ecf2;
  --text: #1c2838;
  --muted: #5b6b81;
  --brand: #151c25;
  --brand-deep: #232f3e;
  --radius: 11px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Rubik", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c9d2dd;
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 0.58rem 0.7rem;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.app-shell {
  width: calc(100vw - 0.3rem);
  max-width: 100vw;
  margin: 0.15rem auto 0.7rem;
}

.app-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.9rem;
  background: var(--brand);
  border: 1px solid #2e3a4a;
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  min-width: 260px;
}

.brand img {
  width: 220px;
  height: 30px;
  flex: 0 0 auto;
  object-fit: contain;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  overflow-x: visible;
  white-space: nowrap;
}

.main-nav a {
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0.38rem 0.62rem;
  color: #e9f2ff;
  font-size: 0.83rem;
  font-weight: 500;
}

.main-nav a.active {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.35);
  background: var(--brand-deep);
}

.user-strip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.82rem;
  color: #e9f2ff;
}

.app-header .btn-light {
  border-color: rgba(255, 255, 255, 0.35);
  color: #f4f8ff;
  background: var(--brand-deep);
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.32rem 0.58rem;
  min-height: 38px;
}

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 27px;
  height: 27px;
  border-radius: 999px;
  background: #f1f6ff;
  color: #1f2d3d;
  font-size: 0.72rem;
  font-weight: 700;
}

.user-avatar-image {
  object-fit: cover;
}

.user-meta {
  font-size: 0.8rem;
  font-weight: 500;
  color: #f2f7ff;
  line-height: 1.1;
}

.content {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.8rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem;
}

.panel h2 {
  margin: 0 0 0.65rem;
  font-size: 0.98rem;
  font-weight: 600;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

.page-header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.page-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.48rem 0.75rem;
  cursor: pointer;
  font-size: 0.88rem;
  white-space: nowrap;
}

.btn-light {
  border-color: #cdd4dd;
  color: #3a4659;
  background: #fff;
}

.btn-primary {
  border-color: #232f3e;
  background: #232f3e;
  color: #ffffff;
  font-weight: 600;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.55rem;
}

.kpi-row article {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem;
  display: grid;
  gap: 0.18rem;
}

.kpi-row span {
  color: var(--muted);
  font-size: 0.78rem;
}

.kpi-row strong {
  font-size: 1.04rem;
}

.filter-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1.3fr auto auto auto;
  gap: 0.55rem;
  align-items: end;
}

.period-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
}

.period-toolbar-meta {
  display: grid;
  gap: 0.14rem;
}

.period-toolbar-label {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.period-toolbar-meta strong {
  font-size: 0.96rem;
  font-weight: 600;
}

.period-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.period-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0.5rem 0.78rem;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  background: #f7f9fc;
  color: #39485a;
  font-size: 0.86rem;
  font-weight: 500;
  white-space: nowrap;
}

.period-chip.is-active {
  border-color: #232f3e;
  background: #232f3e;
  color: #fff;
}

.quarter-picker {
  display: flex;
  align-items: center;
}

.quarter-picker select {
  min-width: 180px;
  width: 180px;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  margin-top: 1.15rem;
}

.check-line input[type="checkbox"] {
  width: 15px;
  height: 15px;
}

.table-panel {
  overflow: auto;
}

.data-grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  min-width: 0;
}

.data-grid th,
.data-grid td {
  border-bottom: 1px solid var(--line-soft);
  padding: 0.52rem 0.48rem;
  vertical-align: top;
  text-align: left;
  font-size: 0.82rem;
  white-space: normal;
}

.data-grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f9fbfd;
  font-size: 0.74rem;
  color: #58677d;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--line);
}

.data-grid thead a {
  color: inherit;
}

.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
}

.sort-indicator {
  color: #9aa8ba;
  font-size: 0.7rem;
  letter-spacing: -0.08em;
  min-width: 0.95rem;
}

.sort-indicator.is-active {
  color: #1d2a39;
}

.data-grid tbody tr:hover {
  background: #fafbfd;
}

.inventory-grid {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.inventory-grid th,
.inventory-grid td {
  white-space: normal;
  overflow-wrap: anywhere;
}

.inventory-grid th:nth-child(1),
.inventory-grid td:nth-child(1) {
  width: 13%;
}

.inventory-grid th:nth-child(2),
.inventory-grid td:nth-child(2) {
  width: 10%;
}

.inventory-grid th:nth-child(3),
.inventory-grid td:nth-child(3) {
  width: 12%;
}

.inventory-grid th:nth-child(4),
.inventory-grid td:nth-child(4) {
  width: 14%;
}

.inventory-grid th:nth-child(5),
.inventory-grid td:nth-child(5),
.inventory-grid th:nth-child(6),
.inventory-grid td:nth-child(6),
.inventory-grid th:nth-child(7),
.inventory-grid td:nth-child(7),
.inventory-grid th:nth-child(8),
.inventory-grid td:nth-child(8),
.inventory-grid th:nth-child(9),
.inventory-grid td:nth-child(9) {
  width: 7%;
}

.inventory-grid th:nth-child(10),
.inventory-grid td:nth-child(10),
.inventory-grid th:nth-child(11),
.inventory-grid td:nth-child(11) {
  width: 8%;
}

.row-link {
  color: #1f3d6f;
  font-weight: 500;
}

.row-link:hover {
  color: #355f9d;
}

.inline-qty-form {
  display: inline-grid;
  grid-template-columns: 44px 18px 18px;
  align-items: center;
  gap: 0.14rem;
}

.qty-input {
  width: 44px;
  min-width: 44px;
  padding: 0.18rem 0.22rem;
  border-radius: 7px;
  text-align: center;
  font-size: 0.75rem;
}

.qty-step {
  width: 18px;
  height: 18px;
  border: 1px solid #cfd8e3;
  border-radius: 999px;
  background: #f6f8fb;
  color: #324155;
  font-size: 0.78rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}

.actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.text-link {
  color: #355f9d;
  font-weight: 500;
}

.link-button {
  border: 0;
  background: transparent;
  color: #b42f3d;
  cursor: pointer;
  padding: 0;
  font: inherit;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.7rem;
  padding-top: 0.7rem;
  font-size: 0.86rem;
}

.pagination a {
  color: #355f9d;
}

.messages {
  display: grid;
  gap: 0.45rem;
}

.message {
  border-radius: 8px;
  border: 1px solid transparent;
  background: #fff;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}

.message-success {
  border-color: #cce6d8;
  color: #0d7349;
}

.message-error {
  border-color: #efc5c9;
  color: #b7313d;
}

.message-warning,
.message-info {
  border-color: #f1dfbe;
  color: #8e5a0f;
}

.error-inline {
  color: #b7313d;
  font-size: 0.8rem;
}

.stack-form,
.form-grid {
  display: grid;
  gap: 0.6rem;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid > .btn {
  grid-column: 1 / -1;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 0.8rem;
}

.inline-form {
  display: flex;
  align-items: end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.quick-grid {
  display: grid;
  gap: 0.6rem;
}

.quick-row {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

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

.simple-table th,
.simple-table td {
  border-bottom: 1px solid var(--line-soft);
  padding: 0.46rem;
  text-align: left;
  font-size: 0.83rem;
}

.simple-table th {
  color: var(--muted);
  font-weight: 500;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 0.8rem;
}

.button-row {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.stack-cell {
  display: grid;
  gap: 0.08rem;
}

.stack-cell span {
  display: block;
  font-size: 0.78rem;
  line-height: 1.2;
}

.more-indicator {
  color: var(--muted);
  font-size: 0.78rem;
}

.user-management {
  display: grid;
  gap: 0.8rem;
  width: 100%;
}

.beheer-forms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  align-items: stretch;
}

.user-table {
  table-layout: fixed;
}

.user-table th,
.user-table td {
  white-space: normal;
  vertical-align: middle;
}

.user-table th:nth-child(1) {
  width: 18%;
}

.user-table th:nth-child(2) {
  width: 24%;
}

.user-table th:nth-child(3) {
  width: 14%;
}

.user-table th:nth-child(4) {
  width: 10%;
}

.user-table th:nth-child(5) {
  width: 20%;
}

.user-table th:nth-child(6) {
  width: 14%;
}

.user-table .check-line {
  margin-top: 0;
}

.user-role-select,
.user-password-input {
  max-width: 230px;
}

.profile-cell {
  display: grid;
  grid-template-columns: 40px auto auto;
  align-items: center;
  gap: 0.45rem;
}

.profile-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.profile-thumb-empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f5f7fb;
  border-style: dashed;
}

.profile-thumb-empty::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #c5d1df;
}

.profile-remove {
  margin-top: 0;
}

.user-photo-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 82px;
  height: 32px;
  border: 1px solid #cfd8e3;
  border-radius: 7px;
  background: #fff;
  color: #324155;
  font-size: 0.76rem;
  font-weight: 500;
  padding: 0 0.7rem;
  cursor: pointer;
}

.user-create-panel {
  max-width: none;
  min-height: 100%;
}

.supplier-panel {
  max-width: none;
  min-height: 100%;
}

.product-create-panel {
  max-width: 760px;
}

.product-edit-panel {
  max-width: none;
}

.product-edit-grid {
  grid-template-columns: repeat(3, minmax(0, 300px));
  column-gap: 0.8rem;
  row-gap: 0.7rem;
}

.product-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.product-mini-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 0.65rem;
  row-gap: 0.6rem;
}

.product-mini-grid > .btn {
  grid-column: 1 / -1;
  justify-self: start;
}

.product-mini-grid > h3 {
  grid-column: 1 / -1;
  margin: 0.15rem 0 0.1rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

.simple-table .button-row {
  align-items: center;
  flex-wrap: nowrap;
}

.simple-table .button-row form {
  margin: 0;
}

.user-create-panel .stack-form {
  max-width: 260px;
}

.user-create-panel input,
.user-create-panel select {
  max-width: 260px;
}

.user-create-panel .btn,
.supplier-panel .btn {
  width: auto;
  min-width: 180px;
  justify-self: start;
}

.supplier-panel .form-grid {
  grid-template-columns: 280px 280px;
  column-gap: 1rem;
  row-gap: 0.75rem;
  max-width: 100%;
}

.supplier-panel input,
.supplier-panel textarea {
  max-width: 280px;
}

.supplier-panel textarea {
  min-height: 42px;
}

.delete-col,
.delete-cell {
  width: 52px;
  text-align: center;
}

.delete-cell form {
  display: flex;
  justify-content: center;
}

.delete-dot {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 999px;
  background: #c73645;
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.login-wrap {
  min-height: 70vh;
  display: grid;
  place-items: center;
}

.login-panel {
  width: min(420px, 100%);
}

.login-panel h1 {
  margin-top: 0;
  margin-bottom: 0.8rem;
  font-size: 1.2rem;
}

@media (max-width: 1480px) {
  .filter-grid {
    grid-template-columns: 1.5fr 1fr 1fr 1fr 1.2fr auto auto auto;
  }
}

@media (max-width: 1200px) {
  .kpi-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

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

  .product-edit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-action-grid {
    grid-template-columns: 1fr;
  }

  .beheer-forms {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100vw - 0.7rem, 100%);
    margin: 0.35rem auto 0.6rem;
  }

  .app-header {
    grid-template-columns: 1fr;
  }

  .brand {
    min-width: 0;
  }

  .main-nav,
  .user-strip {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .brand img {
    width: 190px;
    height: 26px;
  }

  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-grid,
  .page-header {
    grid-template-columns: 1fr;
    display: grid;
  }
}
