:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --radius: 12px;
}

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

body {
  font-family: Inter, system-ui, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.admin-login{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  background:var(--bg);
  color:var(--text);
  padding:20px;
}

/* ===== LAYOUT ===== */
.admin-wrapper {
  min-height: 100vh;
}

.admin-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-header h1 {
  font-size: 18px;
  font-weight: 600;
}

.admin-nav{
  display:flex;
  gap:16px;
  align-items:center;
}
.admin-nav a{
  font-size:14px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  padding:6px 10px;
  border-radius:999px;
}
.admin-nav a.active{
  color:#0f172a;
  background:#eff6ff;
}
.admin-nav a:hover{
  color:#0f172a;
}

.container {
  max-width: 1400px;
  margin: 40px auto;
  padding: 0 24px;
}

/* ===== CARD ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 28px;
}

/* ===== LOGIN ===== */
.login-shell{
  width:100%;
  max-width:420px;
  padding:32px 20px 40px;
}
.login-brand{
  display:flex;
  align-items:baseline;
  gap:6px;
  margin-bottom:18px;
  font-size:13px;
  color:#9ca3af;
}
.login-brand .dot{
  width:8px;
  height:8px;
  border-radius:999px;
  background:linear-gradient(135deg,#2563eb,#4f46e5);
}
.login-brand .brand-text{
  font-weight:600;
  color:var(--text);
}
.login-brand .brand-tagline{
  font-size:12px;
}

.login-card {
  background:#ffffff;
  border-radius:16px;
  border:1px solid var(--border);
  box-shadow:0 22px 60px rgba(15,23,42,.18);
  padding:26px 22px 22px;
}

.login-card h2 {
  margin-bottom: 6px;
  font-size:18px;
  color:var(--text);
}

.login-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 18px;
}

input {
  width: 100%;
  padding: 11px 13px;
  margin-bottom: 14px;
  border-radius: 9px;
  border: 1px solid var(--border);
  font-size: 14px;
  background:#ffffff;
  color:var(--text);
}

input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow:0 0 0 1px rgba(37,99,235,.35);
}

button {
  width: 100%;
  padding: 11px;
  border-radius: 999px;
  background: linear-gradient(135deg,#2563eb,#4f46e5);
  color: #fff;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow:0 12px 40px rgba(37,99,235,.7);
}

button:hover{
  filter:brightness(1.06);
}

.login-back{
  margin-top:14px;
  text-align:center;
}
.login-back a{
  font-size:12px;
  color:#9ca3af;
  text-decoration:none;
}
.login-back a:hover{
  color:#e5e7eb;
}

/* ===== TABLE ===== */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  table-layout: auto;
  min-width: 100%;
}

th {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
}

th a {
  display: flex;
  align-items: center;
  gap: 4px;
}

th a:hover {
  color: var(--primary);
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tr:hover {
  background: #f1f5f9;
}

.dashboard-header-row{
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  gap:16px;
  margin-bottom:18px;
}
.dashboard-title-block h2{
  font-size:18px;
  margin-bottom:4px;
}
.dashboard-title-block p{
  font-size:13px;
  color:var(--muted);
}
.dashboard-actions{
  display:flex;
  gap:10px;
}
.dashboard-actions input{
  width:220px;
  margin-bottom:0;
}
.badge-pill{
  display:inline-flex;
  align-items:center;
  padding:4px 10px;
  border-radius:999px;
  font-size:11px;
  background:#eff6ff;
  color:#1d4ed8;
  border:1px solid #bfdbfe;
}
.status-chip{
  display:inline-flex;
  align-items:center;
  padding:3px 8px;
  border-radius:999px;
  font-size:11px;
  font-weight:500;
}
.status-new{
  background:#eef2ff;
  color:#4f46e5;
}
.status-in_progress{
  background:#fffbeb;
  color:#b45309;
}
.status-closed{
  background:#ecfdf3;
  color:#15803d;
}

/* ===== ACTIONS ===== */
.action-buttons {
  display: flex;
  gap: 8px;
}
.btn-view,
.btn-edit,
.btn-delete {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid;
  transition: all 0.15s ease;
  display: inline-block;
}
.btn-view {
  color: #2563eb;
  background: #eff6ff;
  border-color: #bfdbfe;
}
.btn-view:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}
.btn-edit {
  color: #2563eb;
  background: #eff6ff;
  border-color: #bfdbfe;
}
.btn-edit:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}
.btn-delete {
  color: #dc2626;
  background: #fef2f2;
  border-color: #fecaca;
}
.btn-delete:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  z-index: 10000;
  opacity: 0;
  transform: translateY(-20px);
  transition: opacity .3s ease, transform .3s ease;
  pointer-events: none;
  max-width: 400px;
}
.toast-show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.toast-success {
  background: linear-gradient(135deg, #22c55e, #16a34a);
}
.toast-error {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}
.toast-info {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

/* ===== DRAWER ===== */
.drawer {
  position: fixed;
  top: 0;
  right: -500px;
  width: 500px;
  max-width: 90vw;
  height: 100vh;
  background: white;
  box-shadow: -4px 0 24px rgba(0,0,0,.15);
  z-index: 1000;
  transition: right 0.3s ease;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.drawer.active {
  right: 0;
}
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
  display: none;
}
.drawer-overlay.active {
  display: block;
}
.drawer-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: white;
  z-index: 10;
}
.drawer-close-btn {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  outline: none;
}
.drawer-close-btn:hover {
  background: #f1f5f9;
  color: var(--text);
}
.drawer-close-btn:active {
  background: #e2e8f0;
}
.drawer-close-btn:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.drawer-body {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
}
.drawer-field {
  margin-bottom: 18px;
}
.drawer-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}
.drawer-field input,
.drawer-field textarea,
.drawer-field select {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
  font-family: inherit;
}
.drawer-field textarea {
  min-height: 100px;
  resize: vertical;
}
.drawer-actions {
  padding: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  position: sticky;
  bottom: 0;
  background: white;
}
.drawer-btn {
  flex: 1;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: none;
  outline: none;
  text-align: center;
  min-height: 40px;
}
.drawer-btn-primary {
  background: var(--primary);
  color: #fff;
}
.drawer-btn-primary:hover {
  background: var(--accent);
}
.drawer-btn-primary:active {
  background: var(--accent);
  transform: none;
}
.drawer-btn-primary:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.drawer-btn-secondary {
  background: #f1f5f9;
  color: var(--text);
  font-weight: 500;
}
.drawer-btn-secondary:hover {
  background: #e2e8f0;
}
.drawer-btn-secondary:active {
  background: #cbd5e1;
  transform: none;
}
.drawer-btn-secondary:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ===== CHECKBOX STYLES ===== */
.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-wrapper input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.checkbox-wrapper label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  margin: 0;
  line-height: 1.5;
  user-select: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .container {
    padding: 0 20px;
  }
  .dashboard-header-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  .dashboard-actions {
    width: 100%;
  }
  .dashboard-actions form {
    flex-wrap: wrap;
    width: 100%;
  }
  .dashboard-actions input {
    flex: 1;
    min-width: 200px;
  }
  .table-wrapper {
    overflow-x: auto;
  }
  table {
    min-width: 800px;
  }
  .drawer {
    width: 90vw;
    max-width: 500px;
  }
}

@media (max-width: 768px) {
  .admin-header {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 12px;
  }
  .admin-header h1 {
    font-size: 16px;
  }
  .admin-nav {
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }
  .admin-nav a {
    font-size: 12px;
    padding: 4px 8px;
  }
  .container {
    margin: 20px auto;
    padding: 0 16px;
  }
  .card {
    padding: 20px;
  }
  .dashboard-header-row {
    gap: 12px;
  }
  .dashboard-title-block h2 {
    font-size: 16px;
  }
  .dashboard-title-block p {
    font-size: 12px;
  }
  .dashboard-actions {
    width: 100%;
  }
  .dashboard-actions form {
    flex-direction: column;
    width: 100%;
  }
  .dashboard-actions input,
  .dashboard-actions button,
  .dashboard-actions a {
    width: 100%;
  }
  .table-wrapper {
    margin: 0 -16px;
    padding: 0 16px;
    -webkit-overflow-scrolling: touch;
  }
  table {
    font-size: 12px;
    min-width: 700px;
  }
  th, td {
    padding: 10px 8px;
  }
  .action-buttons {
    flex-direction: column;
    gap: 4px;
  }
  .btn-view,
  .btn-edit,
  .btn-delete {
    width: 100%;
    text-align: center;
    font-size: 11px;
    padding: 6px 8px;
  }
  .tabs {
    flex-wrap: wrap;
    gap: 4px;
    overflow-x: auto;
  }
  .tab {
    padding: 8px 12px;
    font-size: 13px;
    white-space: nowrap;
  }
  .field-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
  }
  .field-row.header {
    display: none;
  }
  .field-row > div::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 11px;
    color: var(--muted);
    display: block;
    margin-bottom: 4px;
  }
  .modal-content {
    width: 95%;
    padding: 20px;
    max-height: 85vh;
  }
  .drawer {
    width: 100vw;
    max-width: 100vw;
  }
  .drawer-header {
    padding: 16px;
  }
  .drawer-header h3 {
    font-size: 14px;
  }
  .drawer-body {
    padding: 16px;
  }
  .drawer-actions {
    padding: 16px;
    flex-direction: column;
  }
  .drawer-actions button {
    width: 100%;
  }
  /* Pagination responsive */
  .pagination-wrapper {
    flex-direction: column;
    align-items: flex-start !important;
  }
  .pagination-info {
    font-size: 11px;
    width: 100%;
  }
  .pagination {
    flex-wrap: wrap;
    gap: 4px;
    width: 100%;
  }
  .pagination-btn,
  .pagination-current {
    padding: 4px 8px !important;
    font-size: 11px !important;
  }
  /* Settings form responsive */
  .settings-form-grid {
    grid-template-columns: 1fr !important;
  }
  .settings-form-grid > div:empty {
    display: none;
  }
  .settings-form-grid button[style*="max-width"] {
    max-width: 100% !important;
    width: 100%;
  }
  /* Email settings responsive */
  .drawer-field input,
  .drawer-field textarea,
  .drawer-field select {
    font-size: 13px;
  }
  /* Email settings form */
  form[style*="display:grid"] > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
  form[style*="display:grid"] > div[style*="display:flex"] {
    flex-direction: column;
  }
  form[style*="display:grid"] button[style*="max-width"],
  .settings-submit-btn {
    max-width: 100% !important;
    width: 100%;
  }
  /* Email settings sections */
  form[style*="display:grid"] > div[style*="border"] {
    padding: 16px !important;
  }
}

@media (max-width: 480px) {
  .admin-header {
    padding: 10px 12px;
  }
  .admin-header h1 {
    font-size: 14px;
  }
  .admin-nav {
    width: 100%;
    justify-content: space-between;
  }
  .admin-nav a {
    font-size: 11px;
    padding: 4px 6px;
  }
  .container {
    margin: 16px auto;
    padding: 0 12px;
  }
  .card {
    padding: 16px;
    border-radius: 8px;
  }
  .dashboard-title-block h2 {
    font-size: 15px;
  }
  .dashboard-title-block p {
    font-size: 11px;
  }
  .badge-pill {
    font-size: 10px;
    padding: 3px 8px;
  }
  .table-wrapper {
    margin: 0 -12px;
    padding: 0 12px;
  }
  table {
    min-width: 600px;
    font-size: 11px;
  }
  th, td {
    padding: 8px 6px;
  }
  .status-chip {
    font-size: 10px;
    padding: 2px 6px;
  }
  .tabs {
    border-bottom-width: 1px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .tab {
    padding: 6px 10px;
    font-size: 12px;
    flex-shrink: 0;
  }
  .login-shell {
    padding: 24px 16px 32px;
    max-width: 100%;
  }
  .login-card {
    padding: 20px 18px 18px;
  }
  .login-card h2 {
    font-size: 16px;
  }
  .login-subtitle {
    font-size: 12px;
  }
  input {
    font-size: 13px;
  }
  button {
    font-size: 13px;
  }
  .drawer-header h3 {
    font-size: 14px;
  }
  .drawer-field label {
    font-size: 11px;
  }
  .drawer-field input,
  .drawer-field textarea,
  .drawer-field select {
    font-size: 13px;
    padding: 8px;
  }
  .toast {
    right: 10px;
    left: 10px;
    max-width: none;
    font-size: 13px;
    padding: 12px 16px;
  }
}

/* ===== UTIL ===== */
.error {
  color: #dc2626;
  margin-bottom: 12px;
  font-size: 14px;
}
