/* CloseBook Support: χρώματα από το logo (#4147FF μπλε, #808080 γκρι) */
:root {
  --brand: #4147ff; --brand-2: #2f35e0; --brand-soft: #eceeff; --brand-ink: #ffffff;
  --gray: #808080;
  --bg: #f4f5fb; --panel: #ffffff; --panel-2: #f8f9fd; --text: #14172b; --muted: #636a85; --line: #e3e6f1;
  --ok: #0f8a4f; --ok-soft: #e2f6ec; --bad: #d1352c; --bad-soft: #fde9e7; --warn: #a96500; --warn-soft: #fff3dd;
  --me: #4147ff; --me-ink: #ffffff; --bot: #ffffff; --sys: #eef0f7;
  --radius: 16px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20,23,43,.05), 0 4px 16px rgba(20,23,43,.06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #6c71ff; --brand-2: #8a8eff; --brand-soft: #1f2347; --brand-ink: #ffffff;
    --bg: #0c0e19; --panel: #151829; --panel-2: #1a1e33; --text: #eceefb; --muted: #9ba1bd; --line: #262b45;
    --ok: #3fd189; --ok-soft: #12301f; --bad: #ff6d64; --bad-soft: #3a1a1a; --warn: #ffb648; --warn-soft: #3a2c13;
    --me: #4f55ff; --bot: #1a1e33; --sys: #191c2e; --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
  .logo-text { filter: brightness(0) invert(1); }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
svg { flex-shrink: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* ---------- Κουμπιά & φόρμες ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--panel);
  border-radius: 999px; padding: 9px 16px; cursor: pointer; font-weight: 500; text-decoration: none; color: var(--text); white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s; min-height: 40px; }
.btn:hover { border-color: var(--brand); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.danger { color: var(--bad); }
.btn.call { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.icon { padding: 0; width: 42px; height: 42px; min-height: 42px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { width: 100%; border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius-sm); padding: 11px 13px; font-size: 16px; }
input:focus, textarea:focus, select:focus { outline: 3px solid var(--brand-soft); border-color: var(--brand); }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; font-weight: 500; }

/* ---------- Μπάρα ---------- */
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand .logo-mark { height: 30px; width: auto; }
.brand .logo-text { height: 18px; width: auto; }
.brand .tag { font-size: 12px; font-weight: 600; color: var(--muted); border-left: 1px solid var(--line); padding-left: 10px; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.who { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; background: var(--sys); white-space: nowrap; font-weight: 500; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.ok .dot { box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 25%, transparent); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }

/* ---------- Είσοδος ---------- */
.login-page { min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero { background: radial-gradient(1200px 600px at -10% -10%, #6b70ff 0%, transparent 60%), linear-gradient(140deg, #4147ff 0%, #2a2fc9 100%);
  color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-hero::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; border: 60px solid rgba(255,255,255,.07); }
.login-hero .badge { display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,.14); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; }
.login-hero h1 { font-size: clamp(28px, 3.4vw, 42px); line-height: 1.15; margin: 18px 0 12px; letter-spacing: -.02em; }
.login-hero p { opacity: .9; max-width: 460px; margin: 0; font-size: 16px; }
.features { list-style: none; padding: 0; margin: 32px 0 0; display: grid; gap: 14px; max-width: 480px; }
.features li { display: flex; gap: 12px; align-items: flex-start; }
.features .fi { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.16); display: grid; place-items: center; flex-shrink: 0; }
.features b { display: block; }
.features span { opacity: .85; font-size: 14px; }
.login-side { display: grid; place-items: center; padding: 32px 20px; }
.login-card { width: 100%; max-width: 400px; }
.login-card .logos { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-card .logos .logo-mark { height: 44px; }
.login-card .logos .logo-text { height: 24px; }
.login-card h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.01em; }
.error { color: var(--bad); font-size: 14px; min-height: 20px; margin-top: 10px; }
.foot { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 18px; }
.foot a { color: var(--muted); }
@media (max-width: 860px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { padding: 28px 20px 30px; }
  .login-hero h1 { font-size: 26px; margin-top: 14px; }
  .features { margin-top: 18px; gap: 10px; }
  .features li:nth-child(n+4) { display: none; }
  .login-side { padding: 22px 16px 26px; align-items: start; order: -1; }
  .login-hero { border-radius: 22px 22px 0 0; }
}

/* ---------- Chat ---------- */
.chat-app { height: 100dvh; display: flex; flex-direction: column; }
.chat-layout { flex: 1; display: flex; min-height: 0; }
.conv-list { width: 300px; border-right: 1px solid var(--line); background: var(--panel); overflow-y: auto; flex-shrink: 0; display: flex; flex-direction: column; }
.conv-list .new { margin: 14px; }
.conv-item { padding: 12px 16px; border-top: 1px solid var(--line); cursor: pointer; }
.conv-item:hover, .conv-item.active { background: var(--brand-soft); }
.conv-item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .m { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.status-strip { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--panel-2); font-size: 13px; }
.messages { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.msg { max-width: min(640px, 82%); padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: var(--shadow); }
.msg.customer { align-self: flex-end; background: var(--me); color: var(--me-ink); border-bottom-right-radius: 6px; }
.msg.agent { align-self: flex-start; background: var(--bot); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.admin { align-self: flex-start; background: var(--warn-soft); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.system { align-self: center; background: var(--sys); color: var(--muted); font-size: 13px; box-shadow: none; text-align: center; border-radius: 12px; max-width: 92%; }
.msg .who { font-size: 12px; font-weight: 600; opacity: .7; margin-bottom: 2px; display: flex; align-items: center; gap: 6px; }
.msg .who img { height: 14px; }
.msg .time { font-size: 11px; opacity: .6; margin-top: 4px; text-align: right; }
.msg .actions-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; white-space: normal; }
.msg a.tel { color: inherit; font-weight: 700; }
.typing { align-self: flex-start; display: inline-flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.welcome { margin: auto; max-width: 560px; width: 100%; padding: 6px 0 12px; }
.welcome .hello { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.welcome .hello img { height: 40px; }
.welcome h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.welcome ul { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.welcome li { display: flex; gap: 10px; align-items: flex-start; }
.welcome li svg { color: var(--brand); margin-top: 2px; }
.welcome .not { font-size: 13px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 4px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 8px 14px; cursor: pointer; font-size: 14px; }
.chip:hover { border-color: var(--brand); color: var(--brand); }

.composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); }
.composer textarea { resize: none; min-height: 44px; height: 44px; max-height: 140px; border-radius: 22px; padding: 11px 16px; line-height: 1.4; }
.composer .btn.icon { width: 44px; height: 44px; min-height: 44px; }
.rec-bar { display: flex; align-items: center; gap: 12px; flex: 1; height: 44px; padding: 0 16px; border-radius: 22px; background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.rec-bar .rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); animation: blink 1s infinite; }
.btn.mic.on { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.speak.on { color: var(--brand); background: var(--brand-soft); }
.back-btn { display: none; }

@media (max-width: 760px) {
  .topbar { padding-left: 10px; padding-right: 10px; gap: 6px; }
  .brand .logo-text, .brand .tag, .hide-m { display: none; }
  .conv-list { width: 100%; border-right: 0; }
  .chat-layout.in-conv .conv-list { display: none; }
  .chat-layout:not(.in-conv) .chat-main { display: none; }
  .back-btn { display: inline-flex; }
  .msg { max-width: 90%; }
  .messages { padding: 14px 10px; }
  .btn.call .lbl { display: none; }
  .btn.call { width: 42px; padding: 0; }
}

/* ---------- Admin ---------- */
.tabs { display: flex; gap: 2px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; position: sticky; top: 61px; z-index: 9; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 12px 14px; border: 0; background: none; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); white-space: nowrap; font-weight: 500; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.tab .count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; text-align: center; margin-left: 4px; }
.page { padding: 18px 16px 40px; max-width: 1280px; margin: 0 auto; }
.grid { display: grid; gap: 12px; }
.grid.apps { grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { padding: 14px 16px; }
.stat .n { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 13px; }
.stat.alert .n { color: var(--bad); }
.app-card h3 { margin: 0 0 10px; font-size: 16px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.check-row { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; align-items: center; }
h2.sec { font-size: 15px; margin: 24px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: var(--panel-2); }
tr.click { cursor: pointer; }
tr.click:hover, tr.sel { background: var(--brand-soft); }
.table-wrap { overflow-x: auto; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters select { width: auto; min-width: 160px; }
.split { display: grid; grid-template-columns: 400px 1fr; gap: 14px; align-items: start; }
.split .messages { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); max-height: 60vh; min-height: 260px; }
.conv-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
pre.out { white-space: pre-wrap; max-height: 180px; overflow: auto; background: var(--sys); padding: 8px 10px; border-radius: 8px; font-size: 12px; margin: 6px 0 0; }
.alert-row { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; align-items: flex-start; }
.alert-row:first-child { border-top: 0; }
.setup-row { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; align-items: center; }
.notice { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: 14px; }
.secret { font-family: ui-monospace, Consolas, monospace; background: var(--sys); padding: 10px 12px; border-radius: 8px; user-select: all; white-space: pre; overflow-x: auto; }
.back-list { display: none; }

@media (max-width: 960px) {
  .split { grid-template-columns: 1fr; }
  .split.has-detail .list-col { display: none; }
  .split:not(.has-detail) #conv-detail { display: none; }
  .back-list { display: inline-flex; }
}
@media (max-width: 760px) {
  .tabs { top: 57px; }
  .page { padding: 14px 10px 40px; }
  .grid.stats { grid-template-columns: repeat(2, 1fr); }
  /* Πίνακες → κάρτες */
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards { border: 0; background: none; }
  table.cards thead { display: none; }
  table.cards tr { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 10px; padding: 6px 4px; }
  table.cards td { border: 0; padding: 6px 12px; }
  table.cards td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
}
