@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --ink: #0a0a0a;
  --paper: #ffffff;
  --grey: #6b7280;
  --line: #eceef1;
  --mut: #9aa0a8;
  --bg: #f4f5f7;
  --danger: #c0392b;
  --danger-bg: #fdeeec;
  --ok: #1e8a4c;
  --ok-bg: #eaf7f0;
  --warn: #a5710a;
  --warn-bg: #fdf5e6;
  --accent: #0a0a0a;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-md: 0 6px 16px rgba(16, 24, 40, .06), 0 2px 6px rgba(16, 24, 40, .04);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .12);
  --ease: cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { cursor: none; }

@media (hover: none), (pointer: coarse) {
  html { cursor: auto !important; }
  .cursor-dot, .cursor-ring { display: none !important; }
}

.cursor-dot,
.cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 9999;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.cursor-dot {
  width: 6px;
  height: 6px;
  background: var(--ink);
}
.cursor-ring {
  width: 32px;
  height: 32px;
  border: 1px solid var(--ink);
  transition: width 0.18s ease, height 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}
.cursor-ring.hovered {
  width: 54px;
  height: 54px;
  background: rgba(10, 10, 10, 0.06);
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.96); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

/* ---------- LOGIN / REGISTER ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 44px 36px;
  animation: fadeUp .5s var(--ease);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.login-logo svg { width: 26px; height: 24px; }
.login-logo span {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  font-size: 20px;
  letter-spacing: 0.08em;
}
.login-sub { font-size: 13px; color: var(--grey); margin-bottom: 32px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--grey); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(10, 10, 10, .06);
}

.btn {
  display: inline-block;
  width: 100%;
  padding: 13px 20px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), opacity .12s var(--ease);
  box-shadow: var(--shadow-sm);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); opacity: .96; }
.btn:active { transform: translateY(0); }
.btn-ghost {
  background: var(--paper);
  color: var(--ink);
  border: 1.5px solid var(--line);
  box-shadow: none;
}
.btn-ghost:hover { border-color: var(--ink); box-shadow: var(--shadow-sm); }
.btn-danger { background: var(--danger); }
.btn-sm { width: auto; padding: 8px 14px; font-size: 13px; border-radius: 8px; }

.error-msg { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 16px; }
.hint { font-size: 12px; color: var(--mut); margin-top: 10px; }

/* ---------- APP SHELL ---------- */
.app { display: flex; min-height: 100vh; gap: 20px; padding: 20px; align-items: flex-start; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; padding: 0 8px; }
.sidebar .brand svg { width: 24px; height: 22px; }
.sidebar .brand span { font-family: 'Cormorant Garamond', serif; font-weight: 600; font-size: 18px; }
.sidebar .role-tag { font-size: 11px; color: var(--mut); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 24px; padding: 0 8px; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--grey);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .8; }
.nav-item:hover { background: var(--bg); color: var(--ink); }
.nav-item.active { color: var(--paper); background: var(--ink); }
.nav-item.active svg { opacity: 1; }

.sidebar-footer { margin-top: auto; padding-top: 16px; }
.user-chip { font-size: 13px; color: var(--grey); margin-bottom: 12px; padding: 0 4px; }

.main { flex: 1; min-width: 0; }
.page-title { font-family: 'Cormorant Garamond', serif; font-weight: 600; font-size: 30px; margin-bottom: 6px; }
.page-sub { font-size: 13px; color: var(--grey); margin-bottom: 28px; }

.panel { display: none; animation: fadeUp .35s var(--ease); }
.panel.active { display: block; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  flex-shrink: 0;
}

/* ---------- NOTIFICATION BELL ---------- */
.bell-wrap { position: relative; }
.bell-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--paper);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  position: relative;
  transition: border-color .15s var(--ease), transform .12s var(--ease);
}
.bell-btn:hover { border-color: var(--ink); transform: translateY(-1px); }
.bell-btn svg { width: 17px; height: 17px; }
.bell-dot {
  position: absolute; top: 7px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger);
  border: 1.5px solid var(--paper);
  display: none;
}
.bell-dot.show { display: block; animation: popIn .2s var(--ease); }

.bell-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 340px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 200;
  animation: popIn .16s var(--ease);
  transform-origin: top right;
}
.bell-dropdown.open { display: block; }
.bell-dropdown-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  font-size: 13px; font-weight: 500;
}
.bell-dropdown-head button {
  background: none; border: none; font-size: 12px; color: var(--grey); cursor: pointer; font-family: inherit;
}
.bell-dropdown-head button:hover { color: var(--ink); }
.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  cursor: pointer;
  transition: background .12s var(--ease);
  position: relative;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: #fafbfc; }
.notif-item.unread::before {
  content: "";
  position: absolute; left: 6px; top: 18px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink);
}
.notif-item .txt { padding-left: 14px; color: var(--ink); }
.notif-item .time { padding-left: 14px; font-size: 11px; color: var(--mut); margin-top: 4px; }

/* ---------- STATS ---------- */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  transition: box-shadow .18s var(--ease), transform .18s var(--ease);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card .icon-badge { margin-bottom: 12px; }
.stat-card .num { font-family: 'Cormorant Garamond', serif; font-size: 30px; font-weight: 600; }
.stat-card .label { font-size: 12px; color: var(--grey); margin-top: 4px; }

.icon-badge {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.icon-badge svg { width: 15px; height: 15px; }

/* ---------- TABLE ---------- */
table { width: 100%; border-collapse: collapse; background: var(--paper); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
th, td { text-align: left; padding: 13px 16px; font-size: 13px; border-bottom: 1px solid var(--line); }
th { color: var(--mut); font-weight: 500; text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em; background: var(--bg); }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s var(--ease); }
tbody tr:hover td { background: var(--bg); cursor: pointer; }

.tag { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; font-size: 11px; border-radius: 20px; font-weight: 500; }
.tag-open { color: var(--ok); background: var(--ok-bg); }
.tag-closed { color: var(--mut); background: var(--bg); }
.tag-pending { color: var(--warn); background: var(--warn-bg); }
.tag-confirmed { color: var(--ok); background: var(--ok-bg); }
.tag-canceled, .tag-error { color: var(--danger); background: var(--danger-bg); }

/* ---------- CARD / SECTION ---------- */
.card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
  margin-bottom: 20px;
  transition: box-shadow .18s var(--ease);
}
.card h3 { font-size: 15px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row .field { flex: 1; min-width: 160px; margin-bottom: 0; }

.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .card-grid { grid-template-columns: 1fr; } }

.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: none; }
.list-row .title { font-size: 13.5px; font-weight: 500; }
.list-row .meta { font-size: 11px; color: var(--mut); margin-top: 2px; }
.list-row-icon {
  width: 34px; height: 34px; border-radius: 9px; background: var(--bg);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.list-row-icon svg { width: 15px; height: 15px; }
.link-arrow { font-size: 12px; color: var(--grey); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.link-arrow:hover { color: var(--ink); }

/* ---------- MODAL ---------- */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(16, 18, 22, .45);
  backdrop-filter: blur(2px);
  align-items: center; justify-content: center;
  z-index: 300;
}
.modal-overlay.active { display: flex; animation: fadeIn .15s var(--ease); }
.modal-box {
  background: var(--paper);
  width: 100%; max-width: 420px;
  padding: 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: popIn .18s var(--ease);
}
.modal-box h3 { font-family: 'Cormorant Garamond', serif; font-size: 22px; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }

/* ---------- CHAT ---------- */
.chat-layout { display: flex; gap: 16px; }
.chat-list { width: 300px; flex-shrink: 0; display: flex; flex-direction: column; gap: 8px; }
.chat-list-item {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-size: 13px;
  transition: box-shadow .15s var(--ease), transform .15s var(--ease), background .15s var(--ease);
}
.chat-list-item:hover { transform: translateX(2px); box-shadow: var(--shadow-md); }

.project-group { margin-bottom: 18px; }
.project-group-title {
  font-size: 12px; font-weight: 600; color: var(--grey);
  text-transform: uppercase; letter-spacing: .04em;
  padding: 0 4px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 8px;
}
.chat-list-item.active { background: var(--ink); color: var(--paper); }
.chat-list-item.active .meta { color: rgba(255,255,255,.6); }
.chat-list-item .title { font-weight: 500; margin-bottom: 4px; }
.chat-list-item .meta { color: var(--mut); font-size: 11px; }

.chat-window {
  flex: 1;
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
  height: 600px;
  overflow: hidden;
}
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; }
.msg-row { display: flex; margin-bottom: 16px; animation: fadeUp .25s var(--ease); }
.msg-row.mine { justify-content: flex-end; }
.msg-row:not(.mine):not(.system) { justify-content: flex-start; }
.msg-row.system { justify-content: center; }

.msg-col { display: flex; flex-direction: column; max-width: 74%; }
.msg-row.mine .msg-col { align-items: flex-end; }
.msg-row:not(.mine) .msg-col { align-items: flex-start; }

.msg-col .who { font-size: 12.5px; font-weight: 600; color: var(--grey); margin-bottom: 5px; padding: 0 4px; }
.msg-col .bubble {
  background: var(--bg);
  padding: 10px 14px;
  border-radius: 14px 14px 14px 4px;
  line-height: 1.5;
  font-size: 13.5px;
  word-break: break-word;
}
.msg-row.mine .bubble { background: var(--ink); color: var(--paper); border-radius: 14px 14px 4px 14px; }
.msg-row.system .bubble { background: var(--warn-bg); color: var(--warn); border-radius: 20px; font-size: 12px; padding: 8px 16px; }

.msg-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.msg-row.mine .msg-files { justify-content: flex-end; }

.file-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--paper); border: 1.5px solid var(--line);
  padding: 8px 12px; border-radius: 10px; font-size: 12px;
  text-decoration: none; color: var(--ink);
  transition: border-color .15s var(--ease);
}
.file-chip:hover { border-color: var(--ink); }
.file-chip svg { width: 14px; height: 14px; flex-shrink: 0; }

.chat-input { display: flex; align-items: center; border-top: 1px solid var(--line); padding: 6px; gap: 4px; }
.chat-input input[type="text"] { flex: 1; border: none; padding: 10px 12px; font-family: inherit; font-size: 13px; background: transparent; }
.chat-input input[type="text"]:focus { outline: none; }
.chat-input button.send-btn {
  border: none; background: var(--ink); color: var(--paper);
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: transform .12s var(--ease);
}
.chat-input button.send-btn:hover { transform: scale(1.06); }
.chat-input .attach-btn {
  border: none; background: transparent; color: var(--grey);
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.chat-input .attach-btn:hover { background: var(--bg); color: var(--ink); }
.chat-input .attach-btn svg, .chat-input button.send-btn svg { width: 16px; height: 16px; }

.empty-state { color: var(--mut); font-size: 13px; padding: 40px; text-align: center; }

/* Settings toggle switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--line); border-radius: 22px;
  cursor: pointer; transition: background .15s var(--ease);
}
.switch .slider::before {
  content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: var(--paper); border-radius: 50%; transition: transform .15s var(--ease);
  box-shadow: var(--shadow-sm);
}
.switch input:checked + .slider { background: var(--ink); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:disabled + .slider { opacity: .5; cursor: not-allowed; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.switch-row .title { font-size: 13.5px; }

.settings-tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.settings-tab {
  padding: 10px 4px; margin-right: 20px; font-size: 13px; color: var(--grey);
  cursor: pointer; border-bottom: 2px solid transparent; transition: color .15s var(--ease), border-color .15s var(--ease);
}
.settings-tab:hover { color: var(--ink); }
.settings-tab.active { color: var(--ink); border-bottom-color: var(--ink); font-weight: 500; }
.settings-subpanel { display: none; animation: fadeUp .25s var(--ease); }
.settings-subpanel.active { display: block; }

@media (max-width: 860px) {
  .app { flex-direction: column; padding: 12px; gap: 12px; }
  .sidebar { width: 100%; height: auto; position: relative; top: 0; max-height: none; flex-direction: row; align-items: center; padding: 14px; gap: 16px; }
  .sidebar .role-tag { display: none; }
  .sidebar nav { flex-direction: row; gap: 4px; overflow-x: auto; }
  .nav-item span.label { display: none; }
  .sidebar-footer { margin-top: 0; margin-left: auto; padding-top: 0; display: flex; align-items: center; gap: 10px; }
  .user-chip { display: none; }
  .main { padding: 0; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .chat-layout { flex-direction: column; }
  .chat-list { width: 100%; flex-direction: row; overflow-x: auto; }
  .chat-list-item { min-width: 220px; }
  .bell-dropdown { width: 92vw; right: -10px; }
}
