:root {
  --bg: #f5efe6;
  --surface: rgba(255, 251, 246, 0.84);
  --surface-strong: #fffaf2;
  --ink: #1f2933;
  --muted: #5b6670;
  --line: rgba(31, 41, 51, 0.1);
  --accent: #0f766e;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --warning: #c2410c;
  --warning-soft: rgba(194, 65, 12, 0.12);
  --shadow: 0 20px 45px rgba(77, 52, 28, 0.12);
  --action-control-size: 2rem;
  --action-cell-pad: 0.25rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.18), transparent 32%),
    radial-gradient(circle at right center, rgba(194, 65, 12, 0.12), transparent 28%),
    linear-gradient(180deg, #f8f4ed 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

code,
input,
button,
table {
  font-family: "SFMono-Regular", "Menlo", monospace;
}

h1,
h2,
h3,
.metric-value {
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
}

.page-shell {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.topbar,
.panel {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  padding: 1.8rem;
}

.topbar-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.topbar h1 {
  margin: 0.2rem 0 0.5rem;
  font-size: clamp(2.2rem, 4vw, 3.4rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.topbar-text,
.empty-state,
th,
td,
label,
.flash,
.compact-list span {
  color: var(--muted);
}

.eyebrow,
.section-kicker,
.panel-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.74rem;
  color: var(--accent);
}

.section-title-accent {
  margin-top: 0.25rem;
  font-size: 1rem;
}

.layout {
  display: block;
  margin-top: 1.5rem;
}

.login-shell {
  min-height: calc(100vh - 6rem);
  display: grid;
  place-items: center;
}

.login-panel {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  padding: 1.8rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.password-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.35rem;
}

.content-stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.content-stack > .flash {
  order: -2;
}

.content-stack > .received-panel {
  order: -1;
}

.panel {
  padding: 1.4rem;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.1rem;
}

.section-heading h2 {
  margin: 0.2rem 0 0;
  font-size: 1.7rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.42rem 0.72rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.82rem;
  white-space: nowrap;
}

.account-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.session-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.2rem;
  padding: 0.45rem 2.3rem 0.45rem 0.8rem;
  border-radius: 999px;
  background: rgba(31, 41, 51, 0.08);
  color: var(--ink);
  font-size: 0.82rem;
  cursor: pointer;
  list-style: none;
  position: relative;
}

.session-chip::-webkit-details-marker {
  display: none;
}

.session-chip:hover,
.account-dropdown[open] .session-chip {
  background: rgba(31, 41, 51, 0.12);
}

.session-chip-arrow {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.8rem;
}

.account-dropdown {
  position: relative;
}

.icon-button {
  width: 2.3rem;
  height: 2.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(31, 41, 51, 0.06);
  color: var(--ink);
  text-decoration: none;
}

.icon-button:hover {
  background: rgba(31, 41, 51, 0.1);
}

.gear-glyph {
  font-size: 1rem;
  line-height: 1;
}

.account-dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.45rem);
  min-width: 180px;
  padding: 0.45rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  z-index: 10;
}

.account-menu-link,
.account-menu-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  text-decoration: none;
  font-size: 0.84rem;
}

.account-menu-link {
  background: transparent;
  color: var(--ink);
}

.account-menu-link:hover {
  background: rgba(31, 41, 51, 0.08);
}

.account-menu-button {
  margin-top: 0;
  border: none;
  background: transparent;
  color: var(--warning);
  cursor: pointer;
}

.account-menu-button:hover {
  filter: none;
  background: rgba(194, 65, 12, 0.08);
}

.settings-form {
  margin-top: 1rem;
}

.token-output {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(15, 118, 110, 0.05);
}

.token-input {
  margin-top: 0.45rem;
}

.token-help {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

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

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

th,
td {
  padding: 0.88rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}

th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

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

.sort-link:hover {
  color: var(--ink);
}

.sort-link.active {
  color: var(--ink);
}

.sort-arrow {
  color: var(--accent);
  font-size: 0.92em;
  line-height: 1;
}

.add-row td {
  background: rgba(15, 118, 110, 0.05);
}

.action-column,
.action-cell {
  width: calc(var(--action-control-size) + (var(--action-cell-pad) * 2));
  white-space: nowrap;
  text-align: center;
}

.action-cell {
  padding-left: var(--action-cell-pad);
  padding-right: var(--action-cell-pad);
}

.action-controls-cell {
  width: auto;
}

.action-controls-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.action-cell form {
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.order-form {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.35rem;
}

input {
  width: 100%;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(31, 41, 51, 0.12);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font-size: 0.94rem;
}

input:focus {
  outline: 2px solid rgba(15, 118, 110, 0.18);
  border-color: var(--accent);
}

.inline-input {
  min-width: 120px;
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  font-size: 0.86rem;
  margin: 0;
}

button {
  margin-top: 0.35rem;
  padding: 0.95rem 1rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #0f766e, #155e75);
  color: white;
  font-size: 0.92rem;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.04);
}

.edit-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent);
  font-size: 0.82rem;
  text-decoration: none;
  white-space: nowrap;
}

.edit-link:hover {
  background: rgba(15, 118, 110, 0.18);
}

.secondary-link {
  background: rgba(31, 41, 51, 0.08);
  color: var(--ink);
}

.secondary-link:hover {
  background: rgba(31, 41, 51, 0.12);
}

@media (max-width: 720px) {
  .topbar-row {
    flex-direction: column;
  }

  .account-bar {
    justify-content: flex-start;
  }
}

.table-button {
  margin: 0;
  padding: 0.6rem 0.8rem;
  font-size: 0.82rem;
}

.action-cell .edit-link {
  min-height: 1.9rem;
  padding: 0.3rem 0.55rem;
}

.edit-glyph {
  width: var(--action-control-size);
  height: var(--action-control-size);
  font-size: 1rem;
  line-height: 1;
}

.action-cell .edit-link.edit-glyph {
  min-height: var(--action-control-size);
  padding: 0;
}

.received-button {
  margin: 0;
  width: var(--action-control-size);
  height: var(--action-control-size);
  padding: 0;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent);
  font-size: 1rem;
  line-height: 1;
}

.received-button:hover {
  background: rgba(15, 118, 110, 0.18);
  filter: none;
}

.picked-up-button {
  margin: 0;
  width: var(--action-control-size);
  height: var(--action-control-size);
  padding: 0;
  border-radius: 999px;
  background: rgba(2, 132, 199, 0.14);
  color: #0369a1;
  font-size: 0.95rem;
  line-height: 1;
}

.picked-up-button:hover {
  background: rgba(2, 132, 199, 0.22);
  filter: none;
}

.return-button {
  margin: 0;
  width: var(--action-control-size);
  height: var(--action-control-size);
  padding: 0;
  border-radius: 999px;
  background: rgba(31, 41, 51, 0.1);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1;
}

.return-button:hover {
  background: rgba(31, 41, 51, 0.16);
  filter: none;
}

.delete-button {
  margin: 0;
  width: var(--action-control-size);
  height: var(--action-control-size);
  padding: 0;
  border-radius: 999px;
  background: rgba(194, 65, 12, 0.12);
  color: var(--warning);
  font-size: 1rem;
  line-height: 1;
}

.delete-button:hover {
  background: rgba(194, 65, 12, 0.18);
  filter: none;
}

.flash {
  padding: 0.95rem 1rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.flash.success {
  border-color: rgba(15, 118, 110, 0.18);
  background: rgba(15, 118, 110, 0.08);
}

.flash.error {
  border-color: rgba(194, 65, 12, 0.16);
  background: rgba(194, 65, 12, 0.08);
}

.flash.warning {
  border-color: rgba(180, 83, 9, 0.16);
  background: rgba(180, 83, 9, 0.08);
}

.tracking-status {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.tracking-status strong {
  font-size: 0.92rem;
}

.tracking-status span,
.empty-inline {
  color: var(--muted);
  font-size: 0.8rem;
}

.api-note {
  margin-top: 1.3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 1rem, 100%);
    padding-top: 0.8rem;
  }

  .topbar,
  .panel {
    border-radius: 22px;
  }
}
