:root{
  --blue:#0057a8;
  --blue2:#eaf4ff;
  --dark:#10233f;
  --muted:#697386;
  --border:#dce7f4;
  --green:#20a45a;
  --amber:#f5a623;
  --red:#d0021b
}

*{
  box-sizing:border-box
}

body{
  margin:0;
  font-family:Inter,Arial,sans-serif;
  background:#f6f9fd;
  color:var(--dark)
}

button,input,select,textarea{
  font:inherit
}

button{
  background:var(--blue);
  color:white;
  border:0;
  border-radius:10px;
  padding:10px 14px;
  cursor:pointer
}

.btn2{
  background:white;
  color:var(--blue);
  border:1px solid var(--border);

  /* Prevent buttons collapsing */
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:fit-content;
  white-space:nowrap;
  padding:10px 14px;
}

.login{
  min-height:100vh;
  display:grid;
  place-items:center;
  background:linear-gradient(135deg,var(--blue),#83bdf4)
}

.login-card{
  width:min(460px,92vw);
  background:white;
  border-radius:22px;
  padding:28px;
  box-shadow:0 20px 60px #0002
}

.logo{
  font-size:25px;
  font-weight:800;
  color:var(--blue);
  margin-bottom:6px
}

.field{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin:14px 0
}

.field input,
.field select,
.field textarea{
  border:1px solid var(--border);
  border-radius:10px;
  padding:12px;
  background:white
}

.demo{
  background:var(--blue2);
  padding:12px;
  border-radius:12px;
  font-size:14px
}

.shell{
  display:grid;
  grid-template-columns:260px 1fr;
  min-height:100vh
}

.side{
  background:white;
  border-right:1px solid var(--border);
  padding:20px;
  position:sticky;
  top:0;
  height:100vh
}

.side a{
  display:block;
  padding:12px;
  border-radius:12px;
  margin:4px 0;
  color:var(--dark);
  text-decoration:none
}

.side a.active,
.side a:hover{
  background:var(--blue2);
  color:var(--blue);
  font-weight:700
}

.main{
  padding:24px
}

.top{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:18px
}

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

.card{
  background:white;
  border:1px solid var(--border);
  border-radius:18px;
  padding:18px;
  box-shadow:0 8px 20px #0057a80a
}

.span3{grid-column:span 3}
.span4{grid-column:span 4}
.span6{grid-column:span 6}
.span8{grid-column:span 8}
.span12{grid-column:span 12}

.metric{
  font-size:32px;
  font-weight:800;
  color:var(--blue)
}

.muted{
  color:var(--muted)
}

.pill{
  display:inline-flex;
  gap:6px;
  align-items:center;
  border-radius:999px;
  padding:5px 10px;
  font-size:13px;
  background:var(--blue2);
  color:var(--blue);
  font-weight:700
}

.green{color:var(--green)}
.amber{color:var(--amber)}
.red{color:var(--red)}

table{
  width:100%;
  border-collapse:collapse
}

th,td{
  text-align:left;
  padding:12px;
  border-bottom:1px solid var(--border);
  vertical-align:top
}

th{
  font-size:13px;
  color:var(--muted);
  font-weight:700
}

.tabs{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-bottom:16px
}

.tab{
  background:white;
  color:var(--blue);
  border:1px solid var(--border)
}

.tab.active{
  background:var(--blue);
  color:white
}

.modal{
  position:fixed;
  inset:0;
  background:#0005;
  display:grid;
  place-items:center;
  padding:20px
}

.modal>div{
  background:white;
  border-radius:18px;
  padding:20px;
  width:min(620px,96vw);
  max-height:92vh;
  overflow:auto
}

.actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap
}

.photo{
  width:70px;
  height:70px;
  border-radius:10px;
  object-fit:cover;
  border:1px solid var(--border)
}

.metric-card{
  text-align:left;
  color:var(--dark);
  background:white;
  border:1px solid var(--border);
  box-shadow:0 8px 20px #0057a80a
}

.metric-card span{
  display:block;
  color:var(--muted);
  margin-top:5px
}

.metric-card:hover{
  outline:2px solid var(--blue2)
}

.tabs button{
  background:white;
  color:var(--blue);
  border:1px solid var(--border)
}

.tabs button.active{
  background:var(--blue);
  color:white
}

.public-page{
  max-width:760px;
  margin:30px auto;
  background:white;
  border:1px solid var(--border);
  border-radius:18px;
  padding:24px
}

.public-page h1{
  color:var(--blue)
}

/* Mobile app chrome (hamburger + slide-in nav). Hidden on desktop. */
.hamburger{
  display:none;
  background:white;
  color:var(--blue);
  border:1px solid var(--border);
  border-radius:10px;
  font-size:20px;
  line-height:1;
  padding:8px 12px;
}
.nav-overlay{display:none}

@media(max-width:850px){
  .shell{
    grid-template-columns:1fr
  }

  /* Sidebar becomes a slide-in drawer, opened by the hamburger button. */
  .side{
    position:fixed;
    left:0;
    top:0;
    height:100vh;
    width:82vw;
    max-width:300px;
    z-index:60;
    transform:translateX(-100%);
    transition:transform .25s ease;
    box-shadow:0 0 40px #0003;
    overflow:auto;
    border-right:1px solid var(--border);
  }
  body.nav-open .side{transform:translateX(0)}

  .nav-overlay{
    position:fixed;
    inset:0;
    background:#0006;
    z-index:55;
  }
  body.nav-open .nav-overlay{display:block}

  .hamburger{display:inline-flex}

  .grid{grid-template-columns:repeat(2,1fr)}
  .grid>*{min-width:0}
  .span3,
  .span4,
  .span6,
  .span8,
  .span12{
    grid-column:1 / -1
  }

  .top{
    align-items:flex-start;
    gap:10px;
    flex-direction:column
  }

  .main{
    padding:14px
  }

  /* Only WIDE grid tables (classed .m-grid by labelizeTables) restyle into
     stacked cards; simple label/value tables are left as-is. */
  table.m-grid thead{display:none}
  table.m-grid tr.m-head{display:none}
  table.m-grid, table.m-grid tbody, table.m-grid tr, table.m-grid td{display:block;width:100%}
  table.m-grid tr{
    border:1px solid var(--border);
    border-radius:14px;
    margin:0 0 12px;
    padding:6px 4px;
    background:white;
    box-shadow:0 4px 14px #0057a80a;
  }
  /* Label on top, value below — stacks cleanly and never overflows sideways,
     even when a cell holds two values (e.g. address + property type). */
  table.m-grid td{
    border:none;
    display:block;
    padding:8px 14px 10px;
    text-align:left;
    overflow-wrap:anywhere;
  }
  table.m-grid td::before{
    content:attr(data-label);
    display:block;
    font-weight:700;
    color:var(--muted);
    font-size:12px;
    margin-bottom:3px;
  }
  table.m-grid td:empty{display:none}
  table.m-grid td .actions{margin-top:6px;justify-content:flex-start;flex-wrap:wrap}
}

/* Native app (Capacitor): use the tidy phone-style layout at ANY width,
   so iPad gets the app layout instead of the wide desktop website. */
html.app-native .shell{grid-template-columns:1fr}
html.app-native .side{position:fixed;
    left:0;
    top:0;
    height:100vh;
    width:82vw;
    max-width:300px;
    z-index:60;
    transform:translateX(-100%);
    transition:transform .25s ease;
    box-shadow:0 0 40px #0003;
    overflow:auto;
    border-right:1px solid var(--border);}
html.app-native body.nav-open .side{transform:translateX(0)}
html.app-native .nav-overlay{position:fixed;
    inset:0;
    background:#0006;
    z-index:55;}
html.app-native body.nav-open .nav-overlay{display:block}
html.app-native .hamburger{display:inline-flex}
html.app-native .grid{grid-template-columns:repeat(2,1fr)}
html.app-native .grid>*{min-width:0}
html.app-native .span3, html.app-native .span4, html.app-native .span6, html.app-native .span8, html.app-native .span12{grid-column:1 / -1}
html.app-native .top{align-items:flex-start;
    gap:10px;
    flex-direction:column}
html.app-native .main{padding:14px}
html.app-native table.m-grid thead{display:none}
html.app-native table.m-grid tr.m-head{display:none}
html.app-native table.m-grid, html.app-native table.m-grid tbody, html.app-native table.m-grid tr, html.app-native table.m-grid td{display:block;width:100%}
html.app-native table.m-grid tr{border:1px solid var(--border);
    border-radius:14px;
    margin:0 0 12px;
    padding:6px 4px;
    background:white;
    box-shadow:0 4px 14px #0057a80a;}
html.app-native table.m-grid td{border:none;
    display:block;
    padding:8px 14px 10px;
    text-align:left;
    overflow-wrap:anywhere;}
html.app-native table.m-grid td::before{content:attr(data-label);
    display:block;
    font-weight:700;
    color:var(--muted);
    font-size:12px;
    margin-bottom:3px;}
html.app-native table.m-grid td:empty{display:none}
html.app-native table.m-grid td .actions{margin-top:6px;justify-content:flex-start;flex-wrap:wrap}



/* In-app document viewer (so opening a certificate never strands you with no
   way back — a persistent Back button is always shown). */
.docviewer{position:fixed;inset:0;background:#0b1b30;z-index:1000;display:flex;flex-direction:column}
.docviewer-bar{display:flex;align-items:center;gap:12px;padding:12px 14px;padding-top:calc(12px + env(safe-area-inset-top));background:#12355b;color:#fff}
.docviewer-back{background:#1f8f6a;color:#fff;border:none;border-radius:8px;padding:9px 14px;font-weight:700}
.docviewer-title{flex:1;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:15px}
.docviewer-dl{color:#fff;text-decoration:none;font-weight:700;border:1px solid rgba(255,255,255,.45);border-radius:8px;padding:8px 12px;font-size:14px}
.docviewer-frame{flex:1;border:none;width:100%;background:#fff}
.docviewer-note{color:#c7d3e2;font-size:13px;text-align:center;padding:8px}
