:root {
  color-scheme: light;
  --ink: #26162f;
  --muted: #756779;
  --purple: #661495;
  --purple-deep: #42105f;
  --line: #e9e1ec;
  --surface: #fff;
  font-family: Vazirmatn, Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: #f8f6fa;
}

button, input, textarea { font: inherit; }
select { font: inherit; }
button { cursor: pointer; }
a { color: var(--purple); text-decoration: none; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 16% 12%, #e7cdf1 0, transparent 34%),
    radial-gradient(circle at 90% 90%, #ede6f0 0, transparent 32%),
    #faf8fc;
}

.login-layout {
  width: min(960px, 100%);
  min-height: 540px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid #ede5ee;
  border-radius: 28px;
  background: var(--surface);
  box-shadow: 0 24px 90px #32103f1b;
}

.login-intro {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 55px;
  background: linear-gradient(135deg, #f7eefb, #e9d7f2 74%, #d6aee9);
}

.intro-orb {
  position: absolute;
  width: 310px;
  height: 310px;
  border-radius: 50%;
  background: #a446c526;
  inset-inline-end: -150px;
  bottom: -160px;
}

.intro-logo { position: relative; width: min(270px, 100%); height: auto; margin-bottom: 26px; }
.login-intro h1 { position: relative; margin: 0 0 12px; font-size: 2.25rem; line-height: 1.4; }
.login-intro p { position: relative; margin: 0; color: #6d5278; line-height: 2; max-width: 320px; }

.login-card { display: flex; flex-direction: column; justify-content: center; padding: 55px; }
.eyebrow { color: var(--purple); font-size: .85rem; font-weight: 700; }
.login-card h2 { margin: 11px 0 6px; font-size: 2rem; }
.login-card-top p { margin: 0 0 30px; color: var(--muted); line-height: 1.8; }
.login-card form { display: flex; flex-direction: column; }
.login-card label { margin: 0 0 8px; font-size: .9rem; font-weight: 700; }
.login-card input:not([type="hidden"]) {
  width: 100%;
  height: 48px;
  margin-bottom: 20px;
  padding: 0 15px;
  border: 1px solid #dacee0;
  border-radius: 12px;
  outline: none;
  background: #fff;
  color: var(--ink);
  direction: ltr;
  text-align: left;
}
.login-card input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px #66149520; }
.primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(110deg, var(--purple), var(--purple-deep));
  color: #fff;
  font-weight: 700;
  transition: transform .15s ease, box-shadow .15s ease;
}
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 8px 24px #66149540; }
.form-error { padding: 12px 14px; margin: 0 0 18px; border-radius: 10px; background: #fff0f2; color: #a32245; font-size: .9rem; }
.card-footer { margin: 24px 0 0; color: #918296; font-size: .8rem; line-height: 1.8; }

.chat-page { height: 100vh; overflow: hidden; }
.chat-shell { height: 100vh; min-height: 470px; display: flex; flex-direction: column; }
.chat-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 86px;
  padding: 8px max(24px, calc((100vw - 1080px)/2));
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.chat-brand { display: flex; align-items: center; gap: 16px; font-weight: 700; }
.chat-brand img { display: block; width: 96px; height: 62px; object-fit: contain; }
.chat-brand span { padding-inline-start: 16px; border-inline-start: 1px solid var(--line); white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.subtle-button { border: 1px solid var(--line); border-radius: 10px; background: #fff; color: #5d4d64; padding: 9px 14px; white-space: nowrap; }
.subtle-button:hover { background: #f8f2fb; color: var(--purple); }
.conversation { flex: 1; min-height: 0; overflow: hidden; }
.messages { height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; max-width: 900px; margin: 0 auto; padding: 30px 24px 40px; }
.welcome { margin: auto; text-align: center; color: var(--muted); }
.welcome-mark { display: inline-grid; place-items: center; width: 54px; height: 54px; border-radius: 18px; background: #efe1f5; color: var(--purple); font-size: 1.8rem; }
.welcome h1 { margin: 20px 0 5px; color: var(--ink); font-size: 1.7rem; }
.welcome p { margin: 0; line-height: 1.8; }
.message { max-width: min(80%, 690px); padding: 14px 18px; border-radius: 18px; line-height: 1.9; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-user { align-self: flex-start; background: var(--purple); color: white; border-bottom-right-radius: 4px; }
.message-assistant { align-self: flex-end; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; box-shadow: 0 4px 18px #3816430b; }
.message-error { border-color: #efb7c2; color: #9b2846; }
.composer-wrap { flex: none; padding: 14px 24px 22px; background: linear-gradient(0deg, #f8f6fa 80%, #f8f6fa00); }
.composer { display: flex; align-items: flex-end; gap: 12px; max-width: 850px; margin: 0 auto; padding: 10px; border: 1px solid #dacde0; border-radius: 18px; background: #fff; box-shadow: 0 12px 40px #32103f13; }
.composer:focus-within { border-color: var(--purple); }
.composer textarea { flex: 1; min-height: 46px; max-height: 180px; resize: vertical; border: 0; outline: none; padding: 11px 12px; background: transparent; color: var(--ink); line-height: 1.7; }
.send-button { width: 46px; height: 46px; flex: none; border: 0; border-radius: 13px; background: var(--purple); color: white; font-size: 1.45rem; }
.send-button:hover { background: var(--purple-deep); }
.send-button:disabled { opacity: .5; cursor: default; }
.composer-hint { margin: 9px auto 0; max-width: 850px; text-align: center; color: #9a8d9d; font-size: .75rem; }
.chat-tools { max-width: 850px; margin: 8px auto 0; text-align: left; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.dashboard-header { display: flex; align-items: center; gap: 18px; min-height: 82px; padding: 8px max(24px, calc((100vw - 1140px)/2)); background: #fff; border-bottom: 1px solid var(--line); font-weight: 700; }
.dashboard-header img { width: 96px; height: 62px; object-fit: contain; }
.dashboard-header nav { margin-inline-start: auto; display: flex; align-items: center; gap: 18px; }
.dashboard-header nav form { display: inline; }
.dashboard-header nav button { border: 0; background: none; color: var(--purple); }
.dashboard-main { width: min(1140px, 100%); margin: 0 auto; padding: 34px 24px 80px; }
.dashboard-main h1 { font-size: 1.8rem; margin: 0 0 6px; }
.dashboard-main > p { color: var(--muted); margin: 0 0 32px; }
.flow-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.flow-card, .empty-card { display: flex; flex-direction: column; gap: 14px; min-height: 175px; padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: white; box-shadow: 0 8px 30px #32103f0b; }
.flow-card strong { color: var(--ink); font-size: 1.15rem; }.flow-card > span:last-child { margin-top: auto; }.flow-icon { color: var(--purple); font-size: 1.6rem; }
.admin-main { max-width: 1120px; }.admin-section { margin: 28px 0 44px; }.admin-section h2 { border-bottom: 1px solid var(--line); padding-bottom: 12px; font-size: 1.3rem; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }.admin-card { padding: 22px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 8px 30px #32103f0b; margin: 14px 0; }
.admin-card h3 { margin: 0 0 18px; font-size: 1.05rem; }.admin-card ul { margin: 0; padding-inline-start: 22px; line-height: 2; }.admin-card li small { display: block; color: var(--muted); font-size: .75rem; }
.admin-card label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; font-weight: 700; margin: 0 0 14px; }
.admin-card input:not([type=hidden]), .admin-card select { min-width: 0; width: 100%; height: 42px; border: 1px solid #dacde0; border-radius: 9px; padding: 7px 10px; background: white; color: var(--ink); }
.admin-card button { border: 0; border-radius: 9px; padding: 10px 15px; background: var(--purple); color: white; font-weight: 700; }
.admin-card .secondary-action, .secondary-action { background: #f0e9f4; color: var(--purple); }
.admin-inline { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }.admin-inline h3 { width: 100%; }.admin-inline label { flex: 1; min-width: 150px; margin: 0; }.admin-inline button { height: 42px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }.user-list { display: grid; gap: 12px; }.user-heading { display: flex; justify-content: space-between; gap: 20px; }.user-heading h3 { margin-bottom: 4px; }.user-heading p { margin: 0 0 16px; color: var(--muted); font-size: .85rem; }.user-heading small { font-weight: 400; }.access-line { line-height: 2.4; margin-bottom: 16px; }.pill { display: inline-block; border-radius: 20px; padding: 2px 10px; background: #f2e8f7; color: var(--purple); margin: 0 5px; font-size: .8rem; }.user-card details { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }.user-card summary { color: var(--purple); cursor: pointer; }.notice { padding: 12px 16px; border-radius: 10px; margin: 12px 0; }.notice-success { background: #e5f7eb; color: #22613a; }.notice-error { background: #fff0f2; color: #9b2846; }

@media (max-width: 760px) {
  .chat-header { flex-wrap: wrap; }.header-actions { flex-wrap: wrap; justify-content: flex-end; }
  .dashboard-header { padding: 8px 14px; gap: 8px; }.dashboard-header img { width: 60px; height: 44px; }.dashboard-header nav { gap: 8px; font-size: .8rem; }.dashboard-main { padding: 22px 14px 50px; }.admin-grid, .form-grid { grid-template-columns: 1fr; }.admin-inline { display: flex; }.user-heading { flex-direction: column; gap: 0; }
  .login-layout { grid-template-columns: 1fr; min-height: 0; max-width: 450px; }
  .login-intro { padding: 28px 32px; }
  .intro-logo { width: 145px; margin-bottom: 0; }
  .login-intro h1 { font-size: 1.25rem; }
  .login-intro p { display: none; }
  .login-card { padding: 32px; }
  .chat-header { min-height: 72px; padding: 8px 14px; }
  .chat-brand { gap: 7px; font-size: .85rem; }
  .chat-brand img { width: 65px; height: 45px; }
  .chat-brand span { padding-inline-start: 8px; }
  .subtle-button { padding: 8px; font-size: .75rem; }
  .messages { padding: 22px 14px; }
  .message { max-width: 92%; }
  .composer-wrap { padding: 10px 12px 16px; }
}
