/* Timdod Li Plus. Shared styles. RTL, mobile-first, blue on white. */
:root {
  --blue: #1d4ed8; --blue-dark: #1e40af; --blue-light: #dbeafe; --blue-bg: #eff6ff;
  --ink: #0f172a; --muted: #64748b; --line: #e2e8f0; --bg: #f8fafc; --card: #ffffff;
  --green: #15803d; --green-bg: #dcfce7; --amber: #b45309; --amber-bg: #fef3c7;
  --red: #b91c1c; --red-bg: #fee2e2; --gray: #475569; --gray-bg: #f1f5f9;
  --radius: 12px; --shadow: 0 1px 3px rgba(15, 23, 42, .08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: 'Heebo', system-ui, sans-serif; font-size: 16px; line-height: 1.5;
  color: var(--ink); background: var(--bg); direction: rtl; min-height: 100vh;
}
a { color: var(--blue); }
h1 { font-size: 22px; margin: 0 0 12px; font-weight: 700; }
h2 { font-size: 18px; margin: 20px 0 10px; font-weight: 700; }
h3 { font-size: 16px; margin: 14px 0 6px; font-weight: 600; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.hidden { display: none !important; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }

/* Header */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--blue); color: #fff;
  padding: 0 16px; height: 56px; display: flex; align-items: center; justify-content: space-between;
}
.topbar .brand { font-weight: 700; font-size: 18px; color: #fff; text-decoration: none; }
.topbar .brand small { font-weight: 400; opacity: .85; margin-right: 6px; font-size: 13px; }
.topbar button, .topbar a.btn { background: rgba(255,255,255,.15); color: #fff; border: 0; }
.topbar .badge-dot { background: #f59e0b; color: #fff; border-radius: 999px; font-size: 12px; padding: 0 6px; margin-right: 4px; }

/* Layout */
.page { max-width: 720px; margin: 0 auto; padding: 16px 16px 90px; }
.page.wide { max-width: 1100px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.card.clickable { cursor: pointer; }
.card.clickable:active { background: var(--blue-bg); }
.card .title { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.card .meta { color: var(--muted); font-size: 14px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 10px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
@media (max-width: 480px) { .kv { grid-template-columns: 110px 1fr; } }

/* Badges */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
  white-space: nowrap;
}
.badge.blue { background: var(--blue-light); color: var(--blue-dark); }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.gray { background: var(--gray-bg); color: var(--gray); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 52px; padding: 0 18px; border-radius: var(--radius); border: 0;
  background: var(--blue); color: #fff; font: inherit; font-weight: 600; font-size: 16px;
  cursor: pointer; text-decoration: none; width: 100%;
}
.btn:hover { background: var(--blue-dark); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--blue-light); color: var(--blue-dark); }
.btn.ghost { background: transparent; color: var(--blue); border: 1px solid var(--line); }
.btn.danger { background: var(--red); }
.btn.success { background: var(--green); }
.btn.sm { min-height: 38px; font-size: 14px; padding: 0 12px; width: auto; }
.btn.auto { width: auto; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

/* Forms */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=date],
input[type=password], input[type=search], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; font: inherit; font-size: 16px; background: #fff; color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-light); border-color: var(--blue); }
input[type=file] { width: 100%; font: inherit; }
.req::after { content: ' *'; color: var(--red); }
.error { color: var(--red); font-size: 14px; margin: 6px 0; }
.ok { color: var(--green); font-size: 14px; margin: 6px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--gray-bg); border-radius: 999px; padding: 2px 10px; font-size: 13px; }
.chip.on { background: var(--blue-light); color: var(--blue-dark); }

/* Tables (admin) */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--gray-bg); font-weight: 600; color: var(--gray); position: sticky; top: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--blue-bg); }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; cursor: pointer; }
.stat .n { font-size: 28px; font-weight: 700; color: var(--blue); line-height: 1.1; }
.stat .l { font-size: 13px; color: var(--muted); }

/* Bottom nav (measurer / customer) */
.bottomnav {
  position: fixed; bottom: 0; right: 0; left: 0; z-index: 20; background: #fff;
  border-top: 1px solid var(--line); display: flex; height: 64px;
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600;
}
.bottomnav a.active { color: var(--blue); }
.bottomnav a .ico { font-size: 22px; line-height: 1; display: inline-flex; }
.ico svg { width: 22px; height: 22px; display: block; }
.btn .ico { display: inline-flex; margin-inline-end: 6px; vertical-align: middle; }
.btn .ico svg { width: 18px; height: 18px; }
.big-ico { color: #15803d; margin-bottom: 8px; }
.big-ico svg { width: 52px; height: 52px; }

/* Tabs / side nav (admin) */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; }
.tabs a { white-space: nowrap; padding: 8px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 600; }
.tabs a.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* Media grid */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.media-grid .m { position: relative; border-radius: 10px; overflow: hidden; background: var(--gray-bg); aspect-ratio: 1; display: flex; align-items: center; justify-content: center; }
.media-grid .m img, .media-grid .m video { width: 100%; height: 100%; object-fit: cover; }
.media-grid .m .del { position: absolute; top: 4px; left: 4px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 6px; padding: 2px 8px; cursor: pointer; }
.media-grid .m .measure { position: absolute; top: 4px; right: 4px; background: var(--blue); color: #fff; border: 0; border-radius: 6px; padding: 2px 8px; font-size: 12px; cursor: pointer; }
.media-grid .m .cap { position: absolute; bottom: 0; right: 0; left: 0; background: rgba(0,0,0,.5); color: #fff; font-size: 11px; padding: 2px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 6px 0 6px 0; border-right: 3px solid var(--blue-light); padding-right: 12px; margin-right: 6px; }
.timeline li .t { color: var(--muted); font-size: 12px; }

/* Toast + modal */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,.2); max-width: 90vw;
}
.toast.err { background: var(--red); }
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 600px) { .modal-bg { align-items: center; } }
.modal { background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 18px 16px; }
@media (min-width: 600px) { .modal { border-radius: 16px; } }
.spinner { text-align: center; padding: 30px; color: var(--muted); }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.login-box { max-width: 400px; margin: 40px auto; }
.logo { font-size: 30px; font-weight: 800; color: var(--blue); text-align: center; margin: 20px 0 4px; }
.logo small { display: block; font-size: 14px; font-weight: 400; color: var(--muted); }
.notice { background: var(--blue-bg); border: 1px solid var(--blue-light); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.notice.warn { background: var(--amber-bg); border-color: #fde68a; }
.price { font-size: 30px; font-weight: 800; color: var(--blue); }
.status-btns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.status-btns .btn { min-height: 64px; flex-direction: column; font-size: 15px; }
.status-btns .btn.done { background: var(--green-bg); color: var(--green); }
.status-btns .btn .sub { font-size: 11px; font-weight: 400; opacity: .8; }
.measure-row { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; background: #fff; }
.measure-row .grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.unread { background: var(--blue-bg); }
