@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800&display=swap');

:root{
  --bg:#f6f7f9;
  --surface:#ffffff;
  --surface-soft:#f1f5f9;
  --text:#172033;
  --muted:#667085;
  --border:#dfe4ea;
  --primary:#1769aa;
  --primary-dark:#0f548a;
  --green:#16803c;
  --red:#c23333;
  --amber:#b7791f;
  --teal:#0f766e;
  --shadow:0 14px 32px rgba(23,32,51,.08);
}

*{box-sizing:border-box}

body{
  margin:0;
  min-height:100vh;
  display:flex;
  background:var(--bg);
  color:var(--text);
  font-family:'Tajawal',Arial,sans-serif;
}

button,input,select,textarea{font:inherit}

.sidebar{
  position:fixed;
  inset:0 0 0 auto;
  width:268px;
  padding:22px;
  overflow:auto;
  color:white;
  background:#162033;
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;
  margin-bottom:28px;
}

.logo{
  width:46px;
  height:46px;
  display:grid;
  place-items:center;
  border-radius:12px;
  background:#25a18e;
  font-size:24px;
  font-weight:800;
}

.brand h1{margin:0;font-size:25px}
.brand p{margin:2px 0 0;color:#cbd5e1;font-size:13px}

nav{display:flex;flex-direction:column;gap:8px}

.nav-item{
  border:0;
  width:100%;
  border-radius:8px;
  padding:13px 14px;
  color:#d4dae4;
  background:transparent;
  cursor:pointer;
  text-align:right;
  font-size:15px;
  font-weight:700;
}

.nav-item:hover,.nav-item.active{background:#263449;color:white}

.main{
  width:calc(100% - 268px);
  margin-right:268px;
  padding:26px;
}

.topbar{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:18px;
  margin-bottom:22px;
}

.topbar h2{margin:0;font-size:30px}
.topbar p{margin:6px 0 0;color:var(--muted)}
.top-actions{display:flex;gap:10px;flex-wrap:wrap}

.primary,.secondary,.tiny,.danger-button,.whatsapp-btn{
  border:0;
  border-radius:8px;
  padding:11px 16px;
  cursor:pointer;
  font-weight:800;
  white-space:nowrap;
}

.primary{background:var(--primary);color:white}
.primary:hover{background:var(--primary-dark)}
.secondary{background:white;color:var(--text);border:1px solid var(--border)}
.tiny{padding:7px 10px;background:#eef2f6;color:#334155}
.danger-button{background:#fee2e2;color:#991b1b}
.whatsapp-btn{background:#18a558;color:white}
.small{padding:8px 12px}

.page{display:none}
.active-page{display:block}

.stats-grid{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:14px;
  margin-bottom:16px;
}

.stat-card,.panel,.mini-card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:8px;
  box-shadow:var(--shadow);
}

.stat-card{padding:18px}
.stat-card span{display:block;color:var(--muted);margin-bottom:8px;font-weight:700}
.stat-card strong{display:block;font-size:30px}
.stat-card small{color:var(--muted)}
.stat-card.success strong{color:var(--green)}
.stat-card.warning strong{color:var(--amber)}
.stat-card.danger strong{color:var(--red)}

.layout-2{
  display:grid;
  grid-template-columns:minmax(0,1.1fr) minmax(320px,.9fr);
  gap:16px;
}

.panel{padding:18px;margin-bottom:16px}

.panel-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:14px;
}

.panel-head h3{margin:0;font-size:21px}
.panel-head p{margin:4px 0 0;color:var(--muted)}
.actions{display:flex;gap:8px;flex-wrap:wrap}

.cards-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:12px;
}

.mini-card{padding:15px;background:#fbfcfe}
.mini-card h4{margin:0 0 6px;font-size:18px}
.mini-card p{margin:0 0 12px;color:var(--muted)}
.card-meta{display:flex;gap:8px;flex-wrap:wrap}

.badge{
  display:inline-flex;
  align-items:center;
  min-height:26px;
  padding:4px 9px;
  border-radius:999px;
  font-size:13px;
  font-weight:800;
  white-space:nowrap;
}

.badge.green{background:#dcfce7;color:#166534}
.badge.red{background:#fee2e2;color:#991b1b}
.badge.yellow{background:#fef3c7;color:#92400e}
.badge.gray{background:#e5e7eb;color:#374151}
.badge.blue{background:#dbeafe;color:#1e40af}
.badge.teal{background:#ccfbf1;color:#115e59}

table{
  width:100%;
  border-collapse:collapse;
  overflow:hidden;
}

th,td{
  padding:13px;
  border-bottom:1px solid var(--border);
  text-align:right;
  vertical-align:middle;
}

th{
  background:#f8fafc;
  color:#475569;
  font-weight:800;
}

tbody tr:hover{background:#fbfdff}

.empty-state{
  display:grid;
  place-items:center;
  min-height:180px;
  padding:26px;
  border:1px dashed #b8c3d1;
  border-radius:8px;
  background:#fbfcfe;
  text-align:center;
}

.empty-state h3{margin:0 0 8px}
.empty-state p{margin:0 0 14px;color:var(--muted)}

.quick-form{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:10px;
  align-items:end;
  margin-bottom:14px;
  padding:14px;
  border-radius:8px;
  background:#f8fafc;
  border:1px solid var(--border);
}

.field label,.quick-form label{
  display:block;
  margin-bottom:6px;
  color:#344054;
  font-weight:800;
  font-size:14px;
}

input,select,textarea{
  width:100%;
  border:1px solid var(--border);
  border-radius:8px;
  padding:10px 12px;
  color:var(--text);
  background:white;
  outline:none;
}

textarea{min-height:110px;resize:vertical}
input:focus,select:focus,textarea:focus{border-color:var(--primary);box-shadow:0 0 0 3px rgba(23,105,170,.12)}

.form-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}

.form-grid .full{grid-column:1/-1}
.form-grid .form-actions{grid-column:1/-1;display:flex;gap:8px;justify-content:flex-start;margin-top:4px}

.modal-backdrop{
  position:fixed;
  inset:0;
  z-index:20;
  display:grid;
  place-items:center;
  padding:20px;
  background:rgba(15,23,42,.42);
}

.modal-backdrop[hidden]{display:none}

.modal{
  width:min(680px,100%);
  max-height:92vh;
  overflow:auto;
  background:white;
  border-radius:10px;
  border:1px solid var(--border);
  box-shadow:0 24px 80px rgba(15,23,42,.22);
  padding:18px;
}

.modal-head{
  display:flex;
  justify-content:space-between;
  gap:12px;
  margin-bottom:14px;
}

.modal-head h3{margin:0;font-size:23px}
.modal-head p{margin:5px 0 0;color:var(--muted)}
.icon-button{
  width:36px;
  height:36px;
  border:1px solid var(--border);
  border-radius:8px;
  background:white;
  cursor:pointer;
  font-size:24px;
  line-height:1;
}

.progress{
  height:12px;
  border-radius:999px;
  background:#e5e7eb;
  overflow:hidden;
}

.progress div{height:100%;background:linear-gradient(90deg,#1769aa,#25a18e)}

.mini-list{display:grid;gap:8px}
.mini-list div{
  display:flex;
  justify-content:space-between;
  gap:10px;
  padding:11px 0;
  border-bottom:1px solid var(--border);
}
.mini-list div:last-child{border-bottom:0}
.muted{color:var(--muted)}
.nowrap{white-space:nowrap}

.kanban{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:12px;
}

.kanban-col{
  min-height:220px;
  padding:12px;
  border:1px dashed #cbd5e1;
  border-radius:8px;
  background:#f8fafc;
}

.kanban-col h4{margin:0 0 10px}
.ticket{
  padding:12px;
  margin-bottom:9px;
  border:1px solid var(--border);
  border-radius:8px;
  background:white;
}
.ticket b{display:block}
.ticket p{margin:5px 0;color:var(--muted)}

.settings-grid{
  display:grid;
  grid-template-columns:minmax(280px,520px);
}

@media(max-width:1080px){
  .stats-grid,.cards-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .layout-2{grid-template-columns:1fr}
  .quick-form{grid-template-columns:repeat(2,minmax(0,1fr))}
}

@media(max-width:760px){
  body{display:block}
  .sidebar{position:relative;width:100%;padding:16px}
  nav{display:grid;grid-template-columns:1fr 1fr}
  .main{width:100%;margin-right:0;padding:16px}
  .topbar{flex-direction:column}
  .stats-grid,.cards-grid,.quick-form,.form-grid,.kanban{grid-template-columns:1fr}
  .top-actions,.actions{width:100%}
  .top-actions button,.actions button{flex:1}
  table{min-width:680px}
  .panel{overflow:auto}
}
