/* ============================================================
   XKIN PARTNER - Main Stylesheet
   Warm brown/tan theme - futuristic typography
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;700;800&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Dark brown gradient primary */
  --blue: #5C3317;
  --blue-dark: #3E1F08;
  --blue-light: #F2E8DE;
  --blue-border: #C4A882;

  /* Copper/gold accent */
  --copper: #B87333;
  --copper-light: #FAF0E6;

  /* Warm dark neutrals */
  --slate-50: #FAF6F0;
  --slate-100: #F0E8DC;
  --slate-200: #DDD0BC;
  --slate-300: #C4B09A;
  --slate-400: #9C8470;
  --slate-500: #7A6655;
  --slate-600: #5C4D3C;
  --slate-700: #3E342A;
  --slate-800: #261F17;
  --slate-900: #150E08;

  --amber-50: #fffbeb;
  --amber-200: #fde68a;
  --amber-600: #d97706;
  --amber-800: #92400e;

  --emerald-50: #ecfdf5;
  --emerald-200: #a7f3d0;
  --emerald-600: #059669;
  --emerald-800: #065f46;

  --red-50: #fef2f2;
  --red-100: #fee2e2;
  --red-200: #fecaca;
  --red-600: #dc2626;
  --red-700: #b91c1c;
  --red-800: #991b1b;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

html, body {
  font-family: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: var(--slate-50);
  color: var(--slate-900);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0.01em;
  overflow-x: hidden;
  max-width: 100vw;
}

a { color: inherit; text-decoration: none; }

/* ---------- Layout ---------- */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: linear-gradient(135deg, #3E1F08 0%, #5C3317 50%, #7A4520 100%);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-logo {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-logo img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  animation: brandPulse 3.5s ease-in-out infinite;
}
@keyframes brandPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.82; }
}
.brand-text .name {
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.08em;
  color: #fff;
}
.brand-text .hub-tag {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 6px;
  text-transform: uppercase;
}
.brand-text .tagline {
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
}

.session-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}
.profile-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius-md);
  padding: 7px 12px;
  color: #fff;
}
.profile-badge .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--copper);
}
.profile-badge .role {
  background: var(--copper);
  color: #fff;
  font-weight: 800;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 9px;
  letter-spacing: 0.1em;
}
.btn-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius-md);
  padding: 9px 14px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-logout:hover { background: rgba(220,38,38,0.7); color: #fff; border-color: transparent; }

.main-layout {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  gap: 24px;
}

/* ---------- Sidebar nav ---------- */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #3E1F08 0%, #2C1505 100%);
  border-radius: var(--radius-lg);
  padding: 12px 8px;
  position: sticky;
  top: 12px;
  height: calc(100vh - 80px);
  max-height: calc(100vh - 80px);
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
  display: flex;
  flex-direction: column;
}
.sidebar-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  padding: 4px 14px 8px;
}
.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,0.65);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(.4,0,.2,1);
  text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: #fff; transform: translateX(3px); }
.nav-item.active {
  background: linear-gradient(135deg, var(--copper) 0%, #D4A865 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transform: translateX(3px);
}
.nav-item .icon { font-size: 16px; width: 18px; text-align: center; display: inline-flex; align-items: center; justify-content: center; }
.nav-item .icon .xk-icon { width: 18px; height: 18px; flex-shrink: 0; }
/* On hover / active the item background is solid copper — flip icon to white for contrast */
.nav-item:hover .xk-icon,
.nav-item.active .xk-icon { stroke: #fff; }

/* ---------- Main content ---------- */
.content { flex: 1; min-width: 0; animation: contentFadeIn 0.3s ease; }
@keyframes contentFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.page-title { font-size: 24px; font-weight: 800; letter-spacing: -0.01em; }
.page-subtitle { font-size: 12px; color: var(--slate-500); margin-top: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.18s cubic-bezier(.4,0,.2,1);
  text-decoration: none;
}
.btn-primary { background: linear-gradient(135deg, var(--blue) 0%, var(--copper) 100%); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.btn-primary:hover { background: var(--blue-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(139,94,52,0.3); }
.btn-secondary { background: #fff; color: var(--slate-700); border-color: var(--slate-200); }
.btn-secondary:hover { background: var(--slate-50); transform: translateY(-1px); }
.btn-danger { background: var(--red-50); color: var(--red-600); border-color: var(--red-100); }
.btn-danger:hover { background: var(--red-100); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--slate-500); border-color: transparent; }
.btn-ghost:hover { background: var(--slate-100); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn-sm { padding: 6px 10px; font-size: 11px; }
.btn:active { transform: scale(0.97); }

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  animation: fadeInUp 0.4s ease both;
}
.card:hover {
  box-shadow: 0 6px 20px rgba(139,94,52,0.08);
  border-color: var(--blue-border);
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.card-pad { padding: 20px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--slate-100);
  margin-bottom: 14px;
}
.card-header h3 {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ---------- KPI grid ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: fadeInUp 0.4s ease both;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(139,94,52,0.1);
  border-color: var(--blue-border);
}
.kpi-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--slate-500);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.kpi-value {
  font-size: 26px;
  font-weight: 800;
  margin-top: 6px;
}
.kpi-value.blue { color: var(--blue); }
.kpi-value.amber { color: var(--amber-600); }
.kpi-value.emerald { color: var(--emerald-600); }
.kpi-sub { font-size: 11px; color: var(--slate-500); margin-top: 4px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th {
  text-align: left;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--slate-500);
  padding: 10px 12px;
  border-bottom: 1px solid var(--slate-200);
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--slate-100);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--slate-50); }

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 4px;
  padding: 2px 8px;
}
.badge-blue { background: var(--blue); color: #fff; }
.badge-outline { background: #fff; color: var(--slate-700); border: 1px solid var(--slate-200); }
.pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 3px 10px;
  border: 1px solid transparent;
}

/* status pill colors */
/* Status pills — colours match milestone_stages exactly */
.status-pending  { background: #fff8e8; color: #92400e; border-color: #fde68a; }
.status-cutting  { background: #fdf2e8; color: #6B3A1A; border-color: #C4A882; }
.status-stitching, .status-washing { background: #e8f0f8; color: #2d4e6e; border-color: #a8c4da; }
.status-dispatch { background: #e8f0f8; color: #2d4e6e; border-color: #a8c4da; }
.status-finishing { background: var(--slate-100); color: var(--slate-700); border-color: var(--slate-300); }
.status-completed, .status-delivered { background: #e8f8f0; color: #065f46; border-color: #a7f3d0; }

/* ---------- Progress bar ---------- */
.progress-track {
  width: 100%;
  height: 8px;
  background: var(--slate-200);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--fill-color, var(--copper));
  transition: width 0.8s cubic-bezier(.4,0,.2,1);
  position: relative;
}
/* Floating/breathing shimmer for active milestones */
.progress-fill[data-animate="true"] {
  background: linear-gradient(
    90deg,
    var(--fill-color, var(--copper)) 0%,
    var(--fill-highlight, #fff8) 40%,
    var(--fill-color, var(--copper)) 80%,
    var(--fill-color, var(--copper)) 100%
  );
  background-size: 300% 100%;
  animation: progressFloat 2.4s ease-in-out infinite;
}
/* Delivered — solid, no animation, slightly desaturated */
.progress-fill[data-animate="false"] {
  background: var(--fill-color, var(--emerald-600));
  opacity: 0.85;
}
@keyframes progressFloat {
  0%   { background-position: 100% 0; }
  50%  { background-position: 0% 0; }
  100% { background-position: 100% 0; }
}

/* ---------- Forms ---------- */
label { display: block; font-size: 11px; font-weight: 700; color: var(--slate-500); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--slate-900);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue-light);
}
textarea { resize: vertical; }
.field { margin-bottom: 16px; }
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.readonly-box {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  background: var(--slate-50);
  font-weight: 800;
  color: var(--slate-900);
}

/* ---------- Grids/orders ---------- */
.orders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.order-card {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s cubic-bezier(.4,0,.2,1);
  animation: fadeInUp 0.35s ease both;
}
.order-card:hover { box-shadow: 0 8px 24px rgba(139,94,52,0.12); border-color: var(--blue-border); transform: translateY(-3px); }
.order-card .top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.order-code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  font-weight: 800;
  font-size: 11px;
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: 4px;
  padding: 3px 8px;
}
.order-card h4 { font-size: 14px; font-weight: 800; margin-bottom: 2px; }
.order-card .meta { font-size: 10px; color: var(--slate-500); text-transform: uppercase; font-weight: 700; letter-spacing: 0.05em; }
.order-card .factory { font-size: 11px; color: var(--slate-500); margin-top: 4px; }
.order-card .progress-row {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--slate-200);
}
.order-card .progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 800;
  color: var(--slate-500);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.order-card .footer-row {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--slate-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.order-card .actions { display: flex; gap: 6px; }
.icon-btn {
  border: none;
  background: transparent;
  color: var(--slate-400);
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.icon-btn:hover { background: #fff; color: var(--slate-900); }
.icon-btn.danger:hover { background: var(--red-50); color: var(--red-600); }

/* ---------- Filter bar ---------- */
.filter-bar {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 20px;
}
.filter-bar .filter-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--slate-200);
  margin-bottom: 12px;
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

/* ---------- Alerts ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.alert-error { background: var(--red-50); border: 1px solid var(--red-100); color: var(--red-700); }
.alert-success { background: var(--slate-100); border: 1px solid var(--slate-200); color: var(--slate-900); }
.alert-warning { background: var(--amber-50); border: 1px solid var(--amber-200); color: var(--amber-800); }

/* ---------- Login page ---------- */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--slate-50);
}
@media (min-width: 1024px) {
  .login-shell { grid-template-columns: 1.05fr 1fr; }
}

/* ── Left brand panel ─────────────────────────────────────── */
.login-side {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  padding: 56px 56px 48px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(120% 120% at 0% 0%, #4A2810 0%, #2C1505 55%, #1C0D03 100%);
  color: #fff;
}
@media (min-width: 1024px) {
  .login-side { display: flex; }
}
/* woven thread texture — subtle, brand-grounded */
.login-side::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(135deg, rgba(255,255,255,0.035) 0 1px, transparent 1px 22px);
  pointer-events: none;
}
.login-side::after {
  content: "";
  position: absolute;
  width: 460px; height: 460px;
  right: -160px; bottom: -160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(184,115,51,0.22) 0%, transparent 70%);
  pointer-events: none;
}
.login-side > * { position: relative; z-index: 1; }

.login-side .brand { display: flex; align-items: center; gap: 12px; }
.login-side .brand .name { color: #fff !important; font-size: 16px; font-weight: 800; letter-spacing: 0.04em; }
.login-side .brand-logo {
  width: 46px; height: 46px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
}
.login-side .brand-logo img { width: 30px; height: 30px; object-fit: contain; }

.login-side .eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--copper); margin-bottom: 20px;
}
.login-side h1 {
  font-size: 38px; font-weight: 800; line-height: 1.18; letter-spacing: -0.01em;
  color: #fff; max-width: 12ch;
}
.login-side h1 .accent { color: var(--copper); }
.login-side .tagline {
  color: rgba(255,255,255,0.62); font-size: 14px; margin-top: 18px; max-width: 38ch; line-height: 1.6;
}
.login-side .legal { font-size: 11px; color: rgba(255,255,255,0.4); font-weight: 500; }

/* ── Right form panel ─────────────────────────────────────── */
.login-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}
.login-box { max-width: 392px; width: 100%; }

/* compact logo shown only on small screens where the brand panel is hidden */
.login-box .mobile-brand {
  display: flex; align-items: center; gap: 10px; margin-bottom: 28px;
}
.login-box .mobile-brand .brand-logo {
  width: 42px; height: 42px; background: #2C1505; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.login-box .mobile-brand .brand-logo img { width: 27px; height: 27px; object-fit: contain; }
.login-box .mobile-brand span { font-weight: 800; font-size: 15px; color: #2C1505; letter-spacing: 0.04em; }
@media (min-width: 1024px) { .login-box .mobile-brand { display: none; } }

.login-box h2 { font-size: 27px; font-weight: 800; color: var(--slate-900); letter-spacing: -0.01em; }
.login-box .subtitle { font-size: 13px; color: var(--slate-500); margin-top: 8px; margin-bottom: 26px; line-height: 1.5; }

/* ── Role toggle — 3 even columns, no wrap ────────────────── */
.role-toggle {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 24px;
}
.role-toggle button {
  padding: 9px 6px;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  background: transparent;
  color: var(--slate-500);
  cursor: pointer;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
  white-space: nowrap;
}
.role-toggle button:hover { color: var(--slate-700); }
.role-toggle button.active {
  background: #fff;
  color: #2C1505;
  box-shadow: 0 1px 3px rgba(44,21,5,0.12);
}

/* ── Fields ───────────────────────────────────────────────── */
.login-box .field { margin-bottom: 16px; }
.login-box .field label {
  display: block; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--slate-600); margin-bottom: 7px;
}
.login-box .field input {
  width: 100%; box-sizing: border-box;
  padding: 12px 14px;
  border: 1px solid var(--slate-200);
  border-radius: 11px;
  font-size: 14px;
  background: #fff;
  color: var(--slate-900);
  transition: border-color 0.18s, box-shadow 0.18s;
}
.login-box .field input::placeholder { color: var(--slate-400); }
.login-box .field input:focus {
  outline: none;
  border-color: var(--copper);
  box-shadow: 0 0 0 3px rgba(184,115,51,0.16);
}
.login-box .help-line {
  font-size: 11.5px; color: var(--slate-500); margin: -4px 0 20px; line-height: 1.5;
}
.login-box .btn-signin {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 11px;
  background: linear-gradient(135deg, #8A541F 0%, #B87333 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(138,84,31,0.28);
  transition: transform 0.12s, box-shadow 0.18s, filter 0.18s;
}
.login-box .btn-signin:hover { filter: brightness(1.05); box-shadow: 0 6px 18px rgba(138,84,31,0.34); }
.login-box .btn-signin:active { transform: translateY(1px); }

@media (prefers-reduced-motion: reduce) {
  .login-box .btn-signin, .role-toggle button, .login-box .field input { transition: none; }
}

/* ---------- Misc ---------- */
.footer-note {
  text-align: center;
  font-size: 11px;
  color: var(--slate-400);
  padding: 16px;
  border-top: 1px solid var(--slate-200);
  background: #fff;
}
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  color: var(--slate-500);
  font-size: 13px;
}
.tabs-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--slate-200);
  padding-bottom: 8px;
}
.tab-btn {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--slate-500);
  cursor: pointer;
}
.tab-btn.active { background: linear-gradient(135deg, var(--blue) 0%, var(--copper) 100%); color: #fff; }
.tab-btn:hover:not(.active) { background: var(--slate-100); }

.size-table {
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  border-collapse: separate;
  border-spacing: 0;
}
.size-table th, .size-table td {
  border-bottom: 1px solid var(--slate-300);
  border-right: 1px solid var(--slate-300);
}
.size-table th:last-child, .size-table td:last-child { border-right: none; }
.size-table thead th {
  background: var(--slate-50);
  position: sticky;
  top: 0;
}
.size-table tbody tr:nth-child(even) { background: var(--slate-50); }
.size-table tbody tr:hover { background: var(--blue-light); }
.size-table th:first-child, .size-table td:first-child {
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 1;
}
.size-table thead th:first-child { background: var(--slate-50); z-index: 2; }
.size-table tbody tr:nth-child(even) td:first-child { background: var(--slate-50); }
.size-table input[type=number] {
  text-align: center;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-weight: 700;
  border: none;
  border-bottom: 1px dashed var(--slate-300);
  border-radius: 0;
  background: transparent;
  padding: 4px;
  transition: background 0.15s;
}
.size-table input[type=number]:focus { box-shadow: none; border-color: var(--blue); background: var(--copper-light); }

.sheet {
  background: #fff;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  padding: 32px;
  max-width: 800px;
  margin: 0 auto;
}
.sheet h1 { font-size: 26px; font-weight: 900; }

@page { size: A4 portrait; margin: 15mm 12mm; }

@media print {
  .topbar, .sidebar, .no-print, header, nav, aside, footer { display: none !important; }
  .main-layout { padding: 0 !important; margin: 0 !important; gap: 0 !important; }
  .app-shell, .content { background: #fff !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ========== Sidebar Notifications ========== */
.notif-empty {
  font-size: 11px;
  color: #6b7280;
  text-align: center;
  padding: 14px 6px;
}
.notif-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 9px 11px;
  margin-bottom: 5px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid #ece4da;
  border-left: 3px solid #d6cabb;
  transition: background 0.2s, border-color 0.2s;
}
.notif-item.unread {
  background: #fff7ec;
  border-color: #f3d9b0;
  border-left-color: #f59e0b;
}
.notif-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
  background: #cbb89f;
}
.notif-dot.unread { background: #f59e0b; }
.notif-body { flex: 1; min-width: 0; }
.notif-title {
  font-size: 11.5px;
  font-weight: 800;
  color: #3E2410;
  line-height: 1.3;
}
.notif-item.unread .notif-title { color: #2C1505; font-weight: 900; }
.notif-msg {
  font-size: 10.5px;
  color: #6b5d4d;
  margin-top: 3px;
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.notif-item.unread .notif-msg { color: #4a3a28; }
.notif-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 5px;
  gap: 6px;
}
.notif-time {
  font-size: 9px;
  color: #9c8b76;
}
.notif-link {
  font-size: 10px;
  font-weight: 800;
  color: #B87333;
  text-decoration: none;
  white-space: nowrap;
}
.notif-link:hover { color: #8a541f; }
.notif-item { position: relative; cursor: pointer; }
.notif-new-badge {
  align-self: flex-start;
  flex-shrink: 0;
  background: #ef4444;
  color: #fff;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 999px;
  margin-left: 6px;
  line-height: 1.3;
}

/* ========== Mobile Bottom Tab Bar ========== */
.mobile-tab-bar {
  display: none; /* Hidden on desktop */
}

@media (max-width: 768px) {
  /* Hide desktop sidebar completely */
  .sidebar { display: none !important; }

  /* Show fixed bottom tab bar */
  .mobile-tab-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: linear-gradient(135deg, #3E1F08 0%, #2C1505 100%);
    border-top: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 -4px 16px rgba(0,0,0,0.3);
    height: 58px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    gap: 0;
    align-items: stretch;
  }
  .mobile-tab-bar::-webkit-scrollbar { display: none; }

  .mob-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 4px;
    flex: 1;              /* fill space evenly */
    min-width: 0;         /* allow shrinking */
    color: #E8D2B8;       /* brighter warm tan (was dull 50% white) */
    text-decoration: none;
    font-size: 18px;
    border: none;
    background: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    border-radius: 0;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
  }
  .mob-tab-label {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: inherit;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }
  .mob-tab.active {
    color: #F5A623;       /* bright amber-gold for the active tab */
    background: rgba(255,255,255,0.10);
    border-top: 2px solid #F5A623;
  }
  .mob-tab:active { background: rgba(255,255,255,0.15); }
  .mob-tab .xk-icon { width: 22px; height: 22px; flex-shrink: 0; stroke: #E8D2B8; }
  /* Active mobile tab: unify icon to bright gold so it matches the label + top border */
  .mob-tab.active .xk-icon { stroke: #F5A623; }

  .mob-more-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    color: rgba(255,255,255,0.8);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.15s;
  }
  .mob-more-item.active { color: var(--copper); background: rgba(255,255,255,0.08); }
  .mob-more-item:active { background: rgba(255,255,255,0.15); }
  .mob-more-item .xk-icon { width: 20px; height: 20px; flex-shrink: 0; }
  .mob-more-item.active .xk-icon { stroke: var(--copper); }

  /* Add bottom padding to content so it's not hidden behind the tab bar */
  .content { padding-bottom: 72px !important; }

  /* Layout */
  #charts-grid { grid-template-columns: 1fr !important; }
  #dash-grid { grid-template-columns: 1fr !important; }
  .main-layout { flex-direction: column; padding: 10px 10px 0 !important; margin: 0 !important; gap: 0; max-width: 100% !important; width: 100% !important; }
  .content { padding-left: 0 !important; padding-right: 0 !important; width: 100% !important; max-width: 100% !important; overflow-x: hidden; }
  .app-shell { overflow-x: hidden; width: 100%; }
  .topbar-inner { overflow: hidden; }
  /* Pending bell - slightly smaller on mobile */
  #pending-bell-wrap { flex-shrink: 0; }
  /* On mobile: hide desktop dropdown bell, show mobile sheet bell */
  #pending-bell-btn { display: none !important; }
  #mob-header-bell-btn { display: flex !important; width:32px !important; height:32px !important; font-size:14px !important; }

  /* Create Order button - compact on mobile */
  a[href="order_form.php"][style*="border-radius:999px"] { padding: 6px 10px !important; font-size: 11px !important; }
  a[href="order_form.php"][style*="border-radius:999px"] span { display: none; }

  /* Topbar */
  .topbar-inner { padding: 8px 12px; gap: 8px; flex-wrap: nowrap; }
  .brand-logo img { width: 28px !important; height: 28px !important; }
  .brand-text .tagline { display: none; }
  .brand-text .name { font-size: 12px; }
  .brand-text .hub-tag { display: none; }
  .session-actions { gap: 6px; flex-shrink: 0; }
  .profile-badge { padding: 5px 8px; font-size: 10px; }
  .profile-badge span:not(.dot):not(.role) { display: none; }
  .profile-badge .role { font-size: 8px; }
  .btn-logout { padding: 7px 10px; font-size: 11px; }
  .btn-logout span:first-child { display: none; }

  /* Content */
  .content { min-width: 0; }
  .page-title { font-size: 18px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-header > a, .page-header .btn { width: 100%; justify-content: center; }

  /* KPI cards */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi-value { font-size: 20px; }
  .kpi-card { padding: 10px 12px; }
  .kpi-sub { font-size: 9px; }
  .card-pad { padding: 12px; }

  /* Tables — horizontal scroll on mobile */
  .card { overflow-x: auto; }
  table { font-size: 11px; min-width: 400px; }
  th, td { padding: 7px 6px; }

  /* Grids */
  .orders-grid { grid-template-columns: 1fr !important; }
  .field-grid, .filter-grid { grid-template-columns: 1fr !important; }
  .settings-card-grid { grid-template-columns: 1fr !important; }
  .inline-form { flex-direction: column; }
  .di-grid-2, .di-grid-3, .di-grid-4 { grid-template-columns: 1fr 1fr !important; }

  /* Settings — all pane layouts collapse to 1 col */
  #tab-factories .settings-card-grid,
  [id^="tab-"] > div[style*="grid"] { grid-template-columns: 1fr !important; }

  /* Settings forms — full width inputs */
  .field input, .field select, .field textarea { width: 100% !important; box-sizing: border-box; }
  .fg input, .fg select { width: 100% !important; box-sizing: border-box; }
  .inline-form .field { width: 100% !important; max-width: 100% !important; }
  .inline-form .field input, .inline-form .field select { width: 100% !important; max-width: 100% !important; }

  /* Settings — register form centered issue fix */
  .card-pad > div[style*="text-align:center"],
  .card-pad > div[style*="text-align: center"] { text-align: left !important; }
  .card-pad input:not([type="checkbox"]):not([type="radio"]),
  .card-pad select, .card-pad textarea {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
  /* Checkboxes / radios keep their natural size everywhere */
  .card-pad input[type="checkbox"],
  .card-pad input[type="radio"],
  .field input[type="checkbox"],
  .field input[type="radio"] {
    width: auto !important;
    max-width: none !important;
    flex: 0 0 auto;
  }

  /* Tabs */
  .tabs-row { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 8px; scrollbar-width: none; }
  .tabs-row::-webkit-scrollbar { display: none; }
  .tab-btn { white-space: nowrap; font-size: 11px; padding: 8px 12px; flex-shrink: 0; }
  .bc-tab { white-space: nowrap; font-size: 11px; flex-shrink: 0; }

  /* Finance */
  .finance-stat-row { gap: 6px; overflow-x: auto; flex-wrap: nowrap; }
  .finance-stat { min-width: 80px; flex-shrink: 0; }
  .finance-stat strong { font-size: 11px; }

  /* Login */
  .login-main { padding: 32px 18px; }
  .login-box { max-width: 100%; }

  /* Action buttons */
  #action-buttons { flex-wrap: wrap; gap: 6px; }
  #action-buttons .btn { font-size: 11px; padding: 8px 12px; }

  /* Milestone grid — single column on mobile so wide labels never overflow */
  .milestone-grid { grid-template-columns: 1fr; gap: 8px; }
  .milestone-btn { padding: 10px 12px; font-size: 11px; width: 100%; max-width: 100%; box-sizing: border-box; min-width: 0; }

  /* Orders filter bar */
  .orders-filter-top { grid-template-columns: 1fr !important; }
  .orders-filter-bottom { flex-wrap: wrap; gap: 8px; }
  .orders-filter-bottom input[type="date"],
  .orders-filter-bottom select { width: 100% !important; flex-shrink: 1; }

  /* Fab images */
  .fab-block-images { grid-template-columns: 1fr !important; }
  .fab-swatch { border-right: none !important; border-bottom: 1px solid var(--slate-300); }
  .fab-swatch .img-box,
  .fab-sample .img-box-large { height: 200px !important; }

  /* User management grid in settings */
  #tab-users > div[style*="grid"] { grid-template-columns: 1fr !important; }

  /* Static barcode sub-tabs */
  #bc-static > div:nth-child(3) { overflow-x: auto; }

  /* Month cards in reports */
  #di-month-cards { grid-template-columns: repeat(3, 1fr) !important; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .page-title { font-size: 16px; }
  .topbar-inner { padding: 6px 10px; }
  .finance-stat { min-width: 70px; }
  .di-grid-2, .di-grid-3, .di-grid-4 { grid-template-columns: 1fr !important; }
  #di-month-cards { grid-template-columns: repeat(2, 1fr) !important; }
}
