:root {
  --purple: #6255d9;
  --purple-dark: #4b3fbd;
  --navy: #17152f;
  --bg: #f4f6fa;
  --text: #202338;
  --muted: #717b91;
  --line: #e7e9f0;
}

body {
  font-family: "DM Sans", "Segoe UI", sans-serif;
  letter-spacing: -.01em;
}

h1, h2, h3, .logo strong, .stats strong {
  font-family: "Manrope", "Segoe UI", sans-serif;
}

aside {
  background:
    radial-gradient(circle at 0 0, rgba(119, 100, 231, .22), transparent 30%),
    linear-gradient(180deg, #211e46 0%, #181630 100%);
  box-shadow: 12px 0 36px rgba(21, 18, 56, .08);
}

.logo {
  padding-top: 3px;
}

.logo > span {
  box-shadow: 0 9px 22px rgba(98, 85, 217, .38);
}

.logo strong {
  letter-spacing: .015em;
}

.nav-label {
  margin: 3px 13px 10px;
  color: #8882ae;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .17em;
}

nav button {
  min-height: 44px;
  font-weight: 600;
  transition: background .18s, color .18s, transform .18s;
}

nav button:hover {
  transform: translateX(2px);
}

nav button.active {
  background: linear-gradient(90deg, rgba(111, 96, 223, .3), rgba(111, 96, 223, .08));
  box-shadow: inset 3px 0 #9184f0;
}

nav i {
  color: #a9a1e7;
  font-size: 17px;
}

header {
  height: 76px;
  padding-inline: 32px;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(12px);
}

.global-search {
  height: 43px;
  border: 1px solid transparent;
  background: #f3f5f9;
  transition: .2s;
}

.global-search:focus-within {
  border-color: #cfc9f5;
  background: #fff;
  box-shadow: 0 5px 18px rgba(75, 63, 189, .08);
}

.header-date {
  display: grid;
  min-width: 108px;
  padding-right: 16px;
  border-right: 1px solid var(--line);
  text-align: right;
}

.connection-state {
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 10px;
  font-weight: 700;
}

.connection-state i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.connection-state.is-online {
  background: #e8f8f1;
  color: #117d61;
}

.connection-state.is-online i {
  background: #20a87e;
  box-shadow: 0 0 0 3px #20a87e22;
}

.connection-state.is-offline {
  background: #fff0e0;
  color: #a96012;
}

.connection-state.is-offline i {
  background: #e5902d;
}

.offline-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 32px;
  background: #fff5e8;
  color: #82521d;
  border-bottom: 1px solid #f2dfc6;
  font-size: 12px;
}

.offline-banner span {
  color: #9a6d3a;
}

body.offline button:disabled,
body.offline input:disabled,
body.offline select:disabled {
  cursor: not-allowed !important;
  opacity: .5;
}

.header-date small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .12em;
}

.header-date strong {
  font-size: 12px;
}

.header-icon, .mobile-user {
  transition: transform .18s, box-shadow .18s;
}

.header-icon:hover, .mobile-user:hover {
  transform: translateY(-1px);
  box-shadow: 0 7px 17px rgba(39, 34, 82, .12);
}

.content {
  padding: 34px;
}

.page-title {
  margin-bottom: 28px;
}

.page-title h1 {
  font-size: 30px;
  letter-spacing: -.035em;
}

.page-title .primary {
  box-shadow: 0 8px 22px rgba(98, 85, 217, .22);
}

.primary {
  min-height: 42px;
  padding-inline: 18px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6b5de0, #5144c0);
  transition: transform .18s, box-shadow .18s;
}

.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 9px 24px rgba(75, 63, 189, .24);
}

.stats {
  gap: 18px;
}

.stats button {
  min-height: 145px;
  overflow: hidden;
  border: 0;
  border-radius: 18px;
  box-shadow: 0 7px 26px rgba(32, 35, 56, .06);
  transition: transform .2s, box-shadow .2s;
}

.stats button::after {
  content: "";
  position: absolute;
  right: -40px;
  bottom: -52px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: currentColor;
  opacity: .035;
}

.stats button:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 35px rgba(32, 35, 56, .1);
}

.stats button > span {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  border-radius: 13px;
  font-size: 20px;
}

.stat-employees > span { color: #6255d9; background: #eeebff; }
.stat-valid > span { color: #159373; background: #e6f7f1; }
.stat-expired > span { color: #d54759; background: #ffebee; }
.stat-warning > span { color: #bd751b; background: #fff3df; }

.stats small {
  font-size: 12px;
  font-weight: 600;
}

.stats strong {
  line-height: 1;
}

.stats em {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.panel {
  border: 0;
  border-radius: 18px;
  box-shadow: 0 7px 27px rgba(32, 35, 56, .055);
}

.panel-head h2 {
  font-size: 16px;
  letter-spacing: -.02em;
}

.panel-head > button {
  border: 0;
  background: transparent;
  color: var(--purple);
  font-weight: 700;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, .75fr);
  gap: 18px;
  margin-bottom: 18px;
}

.priority-panel {
  min-width: 0;
}

.compliance-panel {
  display: flex;
  flex-direction: column;
}

.compliance-ring {
  display: grid;
  place-items: center;
  width: 154px;
  height: 154px;
  margin: 13px auto 22px;
  border-radius: 50%;
  background: conic-gradient(#6255d9 calc(var(--value) * 1%), #ececf4 0);
  position: relative;
}

.compliance-ring::after {
  content: "";
  position: absolute;
  inset: 13px;
  border-radius: 50%;
  background: #fff;
}

.compliance-ring > div {
  position: relative;
  z-index: 1;
  display: grid;
  text-align: center;
}

.compliance-ring strong {
  font: 800 30px "Manrope", sans-serif;
}

.compliance-ring small {
  color: var(--muted);
}

.compliance-legend {
  display: grid;
  gap: 10px;
}

.compliance-legend span {
  display: grid;
  grid-template-columns: 9px 1fr auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.compliance-legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.valid-dot { background: var(--green); }
.warning-dot { background: var(--amber); }
.expired-dot { background: var(--red); }

.team-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.team-cards > button {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 14px;
  background: #fff;
  text-align: left;
  transition: .18s;
}

.team-cards > button:hover {
  border-color: #d3cef5;
  background: #faf9ff;
  transform: translateY(-1px);
}

.team-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-weight: 800;
}

.team-0 { color: #5547c3; background: #eeebff; }
.team-1 { color: #137d65; background: #e6f7f1; }
.team-2 { color: #b06c19; background: #fff3df; }
.team-3 { color: #bd4052; background: #ffebee; }

.team-cards > button > div:nth-child(2) {
  display: grid;
}

.team-cards small {
  color: var(--muted);
}

.team-rate {
  display: grid;
  gap: 4px;
  min-width: 55px;
  text-align: right;
}

.team-rate > span {
  width: 55px;
  height: 4px;
  overflow: hidden;
  border-radius: 99px;
  background: #ececf3;
}

.team-rate i {
  display: block;
  height: 100%;
  background: var(--purple);
}

.table-panel {
  box-shadow: 0 8px 30px rgba(32, 35, 56, .06);
}

.permit-tools {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 260px 100px;
  align-items: end;
  gap: 14px;
  margin-bottom: 14px;
  padding: 16px 18px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 7px 27px rgba(32, 35, 56, .055);
}

.employee-permit-manager {
  margin-bottom: 18px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 10px 35px rgba(32, 35, 56, .07);
}

.manager-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.manager-head h2, .manager-head p { margin: 0; }
.manager-head label { width: min(430px, 100%); margin: 0; }

.selected-employee {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 20px;
  background: #f7f6ff;
}

.selected-employee > span {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  border-radius: 13px;
  background: var(--purple);
  color: #fff;
  font-weight: 800;
}

.selected-employee > div { display: grid; }
.selected-employee small { color: var(--muted); }
.selected-employee > b { margin-left: auto; color: var(--purple); }

.permit-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 12px;
  padding: 18px;
}

.permit-card {
  position: relative;
  min-height: 210px;
  padding: 16px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--green);
  border-radius: 14px;
  background: #fff;
}

.permit-card.warning { border-top-color: var(--amber); }
.permit-card.expired { border-top-color: var(--red); }
.permit-card.missing { border-top-color: #a7adba; background: #fafbfc; }
.permit-card h3 { min-height: 42px; margin: 5px 0 10px; font-size: 16px; }
.permit-card > div > small, .role-lock { color: var(--muted); font-size: 10px; font-weight: 700; }
.permit-card p { color: var(--muted); }
.permit-card dl { display: flex; gap: 25px; margin: 14px 0; }
.permit-card dt { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.permit-card dd { margin: 3px 0 0; font-weight: 800; }
.permit-card > button, .permit-card > .role-lock { position: absolute; right: 16px; bottom: 16px; left: 16px; }
.permit-card > button { width: calc(100% - 32px); color: var(--purple); font-weight: 800; }
.status.missing { background: #eceef2; color: #666d7b; }

.renew-summary {
  display: grid;
  gap: 3px;
  margin-bottom: 12px;
  padding: 13px;
  border-radius: 11px;
  background: #f5f3ff;
}

.renew-summary strong { color: var(--purple); font-size: 17px; }
.renew-summary span { color: var(--muted); }

.permit-tools label {
  margin: 0;
}

.permit-tools label > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.permit-result {
  display: grid;
  place-content: center;
  height: 43px;
  border-left: 1px solid var(--line);
  text-align: center;
}

.permit-result strong {
  font: 800 21px "Manrope", sans-serif;
  line-height: 1;
}

.permit-result span {
  color: var(--muted);
  font-size: 10px;
}

.chips button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  background: #fff;
  color: var(--text);
}

.chips button.active {
  border-color: var(--purple);
  background: var(--purple);
  color: #fff;
}

.chips button b {
  color: inherit;
  opacity: .8;
}

.matricule {
  display: inline-block;
  border-radius: 6px;
  padding: 4px 7px;
  background: #eeebff;
  color: #5547c3;
  font-size: 11px;
  letter-spacing: .04em;
}

.form-section-title {
  margin: 23px 0 5px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  color: var(--purple);
  font-size: 13px;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.form-section-title:first-of-type {
  margin-top: 8px;
}

.full-field {
  grid-column: 1 / -1;
}

.checkbox-label {
  align-content: end;
  grid-template-columns: 18px 1fr;
  align-items: center;
  min-height: 67px;
}

.checkbox-label input[type="checkbox"] {
  width: 17px;
}

.employee-profile-head {
  display: flex;
  align-items: center;
  gap: 17px;
  padding: 5px 0 21px;
  border-bottom: 1px solid var(--line);
}

.employee-profile-head .detail-avatar {
  overflow: hidden;
}

.detail-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.employee-profile-head > div:nth-child(2) {
  flex: 1;
}

.employee-profile-head form {
  align-self: flex-start;
}

.photo-upload {
  display: inline-flex;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 11px;
  color: var(--purple);
  font-size: 11px;
  cursor: pointer;
}

.photo-upload input {
  display: none;
}

.employee-profile-head h2 {
  margin: 0 0 7px;
}

.employee-detail section {
  margin-top: 22px;
}

.employee-detail section h3 {
  display: flex;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 13px;
}

.detail-grid > div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 11px;
  border-radius: 10px;
  background: #f7f8fb;
}

.detail-grid small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.detail-grid strong {
  overflow-wrap: anywhere;
  font-size: 12px;
}

.permit-detail > div {
  display: grid;
}

.permit-detail small {
  color: var(--muted);
}

.settings-stack {
  display: grid;
  gap: 18px;
}

.logo-form {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
  gap: 20px;
}

.logo-form h2 {
  margin-bottom: 3px;
}

.logo-form p {
  margin-top: 0;
  color: var(--muted);
  font-size: 12px;
}

.logo-preview {
  display: grid;
  place-items: center;
  width: 120px;
  height: 100px;
  overflow: hidden;
  border: 1px dashed #c9c5e8;
  border-radius: 13px;
  background: #faf9ff;
  color: var(--purple);
  font-weight: 800;
}

.logo-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.notify-actions {
  display: flex !important;
  gap: 6px;
}

.notify-actions button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 9px;
  background: #fff;
}

.notify-actions .whatsapp-button {
  border-color: #bce9d1;
  background: #eaf9f1;
  color: #087e4b;
  font-weight: 700;
}

.phone-input {
  min-width: 145px;
  padding-block: 7px;
}

.table-check {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: #087e4b;
  font-size: 12px;
}

.table-check input {
  width: 16px;
}

.whatsapp-settings {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 15px;
  align-items: start;
}

.whatsapp-brand {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 15px;
  background: #dcf8e8;
  color: #087e4b;
  font-size: 25px;
  font-weight: 800;
}

.whatsapp-settings h2 {
  margin: 2px 0 4px;
}

.whatsapp-settings p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

th {
  padding-block: 13px;
  background: #f8f9fb;
  letter-spacing: .08em;
}

td {
  height: 65px;
}

tbody tr {
  transition: background .15s;
}

tbody tr:hover {
  background: #fafaff;
}

.status {
  border: 1px solid currentColor;
  border-color: color-mix(in srgb, currentColor 18%, transparent);
}

.header-popover {
  border: 0;
  box-shadow: 0 22px 65px rgba(24, 21, 58, .17);
}

.modal {
  border: 1px solid rgba(255,255,255,.8);
  box-shadow: 0 28px 90px rgba(21, 18, 56, .22);
}

.modal-backdrop {
  backdrop-filter: blur(5px);
}

.install-app {
  box-shadow: 0 12px 32px rgba(75, 63, 189, .28);
}

.read-only-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 13px;
  border: 1px solid #d9dce6;
  border-radius: 999px;
  background: #f7f8fb;
  color: #565c6d;
  font-size: 12px;
  font-weight: 700;
}

.dover-score {
  display: block;
  width: fit-content;
  margin-top: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #ece9ff;
  color: #5846c7;
  font-size: 11px;
  font-weight: 800;
}

.import-review h3 { margin: 22px 0 10px; }

.import-summary {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  gap: 8px 12px;
  align-items: center;
  padding: 16px;
  border-radius: 14px;
  background: #f6f5ff;
}

.import-summary strong {
  color: #5946d2;
  font-size: 24px;
}

.mapping-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.mapping-list span {
  padding: 6px 9px;
  border: 1px solid #dedfea;
  border-radius: 8px;
  background: #fff;
  color: #555b6d;
  font-size: 12px;
}

.preview-table {
  max-height: 310px;
  margin-top: 14px;
  border: 1px solid #e2e3eb;
  border-radius: 12px;
}

@media (max-width: 1150px) {
  .team-cards { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .header-date { display: none; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .compliance-panel { min-height: 310px; }
  .permit-tools { grid-template-columns: 1fr 1fr; }
  .permit-result { display: none; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .connection-state span { display: none; }
}

@media (max-width: 600px) {
  .content { padding: 18px 14px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats button { min-height: 126px; }
  .stats em { display: none; }
  .page-title h1 { font-size: 25px; }
  .permit-tools { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .logo-form { grid-template-columns: 1fr; }
  .offline-banner { align-items: flex-start; padding: 8px 14px; flex-direction: column; gap: 1px; }
  .manager-head { align-items: stretch; flex-direction: column; }
  .selected-employee { align-items: flex-start; flex-wrap: wrap; }
  .selected-employee > b { width: 100%; margin-left: 55px; }
}

@media print {
  body:before { content: "PERMITNOVA 360" !important; }
  .dashboard-grid { display: block; }
  .professional-only { display: none; }
}
