/* ==========================================================================
   Debalay Creator OS — shared stylesheet
   Palette rooted in the craft materials themselves:
   terracotta (Earthen Regalia clay) for the Seller surface,
   indigo (Bengal dye heritage) for the Admin surface,
   raw cotton cream as the shared base.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&family=Work+Sans:wght@400;500;600;700&display=swap');

:root{
  --cream: #F6F1E5;
  --cream-deep: #EFE7D6;
  --paper: #FFFDF8;
  --ink: #2A2118;
  --ink-soft: #6B5F4F;
  --line: #E3D9C2;

  --terracotta: #B5502D;
  --terracotta-deep: #8E3D22;
  --terracotta-tint: #F3E0D5;

  --indigo: #2B3A5C;
  --indigo-deep: #1E2A44;
  --indigo-tint: #E1E5EE;

  --gold: #C08A2E;
  --green: #4C7A52;
  --green-tint: #E4EEE2;
  --red: #B3402F;
  --red-tint: #F5E1DC;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(42,33,24,0.06), 0 8px 24px -12px rgba(42,33,24,0.18);

  --accent: var(--terracotta);
  --accent-deep: var(--terracotta-deep);
  --accent-tint: var(--terracotta-tint);
  --surface-deep: var(--indigo-deep);
}

/* Admin surface swaps the accent to indigo, seller keeps terracotta */
body.role-admin{
  --accent: var(--indigo);
  --accent-deep: var(--indigo-deep);
  --accent-tint: var(--indigo-tint);
}

*,*::before,*::after{ box-sizing:border-box; }
html{ -webkit-text-size-adjust:100%; }
body{
  margin:0;
  font-family:'Work Sans', -apple-system, sans-serif;
  background:var(--cream);
  color:var(--ink);
  font-size:15px;
  line-height:1.5;
}
h1,h2,h3,h4{ font-family:'Fraunces', Georgia, serif; margin:0 0 .4em; color:var(--ink); font-weight:600; }
a{ color:inherit; }
button{ font-family:inherit; }
img{ max-width:100%; display:block; }

/* running-stitch divider — the shared signature motif, evoking kantha embroidery */
.stitch{
  height:1px;
  background-image: repeating-linear-gradient(to right, var(--line) 0 6px, transparent 6px 11px);
  border:none;
  margin: 1.4rem 0;
}

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

.sidebar{
  width:230px; flex-shrink:0;
  background: var(--accent-deep);
  color:#F3ECDD;
  display:flex; flex-direction:column;
  position:fixed; top:0; left:0; bottom:0;
  transform:translateX(0);
  transition: transform .25s ease;
  z-index:40;
}
.sidebar .brand{
  padding:1.25rem 1.2rem 1rem;
  font-family:'Fraunces', serif; font-weight:700; font-size:1.15rem;
  display:flex; align-items:center; gap:.55rem;
  border-bottom:1px solid rgba(255,255,255,.12);
}
.sidebar .brand .mark{
  width:28px;height:28px;border-radius:7px;
  background:var(--gold); color:var(--ink);
  display:flex;align-items:center;justify-content:center;
  font-size:.85rem; font-weight:700;
}
.sidebar .mode-tag{
  font-size:.65rem; letter-spacing:.08em; text-transform:uppercase;
  color:rgba(243,236,221,.6); padding:.6rem 1.2rem 0;
}
.sidebar nav{ padding:.6rem .6rem; flex:1; overflow-y:auto; }
.sidebar nav a{
  display:flex; align-items:center; gap:.65rem;
  padding:.62rem .7rem; margin:.1rem 0; border-radius:8px;
  text-decoration:none; color:rgba(243,236,221,.82); font-size:.9rem; font-weight:500;
}
.sidebar nav a .ic{ font-size:1rem; width:1.2rem; text-align:center; }
.sidebar nav a:hover{ background:rgba(255,255,255,.08); color:#fff; }
.sidebar nav a.active{ background:var(--gold); color:var(--ink); font-weight:600; }
.sidebar .foot{
  padding:.9rem 1.2rem; border-top:1px solid rgba(255,255,255,.12);
  font-size:.72rem; color:rgba(243,236,221,.55);
}

.backdrop{ display:none; }

.main{ margin-left:230px; flex:1; min-width:0; display:flex; flex-direction:column; }

.topbar{
  position:sticky; top:0; z-index:20;
  background:var(--paper); border-bottom:1px solid var(--line);
  display:flex; align-items:center; gap:1rem;
  padding:.85rem 1.5rem;
}
.topbar h1{ font-size:1.15rem; margin:0; flex:1; }
.hamburger{
  display:none; background:none; border:1px solid var(--line); border-radius:8px;
  width:38px; height:38px; align-items:center; justify-content:center; cursor:pointer;
  font-size:1.1rem;
}
.topbar .tb-actions{ display:flex; align-items:center; gap:.9rem; }
.icon-btn{
  width:36px; height:36px; border-radius:50%; border:1px solid var(--line); background:var(--paper);
  display:flex; align-items:center; justify-content:center; cursor:pointer; font-size:1rem; position:relative;
}
.icon-btn .dot{
  position:absolute; top:6px; right:6px; width:7px; height:7px; border-radius:50%; background:var(--terracotta);
  border:1.5px solid var(--paper);
}
.avatar{
  width:36px;height:36px;border-radius:50%;
  background:var(--accent-tint); color:var(--accent-deep);
  display:flex;align-items:center;justify-content:center; font-weight:700; font-size:.85rem;
}

.content{ padding:1.5rem; max-width:1180px; width:100%; margin:0 auto; }
.page-sub{ color:var(--ink-soft); margin-bottom:1.4rem; font-size:.92rem; }

/* ---------- Cards / KPIs ---------- */
.kpi-grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:1rem; margin-bottom:1.6rem; }
.kpi{
  background:var(--paper); border:1px solid var(--line); border-radius:var(--radius);
  padding:1.1rem 1.2rem; box-shadow:var(--shadow);
}
.kpi .label{ font-size:.76rem; text-transform:uppercase; letter-spacing:.05em; color:var(--ink-soft); margin-bottom:.4rem; }
.kpi .value{ font-family:'Fraunces',serif; font-size:1.7rem; font-weight:600; }
.kpi .delta{ font-size:.78rem; color:var(--green); margin-top:.3rem; }

.grid-2{ display:grid; grid-template-columns:1.4fr 1fr; gap:1.2rem; align-items:start; }

.card{
  background:var(--paper); border:1px solid var(--line); border-radius:var(--radius);
  padding:1.2rem 1.3rem; box-shadow:var(--shadow); margin-bottom:1.2rem;
}
.card h3{ font-size:1rem; margin-bottom:.2rem; }

.impact-widget{
  background:var(--accent-deep); color:#F3ECDD; border-radius:var(--radius);
  padding:1.4rem; text-align:center; box-shadow:var(--shadow);
}
.impact-widget .num{ font-family:'Fraunces',serif; font-size:2.2rem; font-weight:700; color:var(--gold); }
.impact-widget .txt{ font-size:.88rem; opacity:.85; margin-top:.2rem; }

.activity-item{ display:flex; gap:.7rem; padding:.55rem 0; border-bottom:1px dashed var(--line); font-size:.88rem; }
.activity-item:last-child{ border-bottom:none; }
.activity-item .tag{ font-size:1rem; }

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex; align-items:center; gap:.4rem;
  padding:.6rem 1.1rem; border-radius:8px; border:1px solid transparent;
  font-size:.86rem; font-weight:600; cursor:pointer; text-decoration:none;
}
.btn-primary{ background:var(--accent); color:#fff; }
.btn-primary:hover{ background:var(--accent-deep); }
.btn-outline{ background:transparent; border-color:var(--line); color:var(--ink); }
.btn-outline:hover{ border-color:var(--accent); color:var(--accent-deep); }
.btn-ghost{ background:transparent; color:var(--accent-deep); padding:.5rem .7rem; }
.btn-sm{ padding:.36rem .68rem; font-size:.78rem; border-radius:6px; }
.btn-danger{ background:var(--red); color:#fff; }
.btn-danger:hover{ background:#8f3021; }

/* ---------- Tables ---------- */
.table-wrap{ overflow-x:auto; background:var(--paper); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow); }
table{ width:100%; border-collapse:collapse; min-width:640px; }
thead th{
  text-align:left; font-size:.72rem; text-transform:uppercase; letter-spacing:.05em;
  color:var(--ink-soft); background:var(--cream-deep); padding:.75rem .9rem; white-space:nowrap;
}
tbody td{ padding:.8rem .9rem; border-top:1px solid var(--line); font-size:.87rem; vertical-align:middle; }
tbody tr:hover{ background:var(--accent-tint); }
.cell-prod{ display:flex; align-items:center; gap:.6rem; }
.thumb{ width:38px; height:38px; border-radius:7px; background:var(--cream-deep); flex-shrink:0; display:flex; align-items:center; justify-content:center; font-size:1rem; }

.badge{ display:inline-block; padding:.24rem .6rem; border-radius:99px; font-size:.72rem; font-weight:600; }
.badge-live, .badge-success, .badge-received{ background:var(--green-tint); color:var(--green); }
.badge-pending{ background:#F5EAD2; color:var(--gold); }
.badge-rejected, .badge-discrepancy{ background:var(--red-tint); color:var(--red); }
.badge-draft{ background:var(--cream-deep); color:var(--ink-soft); }

.toolbar{ display:flex; flex-wrap:wrap; gap:.6rem; align-items:center; justify-content:space-between; margin-bottom:1rem; }
.filters{ display:flex; gap:.5rem; flex-wrap:wrap; }
select, input[type=text], input[type=search], input[type=number]{
  font-family:inherit; padding:.5rem .7rem; border:1px solid var(--line); border-radius:7px;
  background:var(--paper); font-size:.85rem; color:var(--ink);
}

/* ---------- Modal ---------- */
.modal-bg{
  position:fixed; inset:0; background:rgba(42,33,24,.45); display:none;
  align-items:center; justify-content:center; z-index:100; padding:1rem;
}
.modal-bg.open{ display:flex; }
.modal{
  background:var(--paper); border-radius:12px; max-width:560px; width:100%;
  max-height:88vh; overflow-y:auto; padding:1.4rem 1.5rem; box-shadow:0 20px 60px rgba(0,0,0,.25);
}
.modal-head{ display:flex; justify-content:space-between; align-items:center; margin-bottom:.9rem; }
.modal-head button{ background:none; border:none; font-size:1.2rem; cursor:pointer; color:var(--ink-soft); }
.field{ margin-bottom:.9rem; }
.field label{ display:block; font-size:.8rem; font-weight:600; margin-bottom:.3rem; }
.field input, .field select, .field textarea{ width:100%; }
.field-row{ display:grid; grid-template-columns:1fr 1fr; gap:.8rem; }

/* ---------- Toast ---------- */
#toast{
  position:fixed; bottom:1.2rem; left:50%; transform:translateX(-50%) translateY(20px);
  background:var(--ink); color:#fff; padding:.7rem 1.1rem; border-radius:8px; font-size:.85rem;
  opacity:0; pointer-events:none; transition:.25s; z-index:200; box-shadow:var(--shadow);
}
#toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }

/* ---------- Empty state ---------- */
.empty{ text-align:center; padding:2.4rem 1rem; color:var(--ink-soft); }
.empty .ic{ font-size:2rem; margin-bottom:.5rem; }

/* ---------- Responsive ---------- */
@media (max-width: 980px){
  .kpi-grid{ grid-template-columns:repeat(2,1fr); }
  .grid-2{ grid-template-columns:1fr; }
}

@media (max-width: 760px){
  .sidebar{ transform:translateX(-100%); width:240px; }
  .sidebar.open{ transform:translateX(0); box-shadow:0 0 40px rgba(0,0,0,.3); }
  .backdrop{ display:none; position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:30; }
  .backdrop.open{ display:block; }
  .main{ margin-left:0; }
  .hamburger{ display:flex; }
  .kpi-grid{ grid-template-columns:1fr 1fr; gap:.7rem; }
  .kpi .value{ font-size:1.3rem; }
  .content{ padding:1rem; }
  .topbar{ padding:.7rem 1rem; }
  .field-row{ grid-template-columns:1fr; }
  table{ min-width:560px; }
}

@media (max-width: 420px){
  .kpi-grid{ grid-template-columns:1fr 1fr; }
  .topbar h1{ font-size:1rem; }
}
