:root {
  --green:    #1f7a3d;
  --green-dk: #12351f;
  --green-lt: #eafaef;
  --orange:   #f5871f;
  --ink:      #16241b;
  --muted:    #6b7d72;
  --line:     #e6ede8;
  --bg:       #f2f6f3;
  --card:     #ffffff;
  --danger:   #c0392b;
  --shadow:   0 10px 30px rgba(18, 53, 31, .08);
  --radius:   14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--green); text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(135deg, #fff8ec, var(--green-lt)); }
.login-card { background: var(--card); border-radius: 20px; box-shadow: var(--shadow);
  padding: 38px 34px; width: min(400px, 100%); }
.login-card .logo { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  font-size: 1.6rem; background: linear-gradient(135deg, var(--orange), #ffc233); margin-bottom: 18px; }
.login-card h1 { font-size: 1.5rem; color: var(--green-dk); }
.login-card p.sub { color: var(--muted); font-size: .92rem; margin-bottom: 22px; }

/* ---------- Form fields (shared) ---------- */
.field { margin-bottom: 15px; }
.field label { display: block; font-size: .8rem; font-weight: 700; color: var(--green-dk); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: .95rem; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--green-lt); border-color: var(--green); }
.field .hint { font-size: .76rem; color: var(--muted); margin-top: 4px; }
.field.err input, .field.err select, .field.err textarea { border-color: var(--danger); }
.field .msg { color: var(--danger); font-size: .76rem; margin-top: 4px; }
.checkline { display: flex; align-items: center; gap: 8px; }
.checkline input { width: auto; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700;
  padding: 11px 20px; border-radius: 10px; border: 2px solid transparent; font-size: .92rem;
  transition: transform .12s ease, box-shadow .12s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--green); color: #fff; }
.btn-orange  { background: var(--orange); color: #fff; }
.btn-ghost   { background: #fff; color: var(--green-dk); border-color: var(--line); }
.btn-danger  { background: #fff; color: var(--danger); border-color: #f0c9c4; }
.btn-sm { padding: 7px 12px; font-size: .82rem; border-radius: 8px; }
.btn-block { width: 100%; }

.form-error { background: #fdecea; color: var(--danger); padding: 10px 12px; border-radius: 10px;
  font-size: .88rem; margin-bottom: 14px; }
.form-ok { background: var(--green-lt); color: var(--green-dk); padding: 10px 12px; border-radius: 10px;
  font-size: .88rem; margin-bottom: 14px; font-weight: 600; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }
.sidebar { background: var(--green-dk); color: #cfe6d6; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 18px 22px;
  border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar .brand img { height: 40px; width: auto; display: block; }
.sidebar nav { padding: 14px 12px; display: grid; gap: 4px; }
.sidebar nav a { display: flex; align-items: center; gap: 11px; padding: 11px 14px; border-radius: 10px;
  color: #cfe6d6; font-weight: 600; font-size: .93rem; }
.sidebar nav a .ic { width: 20px; text-align: center; }
.sidebar nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar nav a.active { background: var(--green); color: #fff; }
.sidebar nav a .badge { margin-left: auto; background: var(--orange); color: #fff; border-radius: 999px;
  font-size: .68rem; padding: 1px 8px; font-weight: 700; }
.sidebar .foot { margin-top: auto; padding: 16px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar .foot .who { font-size: .82rem; margin-bottom: 10px; }
.sidebar .foot .who b { color: #fff; display: block; }

.main { min-width: 0; }
.topbar { background: var(--card); border-bottom: 1px solid var(--line); padding: 16px 28px;
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; }
.topbar h1 { font-size: 1.3rem; color: var(--green-dk); }
.topbar .hamburger { display: none; background: none; border: 0; font-size: 1.5rem; color: var(--green-dk); }
.content { padding: 28px; }

/* ---------- Cards & stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px; margin-bottom: 26px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); }
.stat .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  font-size: 1.3rem; background: var(--green-lt); margin-bottom: 12px; }
.stat .num { font-size: 1.8rem; font-weight: 800; color: var(--green-dk); }
.stat .lbl { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .5px; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px;
  border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 1.05rem; color: var(--green-dk); }
.panel-body { padding: 4px 0; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; padding: 12px 18px; color: var(--muted); font-size: .74rem;
  text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 13px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.clickable:hover { background: var(--green-lt); cursor: pointer; }
table.data .prod-cell { display: flex; align-items: center; gap: 12px; }
table.data .pthumb { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; flex: none;
  background: var(--green-lt); display: grid; place-items: center; font-size: 1.3rem; }
table.data .prod-name { font-weight: 700; color: var(--green-dk); }
table.data .sub { color: var(--muted); font-size: .8rem; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- Badges / pills ---------- */
.pill { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: .74rem; font-weight: 700;
  text-transform: capitalize; }
.pill.on  { background: var(--green-lt); color: var(--green); }
.pill.off { background: #f1f1f1; color: #888; }
.pill.type-bulk   { background: #fff1df; color: #b9670a; }
.pill.type-single { background: #eef4ff; color: #3b62b0; }
.pill.st-pending    { background: #fff6e0; color: #a9791a; }
.pill.st-confirmed  { background: #e7f0ff; color: #2f5bb0; }
.pill.st-processing { background: #f0e9ff; color: #6b46c1; }
.pill.st-delivered  { background: var(--green-lt); color: var(--green); }
.pill.st-cancelled  { background: #fdecea; color: var(--danger); }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(18,53,31,.5); display: none;
  align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 100; overflow-y: auto; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: 18px; width: min(560px, 100%); box-shadow: var(--shadow);
  animation: pop .18s ease; }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px;
  border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 1.2rem; color: var(--green-dk); }
.modal-head .x { background: none; border: 0; font-size: 1.4rem; color: var(--muted); }
.modal-body { padding: 22px 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
.form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-2col .full { grid-column: 1 / -1; }
.upload-preview { display: block; width: 88px; height: 88px; object-fit: cover; margin-top: 10px;
  border: 1px solid var(--line); border-radius: 10px; }
.size-rows { display:grid; gap:8px; margin-bottom:10px }.size-row { display:grid; grid-template-columns:1.25fr repeat(4,1fr) auto; gap:7px }.size-row input{min-width:0;padding:8px!important;font-size:.8rem!important}@media(max-width:700px){.size-row{grid-template-columns:1fr 1fr}.size-row button{grid-column:2}}

/* ---------- Messages / misc ---------- */
.msg-item { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; gap: 14px; }
.msg-item.unread { background: #fffdf5; }
.msg-item .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--orange); }
.msg-item.read .dot { background: var(--line); }
.msg-item .who { font-weight: 700; color: var(--green-dk); }
.msg-item .meta { color: var(--muted); font-size: .8rem; }
.msg-item .text { margin-top: 5px; }
.msg-item .acts { margin-left: auto; display: flex; gap: 8px; flex: none; }

.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.loading { text-align: center; color: var(--muted); padding: 40px; }
.detail-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: .92rem; }
.detail-row span:first-child { color: var(--muted); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.settings-wide { grid-column: 1 / -1; }
.content-grid { display:grid; grid-template-columns:1fr 1fr; gap:20px; align-items:start }.content-group .field:last-child{margin-bottom:0}.content-save{position:sticky;bottom:0;background:rgba(246,249,247,.94);padding:16px 0;display:flex;justify-content:flex-end;z-index:5}@media(max-width:900px){.content-grid{grid-template-columns:1fr}}

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; width: 244px; height: 100vh; transform: translateX(-100%);
    transition: transform .22s ease; }
  .sidebar.open { transform: none; }
  .topbar .hamburger { display: block; }
  .form-2col, .settings-grid { grid-template-columns: 1fr; }
}
