:root {
  color: #1c2834;
  background: #f4f7fb;
  font-family: "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body { margin: 0; }

body.in #login { display: none; }

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

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.card, dialog {
  width: min(440px, 100%);
  background: white;
  border: 0;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 16px 50px rgba(31, 78, 121, 0.16);
}

.card h1, dialog h2 { margin: 0 0 8px; }

.card p { color: #526273; }

label { display: grid; gap: 6px; margin: 14px 0; font-size: 14px; }

input, select, textarea {
  width: 100%;
  border: 1px solid #d5deea;
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
}

button, .tools a {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  background: #595959;
  color: white;
  text-decoration: none;
  cursor: pointer;
}

button.primary, .card button, .tools a { background: #2e75b6; }
button.danger { background: #a63e3e; }
.error { color: #a63e3e; min-height: 1.2em; }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: #1f4e79;
  color: white;
}

header strong { font-size: 22px; }
#who { margin-left: 12px; opacity: 0.85; }
.view-tabs { display: inline-flex; gap: 6px; margin-left: 16px; vertical-align: middle; }
.view-tabs button { background: transparent; border: 1px solid rgba(255,255,255,.45); padding: 6px 12px; }
.view-tabs button.on { background: white; color: #1f4e79; }
.header-actions { display: flex; align-items: center; gap: 12px; }
#live { font-size: 13px; }
#logout { background: transparent; border: 1px solid rgba(255,255,255,.45); }

.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  background: white;
  border-bottom: 1px solid #e4ebf3;
}

.search { display: flex; align-items: center; gap: 8px; margin: 0 0 0 auto; }
.search input { width: 220px; }

.workspace {
  display: grid;
  grid-template-columns: 1fr 340px;
  min-height: calc(100vh - 148px);
}

#farm {
  display: grid;
  grid-template-columns: minmax(340px, 420px) 1fr;
  min-height: calc(100vh - 148px);
}
#farm .stack { display: grid; gap: 4px; }
#farm td:first-child { width: 46%; }
#farm td:last-child { width: 54%; }
#farm input.cell, #farm select.cell { font-size: 13px; padding: 4px 6px; }
.farm-list { overflow: auto; max-height: calc(100vh - 148px); background: white; border-right: 1px solid #e4ebf3; }
.farm-map { display: flex; flex-direction: column; min-width: 0; background: #d9e2ec; }
.farm-search { display: flex; gap: 8px; padding: 8px; background: white; border-bottom: 1px solid #e4ebf3; }
.farm-search input { flex: 1; width: auto; }
.map-places { max-height: 230px; overflow: auto; background: white; }
.map-places:empty { display: none; }
.map-place { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid #e8eef5; }
.map-place div { min-width: 0; }
.map-place strong, .map-place span { display: block; }
.map-place span { color: #526273; font-size: 13px; }
.map-place button { flex: 0 0 auto; }
#map-frame { flex: 1; width: 100%; min-height: calc(100vh - 210px); border: 0; background: #d9e2ec; }
#farm td.status-cell { min-width: 0; }
#farm select.cell { font-size: 13px; }

.table-wrap { overflow: auto; background: white; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 6px 8px; text-align: left; border-bottom: 1px solid #e8eef5; vertical-align: middle; }
th { position: sticky; top: 0; background: #f7fafc; font-size: 13px; z-index: 1; }
td.readonly { color: #526273; white-space: nowrap; }
td.status-cell { min-width: 240px; }
td.narrow { width: 6.5rem; }
td.narrow input.cell { min-width: 4.5rem; }
.address-line { display: flex; gap: 8px; }
.address-line input.short { max-width: 7rem; }
input.cell, select.cell {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 6px 8px;
  border-radius: 6px;
}
input.cell:hover, select.cell:hover,
input.cell:focus, select.cell:focus {
  border-color: #9bb4cf;
  background: white;
  outline: none;
}
tr.selected td { box-shadow: inset 4px 0 0 #1f4e79; }
tr.status-offen td { background: #f3f6fa; }
tr.status-erreicht td { background: #e7f6ee; }
tr.status-nicht td { background: #fff6e0; }
tr.status-mailbox td { background: #fff8dc; }
tr.status-mail td { background: #e7f1fb; }
tr.status-rueckruf td { background: #fff0e0; }
tr.status-kommt td { background: #d8f5e4; }
tr.status-kein td { background: #fdecec; }
tr.status-falsch td { background: #eeeff1; }
tr.status-spaeter td { background: #f3eef9; }
#empty { padding: 24px; color: #526273; }

aside {
  padding: 16px;
  background: #f5f7fa;
  border-left: 1px solid #e4ebf3;
}

#detail { white-space: pre-wrap; line-height: 1.45; min-height: 240px; }

footer {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 8px 16px;
  background: white;
  border-top: 1px solid #e4ebf3;
}
#meta-line { color: #526273; font-size: 13px; }

dialog::backdrop { background: rgba(18, 32, 47, .45); }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; }

.cards { display: none; }

.customer-card {
  background: white;
  border: 1px solid #e4ebf3;
  border-radius: 14px;
  padding: 14px;
}

.customer-card.selected { border-color: #1f4e79; border-width: 2px; }
.customer-card.status-offen { background: #f3f6fa; }
.customer-card.status-erreicht { background: #e7f6ee; }
.customer-card.status-nicht { background: #fff6e0; }
.customer-card.status-mailbox { background: #fff8dc; }
.customer-card.status-mail { background: #e7f1fb; }
.customer-card.status-rueckruf { background: #fff0e0; }
.customer-card.status-kommt { background: #d8f5e4; }
.customer-card.status-kein { background: #fdecec; }
.customer-card.status-falsch { background: #eeeff1; }
.customer-card.status-spaeter { background: #f3eef9; }
.customer-card input.name { font-weight: 700; font-size: 18px; }
.customer-card p { margin: 4px 0; color: #526273; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.customer-card .dial { background: #2e75b6; color: white; border-radius: 8px; padding: 10px 14px; text-decoration: none; }
.edit-card, #edit-side { background: #595959; margin-top: 8px; }
#edit-side { width: 100%; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .search { margin-left: 0; width: 100%; }
  .search input { width: 100%; }
  .grid-form { grid-template-columns: 1fr; }
  .workspace table { display: none; }
  #farm { grid-template-columns: 1fr; }
  .farm-list { max-height: 42vh; }
  #map-frame { min-height: 55vh; }
  .cards { display: grid; gap: 10px; padding: 12px; }
  header { align-items: flex-start; }
  .tools { position: sticky; top: 0; z-index: 2; }
  dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
    overflow: auto;
  }
  .cell, dialog input, dialog select, dialog textarea { font-size: 16px; }
}
