:root {
  --bg: #f0f4f9;
  --card: #ffffff;
  --text: #102030;
  --muted: #5f7284;
  --line: #d7e1ea;
  --accent: #0957d0;
  --danger: #c62828;
  --success: #1f8d49;
  --warning: #ed8a19;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, #dbeafe 0%, transparent 26%),
    radial-gradient(circle at 90% 0%, #e8f5e9 0%, transparent 24%),
    var(--bg);
}

.container {
  width: min(920px, 94%);
  margin: 1.25rem auto 2rem;
}

.auth-container {
  width: min(460px, 94%);
  margin-top: 3rem;
}

h1,
h2 {
  margin: 0 0 0.5rem;
}

h1 {
  font-size: 1.65rem;
}

h2 {
  font-size: 1.15rem;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.settings-menu {
  position: relative;
}

.settings-button {
  list-style: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdff;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.settings-button::-webkit-details-marker {
  display: none;
}

.settings-button svg {
  width: 20px;
  height: 20px;
  stroke: #174785;
  stroke-width: 1.5;
  fill: none;
}

.settings-menu[open] .settings-button {
  background: #e8f1fe;
  border-color: #bfd7ff;
}

.settings-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  width: min(860px, 92vw);
  z-index: 50;
  margin-bottom: 0;
}

.settings-block + .settings-block {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 8px 24px rgba(16, 32, 48, 0.05);
  margin-bottom: 1rem;
}

.form-grid {
  display: grid;
  gap: 0.8rem;
}

.form-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.93rem;
}

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

.checkbox-inline input {
  width: auto;
  margin: 0;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.75rem;
  background: #fbfdff;
}

textarea {
  resize: vertical;
}

button {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  padding: 0.7rem 0.95rem;
  cursor: pointer;
}

button.secondary {
  background: #e2ebf7;
  color: #174785;
}

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

.actions {
  display: flex;
  gap: 0.65rem;
  margin-top: 0.65rem;
  align-items: center;
  flex-wrap: wrap;
}

.flash {
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.85rem;
  border: 1px solid transparent;
  white-space: pre-wrap;
}

.ai-autofill-status {
  font-size: 0.86rem;
}

.flash.info {
  background: #e8f1fe;
  border-color: #bfd7ff;
}

.flash.error {
  background: #fde8e8;
  border-color: #f3b9b9;
}

.flash.success {
  background: #e8f8ed;
  border-color: #bae8c6;
}

.live-status {
  background: #fff2d7;
  border: 1px solid #f6d58a;
  color: #7a5305;
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  margin-bottom: 1rem;
}

.live-status.hidden {
  display: none;
}

.site-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  display: inline-block;
  text-decoration: none;
  border: 1px solid #bfd7ff;
  color: #16488f;
  background: #e8f1fe;
  border-radius: 999px;
  padding: 0.38rem 0.75rem;
  font-size: 0.88rem;
}

.chip.active {
  border-color: #0f50ba;
  background: #0f50ba;
  color: #ffffff;
}

.current-site {
  margin-top: 0.65rem;
}

.list {
  display: grid;
  gap: 0.9rem;
}

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

.indent-editable-highlight {
  background: #fff8db;
  border-color: #f1d176;
}

.indent-editable-note {
  color: #8a6402;
  font-weight: 700;
}

.nil-po-highlight {
  background: #fff8db;
  border-color: #f1d176;
}

.nil-po-note {
  color: #8a6402;
  font-weight: 700;
}

.vehicle-duplicate-highlight {
  background: #fff4bf;
  border-color: #e8c23f;
}

.vehicle-duplicate-note {
  color: #8a6402;
  font-weight: 700;
  font-size: 0.82rem;
  margin-left: 0.35rem;
}

.staff-note-highlight {
  border-color: #e3bf51;
  background: #fff9df;
}

.staff-note-callout {
  background: #fff4bf;
  border: 1px solid #e8c23f;
  color: #7a5305;
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  font-weight: 700;
}

.staff-note-inline {
  display: inline-block;
  background: #fff4bf;
  border: 1px solid #e8c23f;
  color: #7a5305;
  border-radius: 999px;
  padding: 0.14rem 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.delivery-missed-highlight {
  border-color: #e36a6a;
  background: #ffe8e8;
}

.delivery-missed-note {
  color: #a22323;
  font-weight: 700;
}

.item p {
  margin: 0.45rem 0;
}

.item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}

.badge {
  border-radius: 999px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.22rem 0.55rem;
  font-weight: 700;
}

.badge.pending {
  background: #fff0dd;
  color: var(--warning);
}

.badge.approved {
  background: #e6f7ec;
  color: var(--success);
}

.badge.rejected {
  background: #fdeaea;
  color: var(--danger);
}

.badge.inprogress {
  background: #e8f1fe;
  color: #174785;
}

.badge.attention {
  background: #fff0dd;
  color: #8a6402;
}

.manager-pending-note {
  color: #8a6402;
  font-weight: 700;
}

.preview {
  width: 100%;
  max-height: 360px;
  border-radius: 12px;
  border: 1px solid var(--line);
  object-fit: cover;
  background: #f8fbff;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.55rem;
}

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

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

th,
td {
  text-align: left;
  padding: 0.55rem 0.45rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
  vertical-align: top;
}

tr.nil-po-highlight td {
  background: #fff8db;
}

tr.vehicle-duplicate-highlight td {
  background: #fff4bf;
}

tr.staff-note-highlight td {
  background: #fff9df;
}

tr.delivery-missed-highlight td {
  background: #ffe8e8;
}

.small-note p {
  margin: 0.25rem 0;
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .settings-panel {
    width: 95vw;
    right: 0;
  }

  .container {
    width: 95%;
    margin-top: 1rem;
  }

  .actions {
    flex-wrap: wrap;
  }

  .actions form,
  .actions button {
    width: 100%;
  }
}
