/* =====================================================================
   WMS Web - design system
   ===================================================================== */
:root {
  --navy-900: #0f172a;
  --navy-800: #1e293b;
  --navy-700: #334155;
  --slate-500: #64748b;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50:  #f8fafc;
  --blue-600:  #2563eb;
  --blue-700:  #1d4ed8;
  --blue-50:   #eff6ff;
  --green-600: #16a34a;
  --green-50:  #f0fdf4;
  --red-600:   #dc2626;
  --red-50:    #fef2f2;
  --amber-600: #d97706;
  --amber-50:  #fffbeb;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow-md: 0 4px 14px rgba(15,23,42,.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', -apple-system, Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  background: var(--slate-50);
  color: var(--navy-900);
  font-size: 14px;
  line-height: 1.5;
}
h1 { font-size: 1.4rem; font-weight: 700; margin: 0 0 1.2rem; color: var(--navy-900); }
h2 { font-size: 1.05rem; font-weight: 600; margin: 1.6rem 0 .8rem; color: var(--navy-800); }
a { color: var(--blue-600); }

/* ---------- Auth pages (login / select site) ---------- */
.auth-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-800) 45%, var(--blue-700) 100%);
}
.auth-box {
  background: #fff; padding: 2.4rem 2.2rem; border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25); width: 360px;
}
.auth-box h1 {
  margin: 0 0 .3rem; font-size: 1.3rem; display: flex; align-items: center; gap: .5rem;
}
.auth-box h1::before {
  content: 'WB'; display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px; background: var(--blue-600); color: #fff;
  font-size: .8rem; font-weight: 700; letter-spacing: .5px;
}
.auth-box label { display: block; margin-top: 1rem; font-size: .8rem; font-weight: 600; color: var(--slate-500); }
.auth-box input {
  width: 100%; padding: .65rem .75rem; margin-top: .3rem; border: 1px solid var(--slate-300);
  border-radius: 8px; font-size: .95rem; transition: border-color .15s;
}
.auth-box input:focus { outline: none; border-color: var(--blue-600); box-shadow: 0 0 0 3px var(--blue-50); }
.auth-box button, .auth-box .btn-primary-wide {
  margin-top: 1.4rem; width: 100%; padding: .7rem; background: var(--blue-600); color: #fff;
  border: none; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: .95rem;
  transition: background .15s;
}
.auth-box button:hover { background: var(--blue-700); }

.site-list { display: flex; flex-direction: column; gap: .6rem; margin: 1.1rem 0; }
.site-option {
  display: flex; align-items: center; gap: .6rem; padding: .7rem .8rem; border: 1px solid var(--slate-200);
  border-radius: 8px; cursor: pointer; transition: border-color .15s, background .15s;
}
.site-option:hover { border-color: var(--blue-600); background: var(--blue-50); }
.site-option input { width: auto; margin: 0; }
.site-option small { color: var(--slate-500); display: block; }

.error { color: var(--red-600); background: var(--red-50); border: 1px solid #fecaca; padding: .6rem .8rem; border-radius: 8px; font-size: .85rem; }
.ok { color: var(--green-600); background: var(--green-50); border: 1px solid #bbf7d0; padding: .6rem .8rem; border-radius: 8px; font-size: .85rem; }

/* ---------- App shell (sidebar + topbar) ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; flex-shrink: 0; background: var(--navy-900); color: var(--slate-300);
  display: flex; flex-direction: column; padding: 1.1rem 0;
}
.sidebar .brand {
  display: flex; align-items: center; gap: .6rem; padding: 0 1.2rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 1rem;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; background: var(--blue-600); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .75rem; flex-shrink: 0;
}
.brand-text { font-weight: 700; color: #fff; font-size: 1rem; }

.side-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 .7rem; }
.side-nav a {
  display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border-radius: 8px;
  color: var(--slate-300); text-decoration: none; font-size: .88rem; font-weight: 500;
  transition: background .15s, color .15s;
}
.side-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-nav a.active { background: var(--blue-600); color: #fff; }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 1rem; background: #fff; border-bottom: 1px solid var(--slate-200);
  padding: .85rem 1.6rem; position: sticky; top: 0; z-index: 5;
}
.page-title { font-weight: 700; font-size: 1.05rem; color: var(--navy-900); }
.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: .6rem; padding: .3rem .6rem .3rem .3rem; border-radius: 999px; background: var(--slate-100); }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--blue-600); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem;
}
.user-info { display: flex; flex-direction: column; line-height: 1.15; }
.user-info strong { font-size: .8rem; color: var(--navy-900); }
.user-info small { font-size: .7rem; color: var(--slate-500); }

.content { padding: 1.6rem 1.8rem 3rem; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ---------- Buttons ---------- */
button, .btn {
  display: inline-flex; align-items: center; gap: .4rem; padding: .55rem 1rem; border-radius: 8px;
  border: 1px solid var(--blue-600); background: var(--blue-600); color: #fff; font-weight: 600;
  font-size: .85rem; cursor: pointer; text-decoration: none; transition: background .15s, box-shadow .15s;
}
button:hover, .btn:hover { background: var(--blue-700); border-color: var(--blue-700); }
.btn-ghost { background: transparent; color: var(--slate-500); border: 1px solid var(--slate-300); }
.btn-ghost:hover { background: var(--slate-100); color: var(--navy-900); }

/* ---------- Live weight dashboard cards ---------- */
.wb-cards { display: flex; flex-wrap: wrap; gap: 1rem; }
.wb-card {
  background: #fff; border-radius: var(--radius); padding: 1.3rem 1.4rem; width: 230px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--slate-200); border-top: 4px solid var(--slate-300);
  transition: box-shadow .15s;
}
.wb-card:hover { box-shadow: var(--shadow-md); }
.wb-card.online { border-top-color: var(--green-600); }
.wb-card.offline { border-top-color: var(--red-600); }
.wb-card h3 { margin: 0 0 .5rem; font-size: .85rem; font-weight: 600; color: var(--slate-500); text-transform: uppercase; letter-spacing: .03em; }
.wb-card .weight { font-size: 2.1rem; font-weight: 800; color: var(--navy-900); margin: .2rem 0; }
.wb-card .weight small { font-size: 1rem; font-weight: 500; color: var(--slate-500); }
.wb-card .status { font-size: .8rem; font-weight: 600; color: var(--slate-500); }
.wb-card.online .status { color: var(--green-600); }
.wb-card.offline .status { color: var(--red-600); }

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1.2rem;
  background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius); padding: .9rem 1rem;
}
.filter-bar input, .filter-bar select {
  padding: .5rem .7rem; border: 1px solid var(--slate-300); border-radius: 7px; font-size: .85rem; background: #fff;
}
.filter-bar input:focus, .filter-bar select:focus { outline: none; border-color: var(--blue-600); }
.filter-bar label { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--slate-500); }

.export-links { margin: 0 0 1rem; font-size: .85rem; color: var(--slate-500); }
.export-links a { font-weight: 600; }

.badge {
  display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .02em;
}
.badge-active, .badge-completed, .badge-online { background: var(--green-50); color: var(--green-600); }
.badge-inactive, .badge-disabled { background: var(--slate-100); color: var(--slate-500); }
.badge-open { background: var(--amber-50); color: var(--amber-600); }
.badge-void, .badge-suspended, .badge-offline { background: var(--red-50); color: var(--red-600); }

/* ---------- Tables ---------- */
table.grid {
  width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm); border: 1px solid var(--slate-200);
}
table.grid th, table.grid td { padding: .65rem .9rem; text-align: left; font-size: .85rem; border-bottom: 1px solid var(--slate-100); }
table.grid th {
  background: var(--slate-50); font-weight: 600; color: var(--slate-500); text-transform: uppercase;
  font-size: .72rem; letter-spacing: .04em;
}
table.grid th a { color: var(--slate-500); text-decoration: none; }
table.grid th a:hover { color: var(--navy-900); }
table.grid tbody tr:hover { background: var(--blue-50); }
table.grid tbody tr:last-child td { border-bottom: none; }

.pagination { margin-top: 1rem; display: flex; gap: .3rem; }
.pagination a {
  padding: .4rem .75rem; border: 1px solid var(--slate-300); border-radius: 7px; text-decoration: none;
  color: var(--navy-900); font-size: .82rem; font-weight: 600; background: #fff;
}
.pagination a:hover { border-color: var(--blue-600); color: var(--blue-600); }
.pagination a.active { background: var(--blue-600); color: #fff; border-color: var(--blue-600); }

/* ---------- Forms (masters, admin, create user) ---------- */
form { max-width: 100%; }
form label { display: block; margin: .6rem 0; font-size: .82rem; font-weight: 600; color: var(--slate-500); }
form input[type=text], form input[type=password], form input[type=file], form input[type=number], form select {
  padding: .55rem .7rem; border: 1px solid var(--slate-300); border-radius: 7px; font-size: .85rem;
  background: #fff; margin-top: .25rem;
}
form input[type=text]:focus, form input[type=password]:focus, form select:focus { outline: none; border-color: var(--blue-600); }
fieldset { margin-top: 1rem; border: 1px solid var(--slate-200); border-radius: var(--radius); padding: 1rem; background: #fff; }
fieldset legend { font-size: .78rem; font-weight: 600; color: var(--slate-500); padding: 0 .4rem; }

/* Small "add new record" forms - opt in via class="form-card" */
.form-card {
  background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius); padding: 1.1rem 1.2rem;
  display: flex; flex-wrap: wrap; gap: .7rem; align-items: end; max-width: 900px;
}
.form-card label { margin: 0; }
.form-card button { align-self: end; }

/* Forms that wrap a table (e.g. Field Settings) just need breathing room above the submit button */
form.table-form { background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
form.table-form button { margin-top: 1rem; }

code {
  background: var(--slate-100); padding: .15rem .4rem; border-radius: 5px; font-size: .82rem;
  color: var(--navy-800); word-break: break-all;
}
