:root {
  --bg: #f2eef8;
  --surface: #ffffff;
  --ink: #1a1528;
  --muted: #6b6480;
  --line: #ddd4eb;
  --brand: #531a79;
  --brand-2: #2b1e60;
  --brand-soft: rgba(83, 26, 121, 0.1);
  --accent: #f37021;
  --ok: #6f9a3f;
  --shadow: 0 10px 30px rgba(43, 30, 96, 0.1);
  --radius: 14px;
  --font: "Segoe UI", "Trebuchet MS", sans-serif;
  --sidebar-w: 268px;
  --grad-brand: linear-gradient(90deg, #531a79 0%, #3b1b77 48%, #2b1e60 100%);
  --grad-brand-135: linear-gradient(135deg, #6a2a96 0%, #531a79 45%, #2b1e60 100%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(83, 26, 121, 0.14), transparent 42%),
    radial-gradient(circle at bottom left, rgba(43, 30, 96, 0.1), transparent 40%),
    linear-gradient(180deg, #f8f5fc 0%, var(--bg) 100%);
  min-height: 100vh;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

/* —— Sidebar layout —— */
body.has-sidebar {
  display: block;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  z-index: 40;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(#000 0 10px),
    var(--grad-brand);
  background-color: var(--brand-2);
  color: #efe8f8;
  box-shadow: 4px 0 28px rgba(20, 10, 40, 0.22);
  padding: 0 14px 16px;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 22px 10px 18px;
  margin: 0 -14px 14px;
  background: #000;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
  text-decoration: none;
}

.sidebar-brand:hover {
  text-decoration: none;
}

.sidebar-brand img {
  display: block;
  width: min(168px, 100%);
  height: auto;
}

.sidebar-brand span {
  font-size: 0.8rem;
  color: rgba(232, 224, 245, 0.72);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-link {
  display: block;
  padding: 11px 14px;
  border-radius: 10px;
  color: rgba(239, 232, 248, 0.92);
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  text-decoration: none;
}

.sidebar-link.is-active {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  box-shadow: inset 3px 0 0 #f7a600;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-user {
  padding: 8px 14px 4px;
  font-size: 0.85rem;
  color: rgba(239, 232, 248, 0.75);
  font-weight: 600;
}

.sidebar-logout {
  color: rgba(255, 210, 200, 0.95);
}

.sidebar-logout:hover {
  background: rgba(180, 35, 24, 0.28);
  color: #fff;
}

.app-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}

.app-top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 16px 0;
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
}

.app-top .brand {
  flex: 1;
  min-width: 0;
}

.sidebar-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--brand);
  border-radius: 2px;
}

.sidebar-backdrop {
  display: none;
}

body.has-sidebar .wrap {
  padding-top: 16px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

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

.brand strong {
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--brand);
}

.brand span {
  color: var(--muted);
  font-size: 0.92rem;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  margin-bottom: 8px;
}

.login-brand img {
  width: min(220px, 70vw);
  height: auto;
  background: #000;
  border-radius: 16px;
  padding: 16px 20px;
  box-shadow: var(--shadow);
}

.login-brand span {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.85rem;
  font-weight: 600;
}

.badge-user {
  background: rgba(83, 26, 121, 0.16);
  cursor: default;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(83, 26, 121, 0.08), transparent 70%);
}

.panel-head h1,
.panel-head h2 {
  margin: 0 0 4px;
  font-size: 1.25rem;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.panel-body { padding: 22px; }

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

.grid .full { grid-column: 1 / -1; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
}

input[type="text"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

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

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(83, 26, 121, 0.28);
  border-color: var(--brand);
}

.section-title {
  margin: 22px 0 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 0.95rem;
  color: var(--brand);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--grad-brand-135);
  color: #fff;
}

.btn-secondary {
  background: #ebe4f4;
  color: var(--ink);
}

.btn-danger {
  background: #b42318;
  color: #fff;
}

.btn-danger:hover {
  filter: brightness(1.05);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}

/* Modal konfirmasi kustom */
.ui-modal-root {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  z-index: 100000 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.ui-modal-root.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.ui-modal-backdrop {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(15, 28, 42, 0.48);
  backdrop-filter: blur(4px);
}

.ui-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  max-width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 35, 55, 0.22);
  padding: 22px 22px 18px;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.22s ease;
}

.ui-modal-root.is-open .ui-modal-dialog {
  transform: translateY(0) scale(1);
}

.ui-modal-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  font-size: 1.25rem;
  font-weight: 700;
  background: rgba(180, 35, 24, 0.1);
  color: #b42318;
}

.ui-modal-icon.is-info {
  background: rgba(83, 26, 121, 0.1);
  color: var(--brand);
}

.ui-modal-title {
  margin: 0 0 8px;
  font-size: 1.15rem;
  color: var(--ink);
}

.ui-modal-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.95rem;
}

.ui-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.ui-modal-actions .btn {
  min-width: 96px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 140px;
}

.card .code {
  color: var(--muted);
  font-size: 0.8rem;
}

.card h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.card .meta {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
}

.pill-on {
  background: rgba(111, 154, 63, 0.14);
  color: var(--ok);
}

.pill-off {
  background: rgba(91, 107, 124, 0.12);
  color: var(--muted);
}

.sig-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fbfcfd;
}

.sig-wrap canvas {
  display: block;
  width: 100%;
  height: 160px;
  touch-action: none;
  cursor: crosshair;
  background:
    linear-gradient(#fff, #fff),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 8px,
      rgba(83, 26, 121, 0.03) 8px,
      rgba(83, 26, 121, 0.03) 16px
    );
}

.sig-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  background: #f3f6f9;
  font-size: 0.82rem;
  color: var(--muted);
}

.alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(196, 92, 38, 0.1);
  color: #8a3a12;
  border: 1px solid rgba(196, 92, 38, 0.25);
}

.alert-ok {
  background: rgba(31, 122, 76, 0.1);
  color: #145535;
  border-color: rgba(31, 122, 76, 0.25);
}

.approvals details {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #fafcfd;
}

.approvals summary {
  cursor: pointer;
  font-weight: 650;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 14px;
}

.sig-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fafcfd;
}

.sig-block > summary {
  cursor: pointer;
  font-weight: 650;
}

.sig-options {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.sig-upload {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #fff;
}

.sig-upload span { font-weight: 650; }
.sig-upload small { color: var(--muted); font-weight: 400; }
.sig-upload input[type="file"] {
  padding: 0;
  border: 0;
  background: transparent;
}

.sig-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.sig-preview img {
  max-width: 220px;
  max-height: 80px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 6px;
}

.sig-draw {
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}

.sig-draw > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-105%);
    transition: transform 0.22s ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: flex;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(15, 28, 42, 0.45);
    border: 0;
    padding: 0;
    margin: 0;
    cursor: pointer;
  }

  .sidebar-backdrop[hidden] {
    display: none !important;
  }

  .app-main {
    margin-left: 0;
  }

  body.sidebar-open {
    overflow: hidden;
  }
}

@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
}
