:root {
  --green: #3d7a3f;
  --green-dark: #2c5a2e;
  --green-light: #e8f3e8;
  --gold: #c9a94e;
  --bg: #f4f6f3;
  --card: #ffffff;
  --text: #22301f;
  --muted: #7a8a76;
  --border: #e0e6dd;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Tajawal', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.container.narrow { max-width: 640px; }

/* ---------- nav ---------- */
.nav { background: var(--green-dark); color: #fff; }
.nav-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 16px; gap: 8px; }
.brand { color: #fff; font-size: 22px; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.logo { height: 58px; width: auto; }
.brand span { color: var(--gold); }
.brand small { font-size: 13px; font-weight: 400; opacity: .85; margin-inline-start: 6px; }
.brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.nav-links a, .btn-link {
  color: #ffffffcc; padding: 6px 14px; border-radius: 8px; font-size: 15px;
  background: none; border: none; font-family: inherit; cursor: pointer;
}
.nav-links a.active, .nav-links a:hover { background: #ffffff22; color: #fff; text-decoration: none; }
.nav-admin { background: #1f3520; }

/* ---------- hero ---------- */
.hero { background: linear-gradient(135deg, var(--green-dark), var(--green)); color: #fff; padding: 44px 0 36px; text-align: center; margin-bottom: 28px; }
.hero h1 { font-size: 32px; font-weight: 800; }
.hero p { opacity: .9; font-size: 17px; }

/* ---------- cards & forms ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.card h2, .card h3 { margin-bottom: 14px; color: var(--green-dark); }
.form-card { max-width: 720px; margin: 0 auto 28px; }
.center-card { text-align: center; }
label { display: block; margin-bottom: 14px; font-weight: 500; font-size: 15px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; margin-top: 5px;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-family: inherit; font-size: 16px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.req { color: #c0392b; }
.big-input { font-size: 20px; text-align: center; margin-bottom: 12px; }
.checkbox { font-weight: 400; }
.checkbox input { width: auto; margin-inline-end: 6px; }

.prio-row { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.prio { flex: 1; text-align: center; border: 1.5px solid var(--border); border-radius: 10px; padding: 8px; cursor: pointer; font-weight: 400; margin: 0; min-width: 90px; }
.prio:has(input:checked) { border-color: var(--green); background: var(--green-light); font-weight: 700; }
.prio input { width: auto; margin-inline-end: 4px; }

.btn {
  display: inline-block; background: #eef1ec; color: var(--text);
  border: none; border-radius: 10px; padding: 10px 22px;
  font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn:hover { filter: brightness(.96); text-decoration: none; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-lg { width: 100%; padding: 13px; font-size: 17px; margin-top: 6px; }
.inline { display: inline; }

/* ---------- alerts & badges ---------- */
.alert { border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px; }
.alert.success { background: var(--green-light); border: 1.5px solid var(--green); }
.alert.danger { background: #fdecea; border: 1.5px solid #c0392b; }
.error { color: #c0392b; margin-bottom: 10px; }
.muted { color: var(--muted); }

.badge { padding: 4px 14px; border-radius: 99px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.st-new { background: #fdf0d5; color: #9a6b00; }
.st-in_progress { background: #d6e9f8; color: #1b5e8a; }
.st-resolved { background: var(--green-light); color: var(--green-dark); }
.st-closed { background: #e8e8e8; color: #666; }

.chips { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.chip { background: #f0f2ef; border-radius: 99px; padding: 3px 12px; font-size: 13px; }
.pr-low { background: #eef; }
.pr-high { background: #ffe9d6; color: #a34d00; }
.pr-urgent { background: #ffdddd; color: #b71c1c; font-weight: 700; }
.internal-chip { background: #fff3cd; color: #8a6d00; }

/* ---------- ticket view ---------- */
.ticket-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.meta { color: var(--muted); font-size: 14px; }
.desc { background: #fafbf9; border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin: 12px 0; white-space: pre-wrap; }
.attachments { display: flex; gap: 12px; flex-wrap: wrap; margin: 10px 0; }
.attachments a { background: var(--green-light); padding: 6px 12px; border-radius: 8px; font-size: 14px; }
.status-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 14px; margin-top: 6px; }
.status-bar select { width: auto; margin: 0; }

.reply { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: #fafbf9; white-space: pre-wrap; }
.reply.admin { background: var(--green-light); border-color: #c4dcc4; }
.reply.internal { background: #fffbe8; border-color: #ecd98a; }
.reply-head { font-weight: 700; font-size: 14px; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.reply-head small { color: var(--muted); font-weight: 400; }

/* ---------- admin ---------- */
.page-title { margin: 22px 0 16px; font-size: 26px; color: var(--green-dark); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; text-align: center; display: block; }
.stat b { display: block; font-size: 34px; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 14px; }
.stat:hover { text-decoration: none; border-color: var(--green); }
.stat.st-new b { color: #9a6b00; } .stat.st-in_progress b { color: #1b5e8a; }
.stat.st-resolved b { color: var(--green-dark); } .stat.st-total b { color: var(--gold); }
.stat.st-mine b { color: #6a3fa0; }
.grid-2col { display: grid; grid-template-columns: 3fr 2fr; gap: 18px; align-items: start; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: right; color: var(--muted); font-size: 13px; border-bottom: 2px solid var(--border); padding: 6px 8px; }
.table td { padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }

.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter-bar input, .filter-bar select { width: auto; flex: 1; min-width: 140px; margin: 0; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 14px; }
.bar-row span { min-width: 120px; }
.bar { flex: 1; background: #eef1ec; border-radius: 99px; height: 10px; overflow: hidden; }
.bar div { background: var(--green); height: 100%; border-radius: 99px; }

.task-add { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.task-add input { flex: 2; min-width: 180px; margin: 0; }
.task-add input[name="notes"] { flex: 1; min-width: 120px; }
.task-list { list-style: none; }
.task-list li { padding: 7px 4px; border-bottom: 1px dashed var(--border); display: flex; gap: 8px; align-items: flex-start; }
.task-list li:last-child { border-bottom: none; }
.task-list li.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-list .check, .task-list .del { background: none; border: none; cursor: pointer; font-size: 17px; font-family: inherit; color: var(--green-dark); }
.task-list .del { opacity: .4; } .task-list .del:hover { opacity: 1; }
.task-body { flex: 1; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }

/* ---------- users page ---------- */
.btn-sm { padding: 4px 12px; font-size: 13px; }
.row-disabled td { opacity: .45; }
.actions-cell { display: flex; gap: 6px; align-items: flex-start; flex-wrap: wrap; }
.actions-cell details summary { list-style: none; cursor: pointer; }
.actions-cell details summary::-webkit-details-marker { display: none; }
.mini-form { display: flex; gap: 6px; margin-top: 6px; }
.mini-form input { margin: 0; min-width: 150px; }

.report-head { display: flex; gap: 14px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.report-head input { margin: 0; }

.footer { text-align: center; color: var(--muted); padding: 26px 0; font-size: 14px; }
.dev-name { color: var(--gold); font-weight: 800; }
.login-bg { background: linear-gradient(135deg, #1f3520, var(--green)); min-height: 100vh; }
.login-bg .footer { color: #ffffffbb; }

@media (max-width: 760px) {
  .grid2, .grid-2col { grid-template-columns: 1fr; }

  /* nav: logo on top, links scroll horizontally */
  .nav-inner { padding: 10px 12px; }
  .logo { height: 44px; }
  .nav-links {
    width: 100%; flex-wrap: nowrap; overflow-x: auto;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links a, .btn-link { white-space: nowrap; padding: 9px 12px; font-size: 14px; }

  .hero { padding: 26px 0 22px; margin-bottom: 18px; }
  .hero h1 { font-size: 22px; }
  .hero p { font-size: 15px; }
  .page-title { font-size: 21px; margin: 16px 0 12px; }
  .card { padding: 15px; }

  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 13px; }
  .stat b { font-size: 26px; }

  /* tables scroll sideways instead of squeezing */
  .table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .table td, .table th { white-space: nowrap; }

  /* forms & controls: full-width, comfortable touch targets */
  .btn { padding: 12px 20px; }
  .filter-bar input, .filter-bar select, .filter-bar .btn { width: 100%; flex: none; min-width: 0; }
  .status-bar { flex-direction: column; align-items: stretch; }
  .status-bar select { width: 100%; }
  .task-add { flex-direction: column; }
  .task-add input { min-width: 0; }
  .mini-form { flex-direction: column; }
  .mini-form input { min-width: 0; }
  .actions-cell { flex-direction: column; }
  .ticket-head { flex-direction: column; align-items: stretch; }
  .ticket-head .badge { align-self: flex-start; }
  .prio { min-width: calc(50% - 8px); }
}
@media print {
  .nav, .no-print, .report-head form, .report-head .btn { display: none !important; }
  body { background: #fff; }
  .card, .stat { box-shadow: none; }
}
