:root {
  --primary: #0a4d9c;
  --accent: #00b894;
  --ink: #172033;
  --muted: #64748b;
  --line: #dbe5f0;
  --bg: #f5f8fc;
  --panel: #ffffff;
  --danger: #dc2626;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

a { color: inherit; text-decoration: none; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef6ff, #eefbf7);
}

.login-card {
  width: min(420px, 100%);
  padding: 32px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(10, 77, 156, .12);
}

.login-logo {
  max-width: 160px;
  margin: 0 auto 18px;
}

.login-card h1 {
  margin: 0 0 6px;
  text-align: center;
}

.login-card p {
  margin: 0 0 22px;
  color: var(--muted);
  text-align: center;
}

.login-card label,
.grid-form label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  font: inherit;
  background: #fff;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

select[multiple] {
  min-height: 132px;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 9px 14px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  cursor: pointer;
}

.secondary-button,
.icon-button {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.danger-button {
  background: var(--danger);
}

.success-button {
  background: #15803d;
}

.page-heading,
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-heading {
  margin-bottom: 20px;
}

.page-heading h1,
.dialog-heading h2 {
  margin: 0;
}

dialog.record-dialog {
  width: min(900px, calc(100% - 32px));
  max-height: calc(100vh - 40px);
  padding: 0;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .24);
}

dialog.record-dialog::backdrop {
  background: rgba(15, 23, 42, .55);
}

.dialog-content {
  padding: 22px;
  overflow-y: auto;
}

.dialog-heading {
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.icon-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
  font-size: 22px;
}

.password-field {
  position: relative;
  display: block;
  width: 100%;
}

.password-field input {
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 3px;
  display: inline-grid;
  place-items: center;
  width: 36px !important;
  min-width: 36px !important;
  height: 34px;
  min-height: 34px;
  margin: 0 !important;
  padding: 0;
  transform: translateY(-50%);
  line-height: 1;
  color: #475569;
  background: transparent;
  border: 0;
  border-radius: 4px;
  box-shadow: none;
  z-index: 1;
}

.password-toggle::before {
  content: '';
  width: 17px;
  height: 11px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.password-toggle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.password-toggle.is-visible::before {
  background: #dbeafe;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  color: var(--primary);
  background: #eef6ff;
  outline: none;
}

.inline-form .password-field,
.actions .password-field {
  width: 165px;
}

.table-action {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.login-card button {
  width: 100%;
  margin-top: 18px;
}

.login-help {
  margin-top: 18px;
  padding: 12px;
  font-size: 13px;
  color: var(--muted);
  background: #f8fafc;
  border-radius: 6px;
}

.forgot-link,
.login-back {
  display: block;
  margin-top: 16px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
}

.reset-card {
  width: min(460px, 100%);
}

.reset-card label + label {
  margin-top: 14px;
}

.reset-card .resend-form button {
  margin-top: 10px;
}

.otp-input {
  text-align: center;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 8px;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  color: #fff;
  background: #0b1220;
  overflow-y: auto;
}

.side-logo {
  width: 170px;
  padding: 10px;
  margin-bottom: 18px;
  background: #fff;
  border-radius: 8px;
}

.user-block {
  display: grid;
  gap: 4px;
  padding: 12px;
  margin-bottom: 14px;
  background: rgba(255,255,255,.08);
  border-radius: 8px;
}

.user-block span {
  font-size: 12px;
  color: rgba(255,255,255,.7);
}

.sidebar a {
  display: block;
  padding: 11px 12px;
  margin: 4px 0;
  color: rgba(255,255,255,.82);
  border-radius: 6px;
}

.sidebar a:hover,
.sidebar a.active {
  color: #fff;
  background: rgba(0, 184, 148, .22);
}

.main {
  padding: 28px;
  overflow-x: hidden;
}

h1 {
  margin: 0 0 20px;
  font-size: 30px;
}

h2 {
  margin: 0 0 18px;
  font-size: 19px;
}

.panel {
  margin-bottom: 22px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}

.small-panel {
  max-width: 560px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat {
  padding: 20px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.stat span {
  display: block;
  margin-bottom: 6px;
  font-size: 32px;
  font-weight: 800;
  color: var(--primary);
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.grid-form .wide {
  grid-column: 1 / -1;
}

.grid-form button {
  align-self: end;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

th,
td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  background: #f8fafc;
}

small,
.muted {
  color: var(--muted);
}

.pill {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #e2e8f0;
  color: #334155;
}

.pill.active,
.pill.approved,
.pill.completed,
.pill.closed {
  background: #dcfce7;
  color: #166534;
}

.pill.inactive,
.pill.rejected {
  background: #fee2e2;
  color: #991b1b;
}

.pill.open,
.pill.pending {
  background: #fef3c7;
  color: #92400e;
}

.pill.in_progress,
.pill.planned {
  background: #dbeafe;
  color: #1e40af;
}

.pill.urgent,
.pill.high {
  background: #fee2e2;
  color: #991b1b;
}

.alert {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 6px;
  font-weight: 700;
}

.alert.success {
  color: #166534;
  background: #dcfce7;
}

.alert.error {
  color: #991b1b;
  background: #fee2e2;
}

.actions,
.inline-form,
.button-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.actions form,
.inline-form {
  margin: 0;
}

.actions input,
.inline-form input,
.inline-form select {
  width: auto;
  min-width: 120px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.detail-grid p {
  margin: 0;
  padding: 12px;
  background: #f8fafc;
  border-radius: 6px;
}

.rich-toolbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 7px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
}

.rich-toolbar button {
  min-height: 30px;
  padding: 5px 9px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.rich-editor {
  min-height: 160px;
  padding: 12px;
  font-weight: 400;
  line-height: 1.5;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0 0 6px 6px;
  outline: none;
}

.rich-editor:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(10, 77, 156, .12);
}

.ticket-description {
  max-width: 520px;
  margin-top: 6px;
  color: var(--muted);
}

.ticket-description p {
  margin: 0 0 8px;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .stats,
  .grid-form,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 18px;
  }

  .page-heading {
    align-items: flex-start;
  }
}
