:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --text: #182433;
  --muted: #64748b;
  --line: #dde5ef;
  --blue: #1565c0;
  --green: #2e7d32;
  --amber: #f9a825;
  --teal: #00897b;
  --red: #c62828;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

img,
svg {
  max-width: 100%;
}

input,
select,
textarea {
  max-width: 100%;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.container-wide {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.page-content,
.panel,
.stat-card,
.kanban-column,
.order-card {
  min-width: 0;
}

.page-content {
  padding: 28px 0 48px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-header h1 {
  margin-bottom: 6px;
  font-size: 2rem;
  font-weight: 700;
}

.page-header p,
.auth-header p,
.welcome-panel p {
  color: var(--muted);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand-logo {
  font-weight: 700;
}

.logged-user > span {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  max-width: 260px;
  min-height: 24px;
  padding: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
  font-weight: 700;
  line-height: 1.2;
}

.logged-user .material-icons {
  margin-right: 6px;
}

nav ul li.logged-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  min-width: 150px;
  max-width: 280px;
  height: 64px;
  padding: 7px 0 7px 18px;
}

nav ul li.logged-user a[data-logout] {
  height: auto;
  margin-top: 3px;
  padding: 2px 8px;
  border-radius: 4px;
  color: #e3f2fd;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
  text-transform: uppercase;
}

nav ul li.logged-user a[data-logout]:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.sidenav-user {
  padding: 22px 24px 12px;
  color: var(--text);
  font-weight: 700;
}

.sidenav-user > span {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidenav-user [data-current-user] {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: #e3f2fd;
  color: var(--blue);
  font-size: 36px;
}

.centered-page,
.auth-container {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.welcome-panel,
.auth-card,
.panel,
.stat-card,
.kanban-column {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.welcome-panel {
  width: min(680px, 100%);
  padding: 44px;
  text-align: center;
}

.welcome-panel h1 {
  margin: 16px 0 8px;
  font-size: 3rem;
  font-weight: 800;
}

.welcome-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 28px;
}

.auth-card {
  width: min(440px, 100%);
  padding: 32px;
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-header h1 {
  margin: 14px 0 6px;
  font-size: 2rem;
  font-weight: 700;
}

.auth-footer {
  margin: 22px 0 0;
  text-align: center;
  color: var(--muted);
}

.auth-card .input-field {
  position: relative;
}

.auth-card input[type="password"],
.auth-card input[type="text"]#password {
  padding-right: 44px;
  width: calc(100% - 3rem - 44px);
}

.password-toggle {
  position: absolute;
  right: 0;
  top: 8px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.password-toggle:focus {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.registration-success {
  padding: 12px 0;
  text-align: center;
}

.registration-success .material-icons {
  color: var(--green);
  font-size: 52px;
}

.registration-success h2 {
  margin: 10px 0 8px;
  font-size: 1.4rem;
}

.status-filter {
  max-width: 260px;
  margin: 0 0 20px;
}

.user-section + .user-section {
  margin-top: 24px;
}

.registration-role {
  min-width: 170px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.table-actions {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.status-chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-pending {
  background: #fff8e1;
  color: #8d6e00;
}

.status-approved {
  background: #e8f5e9;
  color: var(--green);
}

.status-rejected {
  background: #ffebee;
  color: var(--red);
}

.full-width {
  width: 100%;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  padding: 20px;
}

.stat-card .material-icons {
  font-size: 30px;
}

.stat-card strong {
  display: block;
  margin: 10px 0 4px;
  font-size: 1.65rem;
}

.stat-card small {
  color: var(--muted);
}

.panel {
  padding: 22px;
}

.panel h2,
.modal h2 {
  font-size: 1.35rem;
  font-weight: 700;
}

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

.responsive-table,
.table-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.responsive-table table,
.table-wrapper table {
  width: 100%;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(240px, 1fr));
  gap: 16px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
}

.kanban-column {
  min-height: 420px;
  padding: 14px;
  scroll-snap-align: start;
}

.kanban-column h2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 700;
}

.order-card {
  padding: 14px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: #fbfdff;
}

.order-card strong {
  display: block;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.order-card small {
  display: block;
  color: var(--muted);
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.order-card .order-product {
  white-space: pre-line;
  margin: 8px 0 6px;
  color: var(--text);
  font-size: 0.95rem;
}

.order-total-preview {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  margin-top: 4px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.order-total-preview span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.order-total-preview span:last-child {
  border-top: 1px solid var(--line);
  padding-top: 6px;
  color: var(--text);
}

.order-card .order-elapsed {
  margin: 4px 0 6px;
  color: var(--blue);
  font-weight: 600;
}

.order-card .order-elapsed strong {
  display: inline;
  margin-bottom: 0;
  font-weight: 800;
}

.order-card .card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 9px;
  border-radius: 999px;
  background: #e3f2fd;
  color: var(--blue);
  font-size: 0.8rem;
  font-weight: 700;
}

.two-column {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
}

.collection {
  border-radius: 8px;
}

.collection .collection-item.avatar {
  min-height: 72px;
}

.search-field {
  margin-top: 0;
}

.delivery-item {
  padding-right: 16px;
}

.delivery-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.delivery-user-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 8px;
}

.delivery-access-fields {
  display: none;
  padding-top: 4px;
}

.delivery-access-fields.is-visible {
  display: block;
}

.delivery-user-link {
  display: block;
  margin-top: 4px;
  color: #455a64;
  font-size: 0.9rem;
}

.delivery-main {
  max-width: 840px;
}

.delivery-status {
  margin-bottom: 14px;
  color: #455a64;
  font-weight: 600;
}

.my-deliveries {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.my-delivery-card,
.empty-delivery-state {
  border: 1px solid #d9e2ec;
  border-radius: 8px;
  background: #fff;
  padding: 18px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

.my-delivery-card__top,
.delivery-customer,
.delivery-address,
.delivery-meta,
.delivery-items li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.my-delivery-card__top {
  align-items: center;
  border-bottom: 1px solid #e5edf5;
  padding-bottom: 12px;
}

.my-delivery-card__top h2 {
  margin: 0;
  color: #0d47a1;
  font-size: 1.8rem;
  line-height: 1.1;
}

.my-delivery-card__top strong {
  color: #1b5e20;
  font-size: 1.3rem;
}

.order-label {
  display: block;
  color: #607d8b;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.delivery-customer {
  align-items: center;
  margin-top: 14px;
}

.delivery-customer strong {
  font-size: 1.15rem;
}

.delivery-customer a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #1565c0;
  font-weight: 700;
}

.delivery-address {
  justify-content: flex-start;
  margin: 16px 0;
  border-radius: 8px;
  background: #eef6ff;
  padding: 14px;
}

.delivery-address > .material-icons {
  color: #1565c0;
}

.delivery-address strong,
.delivery-address span {
  display: block;
}

.delivery-address strong {
  color: #102a43;
  font-size: 1.08rem;
}

.delivery-address span {
  margin-top: 3px;
  color: #334e68;
}

.delivery-meta {
  margin: 0 0 14px;
}

.delivery-meta div {
  min-width: 0;
}

.delivery-meta dt {
  color: #607d8b;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.delivery-meta dd {
  margin: 0;
  color: #102a43;
  font-weight: 700;
}

.delivery-items {
  margin-bottom: 16px;
}

.delivery-items h3,
.empty-delivery-state h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.delivery-items ul {
  margin: 0;
}

.delivery-items li {
  border-top: 1px solid #eef2f7;
  padding: 8px 0;
}

.empty-delivery-state {
  text-align: center;
}

.empty-delivery-state .material-icons {
  color: #2e7d32;
  font-size: 3rem;
}

.product-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.product-search {
  flex: 1;
  margin: 0;
}

.product-inactive-filter {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  white-space: nowrap;
}

.products-table th:last-child,
.products-table td:last-child {
  position: sticky;
  right: 0;
  z-index: 1;
  min-width: 190px;
  background: var(--surface);
  box-shadow: -8px 0 12px rgba(24, 36, 51, 0.06);
}

.products-table th:last-child {
  z-index: 2;
}

.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  color: var(--muted);
}

.pagination-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pagination-actions span {
  color: var(--text);
  font-weight: 700;
}

.status-pill.inactive {
  background: #eeeeee;
  color: #616161;
}

.print-queue-filters {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(180px, 240px) auto auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.print-queue-filters .input-field {
  margin: 0;
}

.print-queue-table {
  min-width: 1050px;
}

.reports-panel {
  overflow: visible;
}

.reports-tabs {
  margin-bottom: 22px;
}

.report-tab-content {
  padding-top: 14px;
}

.report-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr)) auto;
  align-items: end;
  gap: 14px;
  margin-bottom: 14px;
}

.report-filters .input-field {
  margin: 0;
}

.report-filter-actions,
.report-export-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.report-filter-actions {
  justify-content: flex-end;
}

.report-export-actions {
  margin: 10px 0 18px;
}

.report-stats {
  margin-bottom: 18px;
}

.report-section {
  margin-top: 22px;
}

.report-section h2 {
  margin: 0 0 12px;
  color: #102a43;
  font-size: 1.25rem;
}

.print-status {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.print-status-pending {
  background: #fff8e1;
  color: #8d6e00;
}

.print-status-printed {
  background: #e8f5e9;
  color: var(--green);
}

.print-status-error {
  background: #ffebee;
  color: var(--red);
}

.print-status-cancelled {
  background: #eeeeee;
  color: #616161;
}

.print-error-cell {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.address-suggestions {
  display: none;
  margin-top: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.address-suggestions.is-visible {
  display: block;
}

.address-suggestion {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.address-suggestion:last-child {
  border-bottom: 0;
}

.address-suggestion:hover,
.address-suggestion:focus {
  background: #eef6ff;
  outline: none;
}

.address-suggestion strong,
.address-suggestion span {
  display: block;
}

.address-suggestion span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.9rem;
}

.modal {
  width: min(760px, 95vw);
  max-width: 95vw;
  max-height: 90vh;
}

.modal .modal-content {
  width: 100%;
  max-width: 100%;
  max-height: calc(90vh - 64px);
  overflow-x: hidden;
  overflow-y: auto;
}

.modal .modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  height: auto;
  min-height: 56px;
  padding: 8px 16px;
}

.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px 18px;
  flex-wrap: wrap;
  width: 100%;
  padding: 18px 12px 24px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.auth-page .app-footer,
.app-shell .app-footer {
  padding-top: 0;
}

@media (max-width: 920px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kanban-board {
    grid-template-columns: repeat(4, 280px);
  }

  .two-column {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .container-wide,
  .page-content,
  .centered-page,
  .auth-container {
    width: 100%;
    max-width: 100%;
  }

  .container-wide {
    padding-right: 12px;
    padding-left: 12px;
  }

  .page-content {
    padding-top: 20px;
    padding-bottom: 32px;
  }

  .stats-grid,
  .two-column,
  .print-queue-filters,
  .report-filters {
    grid-template-columns: 1fr !important;
  }

  .print-queue-filters > button,
  .report-filter-actions > button,
  .report-filter-actions > .btn,
  .report-filter-actions > .btn-flat,
  .report-export-actions > button {
    width: 100%;
  }

  .report-filter-actions,
  .report-export-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .responsive-table table,
  .table-wrapper table {
    min-width: 700px;
  }

  .products-table-wrapper {
    overflow-x: visible;
    overflow-y: visible;
  }

  .products-table {
    min-width: 0 !important;
  }

  .products-table thead {
    display: none;
  }

  .products-table,
  .products-table tbody,
  .products-table tr,
  .products-table td {
    display: block;
    width: 100%;
  }

  .products-table tr {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
  }

  .products-table td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #eef2f7;
    overflow-wrap: anywhere;
  }

  .products-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 700;
  }

  .products-table td:last-child {
    position: static;
    z-index: auto;
    display: block;
    min-width: 0;
    padding-top: 10px;
    border-bottom: 0;
    background: transparent;
    box-shadow: none;
  }

  .products-table td:last-child::before {
    display: block;
    margin-bottom: 8px;
  }

  .products-table .products-empty-cell {
    display: block;
    text-align: center;
  }

  .products-table .products-empty-cell::before {
    display: none;
  }

  .products-table .table-actions {
    flex-direction: row;
    align-items: center;
    gap: 6px;
  }

  .products-table .table-actions .btn-small {
    flex: 1 1 96px;
    width: auto;
    height: 34px;
    min-height: 34px;
    padding: 0 8px;
    font-size: 0.78rem;
    line-height: 34px;
  }

  .products-table .table-actions .material-icons {
    margin-right: 4px;
    font-size: 16px;
    line-height: 34px;
  }

  .page-actions,
  .table-actions,
  .delivery-actions,
  .welcome-actions,
  .modal .modal-footer {
    flex-wrap: wrap;
    gap: 8px;
  }

  button,
  .btn,
  .btn-small,
  .btn-large {
    min-height: 44px;
  }

  .modal,
  .modal .modal-content {
    width: 95vw;
    max-width: 95vw;
  }

  .modal .modal-content {
    padding: 20px 16px;
  }

  .modal .row {
    margin-right: 0;
    margin-left: 0;
  }

  .modal .row .col {
    width: 100%;
    margin-left: 0;
    padding-right: 0;
    padding-left: 0;
  }

  .modal .modal-footer > button,
  .modal .modal-footer > .btn,
  .modal .modal-footer > .btn-flat {
    flex: 1 1 140px;
    margin: 0;
  }

  .kanban-board {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-right: 0;
    padding-right: 0;
    overflow-x: visible;
    scroll-snap-type: none;
  }

  .kanban-column {
    width: 100%;
    min-height: auto;
    scroll-snap-align: none;
  }

  .order-card,
  .order-card .card-actions,
  .order-card .card-actions .btn-small {
    max-width: 100%;
  }

  .order-card .card-actions .btn-small {
    white-space: normal;
  }
}

@media (max-width: 600px) {
  .container-wide {
    width: 100%;
  }

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

  .page-header h1 {
    font-size: 1.65rem;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions > .btn,
  .page-actions > .btn-large,
  .page-actions > button,
  .page-actions > a {
    flex: 1 1 145px;
    margin: 0;
    text-align: center;
  }

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

  .welcome-panel,
  .auth-card,
  .panel {
    width: 100%;
    max-width: 100%;
    padding: 18px;
  }

  .centered-page,
  .auth-container {
    padding: 12px;
  }

  .welcome-panel h1 {
    font-size: 2.2rem;
  }

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

  .panel-title > button,
  .panel-title > .btn,
  .panel-title > .btn-flat {
    width: 100%;
    margin: 0;
  }

  .delivery-actions {
    justify-content: flex-start;
  }

  .my-delivery-card,
  .empty-delivery-state {
    padding: 16px;
  }

  .my-delivery-card__top,
  .delivery-customer,
  .delivery-meta,
  .delivery-items li {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .my-delivery-card__top strong {
    font-size: 1.2rem;
  }

  .delivery-address {
    padding: 12px;
  }

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

  .table-pagination,
  .pagination-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .pagination-actions .btn-small {
    width: 100%;
  }

  .order-card {
    padding: 12px;
  }

  .order-card .card-actions .btn-small {
    width: 100%;
  }

  .collection .collection-item.avatar {
    padding-left: 20px;
  }

  .delivery-item {
    padding-right: 20px;
  }

  .registration-role {
    min-width: 150px;
  }
}

@media (max-width: 360px) {
  .container-wide {
    padding-right: 10px;
    padding-left: 10px;
  }

  .page-content {
    padding-top: 16px;
  }

  .welcome-panel,
  .auth-card,
  .panel,
  .stat-card {
    padding: 16px;
  }

  .welcome-panel h1 {
    font-size: 2rem;
  }

  .auth-header h1 {
    font-size: 1.7rem;
  }

  .kanban-board {
    grid-template-columns: 1fr;
    margin-right: 0;
    padding-right: 0;
  }
}
