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

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1f23;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #0f4c5c;
  --brand-2: #e36414;
  --ok: #157f3b; --ok-bg: #e5f5ea;
  --warn: #9a5b00; --warn-bg: #fdf1dc;
  --err: #b42318; --err-bg: #fde8e7;
  --info: #1d4ed8; --info-bg: #e5edfd;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--brand); }
.shell { display: flex; min-height: 100vh; }
.side { width: 220px; background: var(--brand); color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 600; font-size: 20px; padding: 20px; }
.brand span { color: var(--brand-2); }
.brand.big { font-size: 28px; color: var(--brand); text-align: center; padding: 0 0 16px; }
.side nav { flex: 1; overflow-y: auto; }
.side nav a { display: flex; justify-content: space-between; align-items: center; color: #dfe9ec; text-decoration: none; padding: 10px 20px; }
.side nav a:hover { background: rgba(255,255,255,.08); }
.side nav a.on { background: rgba(255,255,255,.15); color: #fff; font-weight: 500; }
.count { background: var(--brand-2); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 8px; }
.me { padding: 16px 20px; font-size: 12px; color: #b9cdd2; border-top: 1px solid rgba(255,255,255,.1); }
.me a { color: #fff; }
.main { flex: 1; padding: 20px 28px; min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.top h1 { font-size: 22px; font-weight: 600; margin: 0; }
.menu-btn { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; font-size: 18px; padding: 4px 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 16px; overflow-x: auto; }
.card h2 { font-size: 16px; font-weight: 600; margin: 4px 0 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: right; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 500; color: var(--muted); font-size: 12px; white-space: nowrap; }
tr.dim td { opacity: .5; }
table.kv th { width: 180px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.stat b { font-size: 22px; font-weight: 600; }
.t-ok { color: var(--ok); } .t-warn { color: var(--warn); } .t-err { color: var(--err); } .t-info { color: var(--info); }
.muted { color: var(--muted); font-size: 12px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; white-space: nowrap; background: #eef0f2; color: #4b5563; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.info { background: var(--info-bg); color: var(--info); }
.punch { display: inline-block; margin: 2px; padding: 2px 8px; border-radius: 6px; font-size: 12px; text-decoration: none; border: 1px solid transparent; }
.punch.in { background: var(--ok-bg); color: var(--ok); }
.punch.out { background: #eef0f2; color: #374151; }
.punch.admin { border: 1px dashed currentColor; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
input, select, textarea { font: inherit; padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; color: var(--text); max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc3cc; border-color: var(--brand); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #374151; }
label small { color: var(--muted); font-size: 11px; }
label.check { flex-direction: row; align-items: center; gap: 8px; }
.filters label { flex-direction: row; align-items: center; gap: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid h2 { margin: 8px 0 0; border-top: 1px solid var(--line); padding-top: 14px; }
.form-grid h2:first-of-type { border-top: 0; padding-top: 0; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.inline-form label { flex-direction: row; align-items: center; gap: 6px; }
.btn { display: inline-block; font: inherit; font-size: 13px; padding: 7px 14px; border-radius: 8px; border: 1px solid #cfd4da; background: #fff; color: var(--text); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f3f4f6; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #0b3a46; }
.btn.danger { color: var(--err); border-color: #f1b8b3; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
td.actions { white-space: nowrap; }
td.actions form { display: inline; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.err { background: var(--err-bg); color: var(--err); }
.sched input[type=time] { width: 7.5rem; }
details summary { cursor: pointer; }
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.auth-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { font-size: 20px; margin: 0; }
.auth-card h2 { font-size: 14px; margin: 8px 0 0; color: var(--muted); }
@media (max-width: 860px) {
  .side { position: fixed; right: -240px; z-index: 10; transition: right .2s; }
  .side.open { right: 0; }
  .menu-btn { display: block; }
  .main { padding: 14px 16px; }
}

/* tabs inside a record */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 7px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--text); font-size: 13px; }
.tabs a:hover { border-color: var(--brand); }
.tabs .count { margin-inline-start: 4px; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }

/* documents */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px; }
.doc-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.doc-thumb { display: flex; align-items: center; justify-content: center; height: 130px; background: #f3f4f6; text-decoration: none; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-icon { font-weight: 600; font-size: 20px; color: var(--err); }
.doc-icon.muted { font-size: 12px; font-weight: 400; color: var(--muted); }
.doc-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.doc-edit { border-top: 1px solid var(--line); padding: 6px 12px 10px; }
.doc-edit summary { font-size: 12px; color: var(--brand); padding: 4px 0; }
.doc-edit form { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.doc-edit input[type=file] { font-size: 12px; }
.row-btns { display: flex; gap: 6px; }
.doc-upload { border: 1px dashed #c7cdd4; border-radius: 12px; padding: 16px; background: #fafbfc; display: flex; flex-direction: column; gap: 12px; }
.doc-upload h3 { margin: 0; font-size: 15px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip input { display: none; }
.chip span { display: inline-block; padding: 6px 12px; border-radius: 999px; border: 1px solid #d1d5db; background: #fff; cursor: pointer; font-size: 13px; }
.chip input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.drop { position: relative; display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 110px; border: 2px dashed #c7cdd4; border-radius: 12px; background: #fff; cursor: pointer; text-align: center; padding: 12px; }
.drop.over { border-color: var(--brand); background: #eef6f8; }
.drop.has-file { border-style: solid; border-color: var(--ok); }
.drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-text { color: var(--muted); font-size: 13px; }
.drop.has-file .drop-text { color: var(--ok); font-weight: 500; }
.drop-preview { max-height: 90px; border-radius: 8px; }
.upload-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; justify-content: space-between; }
.upload-row label { flex-direction: row; align-items: center; gap: 8px; }

.danger-zone { border-color: #f1b8b3; }
.danger-zone h2 { color: var(--err); }
