/* Domstadt — Fraktionsplattform Köln
   Colors: Köln red #C7000B, Köln gold #FFCB00, off-white #FAF7F2, slate #1F2328 */

:root {
  --koeln-red:      #C7000B;
  --koeln-red-dark: #8B0008;
  --koeln-red-soft: #F4D4D6;
  --koeln-gold:     #FFCB00;
  --koeln-gold-dk:  #C79E00;
  --paper:          #FAF7F2;
  --paper-edge:     #EDE8DE;
  --ink:            #1F2328;
  --ink-soft:       #55606A;
  --hair:           #D9D2C4;
  --ok:             #2F7D32;
  --warn:           #B26A00;
  --danger:         #B0222B;
  --radius:         6px;
  --shadow:         0 1px 2px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
  --font:           -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif:     "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--koeln-red); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

/* --- Layout shell ------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "header header"
    "nav    main"
    "footer footer";
  min-height: 100vh;
}
.shell > header { grid-area: header; }
.shell > nav    { grid-area: nav; }
.shell > main   { grid-area: main; padding: 28px 36px; overflow: auto; }
.shell > footer { grid-area: footer; }

/* --- Header ------------------------------------------------------------- */

.top-bar {
  background: var(--koeln-red);
  color: #fff;
  border-bottom: 4px solid var(--koeln-gold);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  box-shadow: var(--shadow);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand .dom {
  width: 42px;
  height: 42px;
  color: #fff;
}
.brand-title {
  font-family: var(--font-serif);
  font-size: 22px;
  letter-spacing: 0.3px;
  line-height: 1;
}
.brand-sub {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  opacity: 0.85;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.user-chip .who { text-align: right; line-height: 1.15; }
.user-chip .who strong { display: block; font-weight: 600; }
.user-chip .who span  { opacity: 0.8; font-size: 11px; }
.user-chip button {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.6);
  padding: 5px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
}
.user-chip button:hover { background: rgba(255,255,255,0.12); }

/* --- Sidebar nav -------------------------------------------------------- */

.side-nav {
  background: #fff;
  border-right: 1px solid var(--hair);
  padding: 18px 0;
}
.side-nav ul { list-style: none; margin: 0; padding: 0; }
.side-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  padding: 10px 22px;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.side-nav a:hover { background: var(--paper-edge); text-decoration: none; }
.side-nav a.active {
  background: var(--koeln-red-soft);
  border-left-color: var(--koeln-red);
  color: var(--koeln-red-dark);
  font-weight: 600;
}
.side-nav .icon { width: 16px; text-align: center; opacity: 0.7; }
.side-nav a.active .icon { opacity: 1; }

.side-nav .section-label {
  padding: 14px 22px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--ink-soft);
}

/* --- Footer ------------------------------------------------------------- */

.foot {
  background: #fff;
  border-top: 1px solid var(--hair);
  padding: 10px 24px;
  font-size: 12px;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
}
.foot .gold-bar {
  height: 3px;
  background: var(--koeln-gold);
}

/* --- Login view --------------------------------------------------------- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--paper);
}
.login-hero {
  background: linear-gradient(180deg, var(--koeln-red) 0%, var(--koeln-red-dark) 100%);
  color: #fff;
  padding: 60px 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-hero::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 6px;
  background: var(--koeln-gold);
}
.login-hero .dom-big {
  width: 100%;
  max-width: 420px;
  color: rgba(255,255,255,0.95);
  align-self: center;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.25));
}
.login-hero h1 {
  font-family: var(--font-serif);
  font-size: 42px;
  margin: 0 0 8px;
  letter-spacing: 0.3px;
}
.login-hero .tag {
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0.9;
}
.login-hero .pitch {
  font-size: 15px;
  line-height: 1.55;
  max-width: 380px;
  opacity: 0.92;
}

.login-form {
  padding: 60px 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 100%;
  max-width: 360px;
}
.login-card h2 {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 26px;
}
.login-card .sub { color: var(--ink-soft); font-size: 13px; margin-bottom: 24px; }

/* --- Forms -------------------------------------------------------------- */

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 4px;
}
.field input, .field textarea, .field select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  font: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: 2px solid var(--koeln-gold);
  outline-offset: -1px;
  border-color: var(--koeln-gold-dk);
}
.field textarea { min-height: 160px; font-family: var(--font-serif); line-height: 1.55; }

/* --- Buttons ------------------------------------------------------------ */

.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.btn-primary {
  background: var(--koeln-red);
  color: #fff;
  border-color: var(--koeln-red);
}
.btn-primary:hover { background: var(--koeln-red-dark); }
.btn-primary:disabled { background: #C8A3A6; border-color: #C8A3A6; cursor: not-allowed; }
.btn-ghost {
  background: #fff;
  color: var(--ink);
  border-color: var(--hair);
}
.btn-ghost:hover { background: var(--paper-edge); }
.btn-gold {
  background: var(--koeln-gold);
  color: var(--ink);
  border-color: var(--koeln-gold-dk);
}
.btn-gold:hover { background: var(--koeln-gold-dk); }
.btn-danger {
  background: #fff;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- Page headers ------------------------------------------------------- */

.page-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--koeln-gold);
}
.page-title h1 {
  font-family: var(--font-serif);
  font-size: 28px;
  margin: 0;
}
.page-title .hint { color: var(--ink-soft); font-size: 13px; }

/* --- Dashboard cards ---------------------------------------------------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.card {
  background: #fff;
  border: 1px solid var(--hair);
  border-top: 3px solid var(--koeln-red);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.card h3 {
  margin: 0 0 4px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--ink-soft);
}
.card .big { font-size: 32px; font-weight: 700; font-family: var(--font-serif); }
.card.gold  { border-top-color: var(--koeln-gold-dk); }

/* --- Motion list (Gremium groups) --------------------------------------- */

.gremium-group { margin-bottom: 26px; }
.gremium-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--koeln-red-dark);
  background: var(--koeln-red-soft);
  padding: 6px 12px;
  border-left: 4px solid var(--koeln-red);
  border-radius: 2px;
  margin: 0 0 10px;
  font-weight: 700;
}
.motion-row {
  background: #fff;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 14px;
  align-items: center;
  cursor: pointer;
}
.motion-row:hover {
  border-color: var(--koeln-red);
  box-shadow: var(--shadow);
}
.motion-row .title { font-weight: 600; font-size: 15px; }
.motion-row .meta  { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }

/* Status badges */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}
.badge.DRAFT     { background: #F0ECE3; color: #625A47; }
.badge.FINAL     { background: var(--koeln-gold); color: #4A3A00; }
.badge.SUBMITTED { background: #E6F2FD; color: #1C4A7A; }
.badge.IN_REVIEW { background: #FFF3D6; color: #7A5A00; }
.badge.DEFERRED  { background: #EDEBFF; color: #473F8A; }
.badge.APPROVED  { background: #DEF3E0; color: #1F5C23; }
.badge.REJECTED  { background: #FBDADD; color: #8B1520; }
.badge.WITHDRAWN { background: #E8E8E8; color: #55606A; }

/* --- Motion detail ------------------------------------------------------ */

.motion-detail {
  background: #fff;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  padding: 28px 32px;
  box-shadow: var(--shadow);
  max-width: 900px;
}
.motion-detail h2 {
  font-family: var(--font-serif);
  margin: 0 0 4px;
  font-size: 26px;
}
.motion-detail .meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  color: var(--ink-soft);
  font-size: 13px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--hair);
}
.motion-detail .body-text {
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.action-bar {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--hair);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
form.motion-detail .action-bar {
  position: sticky;
  bottom: 0;
  background: #fff;
  padding-bottom: 16px;
  margin-bottom: -28px;
  z-index: 5;
}

/* --- Flash/toast -------------------------------------------------------- */

.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 14px;
}
.flash.err { background: #FBDADD; color: #8B1520; border: 1px solid #E4A5AC; }
.flash.ok  { background: #DEF3E0; color: #1F5C23; border: 1px solid #A5D4AA; }
.flash.info{ background: #E6F2FD; color: #1C4A7A; border: 1px solid #A5C9E4; }

/* --- Utility ------------------------------------------------------------ */

.muted   { color: var(--ink-soft); }
.center  { text-align: center; }
.spacer  { height: 18px; }
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(0,0,0,0.12);
  border-top-color: var(--koeln-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Responsive --------------------------------------------------------- */

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; grid-template-areas: "header" "nav" "main" "footer"; }
  .side-nav { border-right: none; border-bottom: 1px solid var(--hair); padding: 6px 0; }
  .side-nav ul { display: flex; overflow-x: auto; gap: 4px; padding: 0 10px; }
  .side-nav a { border-left: none; border-bottom: 3px solid transparent; padding: 10px 14px; }
  .side-nav a.active { border-left: none; border-bottom-color: var(--koeln-red); }
  .side-nav .section-label { display: none; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { padding: 36px; }
  .login-form { padding: 36px; }
}

/* --- Modal dialog ------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 25, 30, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--hair);
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close {
  background: transparent;
  border: 0;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-soft);
  padding: 0 4px;
}
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 16px 18px 18px; }
.modal-body .field { margin-bottom: 12px; }
.modal-body .action-bar { margin-top: 14px; display: flex; gap: 8px; justify-content: flex-end; }

/* --- Dashboard monthly calendar ----------------------------------------- */

.dash-calendar {
  margin-top: 28px;
  background: #fff;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px 18px;
}
.dash-calendar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.dash-calendar-head h2 { margin: 0; font-size: 18px; }
.dash-calendar-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}
.dash-calendar-label {
  display: inline-block;
  min-width: 180px;
  text-align: center;
  font-weight: 600;
}
.dash-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  background: var(--hair);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  overflow: hidden;
}
.dash-cal-wd {
  background: var(--paper-edge);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  padding: 6px 8px;
  text-align: center;
}
.dash-cal-day {
  background: #fff;
  min-height: 92px;
  padding: 4px 6px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  position: relative;
}
.dash-cal-day.muted-day { background: var(--paper); color: var(--ink-soft); }
.dash-cal-day.muted-day .dash-cal-num { color: var(--ink-soft); opacity: 0.55; }
.dash-cal-day.is-today {
  background: #FFF7DA;
  outline: 2px solid var(--koeln-gold);
  outline-offset: -2px;
}
.dash-cal-day.has-events:hover { background: #FFFBEC; }
.dash-cal-num {
  font-weight: 600;
  font-size: 12px;
  color: var(--ink);
  margin-bottom: 2px;
}
.dash-cal-ev {
  background: var(--koeln-red);
  color: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 10.5px;
  line-height: 1.4;
}
.dash-cal-more {
  font-size: 10px;
  color: var(--ink-soft);
  font-style: italic;
}

@media (max-width: 700px) {
  .dash-cal-day { min-height: 64px; }
  .dash-cal-ev { font-size: 9.5px; padding: 1px 3px; }
}

/* --- Print template editor (form + DIN-5008 preview) -------------------- */

.pt-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.pt-editor-form { min-width: 0; }
.pt-editor-preview-wrap {
  position: sticky;
  top: 16px;
  min-width: 0;
}
.pt-editor-preview-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.pt-editor-preview {
  background: #fff;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0;
  overflow: hidden;
}
.pt-preview-page {
  font-family: var(--font);
  font-size: 11px;
  line-height: 1.45;
  color: var(--ink);
  padding: 24px 28px;
  aspect-ratio: 1 / 1.414; /* A4 */
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pt-preview-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--hair);
  padding-bottom: 8px;
}
.pt-preview-logo img {
  max-width: 130px;
  max-height: 60px;
  object-fit: contain;
}
.pt-preview-logo-placeholder {
  width: 130px;
  height: 50px;
  border: 1px dashed var(--hair);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--ink-soft);
}
.pt-preview-org { text-align: right; }
.pt-preview-faction { font-weight: 600; font-size: 12px; }
.pt-preview-sender-line {
  font-size: 9px;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-top: 22px;
}
.pt-preview-recipient { margin-top: 4px; }
.pt-preview-date { text-align: right; margin-top: 18px; }
.pt-preview-subject { margin-top: 14px; }
.pt-preview-body { margin-top: 8px; flex: 1; }
.pt-preview-body p { margin: 0 0 6px 0; }
.pt-preview-signers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 18px;
}
.pt-preview-line {
  border-top: 1px solid var(--ink);
  margin-bottom: 4px;
  height: 0;
}
.pt-preview-footer {
  border-top: 1px solid var(--hair);
  padding-top: 6px;
  margin-top: auto;
  font-size: 9px;
  color: var(--ink-soft);
  text-align: center;
}

@media (max-width: 1100px) {
  .pt-editor-grid { grid-template-columns: 1fr; }
  .pt-editor-preview-wrap { position: static; }
}
