* { box-sizing: border-box; }
body {
  margin: 0; font-family: "Segoe UI", Arial, sans-serif; background: #f3f4f6; color: #1f2937;
}
.hidden { display: none !important; }
.error { color: #dc2626; font-size: 13px; min-height: 16px; margin-top: 6px; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.card {
  background: #fff; padding: 32px; border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.08);
  width: 340px; display: flex; flex-direction: column; gap: 10px;
}
.card h1 { margin: 0; color: #1e3a8a; }
.card .sub { margin: 0 0 10px; color: #6b7280; font-size: 14px; }
.card input, .new-case input { padding: 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; }
button {
  padding: 10px 14px; background: #1e3a8a; color: #fff; border: 0; border-radius: 8px;
  cursor: pointer; font-size: 14px;
}
button:hover { background: #1e40af; }
button:disabled { opacity: .5; cursor: default; }
.hint { font-size: 11px; color: #9ca3af; margin-top: 8px; }
.login-note { font-size: 12px; color: #6b7280; text-align: center; margin: 10px 0 0; }
.chooser { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.chooser-btn { background: #fff; color: #1e3a8a; border: 1px solid #c7d2fe; padding: 12px; border-radius: 8px; font-size: 14px; }
.chooser-btn:hover { background: #eef2ff; }
.google-btn { display: flex; justify-content: center; margin: 4px 0; }
.divider { text-align: center; font-size: 12px; color: #9ca3af; margin: 6px 0; position: relative; }
.divider::before, .divider::after { content: ""; position: absolute; top: 50%; width: 28%; height: 1px; background: #e5e7eb; }
.divider::before { right: 0; } .divider::after { left: 0; }

/* app shell */
.app { height: 100vh; display: flex; flex-direction: column; }
header {
  background: linear-gradient(180deg, #245d92 0%, #123960 55%, #02132d 100%); color: #fff; padding: 0 18px; display: flex;
  justify-content: center; align-items: flex-start; overflow: visible; position: relative; z-index: 10;
}
header .brand { display: block; }
header .user { display: flex; gap: 10px; align-items: center; font-size: 14px; }
header .user button { background: rgba(255,255,255,.15); padding: 6px 10px; }

/* Profile button */
.profile-btn {
  position: absolute; left: 18px; top: 50%; transform: translateY(-50%); z-index: 12;
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 5px 10px; border-radius: 8px; font-size: 14px; color: #fff;
  transition: background .15s;
}
@media (max-width: 480px) { #user-name { display: none; } .profile-btn .chevron { display: none; } }
.profile-btn:hover { background: rgba(255,255,255,.15); }
.chevron { font-size: 11px; opacity: .7; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: #C9A84C;
  color: #1e3a8a; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.avatar-lg { width: 42px; height: 42px; font-size: 18px; }

/* Header logo: flush top, slogan overflows below header band */
.header-logo { height: 116px; vertical-align: top; transition: height .2s; display: block; margin-top: -9px; margin-bottom: -38px; position: relative; z-index: 11; }
@media (min-width: 768px) { .header-logo { height: 170px; margin-top: -12px; margin-bottom: -56px; } }
@media (min-width: 1200px) { .header-logo { height: 201px; margin-top: -15px; margin-bottom: -66px; } }

/* Profile dropdown — positioned under profile button on the LEFT */
.profile-dropdown {
  position: absolute; top: 100%; left: 12px; width: 280px; margin-top: 4px;
  background: #fff; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.18);
  z-index: 1000; color: #1f2937; overflow: hidden;
}
.profile-header-box {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; background: #f0f4ff; border-bottom: 1px solid #e5e7eb;
}
.profile-fullname { font-weight: 700; font-size: 15px; }
.profile-role-badge {
  font-size: 11px; color: #1e3a8a; background: #e0e7ff;
  padding: 2px 8px; border-radius: 10px; display: inline-block; margin-top: 3px;
}
.profile-section { padding: 10px 14px; }
.profile-sec-title { font-weight: 700; font-size: 12px; color: #6b7280; text-transform: uppercase; margin-bottom: 6px; letter-spacing: .5px; }
.profile-cases-list { display: flex; flex-direction: column; gap: 4px; max-height: 200px; overflow-y: auto; }
.profile-case-item {
  padding: 8px 10px; border-radius: 8px; background: #f9fafb; cursor: pointer;
  font-size: 13px; border: 1px solid #e5e7eb; transition: background .1s;
}
.profile-case-item:hover { background: #eef2ff; }
.profile-case-meta { font-size: 11px; color: #9ca3af; margin-top: 2px; }
.profile-muted { font-size: 13px; color: #9ca3af; text-align: center; padding: 10px 0; }
.profile-footer {
  padding: 10px 14px; border-top: 1px solid #e5e7eb;
}
.logout-btn {
  width: 100%; background: #fee2e2; color: #b91c1c; border: 0;
  padding: 8px; border-radius: 8px; font-size: 13px; cursor: pointer; text-align: center;
}
.logout-btn:hover { background: #fecaca; }
.main { flex: 1; display: flex; min-height: 0; }

.sidebar { width: 240px; background: #fff; border-left: 1px solid #e5e7eb; padding: 12px; overflow-y: auto; }
.side-head { font-weight: 700; color: #374151; margin: 4px 0 8px; font-size: 14px; }
.cases { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.case-item { padding: 10px; border-radius: 8px; background: #f9fafb; cursor: pointer; font-size: 14px; border: 1px solid #eef0f2; }
.case-item:hover { background: #eef2ff; }
.case-item.active { background: #e0e7ff; border-color: #c7d2fe; }
.case-item .meta { font-size: 11px; color: #9ca3af; margin-top: 3px; }
.new-case { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid #e5e7eb; padding-top: 12px; }
.fee-link { display: block; margin-top: 14px; font-size: 13px; color: #1e3a8a; text-decoration: none; padding-top: 12px; border-top: 1px solid #e5e7eb; }
.fee-link:hover { text-decoration: underline; }

.chat-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.case-title-bar { padding: 12px 18px; background: #fff; border-bottom: 1px solid #e5e7eb; font-weight: 600; }
.messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 72%; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.msg.user { align-self: flex-start; background: #1e3a8a; color: #fff; border-bottom-right-radius: 3px; }
.msg.assistant { align-self: flex-end; background: #fff; border: 1px solid #e5e7eb; border-bottom-left-radius: 3px; }
.msg a { color: inherit; text-decoration: underline; word-break: break-all; }
.msg.assistant a { color: #1e3a8a; }
.msg .who { font-size: 11px; opacity: .7; margin-bottom: 3px; display: flex; align-items: center; gap: 6px; }
.msg-del { background: transparent; color: inherit; opacity: .6; border: 0; padding: 0; font-size: 12px; cursor: pointer; }
.msg-del:hover { opacity: 1; color: #b91c1c; }
.msg.system { align-self: center; max-width: 90%; background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; font-size: 12px; text-align: center; }
.chat-form { display: flex; gap: 8px; padding: 12px 18px; background: #fff; border-top: 1px solid #e5e7eb; align-items: flex-end; }
.chat-form textarea { flex: 1; resize: none; height: 50vh; min-height: 50px; max-height: 85vh; padding: 10px; border: 1px solid #d1d5db; border-radius: 8px; font-family: inherit; font-size: 14px; line-height: 1.5; }
.chat-resize-handle { height: 8px; background: #e5e7eb; cursor: ns-resize; border-top: 1px solid #d1d5db; border-bottom: 1px solid #d1d5db; transition: background .15s; }
.chat-resize-handle:hover, .chat-resize-handle.dragging { background: #c7d2fe; }
.icon-btn { background: #eef2ff; color: #1e3a8a; padding: 8px 10px; font-size: 16px; line-height: 1; }
.icon-btn:hover { background: #e0e7ff; }
.icon-btn.recording { background: #fee2e2; color: #b91c1c; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

.docs-strip { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 18px; background: #fafafa; border-bottom: 1px solid #eef0f2; }
.docs-label { font-size: 12px; color: #6b7280; }
.doc-chip { font-size: 12px; background: #eef2ff; color: #1e3a8a; padding: 3px 8px; border-radius: 10px; }
.doc-chip { display: inline-flex; align-items: center; gap: 6px; }
.doc-del { background: transparent; color: #991b1b; border: 0; padding: 0 2px; font-size: 13px; cursor: pointer; line-height: 1; }
.doc-del:hover { color: #dc2626; }
.doc-chip.uploading { background: #fef3c7; color: #92400e; }
.doc-chip.err { background: #fee2e2; color: #991b1b; }

.disclaimer { font-size: 12px; color: #92400e; background: #fffbeb; border-top: 1px solid #fde68a; padding: 6px 18px; text-align: center; }

.search-row { display: flex; gap: 6px; padding: 8px 18px; background: #fff; border-bottom: 1px solid #eef0f2; }
.search-row input { flex: 1; padding: 8px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 13px; }
.search-row button { padding: 8px 12px; font-size: 13px; }
.search-clear { background: #e5e7eb; color: #374151; }
.search-results { max-height: 220px; overflow-y: auto; padding: 8px 18px; background: #f9fafb; border-bottom: 1px solid #eef0f2; }
.search-hit { padding: 8px; background: #fff; border: 1px solid #eef0f2; border-radius: 8px; margin-bottom: 6px; }
.hit-file { font-size: 12px; color: #1e3a8a; font-weight: 600; }
.hit-snip { font-size: 12px; color: #4b5563; margin-top: 3px; }

.audit-toggle { width: 100%; margin-top: 12px; background: #eef2ff; color: #1e3a8a; font-size: 13px; }
#meta-panel input { width: 100%; padding: 6px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 12px; margin-bottom: 4px; }
#meta-panel button { width: 100%; padding: 6px; font-size: 12px; }
.audit-panel { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.audit-row { font-size: 12px; border: 1px solid #eef0f2; border-radius: 6px; padding: 6px 8px; }
.audit-act { font-weight: 600; color: #1e3a8a; }
.audit-detail { color: #6b7280; }
.audit-ts { color: #9ca3af; font-size: 11px; margin-top: 2px; }

.ledger-col { width: 300px; background: #fff; border-right: 1px solid #e5e7eb; padding: 12px; overflow-y: auto; }
.chain-status { font-size: 12px; padding: 6px 8px; border-radius: 6px; margin-bottom: 10px; }
.chain-ok { background: #dcfce7; color: #166534; }
.chain-bad { background: #fee2e2; color: #991b1b; }
.ledger { display: flex; flex-direction: column; gap: 8px; }
.entry { border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px; font-size: 13px; }
.entry .row { display: flex; justify-content: space-between; margin-bottom: 4px; }
.entry .minutes { font-weight: 700; color: #1e3a8a; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.badge.pending_approval { background: #fef3c7; color: #92400e; }
.badge.approved { background: #dcfce7; color: #166534; }
.badge.rejected { background: #fee2e2; color: #991b1b; }
.entry .actions { display: flex; gap: 6px; margin-top: 6px; }
.entry .actions button { padding: 5px 10px; font-size: 12px; }
.entry .actions .reject { background: #b91c1c; }
.muted { color: #9ca3af; font-size: 13px; padding: 10px; }
