:root {
  color-scheme: light;
  --ink: #193b35;
  --muted: #52665e;
  --green: #155447;
  --green-hover: #103f35;
  --lime: #d5efb0;
  --line: #dbe5de;
  --bg: #f3f6f3;
  --white: #fff;
  --soft: #f7faf7;
  --danger: #8f2922;
  --danger-bg: #fff0ee;
  --success: #155b31;
  --success-bg: #e7f5e9;
  --focus: #075fc1;
  --shadow-sm: 0 2px 8px rgb(20 54 42 / 5%);
  --shadow-md: 0 12px 32px rgb(20 54 42 / 8%);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.75 "Tajawal", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .65; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
::selection { color: #102f28; background: #d9efbd; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  right: 12px;
  padding: 10px 16px;
  transform: translateY(-180%);
  border-radius: 10px;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  box-shadow: var(--shadow-md);
}
.skip-link:focus { transform: translateY(0); }

#sidebar {
  position: fixed;
  z-index: 30;
  top: 0;
  right: 0;
  display: flex;
  width: 252px;
  height: 100dvh;
  flex-direction: column;
  padding: 28px 18px 20px;
  border-left: 1px solid var(--line);
  background: var(--white);
  box-shadow: -8px 0 28px rgb(20 54 42 / 3%);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
  color: var(--ink);
  font-size: 27px;
  font-weight: 800;
  line-height: 1.25;
}
.brand img { flex: 0 0 auto; }
.brand small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.nav-label {
  margin: 34px 14px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
nav { display: grid; gap: 6px; }
nav a {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #435b51;
  font-size: 14px;
  font-weight: 600;
  transition: background-color .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
}
nav a .ico { color: #526f61; }
nav a:hover:not(.active) {
  border-color: #e1e9e2;
  background: #f2f7f1;
  color: var(--ink);
}
nav a.active {
  background: var(--green);
  color: #fff;
  box-shadow: 0 5px 14px rgb(21 84 71 / 18%);
}
nav a.active .ico { color: #e3f3cd; }
.ico {
  display: inline-flex;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  vertical-align: middle;
}
.side-bottom {
  margin-top: auto;
  padding: 18px 8px 0;
  border-top: 1px solid var(--line);
  color: #465f54;
  font-size: 12px;
  font-weight: 600;
}
.side-bottom small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}
.online {
  position: relative;
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 6px;
  border-radius: 50%;
  background: #2b8047;
}
.online::after {
  position: absolute;
  inset: -4px;
  border: 1px solid rgb(43 128 71 / 35%);
  border-radius: 50%;
  content: "";
  animation: online-pulse 2.2s ease-out infinite;
}
@keyframes online-pulse {
  0% { transform: scale(.75); opacity: .8; }
  100% { transform: scale(1.7); opacity: 0; }
}

.workspace { min-width: 0; margin-right: 252px; }
header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 30px;
  border-bottom: 1px solid rgb(219 229 222 / 90%);
  background: rgb(255 255 255 / 94%);
  backdrop-filter: blur(14px);
}
.header-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}
.header-title b { margin: 0 10px; color: #71847a; }
.header-title strong { color: var(--ink); font-weight: 700; }
.header-tools {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}
.workshop-label { color: var(--green); font-size: 13px; font-weight: 800; }
.avatar {
  display: inline-flex;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid #c8ddc0;
  border-radius: 50%;
  background: #e8f3df;
  color: var(--green);
  font-weight: 800;
}
.logout-button { min-height: 40px; padding: 7px 12px; }

main {
  width: 100%;
  max-width: 1600px;
  min-height: calc(100vh - 140px);
  margin: 0 auto;
  padding: 30px 32px 42px;
}
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 {
  margin: 0 0 5px;
  font-size: clamp(23px, 2vw, 29px);
  font-weight: 800;
  letter-spacing: -.45px;
  line-height: 1.35;
}
h2 { margin: 0; font-size: 18px; font-weight: 800; line-height: 1.5; }
h3 { font-size: 16px; font-weight: 800; }
.sub { margin: 0; color: var(--muted); font-size: 13px; }
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.primary, .secondary, .danger, .wa {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.primary {
  background: var(--green);
  color: #fff;
  box-shadow: 0 2px 5px rgb(21 84 71 / 10%);
}
.primary:hover { background: var(--green-hover); box-shadow: 0 5px 14px rgb(21 84 71 / 18%); transform: translateY(-1px); }
.secondary {
  border-color: #cbd9cf;
  background: #fff;
  color: var(--ink);
}
.secondary:hover { border-color: #93b09b; background: #f5f9f5; transform: translateY(-1px); }
.danger { border-color: #f0cbc6; background: var(--danger-bg); color: var(--danger); }
.danger:hover { border-color: #d99c95; background: #ffe4e0; transform: translateY(-1px); }
.wa { background: #e5f5e9; color: #155b31; }
.wa:hover { background: #d5eedc; transform: translateY(-1px); }
.wa .ico { font-size: 18px; }
.primary:active, .secondary:active, .danger:active, .wa:active { transform: translateY(0); }
.icon-button {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
}
.icon-button:hover { border-color: var(--line); background: #f1f6f1; }
.link {
  min-height: 40px;
  padding: 7px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #285d43;
  font-size: 13px;
  font-weight: 700;
}
.link:hover { background: #eff6ec; color: #17482f; text-decoration: underline; text-underline-offset: 3px; }

.hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  overflow: hidden;
  margin-bottom: 24px;
  padding: 30px 32px;
  border: 1px solid #174f43;
  border-radius: 20px;
  background: linear-gradient(125deg, #174f43 0%, #123d34 100%);
  color: #fff;
  box-shadow: var(--shadow-md);
}
.page-hero { min-height: 176px; align-items: center; }
.page-hero .page-hero-copy { min-width: 0; max-width: 760px; }
.page-hero h1 { margin: 7px 0; color: #fff; font-size: clamp(23px, 2.4vw, 31px); line-height: 1.25; }
.page-hero p { max-width: 620px; margin: 8px 0 0; color: #e0eee7; font-size: 15px; }
.page-hero .actions { margin-top: 16px; }
.page-hero .hero-art { flex-shrink: 0; }
.page-hero .primary { background: var(--lime); color: #173d30; box-shadow: none; }
.page-hero .primary:hover { background: #e5f7c9; }
.hero::before {
  position: absolute;
  top: -100px;
  left: 16%;
  width: 260px;
  height: 260px;
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 50%;
  background: rgb(255 255 255 / 3%);
  content: "";
  pointer-events: none;
}
.hero > div:first-child { position: relative; z-index: 1; }
.hero h2 { margin: 7px 0; font-size: clamp(21px, 2.2vw, 26px); }
.hero p { max-width: 560px; margin: 8px 0 18px; color: #e0eee7; font-size: 14px; }
.eyebrow { color: #d5efb0; font-size: 12px; font-weight: 800; }
.hero .primary { background: var(--lime); color: #173d30; box-shadow: none; }
.hero .primary:hover { background: #e5f7c9; }
.hero-art {
  position: relative;
  z-index: 1;
  display: grid;
  width: 132px;
  height: 132px;
  flex: 0 0 132px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 22%);
  border-radius: 50%;
  background: rgb(255 255 255 / 7%);
}
.hero-art .ico { width: 70px; height: 70px; flex-basis: 70px; color: var(--lime); font-size: 58px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--white);
  box-shadow: var(--shadow-sm);
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.stat:hover { transform: translateY(-2px); border-color: #c4d7c8; box-shadow: var(--shadow-md); }
.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.stat-icon {
  display: inline-flex;
  min-width: 38px;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 11px;
  background: #edf5e8;
  color: #315f3c;
}
.stat-icon .ico { font-size: 18px; }
.stat b { display: block; margin: 10px 0 2px; font-size: clamp(23px, 2.3vw, 29px); font-weight: 800; line-height: 1.5; overflow-wrap: anywhere; }
.stat small { display: block; color: var(--muted); font-size: 12px; line-height: 1.6; }

.grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr); gap: 20px; margin-bottom: 22px; }
.panel {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--white);
  box-shadow: var(--shadow-sm);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border-radius: 9px;
  -webkit-overflow-scrolling: touch;
  scrollbar-color: #a9bcb0 #f0f4f0;
  scrollbar-width: thin;
}
.table-wrap:focus-visible { outline-offset: 2px; }
table { width: 100%; border-collapse: collapse; text-align: right; font-size: 13px; white-space: nowrap; }
th { background: #edf3ee; color: #344f42; font-weight: 800; }
th, td { padding: 13px 12px; }
td { border-bottom: 1px solid #e8eee9; }
tbody tr { transition: background-color .15s ease; }
tbody tr:hover { background: #f8fbf8; }
td small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.badge {
  display: inline-flex;
  min-height: 27px;
  align-items: center;
  justify-content: center;
  padding: 4px 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: #edf1ed;
  color: #40564b;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}
.badge.ready { border-color: #cce4c4; background: #e8f5e2; color: #315d25; }
.badge.work { border-color: #cfdbf4; background: #eaf0ff; color: #304f87; }
.badge.wait { border-color: #efd7a4; background: #fff2d8; color: #754b00; }
.empty { padding: 34px 14px; color: var(--muted); font-size: 14px; text-align: center; }
.empty .ico { display: flex; width: 38px; height: 38px; margin: 0 auto 12px; color: #4d7458; font-size: 28px; }
.bars { display: grid; gap: 18px; }
.bar-title { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 7px; color: #455d50; font-size: 13px; }
.track { height: 9px; overflow: hidden; border-radius: 99px; background: #e8eee7; }
.fill { height: 100%; border-radius: inherit; background: #80a95f; transition: width .35s ease; }
.mini-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.mini-row:last-child { border-bottom: 0; }
.hint { margin: 18px 0; padding: 14px 16px; border: 1px solid #d7e6cc; border-radius: 11px; background: #f0f6e9; color: #3f5d32; font-size: 13px; }
.toolbar { display: flex; gap: 12px; margin-bottom: 18px; }
.toolbar input { flex: 1 1 auto; }
.toolbar select { max-width: 240px; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #b9c9be;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
}
input::placeholder, textarea::placeholder { color: #64776c; opacity: 1; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  border-color: var(--focus);
  outline: 3px solid rgb(7 95 193 / 22%);
  outline-offset: 1px;
}
textarea { min-height: 100px; resize: vertical; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.row-actions button, .row-actions a { min-height: 40px; padding: 7px 10px; font-size: 12px; }
footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 16px 32px;
  border-top: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}
#save-state { margin-right: auto; color: #405b4c; font-weight: 600; }
#menu { display: none; }
#shade { display: none; }
dialog {
  width: min(720px, 94vw);
  max-width: 94vw;
  max-height: 90dvh;
  overflow: auto;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid #d7e2d9;
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 24px 90px rgb(12 38 29 / 28%);
}
dialog::backdrop { background: rgb(12 35 28 / 62%); backdrop-filter: blur(4px); }
dialog form { margin: 0; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field { min-width: 0; }
.field label { display: grid; gap: 7px; color: #304d40; font-size: 13px; font-weight: 700; }
.field.full { grid-column: 1 / -1; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
#form-error { color: var(--danger); font-size: 13px; font-weight: 700; }
#form-error:empty { display: none; }
#toast {
  display: none;
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  max-width: min(460px, calc(100vw - 36px));
  padding: 13px 18px;
  border: 1px solid #41675a;
  border-radius: 12px;
  background: #173f35;
  color: #fff;
  box-shadow: 0 12px 35px rgb(10 38 28 / 25%);
  font-size: 14px;
}
#toast[style*="display: block"] { animation: toast-in .2s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.contact h3 { margin: 0; }
.contact p { color: var(--muted); font-size: 13px; }
.contact .actions { margin-top: 16px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.settings-grid .panel p { color: var(--muted); font-size: 13px; }
.setting-form { display: grid; gap: 14px; }
.setting-form label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; }
.receipt { display: none; }

@media (min-width: 1600px) {
  main { padding-top: 38px; }
}
@media (max-width: 1150px) {
  #sidebar { width: 224px; padding-inline: 14px; }
  .workspace { margin-right: 224px; }
  main { padding: 24px; }
  header { padding-inline: 22px; }
  .stats { gap: 10px; }
  .stat { padding: 15px; }
  .grid { grid-template-columns: minmax(0, 1.35fr) minmax(250px, 1fr); gap: 15px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  #sidebar {
    width: min(290px, 86vw);
    padding: 24px 18px 18px;
    transform: translateX(105%);
    transition: transform .22s ease;
    box-shadow: -16px 0 40px rgb(13 42 30 / 18%);
  }
  body.menu-open #sidebar { transform: translateX(0); }
  body.menu-open #shade {
    position: fixed;
    z-index: 19;
    inset: 0;
    display: block;
    background: rgb(13 35 28 / 58%);
    backdrop-filter: blur(2px);
  }
  .workspace { margin-right: 0; }
  #menu { display: inline-flex; }
  header { min-height: 68px; padding: 10px 16px; }
  .header-tools { gap: 8px; }
  .header-tools #today { display: none; }
  main { padding: 22px 18px 32px; }
  .grid, .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .hero { padding: 24px; }
  .page-hero { min-height: 0; gap: 14px; }
  .page-hero h1 { font-size: 24px; }
  .page-hero p { font-size: 14px; }
  .page-hero .hero-art { width: 94px; height: 94px; flex-basis: 94px; }
  .hero-art { width: 94px; height: 94px; flex-basis: 94px; }
  .hero-art .ico { width: 54px; height: 54px; flex-basis: 54px; font-size: 42px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head { align-items: flex-start; }
  .page-head .actions { justify-content: flex-start; }
  footer { padding: 15px 18px; }
  .panel { padding: 18px; }
}
@media (max-width: 520px) {
  header { gap: 8px; }
  .header-title { gap: 6px; font-size: 12px; }
  .header-title b { margin: 0 4px; }
  .header-tools { gap: 6px; }
  .workshop-label { display: none; }
  .avatar { width: 38px; height: 38px; flex-basis: 38px; }
  .logout-button { min-height: 38px; padding: 6px 9px; }
  main { padding: 20px 13px 28px; }
  .page-head { flex-direction: column; gap: 12px; margin-bottom: 20px; }
  .page-head .actions { width: 100%; }
  .page-head .actions > * { flex: 1 1 auto; }
  .hero { margin-bottom: 18px; padding: 21px; border-radius: 16px; }
  .hero-art { display: none; }
  .page-hero .hero-art { display: none; }
  .page-hero { padding: 20px; }
  .page-hero .actions > * { width: 100%; justify-content: center; }
  .hero p { font-size: 13px; }
  .stats { gap: 10px; margin-bottom: 18px; }
  .stat { padding: 13px; border-radius: 12px; }
  .stat-top { align-items: flex-start; font-size: 12px; }
  .stat-icon { min-width: 34px; min-height: 34px; padding: 6px; }
  .stat b { margin-top: 8px; font-size: 23px; }
  .stat small { font-size: 12px; }
  .grid { gap: 14px; margin-bottom: 16px; }
  .panel { padding: 15px; border-radius: 13px; }
  .panel-head { align-items: flex-start; }
  .toolbar { flex-direction: column; gap: 9px; }
  .toolbar select { max-width: none; }
  .cards, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .field.full { grid-column: auto; }
  .dialog-actions > * { flex: 1 1 auto; }
  dialog { width: calc(100vw - 20px); max-width: calc(100vw - 20px); max-height: 92dvh; padding: 17px; }
  .row-actions { gap: 5px; }
  .row-actions button, .row-actions a { min-height: 42px; }
  footer { gap: 6px; padding: 14px 13px; font-size: 12px; }
  #save-state { width: 100%; margin-right: 0; }
  #toast { right: 12px; max-width: calc(100vw - 24px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
@media print {
  body > * { display: none !important; }
  body > .receipt { display: block !important; padding: 30px; background: #fff; color: #000; }
  .receipt table { white-space: normal; }
  .receipt h1 { font-size: 26px; }
}