*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: #1e293b;
  background: #e8ecf1;
}

.page {
  width: 100%;
  max-width: 520px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: #fff;
  display: flex;
  flex-direction: column;
}

@media (min-width: 540px) {
  body { padding: 12px 0; }
  .page {
    min-height: calc(100vh - 24px);
    min-height: calc(100dvh - 24px);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(15, 23, 42, .1);
    overflow: hidden;
  }
}

/* Header */
.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
}

.head-logo img {
  display: block;
  height: 36px;
  width: auto;
  max-width: 170px;
}

.head-id {
  font-size: 13px;
  font-weight: 700;
  color: #64748b;
  background: #f1f5f9;
  padding: 4px 10px;
  border-radius: 20px;
  flex-shrink: 0;
}

.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.konu {
  margin: 0;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
  border-bottom: 1px solid #e2e8f0;
  word-break: break-word;
}

/* Alerts */
.flash {
  margin: 10px 16px 0;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}

.flash-ok { background: #ecfdf5; color: #065f46; }
.flash-err { background: #fef2f2; color: #991b1b; }

/* Contact */
.contact {
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #fafbfc;
}

.contact-alert {
  background: #fffbeb;
  border-bottom-color: #fde68a;
}

.contact-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tag {
  font-size: 11px;
  font-weight: 700;
  color: #92400e;
  background: #fef3c7;
  padding: 2px 8px;
  border-radius: 20px;
}

.contact-form {
  display: grid;
  gap: 8px;
}

.fld {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fld span {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
}

.fld input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font: inherit;
  font-size: 15px;
  background: #fff;
}

.fld input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}

.btn-save {
  justify-self: start;
  margin-top: 2px;
  padding: 8px 16px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #2563eb;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-save:hover { background: #eff6ff; }

/* Messages */
.thread {
  flex: 1;
  padding: 16px;
  background: #f1f5f9;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.thread-empty {
  margin: auto;
  color: #64748b;
  font-size: 14px;
}

.msg {
  max-width: 90%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
}

.msg-them {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}

.msg-me {
  align-self: flex-end;
  background: #dbeafe;
  border-bottom-right-radius: 4px;
}

.msg-head {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 4px;
}

.msg-body {
  line-height: 1.5;
  word-break: break-word;
}

.msg-file {
  display: inline-block;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #1d4ed8;
  text-decoration: none;
}

.msg-file::before { content: "📎 "; }
.msg-file:hover { text-decoration: underline; }

/* Composer */
.write {
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0));
  border-top: 1px solid #e2e8f0;
  background: #fff;
}

.write textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font: inherit;
  font-size: 15px;
  resize: none;
  display: block;
}

.write textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}

.write-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.file-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.btn-file {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #475569;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-file:hover { background: #f1f5f9; }

.file-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: #2563eb;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-send {
  margin-left: auto;
  padding: 9px 22px;
  border: 0;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-send:hover { background: #1d4ed8; }

.hidden { display: none !important; }

/* Error page fallback */
.wrap { max-width: 520px; margin: 0 auto; padding: 16px; }
.card { background: #fff; border-radius: 12px; padding: 20px; border: 1px solid #e2e8f0; }
.alert { padding: 12px; border-radius: 8px; }
.alert.err { background: #fef2f2; color: #991b1b; }
.sub { color: #64748b; font-size: 14px; }
.site-logo { height: 36px; }

/* Account / dashboard */
.page-wide { max-width: 720px; }
.head-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.head-link { color: #1d4ed8; text-decoration: none; font-size: 13px; font-weight: 600; }
.head-link:hover { text-decoration: underline; }
.head-user { font-size: 12px; color: #64748b; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.auth-card, .dash {
  padding: 20px 16px 28px;
}
.auth-card h1, .dash-head h1 {
  margin: 0 0 6px;
  font-size: 22px;
  color: #0f172a;
}
.auth-form { display: grid; gap: 12px; margin-top: 14px; }
.auth-form .fld span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #334155; }
.auth-form input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font: inherit;
}
.auth-form input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.btn-main {
  display: inline-block;
  margin-top: 4px;
  padding: 12px 16px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, #2563eb, #1d4ed8);
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.btn-main:hover { filter: brightness(.96); }
.auth-links { margin-top: 16px; font-size: 13px; color: #64748b; display: flex; gap: 8px; flex-wrap: wrap; }
.auth-links a { color: #1d4ed8; font-weight: 600; text-decoration: none; }
.hint { margin-top: 14px; font-size: 12px; color: #64748b; line-height: 1.5; }

.dash-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}
.chip.active { background: #dbeafe; color: #1d4ed8; }
.ticket-list { display: grid; gap: 10px; }
.ticket-card {
  display: block;
  padding: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.ticket-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 4px 14px rgba(37,99,235,.08);
}
.ticket-card-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.ticket-card-title { margin-top: 6px; font-weight: 600; color: #0f172a; line-height: 1.4; }
.ticket-card-meta { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: #64748b; }
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.badge-ok { background: #ecfdf5; color: #047857; }
.badge-muted { background: #f1f5f9; color: #64748b; }
.unread { background: #fee2e2; color: #b91c1c; padding: 2px 8px; border-radius: 999px; font-weight: 700; }
.empty-card {
  padding: 28px 16px;
  text-align: center;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  color: #64748b;
}
.ticket-meta-line {
  margin: 0;
  padding: 0 16px 12px;
  font-size: 12px;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
}
.urun-line {
  padding: 6px 0;
  border-bottom: 1px solid #e2e8f0;
  font-size: 13px;
}
.urun-line small { display: block; color: #64748b; }
.urun-line span { display: block; color: #475569; font-size: 12px; }
