:root {
  /* Palette matched to the LDC logo (navy + Google-map accents) */
  --brand: #123c63;        /* deep navy from logo outline & text */
  --brand-2: #1c6fb8;      /* Google-map blue */
  --brand-soft: #dcebf7;   /* light navy/blue tint */
  --bg: #f2f5f9;
  --card: #ffffff;
  --text: #17273a;
  --muted: #6b7686;
  --border: #dde3ec;
  --ok: #34a853;           /* Google-map green */
  --danger: #ea4335;       /* Google-map red */
  --danger-soft: #fdecea;
  --accent-yellow: #fbbc04;/* Google-map yellow */
  --shadow: 0 6px 24px rgba(18, 60, 99, 0.10);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, "Cairo", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.topbar {
  position: relative;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  padding: 18px 24px;
  box-shadow: var(--shadow);
}
/* Google-map colored accent strip that echoes the logo */
.topbar::after {
  content: "";
  position: absolute; inset-inline: 0; bottom: 0; height: 4px;
  background: linear-gradient(90deg,
    #4285f4 0 25%, #ea4335 25% 50%, #fbbc04 50% 75%, #34a853 75% 100%);
}
.topbar .wrap { max-width: 1400px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar .brand { display: flex; align-items: center; gap: 14px; }
.brand-logo {
  height: 58px; width: auto; display: block; flex: none;
  background: #fff; border-radius: 12px; padding: 5px 9px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .18);
}
.topbar h1 { margin: 0; font-size: 22px; font-weight: 800; }
.topbar p { margin: 4px 0 0; opacity: 0.9; font-size: 14px; }
.topbar a { color: #fff; text-decoration: none; font-size: 14px; opacity: 0.9; }
.topbar a:hover { opacity: 1; text-decoration: underline; }
@media (max-width: 520px) {
  .brand-logo { height: 46px; }
  .topbar h1 { font-size: 18px; }
}

.container { max-width: 1400px; margin: 26px auto; padding: 0 24px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 22px;
}
.card > h2 {
  margin: 0 0 4px;
  font-size: 18px;
  color: var(--brand);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card .sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px 18px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; }
.field .en { color: var(--muted); font-weight: 400; font-size: 11px; }
.field .req { color: var(--danger); }
.field input, .field select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(28, 111, 184, 0.15);
}
.field input.invalid { border-color: var(--danger); background: var(--danger-soft); }
.field.disabled { opacity: .55; }
.field.disabled label { color: var(--muted); }
.field input:disabled, .field select:disabled {
  background: #f0f0f0;
  color: var(--muted);
  cursor: not-allowed;
}
.field input[readonly] {
  background: #f4f6f8;
  color: #555;
  cursor: not-allowed;
}

.group-title {
  grid-column: 1 / -1;
  font-size: 12px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: .3px;
  margin-top: 6px;
  padding-bottom: 4px;
  border-bottom: 2px dashed var(--brand-soft);
}

.switch { display: flex; align-items: center; gap: 8px; }
.switch input { width: 18px; height: 18px; accent-color: var(--brand); }

.vehicle {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  background: #fcfcfd;
  position: relative;
}
.vehicle .vhead {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.vehicle .vhead h3 { margin: 0; font-size: 15px; color: var(--brand); }

.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform .05s, filter .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--brand); border: 1px solid var(--brand-soft); }
.btn-ghost:hover { background: var(--brand-soft); }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #f4c3bf; padding: 6px 12px; font-size: 13px; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 7px 14px; font-size: 13px; }

.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

.banner { padding: 12px 16px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; display: none; }
.banner.show { display: block; }
.banner.err { background: var(--danger-soft); border: 1px solid #f4c3bf; color: var(--danger); }
.banner.ok { background: #e9f7ef; border: 1px solid #bde6cd; color: var(--ok); }
.banner ul { margin: 6px 0 0; padding-inline-start: 20px; }

#tableWrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 12px; text-align: start; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--brand); color: #fff; font-weight: 700; white-space: nowrap; }
tr:hover td { background: #fafafa; }
.row-actions { display: flex; gap: 8px; flex-wrap: nowrap; align-items: center; }
.row-actions .btn { white-space: nowrap; }
.badge { background: var(--brand-soft); color: var(--brand); padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }

.empty { text-align: center; color: var(--muted); padding: 40px; }

/* commercial-record upload + attachments */
.upload-box {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  border: 2px dashed var(--brand-soft); background: #f5faff; border-radius: 12px;
  padding: 16px 18px; margin-bottom: 14px;
}
.upload-box .upload-info { display: flex; flex-direction: column; gap: 4px; }
.upload-box .upload-info strong { color: var(--brand); font-size: 15px; }
.attach-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.attach-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; background: #fff;
}
.attach-name { font-size: 14px; font-weight: 600; }
.attach-acts { display: flex; gap: 8px; align-items: center; }
.attach-acts a.btn { text-decoration: none; }
.field input.autofilled, .field select.autofilled {
  border-color: var(--ok); background: #f2fbf6;
  box-shadow: 0 0 0 3px rgba(26,127,75,.12);
}

/* collapsed company summary */
.summary-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px 18px; margin-top: 6px;
}
.summary-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fcfcfd;
}
.summary-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.summary-value { font-size: 14px; font-weight: 700; color: var(--text); word-break: break-word; }

/* per-vehicle documents (inside vehicle modal) */
.veh-docs-wrap { padding: 0 22px 6px; }
.veh-doc {
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
  margin-bottom: 12px; background: #fcfcfd;
}
.veh-doc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.veh-doc-head strong { color: var(--brand); font-size: 14px; }
.veh-doc-empty { color: var(--muted); }
.veh-doc-note {
  background: #f5faff; border: 1px dashed var(--brand-soft); color: var(--muted);
  border-radius: 10px; padding: 12px 14px; font-size: 13px;
}

/* admin: per-vehicle attachment row */
.veh-row-item { border-bottom: 1px dashed var(--border); padding: 4px 0 8px; }
.veh-item-atts { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 2px 26px; }
.veh-item-atts.empty-sub { color: var(--muted); font-size: 12px; }

/* expandable client rows + vehicle checklist */
.expand-btn {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: var(--brand); cursor: pointer; font-size: 13px; line-height: 1;
  transition: transform .15s, background .15s;
}
.expand-btn:hover:not(:disabled) { background: var(--brand-soft); }
.expand-btn.open { transform: rotate(180deg); background: var(--brand-soft); }
.expand-btn:disabled { opacity: .35; cursor: not-allowed; }
.detail-row td { background: #fafbfc; padding: 0; }
.detail-row tr:hover td { background: #fafbfc; }
.veh-panel { padding: 16px 18px; }
.veh-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; flex-wrap: wrap; }
.veh-count { font-size: 13px; color: var(--muted); font-weight: 600; }
.veh-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 8px; margin-bottom: 16px;
}
.veh-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
  font-size: 13px; cursor: pointer;
}
.veh-item:hover { border-color: var(--brand-soft); }
.veh-item input { width: 17px; height: 17px; accent-color: var(--brand); flex: none; cursor: pointer; }
.veh-all { background: var(--brand-soft); border-color: var(--brand-soft); font-weight: 700; color: var(--brand); }
.veh-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.veh-attach { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px dashed var(--border); }
.veh-attach strong { font-size: 13px; color: var(--brand); }
.veh-attach a.btn { text-decoration: none; }
.login-box { max-width: 380px; margin: 60px auto; }
.plate-ref { font-size: 12px; color: var(--muted); }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }
.spinner { display:inline-block; width:14px; height:14px; border:2px solid #fff; border-top-color:transparent; border-radius:50%; animation:spin .7s linear infinite; vertical-align:-2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* tabs */
.tabs { display: flex; gap: 8px; margin-bottom: 18px; border-bottom: 2px solid var(--border); }
.tab {
  background: none; border: none; padding: 10px 16px; font-size: 15px; font-weight: 700;
  font-family: inherit; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

/* vehicle cards in dashboard */
.vcard {
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; background: #fcfcfd;
}
.vcard .vinfo { display: flex; flex-direction: column; gap: 2px; }
.vcard .vplate { font-weight: 800; font-size: 15px; color: var(--text); }
.vcard .vmeta { font-size: 13px; color: var(--muted); }
.vcard .vacts { display: flex; gap: 8px; }

/* modal */
.modal { display: none; position: fixed; inset: 0; background: rgba(17,24,39,.55); z-index: 50; padding: 24px; overflow-y: auto; }
.modal.open { display: flex; align-items: flex-start; justify-content: center; }
.modal-card { background: #fff; border-radius: var(--radius); width: min(1120px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.3); margin: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; color: var(--brand); }
.modal-close { background: none; border: none; font-size: 28px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal .grid { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 12px; padding: 16px 22px; border-top: 1px solid var(--border); }
.modal #modalBanner, .modal #pwBanner { margin: 16px 22px 0; }

/* user avatar + dropdown menu */
.usermenu { position: relative; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; cursor: pointer;
  border: 2px solid rgba(255,255,255,.6); background: rgba(255,255,255,.18);
  color: #fff; font-size: 18px; font-weight: 800; font-family: inherit;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .05s; text-transform: uppercase;
}
.avatar:hover { background: rgba(255,255,255,.3); }
.avatar:active { transform: scale(.96); }
.menu {
  position: absolute; top: 52px; left: 0; right: auto; min-width: 240px;
  background: #fff; color: var(--text); border-radius: 12px;
  box-shadow: 0 12px 34px rgba(0,0,0,.22); border: 1px solid var(--border);
  padding: 8px; z-index: 40; opacity: 0; visibility: hidden;
  transform: translateY(-6px); transition: opacity .15s, transform .15s, visibility .15s;
}
.menu.open { opacity: 1; visibility: visible; transform: translateY(0); }
.menu-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px;
  text-transform: uppercase; flex: none;
}
.menu-id { display: flex; flex-direction: column; overflow: hidden; }
.menu-label { font-size: 11px; color: var(--muted); }
.menu-email { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: start;
  background: none; border: none; padding: 11px 12px; border-radius: 8px;
  font-family: inherit; font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer;
}
.menu-item:hover { background: #f4f5f7; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.mi-icon { font-size: 16px; width: 20px; text-align: center; }

/* Saudi license plate widget */
.plate-field { grid-column: 1 / -1; align-items: flex-start; }
.ksa-plate {
  display: inline-flex; align-items: stretch; background: #fff;
  border: 3px solid #1a1a1a; border-radius: 10px; overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.15); font-family: Arial, sans-serif; max-width: 100%;
}
.ksa-strip {
  background: #006c35; color: #fff; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; padding: 6px 10px; min-width: 58px;
}
.ksa-strip .ksa-en { font-weight: 800; font-size: 15px; letter-spacing: 1px; }
.ksa-strip .ksa-ar { font-size: 11px; font-family: "Cairo", sans-serif; }
.plate-main { display: flex; align-items: stretch; flex: 1; }
.plate-group { display: flex; gap: 8px; padding: 10px 12px; align-items: flex-start; }
.plate-divider { width: 2px; background: #d0d0d0; margin: 8px 0; }
.plate-group .cell { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.plt-digit, .plt-letter {
  border: 1px solid #cbd0d8; border-radius: 8px; text-align: center; background: #fff;
  font-weight: 800; color: #111; font-family: Arial, sans-serif;
}
.plt-digit { width: 42px; height: 46px; font-size: 26px; padding: 0; }
.plt-letter { width: 56px; height: 46px; font-size: 22px; padding: 0 4px; }
.plt-digit:focus, .plt-letter:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(28,111,184,.15); }
.plate-group .cell .sub { font-size: 15px; font-weight: 800; color: #333; min-height: 18px; letter-spacing: .5px; }
.plate-hint { color: var(--muted); font-size: 12px; margin-top: 8px; }
@media (max-width: 520px) {
  .plt-digit { width: 34px; height: 40px; font-size: 21px; }
  .plt-letter { width: 46px; height: 40px; font-size: 18px; }
  .plate-group { gap: 5px; padding: 8px; }
}
