:root{
  --bg:#f5f7fb;
  --card:#fff;
  --text:#1d2433;
  --muted:#6b7280;
  --brand:#1f4e78;
  --line:#d9dfe8;
  --ok:#e2f0d9;
  --warn:#fff2cc;
  --bad:#fce4d6;
  --gray:#eceff4;
  --sidebar:#13283f;
}

*{
  box-sizing:border-box;
}

html,body{
  margin:0;
  padding:0;
  max-width:100%;
  overflow-x:hidden;
}

body{
  font-family:Arial,Helvetica,sans-serif;
  background:var(--bg);
  color:var(--text);
}

a{
  text-decoration:none;
  color:inherit;
}

/* Sidebar */
.sidebar{
  position:fixed;
  left:0;
  top:0;
  bottom:0;
  width:240px;
  background:var(--sidebar);
  color:#fff;
  padding:20px;
  display:flex;
  flex-direction:column;
  z-index:1000;
}

.brand{
  font-size:22px;
  font-weight:700;
  margin-bottom:24px;
}

.sidebar nav{
  display:grid;
  gap:8px;
}

.sidebar nav a{
  padding:10px 12px;
  border-radius:10px;
  background:rgba(255,255,255,.06);
  transition:.2s ease;
}

.sidebar nav a:hover{
  background:rgba(255,255,255,.12);
}

.userbox{
  margin-top:auto;
  border-top:1px solid rgba(255,255,255,.12);
  padding-top:16px;
}

/* Mobile menu */
.mobile-menu-btn{
  display:none;
  position:fixed;
  top:14px;
  left:14px;
  z-index:1200;
  border:none;
  border-radius:12px;
  background:var(--sidebar);
  color:#fff;
  padding:10px 14px;
  font-size:20px;
  cursor:pointer;
  box-shadow:0 8px 22px rgba(0,0,0,.18);
}

.mobile-overlay{
  display:none;
}

.mobile-overlay.show{
  display:block;
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.35);
  z-index:999;
}

/* Layout */
main,
.main{
  padding:28px;
  min-height:calc(100vh - 120px);
}

.with-sidebar{
  margin-left:240px;
}

.page-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  margin-bottom:16px;
}

/* Cards */
.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:18px;
  padding:18px;
  box-shadow:0 4px 18px rgba(0,0,0,.04);
  margin-bottom:20px;
}

.cards{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:16px;
  margin-bottom:20px;
}

.stat .label{
  color:var(--muted);
  margin-bottom:8px;
}

.stat .value{
  font-size:32px;
  font-weight:700;
}

.stat.yellow{
  background:var(--warn);
}

.stat.red{
  background:var(--bad);
}

.stat.gray{
  background:var(--gray);
}

.two-col{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:20px;
}

.three-col{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:16px;
}

/* Forms */
.form-grid{
  display:grid;
  gap:14px;
}

.form-grid.one-col{
  grid-template-columns:1fr;
}

.form-grid.two-col{
  grid-template-columns:1fr 1fr;
}

.form-grid.three-col{
  grid-template-columns:repeat(3,minmax(0,1fr));
}

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

label{
  display:grid;
  gap:6px;
  font-weight:600;
}

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

input,
select,
textarea{
  width:100%;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:10px;
  background:#fff;
}

textarea{
  resize:vertical;
  min-height:90px;
}

.actions{
  display:flex;
  justify-content:flex-end;
  gap:8px;
  flex-wrap:wrap;
}

/* Buttons */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:10px 14px;
  border-radius:10px;
  background:var(--brand);
  color:#fff;
  border:none;
  cursor:pointer;
  white-space:nowrap;
}

.btn-secondary{
  background:#fff;
  color:var(--text);
  border:1px solid var(--line);
}

.btn-small{
  padding:8px 10px;
  font-size:13px;
}

/* Text / alerts */
.muted{
  color:var(--muted);
  font-size:14px;
}

.flash{
  padding:12px 14px;
  border-radius:12px;
  margin-bottom:16px;
}

.flash.success{
  background:var(--ok);
}

.flash.error{
  background:var(--bad);
}

/* Badges */
.badge{
  display:inline-block;
  padding:6px 10px;
  border-radius:999px;
  background:var(--gray);
  font-size:13px;
  white-space:nowrap;
}

.badge.ok{
  background:var(--ok);
}

.badge.bald-faellig,
.badge.bald,
.badge.heute-faellig{
  background:var(--warn);
}

.badge.red,
.badge.ueberfaellig,
.badge.überfällig{
  background:var(--bad);
}

/* Tables */
.card table,
.table-wrap{
  width:100%;
}

table{
  width:100%;
  border-collapse:collapse;
  min-width:720px;
}

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

/* Dynamic item rows */
.item-row{
  display:grid;
  grid-template-columns:2fr 1fr .8fr 2fr;
  gap:10px;
  margin-bottom:10px;
}

/* Tabs */
.obj-tabs{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.tab-panel table th{
  text-align:left;
}

/* Login */
.login-wrap{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:20px;
}

.login-card{
  width:min(420px,92vw);
}

/* Footer */
.site-footer{
  margin-top:40px;
  padding:20px 16px;
  text-align:center;
  color:#6c757d;
  font-size:15px;
  border-top:1px solid #e5e5e5;
  margin-left:240px;
}

/* Utility for cards containing wide tables */
.card{
  overflow-x:auto;
}

/* Tablet */
@media (max-width:1200px){
  .cards{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

  .two-col{
    grid-template-columns:1fr;
  }
}

/* Mobile / smaller tablet */
@media (max-width:900px){
  .mobile-menu-btn{
    display:inline-flex;
  }

  .sidebar{
    transform:translateX(-100%);
    transition:transform .25s ease;
    width:280px;
    max-width:85vw;
  }

  .sidebar.open{
    transform:translateX(0);
  }

  .with-sidebar{
    margin-left:0;
  }

  main,
  .main{
    padding:72px 16px 20px;
  }

  .site-footer{
    margin-left:0;
    padding:20px 16px 28px;
  }

  .cards,
  .two-col,
  .three-col,
  .form-grid.two-col,
  .form-grid.three-col,
  .item-row{
    grid-template-columns:1fr;
  }

  .page-head{
    align-items:flex-start;
  }

  .card{
    padding:16px;
    border-radius:16px;
  }

  table{
    min-width:680px;
  }
}

/* Phone */
@media (max-width:700px){
  .form-grid.two-col,
  .form-grid.three-col,
  .three-col{
    grid-template-columns:1fr;
  }

  .actions{
    flex-direction:column;
    justify-content:stretch;
  }

  .actions .btn,
  .actions .btn-secondary{
    width:100%;
  }

  .obj-tabs{
    display:grid;
    grid-template-columns:repeat(2,1fr);
  }

  .obj-tabs .btn{
    width:100%;
  }

  /* Mobile Tabellen als Karten */
  table{
    min-width:unset;
    width:100%;
  }

  thead{
    display:none;
  }

  table tr{
    display:block;
    margin-bottom:14px;
    border:1px solid var(--line);
    border-radius:14px;
    padding:12px;
    background:var(--card);
  }

  table td{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:10px;
    border:none;
    padding:6px 0;
    word-break:break-word;
  }

  table td::before{
    content:attr(data-label);
    font-weight:600;
    color:var(--muted);
    flex:0 0 42%;
  }

  td .btn,
  td form{
    width:100%;
  }

  td form{
    margin-top:6px;
  }

  .page-head .btn{
    width:100%;
  }
}

@media (max-width:600px){
  main,
  .main{
    padding:72px 12px 16px;
  }

  h1{
    font-size:32px;
    line-height:1.15;
  }

  h2{
    font-size:26px;
    line-height:1.2;
  }

  .cards{
    grid-template-columns:1fr;
  }

  .btn,
  .btn-secondary{
    width:100%;
  }

  input,
  select,
  textarea{
    padding:11px 12px;
  }

  .site-footer{
    font-size:14px;
  }

  th,
  td{
    padding:9px 8px;
  }
}

/* Datei-Upload / Vorschau */
.drop-zone {
  border: 2px dashed #9fb3c8;
  border-radius: 16px;
  background: #f8fbff;
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: 0.2s ease;
}

.drop-zone:hover,
.drop-zone.dragover {
  background: #eef5fc;
  border-color: #1f4e78;
}

.drop-zone-inner {
  pointer-events: none;
}

.file-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.upload-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.upload-preview-item {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.upload-preview-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.upload-preview-text {
  word-break: break-word;
}

@media (max-width: 700px) {
  .file-thumb {
    width: 56px;
    height: 56px;
  }

  .drop-zone {
    padding: 20px 14px;
  }
}
.global-back-wrap {
  margin-bottom: 16px;
  display: flex;
  justify-content: flex-start;
}

.global-back-btn {
  min-width: 110px;
}

/* Hausmeister mobile optimizations */
.mobile-page-head{
  margin-bottom:16px;
}

.property-detail-card{
  overflow:visible;
}

.property-tabs{
  margin-bottom:20px;
}

.section-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
  margin-bottom:16px;
}

.info-list{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:12px;
}

.info-item{
  border:1px solid var(--line);
  border-radius:14px;
  padding:14px;
  background:#fff;
}

.info-label{
  display:block;
  color:var(--muted);
  font-size:13px;
  margin-bottom:6px;
}

.info-value{
  display:block;
  font-weight:600;
  word-break:break-word;
}

.mobile-action-stack{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

.mobile-action-stack form{
  margin:0;
}

.property-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(260px,1fr));
  gap:16px;
}

.property-tile{
  transition:transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.property-tile:hover{
  transform:translateY(-2px);
  box-shadow:0 10px 24px rgba(0,0,0,.08);
  border-color:#b8c6d8;
}

.btn-danger{
  background:#b91c1c;
  color:#fff;
  border:none;
}

@media (max-width:900px){
  .section-head .btn,
  .section-head .btn-secondary{
    width:100%;
  }

  .info-list{
    grid-template-columns:1fr;
  }
}

@media (max-width:700px){
  .mobile-page-head{
    padding-top:4px;
  }

  .property-search-card input{
    max-width:none !important;
    font-size:16px !important;
  }

  .property-grid{
    grid-template-columns:1fr !important;
    gap:12px !important;
  }

  .property-tile{
    min-height:unset !important;
    padding:16px;
  }

  .obj-tabs{
    grid-template-columns:1fr;
    gap:10px;
  }

  .obj-tabs .btn,
  .tab-btn{
    width:100%;
    padding:12px 14px;
    font-size:15px;
  }

  .tab-panel h2{
    margin-top:0;
  }

  table tr{
    padding:14px;
    margin-bottom:12px;
  }

  table td{
    flex-direction:column;
    align-items:flex-start;
    gap:6px;
  }

  table td::before{
    flex:0 0 auto;
  }

  .mobile-action-stack{
    width:100%;
    flex-direction:column;
  }

  .mobile-action-stack .btn,
  .mobile-action-stack form,
  .mobile-action-stack form .btn,
  td .btn,
  td form,
  td select{
    width:100%;
  }

  .mobile-form-card,
  .tab-filter-card{
    padding:14px;
  }

  .section-head{
    align-items:stretch;
  }
}

@media (max-width:600px){
  .card{
    padding:14px;
  }

  .info-item{
    padding:12px;
  }

  h1{
    font-size:28px;
  }

  h2{
    font-size:22px;
  }
}
