:root {
  --canvas: #b9f0f4;
  --canvas-soft: #eaf9fa;
  --surface: #fafcfc;
  --panel: #ffffff;
  --ink: #111923;
  --muted: #68737d;
  --faint: #929ca5;
  --line: #dce6e7;
  --line-strong: #cbdadb;
  --aqua: #21abbe;
  --teal: #1a94a3;
  --accent: #009db4;
  --accent-dark: #087f90;
  --accent-soft: #dcf5f7;
  --danger: #aa4139;
  --warning-soft: #fff1dc;
  --success-soft: #e3f5ef;
  --radius: 12px;
  --shell-radius: 18px;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Aptos", "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; min-width: 320px; min-height: 100dvh; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.brand-lockup { display: grid; width: fit-content; gap: 4px; color: var(--ink); line-height: 1; }
.brand-lockup strong { font-size: 22px; font-weight: 700; letter-spacing: .22em; }
.brand-lockup span { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .52em; text-align: center; }
.overline, .context-label, .sidebar-label { margin: 0; color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: .14em; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
input, select { height: 46px; padding: 0 14px; }
textarea { padding: 12px 14px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #9ba5ad; }
input:focus, select:focus, textarea:focus { border-color: var(--aqua); box-shadow: 0 0 0 3px rgba(33,171,190,.13); }
label { display: grid; gap: 8px; color: #34404a; font-size: 13px; font-weight: 700; }
.form-error { margin: 0; color: var(--danger); font-size: 13px; line-height: 1.45; }

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform .12s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.button:active { transform: translateY(1px); }
.button:focus-visible { outline: 3px solid rgba(33,171,190,.25); outline-offset: 2px; }
.button.primary { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 8px 20px rgba(0,157,180,.14); }
.button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.button.secondary { background: var(--panel); color: var(--ink); border-color: var(--line); box-shadow: none; }
.button.secondary:hover { border-color: var(--aqua); color: var(--teal); }
.button.full { width: 100%; }

/* Login */
.login-shell {
  width: min(1360px, calc(100% - 64px));
  min-height: min(760px, calc(100dvh - 80px));
  margin: 40px auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid rgba(26,148,163,.18);
  border-radius: var(--shell-radius);
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(20,101,111,.14);
}
.login-brand, .login-panel { padding: clamp(48px, 6vw, 88px); }
.login-brand { display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.login-copy { margin: auto 0 0; }
.login-copy h1 { max-width: 580px; margin: 0; font-size: clamp(48px, 5.2vw, 74px); line-height: .98; letter-spacing: -.055em; }
.login-copy p { max-width: 510px; margin: 26px 0 0; color: var(--muted); font-size: 18px; line-height: 1.55; }
.short-link-demo { margin-top: 58px; display: flex; align-items: baseline; color: var(--teal); font-size: clamp(19px, 2vw, 30px); font-weight: 700; letter-spacing: -.035em; }
.short-link-demo strong { color: var(--accent); }
.login-panel { display: grid; align-content: center; gap: 44px; }
.login-heading h2 { margin: 0; font-size: 34px; letter-spacing: -.04em; }
.login-heading p { margin: 9px 0 0; color: var(--muted); font-size: 13px; }
.form-stack { display: grid; gap: 22px; }
.form-stack input { height: 54px; }
.form-stack .button { min-height: 54px; margin-top: 5px; font-size: 14px; }

/* App shell */
.app-shell {
  width: min(1540px, calc(100% - 48px));
  min-height: calc(100dvh - 48px);
  margin: 24px auto;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  overflow: clip;
  border: 1px solid rgba(26,148,163,.18);
  border-radius: var(--shell-radius);
  background: var(--surface);
  box-shadow: 0 22px 65px rgba(20,101,111,.13);
}
.sidebar {
  position: sticky;
  top: 0;
  height: calc(100dvh - 48px);
  min-height: 680px;
  padding: 36px 28px 28px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
}
.sidebar-label { margin-top: 62px; }
.sidebar nav { display: grid; gap: 7px; margin-top: 14px; }
.nav-item {
  position: relative;
  width: 100%;
  min-height: 48px;
  padding: 0 16px 0 43px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #36424c;
  text-align: left;
  font-weight: 700;
  cursor: pointer;
  transition: color .18s ease, background .18s ease;
}
.nav-item::before { content: ""; position: absolute; left: 17px; top: 50%; width: 12px; height: 12px; border: 2px solid #829098; border-radius: 3px; transform: translateY(-50%); }
.nav-item[data-view="links"]::before { border-radius: 50%; }
.nav-item:hover { color: var(--teal); background: #f1f9f9; }
.nav-item:focus { outline: none; }
.nav-item:focus-visible { box-shadow: inset 0 0 0 2px rgba(33,171,190,.42); }
.nav-item.active { color: var(--teal); background: var(--accent-soft); }
.nav-item.active::before { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 3px var(--accent-soft); }
.sidebar-foot { margin-top: auto; padding-top: 22px; display: grid; gap: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.sidebar-foot::before { content: "IN"; width: 38px; height: 38px; display: grid; place-items: center; margin-bottom: 4px; border-radius: 50%; background: var(--accent-soft); color: var(--teal); font-weight: 800; }
.text-button { width: fit-content; padding: 0; border: 0; background: none; color: var(--teal); font-size: 12px; font-weight: 700; cursor: pointer; }
.text-button:focus-visible { outline: 2px solid rgba(33,171,190,.42); outline-offset: 3px; border-radius: 3px; }

.workspace { min-width: 0; background: #f9fbfb; }
.topbar {
  min-height: 102px;
  padding: 22px clamp(24px, 3.2vw, 48px);
  display: grid;
  grid-template-columns: minmax(150px, .55fr) minmax(260px, 1.45fr) auto auto;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(250,252,252,.96);
}
.page-heading h1 { margin: 0; font-size: 27px; letter-spacing: -.04em; }
.global-search { max-width: 560px; width: 100%; }
.global-search input { height: 48px; padding-left: 18px; background: #fff; font-weight: 400; }
.profile-orb { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid #9be2e9; border-radius: 50%; background: var(--accent-soft); color: var(--teal); font-size: 11px; font-weight: 800; }
.menu-button { display: none; }
.content { max-width: 1380px; margin: 0 auto; padding: clamp(28px, 3.2vw, 48px); }
.view-section { display: grid; gap: 22px; }

/* Dashboard */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 5px 18px rgba(39,79,84,.045);
}
.metric-grid article { min-height: 128px; padding: 26px clamp(26px, 3vw, 46px); display: flex; align-items: center; }
.metric-grid article + article { border-left: 1px solid var(--line); }
.metric-grid article::before { content: ""; flex: 0 0 56px; width: 56px; height: 56px; margin-right: 22px; border-radius: 50%; background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(33,171,190,.09); }
.metric-grid article div { display: grid; gap: 5px; }
.metric-grid strong { font-size: clamp(36px, 3.5vw, 52px); line-height: .9; letter-spacing: -.055em; font-variant-numeric: tabular-nums; }
.metric-grid span { color: var(--muted); font-size: 13px; }
.analytics-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(270px, .8fr); gap: 20px; }
.data-panel { padding: 25px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: 0 5px 18px rgba(39,79,84,.045); }
.panel-heading { min-height: 58px; display: flex; justify-content: space-between; align-items: start; gap: 18px; }
.panel-heading h2 { margin: 0; font-size: 17px; letter-spacing: -.025em; }
.panel-heading p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.panel-heading select { width: 132px; height: 38px; padding-inline: 11px; font-size: 12px; }
.bar-chart { height: 270px; padding-top: 28px; display: flex; align-items: end; gap: clamp(3px, .65vw, 9px); border-bottom: 1px solid var(--line); background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 66px, rgba(220,230,231,.75) 67px); }
.bar-column { position: relative; flex: 1; min-width: 3px; height: var(--height); border-radius: 3px 3px 0 0; background: var(--aqua); transition: background .16s ease; }
.bar-column:nth-child(3n) { background: var(--accent); }
.bar-column:hover, .bar-column:focus { background: var(--teal); outline: 0; }
.bar-column span { position: absolute; left: 50%; bottom: calc(100% + 7px); z-index: 2; padding: 5px 7px; border-radius: 6px; background: var(--ink); color: #fff; font-size: 10px; opacity: 0; pointer-events: none; transform: translateX(-50%); white-space: nowrap; }
.bar-column:hover span, .bar-column:focus span { opacity: 1; }
.stat-list { padding-top: 13px; display: grid; gap: 25px; }
.stat-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.stat-row strong { font-size: 13px; }
.stat-row span { color: var(--muted); font-size: 12px; }
.mini-bar { grid-column: 1 / -1; height: 6px; overflow: hidden; border-radius: 6px; background: var(--accent-soft); }
.mini-bar i { display: block; width: var(--width); height: 100%; border-radius: inherit; background: var(--accent); }
.referrer-list { padding-top: 5px; }
.referrer-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; padding: 15px 0; border-bottom: 1px solid #edf2f2; font-size: 13px; }
.referrer-row:last-child { border-bottom: 0; }
.referrer-row span:first-child { overflow: hidden; text-overflow: ellipsis; }
.referrer-row strong { color: var(--teal); font-variant-numeric: tabular-nums; }

/* Links */
.toolbar { display: grid; grid-template-columns: minmax(260px, 1fr) 180px auto; gap: 12px; }
.search-field input { padding-left: 15px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: 0 5px 18px rgba(39,79,84,.045); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 14px 16px; background: #f5fafa; color: var(--muted); font-size: 10px; text-align: left; letter-spacing: .07em; text-transform: uppercase; }
td { padding: 17px 16px; border-top: 1px solid #edf2f2; vertical-align: middle; }
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: #f7fbfb; }
th.numeric, td.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.link-cell { display: grid; gap: 5px; min-width: 190px; }
.short-url { color: var(--teal); font-weight: 700; text-decoration: none; }
.short-url:hover { color: var(--accent); text-decoration: underline; }
.link-title { color: var(--muted); font-size: 12px; }
.destination { display: block; max-width: 360px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.status { display: inline-flex; padding: 6px 9px; border-radius: 7px; background: #edf2f2; color: #59646b; font-size: 10px; font-weight: 800; }
.status.active { background: var(--success-soft); color: #267466; }
.status.paused { background: var(--warning-soft); color: #825b1c; }
.row-actions { display: flex; justify-content: flex-end; gap: 7px; }
.small-button { min-height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); font-size: 11px; font-weight: 700; cursor: pointer; }
.small-button:hover { border-color: var(--aqua); color: var(--teal); }
.loading-state, .empty-state { min-height: 390px; display: grid; place-content: center; justify-items: center; color: var(--muted); text-align: center; }
.empty-state::before { content: ""; width: 74px; height: 74px; margin-bottom: 22px; border-radius: 50%; background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(33,171,190,.12); }
.empty-state h2 { margin: 0; color: var(--ink); font-size: 22px; letter-spacing: -.025em; }
.empty-state p { margin: 10px 0 22px; }

/* Dialog and notifications */
dialog { width: min(620px, calc(100% - 28px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: var(--surface); box-shadow: 0 28px 90px rgba(15,74,81,.22); }
dialog::backdrop { background: rgba(13,56,62,.38); backdrop-filter: blur(4px); }
dialog form { padding: 30px; display: grid; gap: 19px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: start; gap: 20px; }
.dialog-heading h2 { margin: 0; font-size: 27px; letter-spacing: -.04em; }
.close-button { padding: 7px 0; border: 0; background: none; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.form-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.code-note { padding: 13px 14px; display: flex; justify-content: space-between; gap: 18px; border-radius: 9px; background: var(--accent-soft); color: var(--muted); font-size: 12px; }
.code-note strong { color: var(--teal); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 4px; }
.toast { position: fixed; right: 28px; bottom: 28px; z-index: 20; max-width: min(390px, calc(100% - 56px)); padding: 15px 18px; border-radius: var(--radius); background: var(--teal); color: #fff; box-shadow: 0 16px 45px rgba(12,94,105,.24); font-size: 13px; font-weight: 700; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .sidebar { padding-inline: 22px; }
  .topbar { grid-template-columns: minmax(125px, .45fr) minmax(230px, 1.2fr) auto; }
  .profile-orb { display: none; }
  .metric-grid article { padding-inline: 24px; }
  .metric-grid article::before { flex-basis: 44px; width: 44px; height: 44px; margin-right: 15px; }
  th:nth-child(2), td:nth-child(2) { display: none; }
}

@media (max-width: 920px) {
  body { background: var(--surface); }
  .app-shell { width: 100%; min-height: 100dvh; margin: 0; grid-template-columns: 1fr; border: 0; border-radius: 0; box-shadow: none; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 10; width: 250px; height: 100dvh; min-height: 0; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); box-shadow: 20px 0 70px rgba(12,74,81,.18); }
  .topbar { min-height: 88px; grid-template-columns: auto minmax(110px, 1fr) auto; padding: 16px 20px; gap: 14px; }
  .global-search, .profile-orb { display: none; }
  .menu-button { min-height: 36px; display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); font-size: 11px; font-weight: 700; }
  .analytics-grid { grid-template-columns: 1fr; }
  .login-shell { width: min(680px, calc(100% - 32px)); min-height: auto; margin: 24px auto; grid-template-columns: 1fr; }
  .login-brand { min-height: 510px; border-right: 0; border-bottom: 1px solid var(--line); }
}

@media (max-width: 680px) {
  .login-shell { width: 100%; min-height: 100dvh; margin: 0; border: 0; border-radius: 0; box-shadow: none; }
  .login-brand, .login-panel { padding: 34px 22px; }
  .login-brand { min-height: 410px; }
  .login-copy h1 { font-size: 45px; }
  .login-copy p { margin-top: 18px; font-size: 15px; }
  .short-link-demo { margin-top: 34px; font-size: 19px; }
  .login-panel { min-height: 480px; gap: 32px; }
  .topbar { padding-inline: 14px; }
  .page-heading h1 { font-size: 23px; }
  .topbar .button { min-height: 40px; padding-inline: 12px; }
  .content { padding: 22px 14px 36px; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-grid article { min-height: 104px; padding: 19px 22px; }
  .metric-grid article + article { border-top: 1px solid var(--line); border-left: 0; }
  .metric-grid article::before { flex-basis: 46px; width: 46px; height: 46px; }
  .metric-grid strong { font-size: 40px; }
  .data-panel { padding: 20px 17px; }
  .bar-chart { height: 230px; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .toolbar .search-field { grid-column: 1 / -1; }
  th:nth-child(5), td:nth-child(5) { display: none; }
  .form-columns { grid-template-columns: 1fr; }
  dialog form { padding: 23px 18px; }
  .code-note { align-items: start; flex-direction: column; gap: 4px; }
  .toast { right: 16px; bottom: 16px; max-width: calc(100% - 32px); }
}

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