/* REYTOP SCM — application styles (matches rey-sourcing.com brand) */
:root {
  --green: #2b9b83;
  --green-dark: #0f6e56;
  --ink: #1c1f20;
  --muted: #6b7174;
  --bg: #f4f7f6;
  --border: #e8eceb;
  --white: #ffffff;
  --red: #c0392b;
  --amber: #b9770e;
  --blue: #2b6e9b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20, 40, 35, 0.08), 0 6px 20px rgba(20, 40, 35, 0.06);
  --font-display: "Saira", "Segoe UI", sans-serif;
  --font-body: "Montserrat", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}
a { color: var(--green-dark); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 15% -10%, rgba(43,155,131,0.18), transparent),
              radial-gradient(900px 500px at 100% 110%, rgba(15,110,86,0.16), transparent),
              var(--ink);
}
.login-card {
  background: var(--white);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
  width: 100%;
  max-width: 420px;
  padding: 40px 36px;
}
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.login-logo .mark {
  width: 46px; height: 46px; flex: none;
  background: var(--green-dark); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.login-logo .mark svg { width: 26px; height: 26px; }
.login-logo .word { font-family: var(--font-display); font-weight: 800; font-size: 22px; color: var(--ink); }
.login-logo .word span { color: var(--green-dark); }
.login-card h1 { font-family: var(--font-display); font-size: 22px; font-weight: 700; margin: 12px 0 4px; }
.login-card .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 24px; line-height: 1.5; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: 9px; font-family: inherit; font-size: 14px; color: var(--ink);
  background: #fff; transition: border .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(43,155,131,0.15);
}
.field textarea { min-height: 84px; resize: vertical; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 9px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green-dark); color: #fff; }
.btn-primary:hover { background: #0b5b47; }
.btn-outline { background: #fff; color: var(--green-dark); border-color: var(--green-dark); }
.btn-outline:hover { background: #f0f7f5; }
.btn-danger { background: #fff; color: var(--red); border-color: #e5c8c4; }
.btn-danger:hover { background: #fdf1ef; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.form-error { color: var(--red); font-size: 13px; margin-bottom: 12px; min-height: 18px; }
.form-success { color: var(--green-dark); font-size: 13px; margin-bottom: 12px; min-height: 18px; }
.lang-row { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 20px; }
.lang-row button {
  background: #fff; border: 1px solid var(--border); color: var(--muted);
  font-size: 12px; padding: 6px 10px; border-radius: 6px;
}
.lang-row button.active { background: var(--green-dark); color: #fff; border-color: var(--green-dark); }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex: none; background: var(--ink); color: #fff;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar .brand .mark { width: 40px; height: 40px; background: var(--green-dark); border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.sidebar .brand .mark svg { width: 22px; height: 22px; }
.sidebar .brand .word { font-family: var(--font-display); font-weight: 800; font-size: 18px; }
.sidebar .brand .word span { color: var(--green); }
.sidebar nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border-radius: 9px; color: rgba(255,255,255,0.78); font-size: 13.5px; font-weight: 500;
  margin-bottom: 2px; transition: background .12s, color .12s;
}
.sidebar nav a svg { width: 18px; height: 18px; flex: none; }
.sidebar nav a:hover { background: rgba(255,255,255,0.07); color: #fff; }
.sidebar nav a.active { background: var(--green-dark); color: #fff; }
.sidebar .foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 12px; color: rgba(255,255,255,0.5); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px; position: sticky; top: 0; z-index: 20;
}
.topbar .page-title { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.topbar .right { display: flex; align-items: center; gap: 14px; }
.lang-switch { position: relative; }
.lang-switch .lang-btn {
  display: flex; align-items: center; gap: 6px; background: #fff;
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 11px; font-size: 13px; color: var(--ink);
}
.lang-switch .menu {
  position: absolute; right: 0; top: calc(100% + 6px); background: #fff;
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  min-width: 150px; padding: 6px; display: none; z-index: 50;
}
.lang-switch.open .menu { display: block; }
.lang-switch .menu button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 8px 10px; border-radius: 7px; font-size: 13.5px; color: var(--ink);
}
.lang-switch .menu button:hover { background: var(--bg); }
.lang-switch .menu button.active { color: var(--green-dark); font-weight: 600; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--green-dark); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.user-chip .meta { line-height: 1.15; }
.user-chip .meta .nm { font-size: 13px; font-weight: 600; }
.user-chip .meta .rl { font-size: 11px; color: var(--muted); }
.icon-btn { background: none; border: none; color: var(--muted); padding: 7px; border-radius: 7px; }
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

.content { flex: 1; padding: 24px; max-width: 1280px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { font-family: var(--font-display); font-size: 20px; font-weight: 700; }

/* ---------- Stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.stat .ic { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.stat .ic svg { width: 20px; height: 20px; }
.stat .num { font-family: var(--font-display); font-size: 30px; font-weight: 800; line-height: 1; }
.stat .lbl { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.ic-green { background: #e2f3ef; color: var(--green-dark); }
.ic-blue { background: #e4eef6; color: var(--blue); }
.ic-amber { background: #f8efe0; color: var(--amber); }
.ic-purple { background: #ece7f6; color: #6d4bb5; }

/* ---------- Cards / panels ---------- */
.panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 20px; }
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-head h3 { font-family: var(--font-display); font-size: 16px; font-weight: 700; }
.panel-body { padding: 20px; }
.panel-body.no-pad { padding: 0; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th, table.tbl td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl th { background: #fafcfb; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; white-space: nowrap; }
table.tbl tbody tr:hover { background: #fafcfb; }
table.tbl tbody tr:last-child td { border-bottom: none; }
.tbl-actions { display: flex; gap: 6px; }
.tbl-actions .icon-btn { border: 1px solid var(--border); background: #fff; }
.tbl-actions .icon-btn:hover { border-color: var(--green); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-draft { background: #f1f3f2; color: #5b6164; }
.badge-submitted { background: #e4eef6; color: var(--blue); }
.badge-confirmed { background: #e2f3ef; color: var(--green-dark); }
.badge-completed { background: #ece7f6; color: #6d4bb5; }
.badge-active { background: #e2f3ef; color: var(--green-dark); }
.badge-disabled { background: #f6e4e2; color: var(--red); }
.badge-admin { background: #f8efe0; color: var(--amber); }
.badge-user { background: #f1f3f2; color: #5b6164; }
.rating-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; border-radius: 8px; font-weight: 700; font-size: 14px; }
.rating-a { background: #e2f3ef; color: var(--green-dark); }
.rating-b { background: #e4eef6; color: var(--blue); }
.rating-c { background: #f8efe0; color: var(--amber); }
.rating-d { background: #f6e4e2; color: var(--red); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,30,28,0.45);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px;
  z-index: 100; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 14px; box-shadow: 0 24px 60px rgba(0,0,0,0.25);
  width: 100%; max-width: 640px; margin: auto 0;
}
.modal-lg { max-width: 820px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-family: var(--font-display); font-size: 17px; font-weight: 700; }
.modal-body { padding: 22px; max-height: 68vh; overflow-y: auto; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.fs12 { font-size: 12px; }

/* ---------- Product grid ---------- */
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.prod-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.prod-card .img { aspect-ratio: 4/3; background: var(--bg); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.prod-card .img img { width: 100%; height: 100%; object-fit: cover; }
.prod-card .img .ph { color: #c3cbc9; font-size: 12px; }
.prod-card .body { padding: 13px 14px; }
.prod-card .body .model { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.prod-card .body .name { color: var(--muted); font-size: 12.5px; margin: 2px 0 6px; }
.prod-card .body .price { color: var(--green-dark); font-weight: 700; font-size: 15px; }

/* ---------- Inspection gallery ---------- */
.insp-head { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 20px; }
.insp-head .cell { background: #fff; padding: 12px 14px; }
.insp-head .cell .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.insp-head .cell .v { font-family: var(--font-display); font-weight: 700; font-size: 15px; margin-top: 3px; }
.part-block { margin-bottom: 24px; }
.part-block .part-title { font-family: var(--font-display); font-weight: 700; font-size: 16px; color: var(--green-dark); margin-bottom: 12px; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.photo-grid .ph-item { aspect-ratio: 4/3; border-radius: 9px; overflow: hidden; border: 1px solid var(--border); background: var(--bg); }
.photo-grid .ph-item img { width: 100%; height: 100%; object-fit: cover; }
.img-upload-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.img-upload-grid .thumb { aspect-ratio: 4/3; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); position: relative; background: var(--bg); }
.img-upload-grid .thumb img { width: 100%; height: 100%; object-fit: cover; }
.img-upload-grid .thumb .rm { position: absolute; top: 5px; right: 5px; background: rgba(0,0,0,0.55); color: #fff; border: none; border-radius: 50%; width: 22px; height: 22px; font-size: 12px; line-height: 1; }
.img-upload-grid .add-tile { aspect-ratio: 4/3; border: 2px dashed var(--border); border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); background: #fff; }

/* ---------- Order items ---------- */
.order-item-row { display: grid; grid-template-columns: 2fr 1fr 1fr 32px; gap: 10px; align-items: center; margin-bottom: 10px; }

/* ---------- Empty / notice ---------- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state svg { width: 40px; height: 40px; color: #c3cbc9; margin-bottom: 10px; }
.notice { background: #f0f7f5; border: 1px solid #d7ebe6; color: var(--green-dark); border-radius: 10px; padding: 12px 16px; font-size: 13px; margin-bottom: 18px; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.25); font-size: 13.5px; max-width: 340px; animation: slidein .25s ease; }
.toast.success { background: var(--green-dark); }
.toast.error { background: var(--red); }
@keyframes slidein { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .insp-head { grid-template-columns: repeat(2, 1fr); }
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .topbar { padding: 10px 16px; }
  .content { padding: 16px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .photo-grid, .img-upload-grid { grid-template-columns: 1fr 1fr; }
  .user-chip .meta { display: none; }
}
