:root {
  --bg: #0f1420;
  --panel: #171d2b;
  --panel-2: #1f2635;
  --border: #2a3244;
  --text: #e7ebf3;
  --muted: #97a1b6;
  --accent: #5b8cff;
  --accent-2: #38c78f;
  --danger: #ef5a6f;
  --warn: #f0a840;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout {
  display: flex;
  min-height: 100vh;
  align-items: flex-start;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-x: hidden;
  transition: width 0.15s ease;
}

.sidebar.collapsed { width: 60px; }

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.sidebar.collapsed .sidebar-top { justify-content: center; padding: 16px 8px; }
.sidebar.collapsed .brand { display: none; }

.brand { font-weight: 700; font-size: 15px; }

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  flex-shrink: 0;
}

.sidebar-toggle:hover { background: var(--panel-2); color: var(--text); }

.new-order-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 12px;
  padding: 10px 14px;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
}

.new-order-btn:hover { text-decoration: none; filter: brightness(1.08); }
.sidebar.collapsed .new-order-btn { margin: 14px 8px; padding: 10px; justify-content: center; }
.sidebar.collapsed .new-order-btn .label { display: none; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.sidebar-nav a.active { background: var(--panel-2); color: var(--text); font-weight: 600; }
.sidebar.collapsed .sidebar-nav a { justify-content: center; padding: 10px; }
.sidebar.collapsed .sidebar-nav a .label { display: none; }

.nav-icon { font-size: 16px; flex-shrink: 0; width: 18px; text-align: center; }

.sidebar-bottom {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-bottom .username { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.sidebar-bottom .role { font-size: 11px; color: var(--muted); display: block; }
.sidebar.collapsed .sidebar-bottom .username, .sidebar.collapsed .sidebar-bottom .role { display: none; }
.sidebar.collapsed .sidebar-bottom { justify-content: center; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card { width: 100%; max-width: 340px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card p.muted { margin: 0 0 20px; font-size: 13px; }

main {
  flex: 1;
  min-width: 0;
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 720px) {
  .sidebar:not(.collapsed) { width: 60px; }
  .sidebar:not(.collapsed) .brand,
  .sidebar:not(.collapsed) .new-order-btn .label,
  .sidebar:not(.collapsed) .sidebar-nav a .label { display: none; }
  .sidebar:not(.collapsed) .new-order-btn { justify-content: center; padding: 10px; }
  .sidebar:not(.collapsed) .sidebar-nav a { justify-content: center; padding: 10px; }
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
}

h2 { margin-top: 0; }

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}

input, select, textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 14px;
}

input:focus, select:focus, textarea:focus {
  outline: 1px solid var(--accent);
}

.field { margin-bottom: 12px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  background: var(--accent);
  color: white;
}

button.secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}

button.danger {
  background: var(--danger);
}

button.small {
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
}

.items-table th, .items-table td {
  border: 1px solid var(--border);
  padding: 6px;
  font-size: 13px;
}

.items-table th { color: var(--muted); text-align: left; }

table.orders-table {
  width: 100%;
  border-collapse: collapse;
}

table.orders-table th, table.orders-table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  font-size: 14px;
  text-align: left;
}

table.orders-table th { color: var(--muted); font-weight: 600; }
table.orders-table tr:hover { background: var(--panel-2); }

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  border: 1px solid rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
}

.receipt-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.receipt-card {
  width: 160px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.receipt-thumb {
  display: block;
  width: 160px;
  height: 160px;
  object-fit: cover;
  background: #fff;
}

.receipt-file-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 160px;
  height: 160px;
  font-size: 48px;
  text-decoration: none;
}

.receipt-card-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  font-size: 12px;
  border-top: 1px solid var(--border);
}

.receipt-card-foot .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: var(--panel-2);
}

.dropzone input[type="file"] { margin-top: 8px; }

.pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--panel-2);
  border: 1px solid var(--border);
}

.pill.new { color: var(--accent); }
.pill.to_collect { color: var(--warn); }
.pill.collected { color: var(--accent-2); }
.pill.shipped { color: #6fd0ff; }
.pill.delivered { color: #9be38a; }
.pill.cancelled { color: var(--danger); }

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar input[type="search"] { max-width: 280px; }
.spacer { flex: 1; }

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 12px;
  overflow-x: auto;
}

.board-col {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 200px;
}

.board-col h3 {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 4px 4px 10px;
  display: flex;
  justify-content: space-between;
}

.board-col.dragover { outline: 2px dashed var(--accent); }

.order-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: grab;
  font-size: 13px;
}

.order-card:active { cursor: grabbing; }
.order-card .name { font-weight: 600; margin-bottom: 4px; }
.order-card .meta { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.order-card .total { margin-top: 6px; font-weight: 700; color: var(--accent-2); }

.muted { color: var(--muted); }
.right { text-align: right; }

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 40px 0;
}

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}

.toast {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  animation: toast-in 0.15s ease;
}

.toast.success { border-left-color: var(--accent-2); }
.toast.error { border-left-color: var(--danger); }

.toast-out { animation: toast-out 0.2s ease forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px); }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 16, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.modal-box p { margin: 0 0 18px; font-size: 14px; line-height: 1.5; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
