:root{
  --primary:#a53d4c;        /* Sidebar / primary */
  --text:#5d5754;           /* Text on white */
  --accent:#cab699;         /* Accent */

  --bg:#f3f2f1;
  --card:#ffffff;
  --border:rgba(93,87,84,0.18);

  --shadow:0 6px 18px rgba(0,0,0,0.06);
  --radius:12px;
  --radius-sm:10px;
}

*{ box-sizing:border-box; }
html, body{ height:100%; }
body{
  margin:0;
  font-family: "Cairo", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color:var(--text);
  background:var(--bg);
}

a{ color:inherit; text-decoration:none; }

/* App shell */
.app{ min-height:100vh; display:flex; flex-direction:column; }
.topbar{
  position:sticky;
  top:0;
  z-index:20;
  display:flex;
  align-items:center;
  gap:12px;
  padding:10px 14px;
  background:var(--card);
  border-bottom:1px solid var(--border);
  flex-wrap:nowrap; /* keep header one row */
}

/* Icon buttons in header */
.icon-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  border:1px solid var(--border);
  background:rgba(255,255,255,0.95);
  color:var(--text);
  padding:8px 10px;
  border-radius:12px;
  cursor:pointer;
  user-select:none;
  line-height:1;
}
.icon-btn:hover{ background:rgba(0,0,0,0.03); }
.icon-btn:active{ transform:translateY(0.5px); }
.icon-svg{ width:20px; height:20px; }

.brand{ display:flex; align-items:center; gap:10px; min-width:0; }
.brand-logo{ height:36px; width:auto; object-fit:contain; }
.brand-text{ display:flex; flex-direction:column; line-height:1.1; min-width:0; }
.brand-title{ font-weight:800; letter-spacing:0.3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.brand-sub{ font-size:12px; opacity:0.8; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

@media (max-width: 720px){
  .brand-sub{ display:none; }
}
@media (max-width: 520px){
  .brand-text{ display:none; }
}

.topbar-actions{
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:nowrap; /* keep header one row */
  min-width:0;
}
[dir="rtl"] .topbar-actions{ margin-left:0; margin-right:auto; }

/* Notification badge */
.notif-btn{ position:relative; }
.notif-badge{
  position:absolute;
  top:-6px;
  right:-6px;
  min-width:18px;
  height:18px;
  padding:0 5px;
  border-radius:999px;
  background:var(--primary);
  color:#fff;
  font-size:11px;
  font-weight:900;
  display:flex;
  align-items:center;
  justify-content:center;
  border:2px solid #fff;
}
[dir="rtl"] .notif-badge{ right:auto; left:-6px; }

/* Header user button */
.user-btn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  border:1px solid var(--border);
  background:rgba(255,255,255,0.95);
  padding:6px 10px;
  border-radius:999px;
  font-weight:900;
  max-width:240px;
  min-width:0;
}
.user-btn:hover{ background:rgba(0,0,0,0.03); }
.avatar{
  width:30px;
  height:30px;
  border-radius:999px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(165,61,76,0.12);
  border:1px solid rgba(165,61,76,0.25);
  color:var(--primary);
  font-weight:900;
  flex:0 0 30px;
}
.user-name{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
@media (max-width: 520px){
  .user-name{ display:none; }
}

/* Language dropdown */
details.dropdown{ position:relative; }
details.dropdown > summary{ list-style:none; }
details.dropdown > summary::-webkit-details-marker{ display:none; }
.dropdown-label{ font-weight:900; }
.dropdown-menu{
  position:absolute;
  top:calc(100% + 8px);
  right:0;
  min-width:170px;
  background:#fff;
  border:1px solid var(--border);
  border-radius:12px;
  box-shadow:var(--shadow);
  padding:6px;
  z-index:50;
}
[dir="rtl"] .dropdown-menu{ right:auto; left:0; }
.dd-item{
  display:block;
  padding:10px 10px;
  border-radius:10px;
  font-weight:900;
}
.dd-item:hover{ background:rgba(202,182,153,0.18); }
.dd-item.active{ background:rgba(165,61,76,0.10); }

.main{ display:flex; align-items:stretch; min-height:calc(100vh - 62px); }

/* Sidebar */
.sidebar{
  width:260px;
  flex:0 0 260px;
  background:var(--primary);
  color:var(--accent);
  display:flex;
  flex-direction:column;
  border-right:1px solid rgba(202,182,153,0.25);
}
[dir="rtl"] .sidebar{ border-right:none; border-left:1px solid rgba(202,182,153,0.25); }

.sidebar-header{
  padding:16px 16px 12px;
  border-bottom:1px solid rgba(202,182,153,0.25);
}
.sidebar-title{ font-weight:900; letter-spacing:0.4px; }
.sidebar-sub{ font-size:12px; opacity:0.95; margin-top:4px; }

.nav{ padding:10px; display:flex; flex-direction:column; gap:6px; }
.nav-item{
  display:flex;
  align-items:center;
  padding:10px 12px;
  border-radius:12px;
  color:var(--accent);
  font-weight:700;
}
.nav-item:hover{ background:rgba(255,255,255,0.08); }
.nav-item.active{ background:rgba(255,255,255,0.14); }

.nav-sep{
  height:1px;
  background:rgba(202,182,153,0.25);
  margin:10px 6px;
}

.nav-item.nav-logout{
  background:rgba(255,255,255,0.08);
}
.nav-item.nav-logout:hover{ background:rgba(255,255,255,0.14); }

.sidebar-footer{
  margin-top:auto;
  padding:12px 16px 16px;
  border-top:1px solid rgba(202,182,153,0.25);
}
.copyright{ font-size:12px; opacity:0.95; }

/* Content */
.content{ flex:1; padding:16px; min-width:0; }

.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:14px;
  margin-bottom:14px;
}
.card h2, .card h3{ margin:0 0 10px; }

.muted{ opacity:0.78; }
.small{ font-size:12px; }

/* Metro tiles */
.kpi-row{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap:12px;
  margin-top:12px;
}
.kpi-tile{
  display:block;
  border:1px solid var(--border);
  border-radius:12px;
  background:#fff;
  padding:12px;
  box-shadow:0 2px 0 rgba(0,0,0,0.02);
  min-width:0;
}
.kpi-tile:hover{ background:rgba(202,182,153,0.12); }
.kpi-label{ font-weight:800; font-size:13px; opacity:0.9; }
.kpi-value{ font-size:26px; font-weight:900; margin-top:6px; line-height:1; }
.kpi-hint{ margin-top:8px; font-size:12px; opacity:0.85; }

@media (max-width: 520px){
  .kpi-row{ gap:8px; }
  .kpi-tile{ padding:10px; }
  .kpi-value{ font-size:22px; }
  .kpi-label{ font-size:12px; }
}

/* Department list on dashboard */
.dept-list{ display:flex; flex-direction:column; gap:10px; }
.dept-row{
  border:1px solid var(--border);
  border-radius:12px;
  background:#fff;
  padding:12px;
}
.dept-row-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
}
.dept-name{ font-weight:900; }
.dept-meta{ font-size:12px; opacity:0.82; margin-top:2px; }

.dept-stats{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap:10px;
  margin-top:10px;
}
.dept-stat{
  border:1px solid rgba(202,182,153,0.35);
  border-radius:10px;
  padding:10px;
  background:rgba(202,182,153,0.10);
  min-width:0;
}
.dept-stat .label{ font-size:12px; opacity:0.85; font-weight:800; }
.dept-stat .value{ font-size:18px; font-weight:900; margin-top:4px; }

.progress{
  height:10px;
  border-radius:999px;
  background:rgba(93,87,84,0.12);
  overflow:hidden;
  margin-top:10px;
}
.progress > .bar{
  height:100%;
  width:0;
  background:var(--primary);
}

/* Grid */
.grid{ display:grid; grid-template-columns: repeat(12, 1fr); gap:12px; }
.col-12{ grid-column:span 12; }
.col-6{ grid-column:span 6; }
.col-4{ grid-column:span 4; }
.col-3{ grid-column:span 3; }

@media (max-width: 900px){
  .col-6{ grid-column:span 12; }
  .col-4{ grid-column:span 6; }
  .col-3{ grid-column:span 6; }
}
@media (max-width: 600px){
  .col-4,.col-3{ grid-column:span 12; }
}

/* Buttons / chips */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:var(--card);
  color:var(--text);
  cursor:pointer;
  font-weight:800;
}
.btn:hover{ background:rgba(0,0,0,0.03); }
.btn.primary{ background:var(--primary); border-color:rgba(0,0,0,0.08); color:#fff; }
.btn.danger{ background:#b33b3b; color:#fff; border-color:rgba(0,0,0,0.08); }
.btn.accent{ background:var(--accent); color:#2d2b2a; border-color:rgba(0,0,0,0.06); }
.btn.small{ padding:8px 10px; border-radius:10px; font-size:13px; }

.chip{
  display:inline-flex;
  align-items:center;
  border:1px solid var(--border);
  background:var(--card);
  padding:8px 10px;
  border-radius:999px;
  font-weight:800;
}
.chip.danger{ background:#b33b3b; color:#fff; border-color:rgba(0,0,0,0.06); }
.chip-count{
  min-width:22px;
  padding:2px 7px;
  border-radius:999px;
  background:rgba(165,61,76,0.12);
  border:1px solid rgba(165,61,76,0.25);
  font-size:12px;
  text-align:center;
}

/* Forms */
.form{ display:flex; flex-direction:column; gap:10px; }
.field{ display:flex; flex-direction:column; gap:6px; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"], select, textarea{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  outline:none;
}
textarea{ min-height:90px; resize:vertical; }

.row{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; }

.checkbox{ display:flex; gap:10px; align-items:center; }
.checkbox input{ width:18px; height:18px; }

.flash-wrap{ display:flex; flex-direction:column; gap:8px; margin-bottom:12px; }
.flash{ padding:10px 12px; border-radius:12px; border:1px solid var(--border); background:#fff; }
.flash.success{ border-color:rgba(46,125,50,0.35); background:rgba(46,125,50,0.07); }
.flash.danger{ border-color:rgba(179,59,59,0.35); background:rgba(179,59,59,0.07); }
.flash.info{ border-color:rgba(2,136,209,0.35); background:rgba(2,136,209,0.07); }

/* Tables */
.table-wrap{ overflow:auto; border-radius:var(--radius); border:1px solid var(--border); background:var(--card); }
table{ width:100%; border-collapse:collapse; }
th, td{ padding:10px 12px; border-bottom:1px solid var(--border); text-align:left; vertical-align:top; }
[dir="rtl"] th, [dir="rtl"] td{ text-align:right; }
th{ font-size:12px; text-transform:uppercase; letter-spacing:0.04em; opacity:0.9; }
tr:last-child td{ border-bottom:none; }

.badge{
  display:inline-flex;
  align-items:center;
  padding:3px 8px;
  border-radius:999px;
  border:1px solid var(--border);
  font-size:12px;
  font-weight:900;
}
.badge.approved{ background:rgba(46,125,50,0.12); border-color:rgba(46,125,50,0.25); }
.badge.rejected{ background:rgba(179,59,59,0.12); border-color:rgba(179,59,59,0.25); }
.badge.pending{ background:rgba(2,136,209,0.10); border-color:rgba(2,136,209,0.22); }
.badge.requested{ background:rgba(251,140,0,0.12); border-color:rgba(251,140,0,0.25); }
.badge.in_progress{ background:rgba(165,61,76,0.12); border-color:rgba(165,61,76,0.25); }
.badge.completed{ background:rgba(46,125,50,0.12); border-color:rgba(46,125,50,0.25); }
.badge.not_started{ background:rgba(93,87,84,0.10); border-color:rgba(93,87,84,0.22); }

hr.sep{ border:none; border-top:1px dashed rgba(202,182,153,0.65); margin:12px 0; }

/* Segmented tabs */
.segmented{
  display:inline-flex;
  gap:0;
  border:1px solid var(--border);
  border-radius:999px;
  overflow:hidden;
  background:#fff;
}
.segmented a{
  padding:8px 12px;
  font-weight:900;
  font-size:13px;
  border-right:1px solid var(--border);
}
[dir="rtl"] .segmented a{ border-right:none; border-left:1px solid var(--border); }
.segmented a:last-child{ border-right:none; }
[dir="rtl"] .segmented a:last-child{ border-left:none; }
.segmented a.active{ background:rgba(165,61,76,0.10); }

/* Cards grid (suppliers etc.) */
.cards-grid{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap:12px;
}
@media (max-width: 900px){
  .cards-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px){
  .cards-grid{ grid-template-columns: 1fr; }
}

.mini-card{
  border:1px solid var(--border);
  border-radius:12px;
  padding:12px;
  background:#fff;
  min-width:0;
}
.mini-card .title{ font-weight:900; }
.mini-card .line{ margin-top:6px; font-size:13px; opacity:0.9; word-break:break-word; }

/* Responsive sidebar */
@media (max-width: 900px){
  .sidebar{
    position:fixed;
    top:0;
    bottom:0;
    left:0;
    transform:translateX(-110%);
    transition:transform 180ms ease;
    z-index:40;
    box-shadow: 0 18px 35px rgba(0,0,0,0.25);
  }
  [dir="rtl"] .sidebar{
    left:auto;
    right:0;
    transform:translateX(110%);
  }
  .sidebar.open{ transform:translateX(0); }
  .main{ min-height:auto; }
  .content{ padding:14px; }
  .backdrop{ position:fixed; inset:0; background:rgba(0,0,0,0.35); z-index:30; }
}

/* Login */
.login-body{
  min-height:100vh;
  background:#111;
}
.login-video{
  position:fixed;
  inset:0;
  width:100%;
  height:100%;
  object-fit:cover;
  z-index:0;
}
.login-overlay{
  position:fixed;
  inset:0;
  background:linear-gradient(135deg, rgba(165,61,76,0.55), rgba(0,0,0,0.55));
  z-index:1;
}
.login-wrap{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
  position:relative;
  z-index:2;
}
.login-card{
  width:100%;
  max-width:460px;
  background:rgba(255,255,255,0.96);
  border:1px solid rgba(255,255,255,0.35);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:18px;
}
.login-brand{ text-align:center; margin-bottom:10px; }
.login-logo{ height:70px; width:auto; object-fit:contain; }
.login-title{ font-size:18px; font-weight:900; margin-top:10px; }
.login-sub{ margin-top:6px; opacity:0.88; }
.login-footer{ margin-top:12px; display:flex; align-items:center; justify-content:space-between; gap:10px; }

/* Splash */
.splash{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background:#fff;
  z-index:100;
  transition:opacity 350ms ease;
}
.splash video, .splash img{
  max-width:min(90vw, 520px);
  height:auto;
  object-fit:contain;
}
.splash.hide{ opacity:0; pointer-events:none; }

/* Mobile tables to cards */
@media (max-width: 650px){
  table.responsive thead{ display:none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td{ display:block; width:100%; }
  table.responsive tr{ border-bottom:1px solid var(--border); padding:10px 10px; }
  table.responsive td{
    border:none;
    padding:6px 0;
    display:flex;
    justify-content:space-between;
    gap:12px;
  }
  table.responsive td::before{ content: attr(data-label); font-weight:900; opacity:0.85; }
}

/* Prevent horizontal scroll globally */
img, video{ max-width:100%; height:auto; }
