@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700;800&display=swap');

:root{
  --gold:#a9822f;
  --gold-dark:#7a5c1e;
  --cream:#fbf7ee;
  --ink:#332a1c;
  --muted:#9c8c64;
  --line:#e2d5b0;
  --bg:#2b2f36;
  --panel:#20242b;
  --panel-2:#262b33;
  --text-light:#e9e6de;
  --danger:#c0392b;
  --success:#3a7a4e;
}

*{box-sizing:border-box;}
body{
  margin:0;
  font-family:'IBM Plex Sans Arabic', sans-serif;
  background:var(--bg);
  color:var(--text-light);
}

/* ================= أزرار وعناصر عامة ================= */
.btn{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:10px 18px;
  border-radius:8px;
  border:none;
  font-family:inherit;
  font-size:14px;
  font-weight:600;
  cursor:pointer;
  transition:.15s;
}
.btn-gold{background:var(--gold); color:#fff;}
.btn-gold:hover{background:var(--gold-dark);}
.btn-outline{background:transparent; border:1px solid #4b515a; color:var(--text-light);}
.btn-outline:hover{border-color:var(--gold); color:var(--gold);}
.btn-danger{background:var(--danger); color:#fff;}
.btn-success{background:#25D366; color:#fff;}
.btn-sm{padding:7px 12px; font-size:12.5px;}
.btn:disabled{opacity:.5; cursor:not-allowed;}

input, select, textarea{
  font-family:inherit;
  background:var(--panel-2);
  border:1px solid #3a4149;
  color:var(--text-light);
  border-radius:7px;
  padding:10px 12px;
  font-size:14px;
  width:100%;
}
input:focus, select:focus, textarea:focus{
  outline:none;
  border-color:var(--gold);
}
label{
  display:block;
  font-size:12.5px;
  color:#aab0b8;
  margin-bottom:6px;
}
.field{margin-bottom:14px;}

/* ================= شاشة تسجيل الدخول ================= */
.login-wrap{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:20px;
}
.login-card{
  background:var(--panel);
  border:1px solid #333a42;
  border-radius:14px;
  padding:36px 32px;
  width:100%;
  max-width:360px;
  text-align:center;
}
.login-card img{width:64px; margin-bottom:12px;}
.login-card h1{font-size:19px; margin:0 0 4px; color:var(--text-light);}
.login-card p{font-size:12.5px; color:#8b9199; margin:0 0 24px;}
.login-card .field{text-align:right;}
.error-msg{
  color:#ff8a80;
  font-size:12.5px;
  margin-top:10px;
  min-height:16px;
}

/* ================= لوحة التحكم ================= */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 24px;
  background:var(--panel);
  border-bottom:1px solid #333a42;
  position:sticky;
  top:0;
  z-index:10;
}
.topbar .brand{display:flex; align-items:center; gap:10px;}
.topbar .brand img{width:34px;}
.topbar .brand b{font-size:15px;}
.topbar .brand small{display:block; font-size:11px; color:#8b9199;}
.topbar nav{display:flex; gap:8px;}
.topbar .userbox{display:flex; align-items:center; gap:12px; font-size:13px; color:#aab0b8;}

.container{max-width:1080px; margin:0 auto; padding:24px;}

.card{
  background:var(--panel);
  border:1px solid #333a42;
  border-radius:12px;
  padding:20px;
  margin-bottom:20px;
}
.card h2{font-size:15px; margin:0 0 16px; color:var(--text-light);}

.search-row{
  display:flex;
  gap:10px;
  margin-bottom:18px;
}
.search-row input{flex:1;}

table.data-table{
  width:100%;
  border-collapse:collapse;
  font-size:13.5px;
}
table.data-table th{
  text-align:right;
  color:var(--gold);
  font-size:11.5px;
  padding:10px 8px;
  border-bottom:2px solid #3a4149;
}
table.data-table td{
  padding:12px 8px;
  border-bottom:1px solid #2e343c;
  color:var(--text-light);
}
table.data-table tr:hover{background:#262c34;}
/* ================= قائمة الخيارات (⋮) بجدول الفواتير ================= */
.actions-cell{position:relative; text-align:center;}
.menu-btn{
  background:none;
  border:none;
  color:#aab0b8;
  font-size:19px;
  cursor:pointer;
  padding:4px 10px;
  border-radius:6px;
  line-height:1;
}
.menu-btn:hover{background:#333a42; color:var(--text-light);}
.dropdown-menu{
  position:absolute;
  left:0;
  top:calc(100% + 4px);
  background:#2c323a;
  border:1px solid #3a4149;
  border-radius:8px;
  min-width:130px;
  box-shadow:0 8px 24px rgba(0,0,0,.4);
  z-index:50;
  overflow:hidden;
  display:none;
}
.dropdown-menu.open{display:block;}
.dropdown-menu button{
  display:flex;
  align-items:center;
  gap:8px;
  width:100%;
  padding:10px 14px;
  background:none;
  border:none;
  color:var(--text-light);
  font-size:13px;
  font-family:inherit;
  cursor:pointer;
  text-align:right;
}
.dropdown-menu button:hover{background:#3a4149;}
.dropdown-menu button.danger{color:#ff8a80;}
.dropdown-menu button.danger:hover{background:#4a2a28;}

.empty-state{
  text-align:center;
  padding:40px 16px;
  color:#6b7178;
  font-size:13px;
}

.grid-2{display:grid; grid-template-columns:1fr 1fr; gap:14px;}
.grid-3{display:grid; grid-template-columns:1fr 1fr 1fr; gap:14px;}
@media(max-width:640px){
  .grid-2, .grid-3{grid-template-columns:1fr;}
}

.items-list{margin-bottom:14px;}
.item-row{
  display:flex;
  gap:10px;
  margin-bottom:10px;
  align-items:center;
}
.item-row input:first-child{flex:1;}
.item-row input:nth-child(2){width:140px;}
.item-row .remove-item{
  background:none; border:none; color:#ff8a80; cursor:pointer; font-size:18px; flex-shrink:0;
}

.totals-box{
  background:var(--panel-2);
  border-radius:10px;
  padding:16px;
  margin-top:10px;
}
.totals-box .row{
  display:flex;
  justify-content:space-between;
  padding:6px 0;
  font-size:14px;
}
.totals-box .row.final{
  border-top:1px solid #3a4149;
  margin-top:6px;
  padding-top:10px;
  font-weight:800;
  color:var(--gold);
  font-size:17px;
}

.badge{
  display:inline-block;
  padding:3px 10px;
  border-radius:999px;
  font-size:11px;
  background:#3a4149;
  color:#c7cbd1;
}

.file-drop{
  border:1.5px dashed #4b515a;
  border-radius:10px;
  padding:18px;
  text-align:center;
  font-size:12.5px;
  color:#8b9199;
  cursor:pointer;
  position:relative;
}
.file-drop.has-file{border-color:var(--gold); color:var(--gold);}
.file-drop input{position:absolute; inset:0; opacity:0; cursor:pointer;}

.toolbar{display:flex; justify-content:space-between; align-items:center; margin-bottom:18px; flex-wrap:wrap; gap:10px;}
.actions-row{display:flex; gap:8px; flex-wrap:wrap;}

/* ================= الفاتورة (نمط ذهبي مطابق للنموذج المعتمد) ================= */
.invoice-outer{
  background:var(--bg);
  min-height:100vh;
  padding:30px 14px 60px;
}
.invoice-sheet{
  max-width:560px;
  margin:0 auto;
  background:var(--cream);
  color:var(--ink);
  border:1px solid var(--line);
  border-radius:2px;
}
.invoice-sheet .inv-head{
  text-align:center;
  padding:28px 20px 18px;
  border-bottom:3px double var(--gold);
}
.invoice-sheet .inv-head img{width:56px; margin-bottom:10px;}
.invoice-sheet .inv-head .shop-name{
  font-size:23px;
  font-weight:800;
  color:var(--gold-dark);
}
.invoice-sheet .inv-head .shop-sub{
  font-size:12px;
  color:var(--muted);
  margin-top:6px;
}
.invoice-sheet .no-row{
  display:flex;
  justify-content:space-between;
  padding:14px 28px 0;
  font-size:12.5px;
  color:#7a6c4a;
}
.invoice-sheet .no-row b{color:var(--ink); font-size:16px;}
.invoice-sheet .meta{
  padding:16px 28px 6px;
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px 18px;
  font-size:13.5px;
}
.invoice-sheet .meta div span{
  display:block;
  font-size:11px;
  color:var(--muted);
  margin-bottom:3px;
}
.invoice-sheet .meta div b{font-weight:700; font-size:15px;}
.invoice-sheet table.items{
  width:calc(100% - 56px);
  margin:18px 28px 0;
  border-collapse:collapse;
  font-size:13.5px;
  border:1px solid var(--line);
}
.invoice-sheet table.items th{
  text-align:right;
  background:var(--gold);
  color:var(--cream);
  padding:10px 14px;
  font-size:12px;
  font-weight:700;
}
.invoice-sheet table.items th:last-child, .invoice-sheet table.items td:last-child{text-align:left;}
.invoice-sheet table.items td{
  padding:11px 14px;
  border-bottom:1px solid #e9dfc4;
}
.invoice-sheet .totals{padding:18px 28px 8px;}
.invoice-sheet .totals .row{
  display:flex;
  justify-content:space-between;
  font-size:13.5px;
  padding:5px 0;
  color:#6b5e42;
}
.invoice-sheet .totals .row.final{
  color:var(--gold-dark);
  font-size:21px;
  font-weight:900;
  border-top:1px dashed #c9b787;
  margin-top:6px;
  padding-top:12px;
}
.invoice-sheet .attach-note{
  margin:0 28px 8px;
  padding:10px 14px;
  background:#f2ead2;
  border:1px solid var(--line);
  border-radius:6px;
  font-size:12px;
  color:#6b5e42;
}
.invoice-sheet .attach-note a{color:var(--gold-dark); font-weight:700;}
.invoice-sheet .sign{
  display:flex;
  justify-content:space-between;
  padding:26px 28px 8px;
  font-size:12px;
  color:#7a6c4a;
}
.invoice-sheet .sign .line{
  display:block;
  margin-top:30px;
  border-top:1px solid #c9b787;
  width:140px;
}
.invoice-sheet .inv-foot{
  text-align:center;
  padding:16px;
  font-size:11px;
  color:var(--muted);
  border-top:3px double var(--gold);
  margin-top:10px;
}

.print-actions{
  max-width:560px;
  margin:0 auto 16px;
  display:flex;
  gap:10px;
  justify-content:flex-end;
}

@media print{
  body{background:#fff;}
  .print-actions{display:none;}
  .invoice-outer{background:#fff; padding:0;}
  .invoice-sheet{border:none; max-width:100%;}
}
