/* =========================================================
   LYNKKU PANEL — Clean Minimal UI
   Layout class/logic tetap sama, hanya visual CSS.
   ========================================================= */

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

:root {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-alt: #fafafb;
  --border: #e7e7eb;
  --border-strong: #d7d7dd;

  --text-primary: #17171c;
  --text-muted: #6b6b74;
  --text-dim: #9a9aa3;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;

  --green: #16a34a;
  --green-soft: #eafaf0;
  --blue: #2563eb;
  --blue-soft: #eef4ff;
  --amber: #b45309;
  --amber-soft: #fef6e7;
  --red: #dc2626;
  --red-soft: #fdedec;

  --radius: 10px;
  --radius-lg: 14px;

  --shadow-xs: 0 1px 2px rgba(20, 20, 25, .045);
  --shadow-sm: 0 2px 8px rgba(20, 20, 25, .05);
  --shadow-md: 0 8px 24px rgba(20, 20, 25, .08);
  --shadow-lg: 0 20px 48px rgba(20, 20, 25, .12);

  --ease: cubic-bezier(.2, .7, .3, 1);
}

html, body {
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.55;
  background: var(--bg);
  scrollbar-color: var(--border-strong) transparent;
}

body { position: relative; }

html { scroll-behavior: smooth; }

::selection { background: var(--accent-soft); color: var(--accent); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: #b9b9c2; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color .15s var(--ease);
}
a:hover { color: var(--accent-hover); text-decoration: none; }

@keyframes fadeLift {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes revealUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes shimmerSweep {
  from { background-position: -300px 0; }
  to   { background-position: 300px 0; }
}

@keyframes rippleOut {
  from { transform: scale(0); opacity: .28; }
  to   { transform: scale(2.6); opacity: 0; }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; max-height: 80px; }
  to   { opacity: 0; max-height: 0; margin: 0; padding-top: 0; padding-bottom: 0; }
}

@keyframes progressGrow {
  0%   { width: 0%; opacity: 1; }
  70%  { width: 78%; }
  100% { width: 92%; }
}

@keyframes progressDone {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes barRise {
  from { transform: scaleY(.12); opacity: .55; }
  to   { transform: scaleY(1); opacity: 1; }
}

/* =========================================================
   LAYOUT
   ========================================================= */

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--text-primary);
}

.logo svg {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.sidebar-nav {
  padding: 12px 10px 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.nav-section { margin-bottom: 12px; }

.nav-label {
  padding: 10px 12px 6px;
  font-size: 10px;
  font-weight: 800;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .1em;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0;
  padding: 9px 11px;
  border-radius: 9px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 550;
  text-decoration: none;
  transition: background .15s var(--ease), color .15s var(--ease);
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--surface-alt);
  text-decoration: none;
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
}

.nav-item svg { flex-shrink: 0; }

.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 62px;
  padding: 13px 26px;
  background: rgba(255, 255, 255, .88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.topbar-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.015em;
  color: var(--text-primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  background: var(--accent);
}

.content {
  flex: 1;
  padding: 24px 26px 32px;
}

/* =========================================================
   CARDS & GRIDS
   ========================================================= */

.card {
  position: relative;
  margin-bottom: 16px;
  padding: 20px 22px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  animation: fadeLift .35s var(--ease) both;
  transition: box-shadow .2s var(--ease), border-color .2s var(--ease);
}

.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(174px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  position: relative;
  padding: 18px;
  min-height: 110px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: transform .2s var(--ease), border-color .2s var(--ease), box-shadow .2s var(--ease);
  animation: revealUp .4s var(--ease) both;
}

.stats-grid > .stat-card:nth-child(1) { animation-delay: .02s; }
.stats-grid > .stat-card:nth-child(2) { animation-delay: .06s; }
.stats-grid > .stat-card:nth-child(3) { animation-delay: .1s; }
.stats-grid > .stat-card:nth-child(4) { animation-delay: .14s; }
.stats-grid > .stat-card:nth-child(n+5) { animation-delay: .18s; }

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.stat-label {
  margin-bottom: 8px;
  font-size: 10px;
  font-weight: 800;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .09em;
}

.stat-val {
  font-size: clamp(24px, 4vw, 30px);
  line-height: 1;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -.03em;
}

.stat-sub {
  margin-top: 8px;
  font-size: 12px;
  color: var(--green);
  font-weight: 600;
}

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

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: .09em;
}

.section-title::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
}

.text-muted { color: var(--text-muted) !important; }

/* =========================================================
   TABLES
   ========================================================= */

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.table th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 12px;
  text-align: left;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}

.table td {
  padding: 12px;
  color: var(--text-primary);
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr {
  opacity: 0;
  transform: translateY(4px);
}

.table tbody tr.row-in {
  opacity: 1;
  transform: translateY(0);
  transition: opacity .3s var(--ease), transform .3s var(--ease), background .12s ease;
}

.table tbody tr:hover td { background: var(--surface-alt); }
.table a { font-weight: 700; }

/* =========================================================
   PILLS / BADGES
   ========================================================= */

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 22px;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .01em;
}

.pill.green  { background: var(--green-soft); color: var(--green); }
.pill.blue   { background: var(--blue-soft);  color: var(--blue); }
.pill.amber  { background: var(--amber-soft); color: var(--amber); }
.pill.red    { background: var(--red-soft);   color: var(--red); }

/* =========================================================
   FORMS
   ========================================================= */

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label,
.form-group label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.form-input,
.edit-body textarea {
  width: 100%;
  outline: none;
  color: var(--text-primary);
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}

.form-input {
  padding: 9px 12px;
  min-height: 40px;
  font-size: 13px;
}

.form-input:focus,
.edit-body textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-input::placeholder { color: var(--text-dim); }
select.form-input { cursor: pointer; }

/* =========================================================
   BUTTONS
   ========================================================= */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 8px 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}

.btn:hover {
  color: var(--text-primary);
  text-decoration: none;
  background: var(--surface-alt);
  border-color: var(--border-strong);
}

.btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(20, 20, 25, .1);
  pointer-events: none;
  transform: scale(0);
  animation: rippleOut .5s ease-out forwards;
}

.btn-primary {
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
}

.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary .ripple { background: rgba(255, 255, 255, .35); }

.btn-danger {
  color: var(--red);
  border-color: #f3caca;
  background: var(--red-soft);
}

.btn-danger:hover { background: #fbdede; border-color: #ecb3b3; }

.btn-sm {
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
}

.btn-block { width: 100%; justify-content: center; }

/* =========================================================
   ALERTS
   ========================================================= */

.alert {
  position: relative;
  overflow: hidden;
  padding: 11px 14px 11px 17px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  border: 1px solid;
  font-size: 13px;
  font-weight: 600;
  animation: toastIn .3s var(--ease) both;
}

.alert.leaving { animation: toastOut .32s var(--ease) forwards; }

.alert::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: currentColor;
}

.alert-success { background: var(--green-soft); color: var(--green); border-color: #cdeed9; }
.alert-danger  { background: var(--red-soft);   color: var(--red);   border-color: #f3caca; }
.alert-info    { background: var(--blue-soft);  color: var(--blue);  border-color: #cfe0fb; }

/* =========================================================
   QUICK LINKS
   ========================================================= */

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

.quick-link,
.fm-target {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  text-decoration: none;
  background: var(--surface);
  transition: border-color .15s var(--ease), color .15s var(--ease), background .15s var(--ease);
}

.quick-link {
  min-height: 104px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 16px 12px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  animation: revealUp .4s var(--ease) both;
}

.quick-links > *:nth-child(1) { animation-delay: .02s; }
.quick-links > *:nth-child(2) { animation-delay: .06s; }
.quick-links > *:nth-child(3) { animation-delay: .1s; }
.quick-links > *:nth-child(n+4) { animation-delay: .14s; }

.quick-link:hover,
.fm-target:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.quick-link svg,
.fm-target svg { color: var(--accent); }

.fm-target {
  align-items: center;
  gap: 11px;
  padding: 13px 15px;
  cursor: pointer;
  font-size: 13px;
}

.fm-target.domain { border-left: 3px solid var(--accent); }
.fm-target.subdomain { border-left: 3px solid var(--blue); padding-left: 20px; }

.fm-targets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 13px;
}

.breadcrumb a { color: var(--accent); font-weight: 700; }

.fm-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.file-icon { font-size: 16px; margin-right: 6px; }

/* =========================================================
   MODAL
   ========================================================= */

.edit-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(20, 20, 25, .32);
  backdrop-filter: blur(4px);
}

.edit-modal.open { display: flex; }

.edit-box {
  width: min(90%, 880px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: revealUp .25s var(--ease) both;
}

.edit-header {
  padding: 14px 17px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.edit-body { flex: 1; overflow: auto; padding: 18px; }

.edit-body textarea {
  height: 420px;
  padding: 14px;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Courier New", monospace;
  font-size: 13px;
  resize: vertical;
}

/* =========================================================
   LOGIN PAGE
   ========================================================= */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
  background: var(--bg);
}

.login-box {
  width: 100%;
  max-width: 400px;
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: revealUp .4s var(--ease) both;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 20px;
  color: var(--text-primary);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.login-logo svg {
  width: 28px;
  height: 28px;
  color: var(--accent);
}

.login-box h2 {
  margin-bottom: 22px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
}

.login-box .form-group { margin-bottom: 14px; }
.login-box .btn-block { margin-top: 8px; padding: 11px; min-height: 44px; font-size: 14px; }

.login-footer {
  margin-top: 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: .04em;
}

/* =========================================================
   CHART
   ========================================================= */

.chart-wrap {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 180px;
  padding: 10px 0 2px;
}

.chart-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
}

.chart-bar-label-top,
.chart-bar-label {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

.chart-bar-label-top { color: var(--text-muted); font-weight: 700; }

.chart-bar-outer {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  border-radius: 999px 999px 6px 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  overflow: hidden;
}

.chart-bar-fill {
  width: 100%;
  min-height: 4px;
  border-radius: 999px 999px 6px 6px;
  transform-origin: bottom;
  animation: barRise .6s var(--ease) both;
  background: var(--border-strong);
}

.chart-bar-fill.today { background: var(--accent); }

/* =========================================================
   PREMIUM INTERACTIONS
   ========================================================= */

#topProgressBar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 2.5px;
  z-index: 9999;
  background: var(--accent);
  pointer-events: none;
  transition: opacity .2s ease;
}

#topProgressBar.running { animation: progressGrow 1s var(--ease) forwards; }
#topProgressBar.done { width: 100%; animation: progressDone .25s ease forwards .12s; }

.skeleton {
  position: relative;
  color: transparent !important;
  border-radius: 6px;
  background: linear-gradient(90deg, #eeeef1 25%, #f7f7f9 37%, #eeeef1 63%);
  background-size: 400px 100%;
  animation: shimmerSweep 1.3s ease-in-out infinite;
}

.info-box {
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 2;
}

.info-box p + p {
  padding-top: 9px;
  margin-top: 9px;
  border-top: 1px solid var(--border);
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 980px) {
  .two-col { grid-template-columns: 1fr; }
  .sidebar { width: 220px; }
}

@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-header { padding: 14px 16px; }
  .sidebar-nav { padding: 10px; }
  .nav-section { margin-bottom: 8px; }
  .nav-item { padding: 9px 10px; }
  .topbar { min-height: 58px; padding: 12px 16px; }
  .topbar-title { font-size: 16px; }
  .content { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 16px; }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
  .login-box { padding: 28px 22px; }
}

@media (max-width: 520px) {
  .stats-grid,
  .quick-links,
  .fm-targets { grid-template-columns: 1fr; }
  .topbar-right { gap: 8px; }
  .badge { display: none; }
  .stat-card { min-height: 100px; }
  .fm-toolbar form { width: 100%; }
  .fm-toolbar .form-input { flex: 1; width: 100% !important; }
  .btn { width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}

/* Redeploy row/box toggle (Free Subdomain page) */
.redeploy-row { display: none; }
.redeploy-row.open { display: block; }
.redeploy-row td { background: var(--surface-alt); }
