@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500;9..40,600&display=swap');

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

:root {
  --bg:            #f3faf5;
  --surface:       #ffffff;
  --surface-2:     #eaf6ee;
  --border:        #c0ddc8;
  --border-active: #7db890;
  --navy:          #0f2240;
  --navy-mid:      #1a3560;
  --navy-light:    #2a4a7f;
  --mint:          #a8dbb5;
  --mint-light:    #ccefd6;
  --mint-pale:     #e8f8ee;
  --white:         #ffffff;
  --accent:        #0f2240;
  --text:          #0f2240;
  --text-muted:    #4a6b58;
  --text-dim:      #90b09a;
  --text-on-navy:  #ccefd6;
  --status-open-bg:       #d6f0df;
  --status-open-text:     #1a5c35;
  --status-open-border:   #8fcca0;
  --status-ans-bg:        #d6e8f8;
  --status-ans-text:      #0f2e5c;
  --status-ans-border:    #7aaad4;
  --status-closed-bg:     #e8eeea;
  --status-closed-text:   #5a7060;
  --status-closed-border: #b0c8b8;
  --danger:               #c0392b;
  --danger-bg:            #fde8e6;
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(15,34,64,0.06), 0 1px 2px rgba(15,34,64,0.04);
  --shadow:    0 4px 16px rgba(15,34,64,0.08), 0 1px 4px rgba(15,34,64,0.05);
  --shadow-lg: 0 12px 40px rgba(15,34,64,0.12);
  --transition: 160ms ease;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
#app { min-height: 100vh; display: flex; flex-direction: column; }
.page { display: none; flex-direction: column; min-height: 100vh; }
.page.active { display: flex; }

/* ── Login ── */
#login-page {
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 110% 70% at 50% -5%, var(--mint-light) 0%, transparent 60%),
    linear-gradient(170deg, #e0f5e8 0%, var(--bg) 55%);
}

.login-wrap { width: 100%; max-width: 420px; padding: 20px; }

.login-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 44px 40px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.4s ease both;
}

.login-mark {
  width: 46px; height: 46px;
  background: var(--navy);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 22px;
}

.login-mark-inner {
  width: 18px; height: 18px;
  background: var(--mint);
  border-radius: 3px;
  transform: rotate(12deg);
}

.login-title {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--navy);
  margin-bottom: 4px;
  line-height: 1.2;
}

.login-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 36px; }

/* ── Form elements ── */
.form-group { margin-bottom: 18px; }

label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 7px;
  text-transform: uppercase;
}

input[type="text"], input[type="password"], input[type="email"], textarea, select {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  appearance: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--navy-light);
  box-shadow: 0 0 0 3px rgba(42,74,127,0.1);
  background: var(--white);
}

textarea { resize: vertical; min-height: 120px; line-height: 1.6; }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%234a6b58' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 36px;
  cursor: pointer;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px 20px;
  border: 1.5px solid transparent;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.2;
}

.btn-primary {
  background: var(--navy);
  color: var(--mint-light);
  border-color: var(--navy);
  width: 100%;
  justify-content: center;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
}
.btn-primary:hover  { background: var(--navy-mid); border-color: var(--navy-mid); }
.btn-primary:active { background: var(--navy-light); }

.btn-secondary {
  background: var(--white);
  color: var(--navy);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--navy); background: var(--mint-pale); }

.btn-mint {
  background: var(--mint);
  color: var(--navy);
  border-color: var(--mint);
  font-weight: 600;
}
.btn-mint:hover { background: #90ceaa; border-color: #90ceaa; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
  padding: 8px 12px;
}
.btn-ghost:hover { color: var(--navy); background: var(--mint-pale); border-color: var(--border); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--border);
}
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 60px;
  background: var(--navy);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(15,34,64,0.2);
}

.header-logo {
  font-family: var(--font-display);
  font-size: 21px;
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo-mark {
  width: 28px; height: 28px;
  background: var(--mint);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}

.header-logo-mark-inner {
  width: 10px; height: 10px;
  background: var(--navy);
  border-radius: 2px;
  transform: rotate(10deg);
}

.header-right { display: flex; align-items: center; gap: 8px; }

.user-badge {
  font-size: 12px;
  color: var(--mint-light);
  padding: 4px 12px;
  border: 1px solid rgba(168,219,181,0.3);
  border-radius: 99px;
  background: rgba(168,219,181,0.08);
}

.header .btn-ghost { color: rgba(204,239,214,0.8); }
.header .btn-ghost:hover { color: var(--white); background: rgba(255,255,255,0.1); border-color: transparent; }

/* ── Page wrappers ── */
.page-body      { flex: 1; padding: 40px 32px; max-width: 960px;  margin: 0 auto; width: 100%; }
.page-body-wide { flex: 1; padding: 40px 32px; max-width: 1200px; margin: 0 auto; width: 100%; }

/* ── Dashboard ── */
.greeting { font-family: var(--font-display); font-size: 30px; color: var(--navy); margin-bottom: 4px; line-height: 1.2; }
.greeting-sub { color: var(--text-muted); margin-bottom: 36px; font-size: 14px; }

.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 44px; }

.action-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 28px 24px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
  text-align: left;
}
.action-card:hover { border-color: var(--navy); box-shadow: var(--shadow); transform: translateY(-2px); }

.action-card-icon {
  width: 46px; height: 46px;
  background: var(--mint-pale);
  border: 1px solid var(--mint);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: 16px;
}

.action-card-title { font-family: var(--font-display); font-size: 19px; color: var(--navy); margin-bottom: 5px; }
.action-card-desc  { color: var(--text-muted); font-size: 13px; line-height: 1.5; }

/* ── Section headers ── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title  { font-family: var(--font-display); font-size: 19px; color: var(--navy); }
.page-title     { font-family: var(--font-display); font-size: 28px; color: var(--navy); margin-bottom: 4px; line-height: 1.2; }
.page-sub       { color: var(--text-muted); margin-bottom: 32px; font-size: 14px; }

/* ── Ticket table ── */
.ticket-table-wrap {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.ticket-table { width: 100%; border-collapse: collapse; }

.ticket-table thead tr { background: var(--navy); }
.ticket-table thead th {
  text-align: left;
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: rgba(204,239,214,0.75);
}

.ticket-table tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.ticket-table tbody tr:last-child { border-bottom: none; }
.ticket-table tbody tr:hover { background: var(--mint-pale); }
.ticket-table tbody td { padding: 13px 16px; font-size: 13.5px; color: var(--text); }
.ticket-table tbody tr:hover td { color: var(--navy); }

.ticket-id      { font-weight: 600; color: var(--navy-light) !important; font-size: 12.5px !important; }
.ticket-subject { font-weight: 500; }
.ticket-date    { color: var(--text-muted) !important; font-size: 12px !important; }

/* ── Status badges ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid;
}
.status-badge::before { content:''; width:5px; height:5px; border-radius:50%; background:currentColor; }
.status-open     { background:var(--status-open-bg);   color:var(--status-open-text);   border-color:var(--status-open-border); }
.status-answered { background:var(--status-ans-bg);    color:var(--status-ans-text);    border-color:var(--status-ans-border); }
.status-closed   { background:var(--status-closed-bg); color:var(--status-closed-text); border-color:var(--status-closed-border); }

/* ── Ticket detail ── */
.ticket-detail-header {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.ticket-detail-id {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--navy-light);
  text-transform: uppercase;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ticket-detail-title { font-family: var(--font-display); font-size: 24px; color: var(--navy); margin-bottom: 10px; line-height: 1.25; }
.ticket-info-row { display: flex; gap: 20px; font-size: 12.5px; color: var(--text-muted); flex-wrap: wrap; align-items: center; }
.ticket-info-row a { color: var(--navy-light); text-decoration: underline; }

/* ── Messages ── */
.conversation { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }

.message {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  animation: fadeUp 0.2s ease both;
}

.message.team-message {
  background: var(--navy);
  border-color: var(--navy);
  border-left: 4px solid var(--mint);
}

.message.team-message .message-author { color: var(--mint-light); }
.message.team-message .message-time   { color: rgba(200,230,210,0.5); }
.message.team-message .message-body   { color: #dff0e8; }
.message.team-message .team-tag       { background: rgba(168,219,181,0.15); color: var(--mint); border-color: rgba(168,219,181,0.3); }

.message-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.message-author { font-size: 11.5px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: var(--navy); display: flex; align-items: center; gap: 8px; }
.team-tag { font-size: 10px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; background: var(--mint-pale); color: var(--navy-light); padding: 2px 8px; border-radius: 99px; border: 1px solid var(--mint); }
.message-time { font-size: 11.5px; color: var(--text-dim); }
.message-body { color: var(--text); white-space: pre-wrap; line-height: 1.7; font-size: 14px; }

/* ── Reply box ── */
.reply-box {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.reply-box-title { font-size: 11px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 12px; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* ── File upload ── */
.file-label {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text-muted); font-size: 13px;
  transition: all var(--transition);
}
.file-label:hover { border-color: var(--navy-light); color: var(--navy); background: var(--mint-pale); }
.file-input-wrapper input[type="file"] { display: none; }
.file-name { font-size: 12px; color: var(--navy-light); margin-top: 6px; font-weight: 500; }

/* ── Admin tabs ── */
.admin-tabs {
  display: flex; gap: 2px;
  margin-bottom: 28px;
  border-bottom: 2px solid var(--border);
}

.admin-tab {
  padding: 10px 20px;
  background: transparent; border: none;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  cursor: pointer; font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition);
  font-family: var(--font-body);
}
.admin-tab.active { color: var(--navy); border-bottom-color: var(--navy); font-weight: 600; }
.admin-tab:hover:not(.active) { color: var(--navy); }

/* ── Routing rule cards ── */
.rule-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 8px;
  display: grid;
  grid-template-columns: 80px 1fr 1fr 1fr auto;
  gap: 16px;
  align-items: center;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition);
}
.rule-card:hover { border-color: var(--navy-light); }
.rule-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-dim); margin-bottom: 3px; }
.rule-value { font-size: 13px; font-weight: 500; color: var(--navy); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--mint-pale); border: 1px solid var(--mint);
  border-radius: 99px; padding: 2px 10px;
  font-size: 12px; color: var(--navy); font-weight: 500; margin: 2px;
}

.priority-badge {
  display: inline-block;
  font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
  padding: 2px 9px; border-radius: 99px;
}
.priority-1 { background:#fde8d8; color:#a03000; border:1px solid #f5b88a; }
.priority-2 { background:#fff3cc; color:#7a5000; border:1px solid #f0d080; }
.priority-3 { background:var(--mint-pale); color:var(--navy); border:1px solid var(--mint); }

/* ── Modal ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,34,64,0.35); z-index: 200;
  backdrop-filter: blur(3px);
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.25s ease both;
}

.modal-title { font-family: var(--font-display); font-size: 22px; color: var(--navy); margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; margin-top: 24px; }
.modal-actions .btn-primary { flex: 1; }

/* ── Alerts ── */
.alert {
  padding: 12px 16px; margin-bottom: 16px;
  font-size: 13.5px; border-radius: var(--radius-sm);
  animation: fadeUp 0.2s ease both; line-height: 1.5;
}
.alert-error   { background: var(--danger-bg); border: 1px solid rgba(192,57,43,0.25); color: #8b2020; }
.alert-success { background: var(--status-open-bg); border: 1px solid var(--status-open-border); color: var(--status-open-text); }
.alert-info    { background: var(--status-ans-bg); border: 1px solid var(--status-ans-border); color: var(--status-ans-text); }

/* ── Spinner ── */
.spinner {
  display: inline-block; width: 15px; height: 15px;
  border: 2px solid var(--border); border-top-color: var(--navy);
  border-radius: 50%; animation: spin 0.6s linear infinite;
}

.empty-state { text-align: center; padding: 56px 20px; color: var(--text-muted); }
.empty-icon  { font-size: 36px; margin-bottom: 12px; opacity: 0.45; }
.empty-text  { font-size: 14px; }
.divider     { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* ── Animations ── */
@keyframes fadeUp { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
@keyframes spin   { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 640px) {
  .action-row { grid-template-columns: 1fr; }
  .header { padding: 0 16px; }
  .page-body, .page-body-wide { padding: 24px 16px; }
  .login-card { padding: 32px 24px; }
  .rule-card { grid-template-columns: 1fr 1fr; }
}
