:root {
  --bg: #f4f7f9;
  --card: #ffffff;
  --text: #1c2b36;
  --muted: #5f7080;
  --line: #dde5ea;
  --primary: #0e7c86;
  --primary-dark: #0a5f67;
  --danger: #b3261e;
  --ok: #1b7a3d;
  --warn: #a15c00;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; font-size: 15px; }
a { color: var(--primary-dark); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

header.top { background: var(--primary-dark); color: #fff; }
header.top .bar { max-width: 1100px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; min-height: 56px; }
header.top .brand { font-weight: 700; font-size: 1.1rem; color: #fff; text-decoration: none; }
header.top nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
header.top nav a { color: #d7eef0; text-decoration: none; padding: 8px 12px; border-radius: 6px; }
header.top nav a:hover, header.top nav a.active { background: rgba(255,255,255,.15); color: #fff; }
header.top .who { display: flex; align-items: center; gap: 12px; font-size: .9rem; }
header.top .who form { margin: 0; }
header.top .who button { background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff; padding: 5px 12px; border-radius: 6px; cursor: pointer; }

main { max-width: 1100px; margin: 24px auto; padding: 0 16px 48px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }

.btn { display: inline-block; background: var(--primary); color: #fff; border: 0; padding: 9px 16px; border-radius: 7px; font-size: .95rem; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #e6eef1; color: var(--text); }
.btn.secondary:hover { background: #d5e2e7; }
.btn.danger { background: var(--danger); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

label { display: block; font-weight: 600; margin: 0 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=file], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #b9c7cf; border-radius: 7px; font: inherit; background: #fff;
}
textarea { min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #8fd0d6; border-color: var(--primary); }
.field { margin-bottom: 14px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.check input { width: auto; }
.check label { margin: 0; font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 3px; }
.error { color: var(--danger); font-size: .88rem; margin-top: 3px; }

.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; }
.alert.ok { background: #e3f4e8; color: #14532d; border: 1px solid #b7e0c3; }
.alert.err { background: #fde8e6; color: #7a1a14; border: 1px solid #f3bdb8; }
.alert.warn { background: #fff4de; color: #6b4200; border: 1px solid #f0d8a3; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #eef3f6; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
tr.unread td:first-child { border-left: 4px solid var(--primary); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.new { background: #dff3f5; color: #0a5f67; }
.badge.opened { background: #fff1d6; color: #8a5200; }
.badge.confirmed { background: #dff3e5; color: #17663a; }
.badge.gray { background: #e8edf0; color: #51606c; }
.badge.red { background: #fde0dd; color: #8e1c14; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input, .filters select { width: auto; min-width: 180px; }

.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 18px; min-width: 130px; text-decoration: none; color: inherit; }
.stat b { display: block; font-size: 1.6rem; }
.stat.active { border-color: var(--primary); box-shadow: 0 0 0 2px #bfe3e6; }

.preview { width: 100%; height: 75vh; border: 1px solid var(--line); border-radius: 8px; background: #eee; }
.meta { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: .9rem; margin-top: 4px; }
.comment { border-top: 1px solid var(--line); padding: 12px 0; }
.comment:first-child { border-top: 0; }
.comment .who { font-weight: 600; }
.comment p { margin: 4px 0 0; white-space: pre-wrap; }
.pagination { display: flex; gap: 6px; padding: 12px 14px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; background: #fff; }
.pagination .active span { background: var(--primary); color: #fff; border-color: var(--primary); }

.guest { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.guest .box { width: 100%; max-width: 420px; }
.guest .brand { text-align: center; font-size: 1.4rem; font-weight: 700; color: var(--primary-dark); margin-bottom: 16px; }

@media (max-width: 720px) {
  .grid2 { grid-template-columns: 1fr; }
  th, td { padding: 8px 10px; }
  .hide-sm { display: none; }
  .table-wrap { overflow-x: auto; }
}
@media print {
  header.top, .actions, .filters, .btn { display: none !important; }
  body { background: #fff; }
  .card { border: 0; }
}
