/* =========================
   TuneTunnel Portal Theme v3 (CLEAN + FORM FRIENDLY)
   ========================= */

/* ========== Tokens ========== */
:root{
  --bg0:#f5f7fb;
  --bg1:#eef2f8;

  --card:#ffffff;
  --text:#0b1220;
  --muted:#667085;

  --line:#e5eaf3;
  --line2:#d6deea;

  --brand:#136f3a;
  --brand2:#0f5a2f;

  --shadow1: 0 1px 2px rgba(16,24,40,.06);
  --shadow2: 0 18px 40px rgba(16,24,40,.10);

  --r12:12px;
  --r16:16px;
  --r20:20px;

  --focus: 0 0 0 4px rgba(19,111,58,.14);
}

/* ========== Base ========== */
*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji","Segoe UI Emoji";
  color:var(--text);
  background:
    radial-gradient(900px 500px at 15% 0%, rgba(19,111,58,.12), transparent 55%),
    radial-gradient(800px 500px at 85% 10%, rgba(59,130,246,.10), transparent 55%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a{ color:inherit; }

/* ========== Typography helpers ========== */
h1{
  margin:0;
  font-size: 18px;
  letter-spacing: .2px;
}

h2{
  margin: 0;
  font-size: 15px;
  font-weight: 950;
  letter-spacing: .2px;
}

.muted{
  color: var(--muted);
  font-size: 13px;
}

.centerText{ text-align:center; }

/* ========== Inputs ========== */
input,select,textarea,button{ font: inherit; }

input,select,textarea{
  width:100%;
  border: 1px solid var(--line2);
  background:#fff;
  border-radius: 14px;
  padding: 11px 12px;
  outline: none;
  transition: box-shadow .15s ease, border-color .15s ease, transform .08s ease;
}

input:focus,select:focus,textarea:focus{
  border-color: rgba(19,111,58,.45);
  box-shadow: var(--focus);
}

input[readonly]{
  background: #f8fafc;
  color: #111827;
}

/* Make selects look intentional (still native) */
select{
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #98a2b3 50%),
    linear-gradient(135deg, #98a2b3 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

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

label{
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}

/* Tiny helper under fields */
.help{
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

/* Pre blocks used on licensee address */
.pre{
  margin:0;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12.5px;
  color: #111827;
}

/* Links */
.link{
  color: var(--brand2);
  text-decoration: none;
  font-weight: 900;
}
.link:hover{ text-decoration: underline; }

/* ========== Buttons ========== */
.btn{
  border-radius: 14px;
  border: 1px solid var(--line2);
  background:#fff;
  font-weight: 900;
  cursor:pointer;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  text-decoration: none !important;
  height: 40px;
  padding: 0 14px;
}
.btn:active{ transform: translateY(1px); }

.btn.primary{
  border-color: rgba(19,111,58,.35);
  background: linear-gradient(180deg, rgba(19,111,58,.18), rgba(19,111,58,.10));
}
.btn.primary:hover{
  border-color: rgba(19,111,58,.50);
  background: linear-gradient(180deg, rgba(19,111,58,.22), rgba(19,111,58,.12));
}

.btn.ghost{
  background:#fff;
  border-color: var(--line2);
}
.btn.ghost:hover{ background:#f6f8fd; }

/* ========== Alerts ========== */
.alert{
  border-radius: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background:#fff;
  box-shadow: var(--shadow1);
}
.alert.err{
  background:#fff1f2;
  border-color:#fecdd3;
  color:#9f1239;
}

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

body.auth{ min-height:100vh; }

.authShell{
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.authCard{
  width: min(460px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r20);
  box-shadow: var(--shadow2);
  padding: 22px;
}

.authHeader{ margin-bottom: 14px; }
.authHeader h1{
  margin: 0;
  font-size: 20px;
  font-weight: 950;
  letter-spacing: .2px;
}

/* Auth form helpers */
.form{
  display:flex;
  flex-direction:column;
  gap: 14px;
}

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

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

body.app .shell{
  min-height:100vh;
  display:grid;
  grid-template-columns: 260px 1fr;
}

.sidebar{
  background:#fff;
  border-right: 1px solid var(--line);
  padding: 16px;
  display:flex;
  flex-direction:column;
  gap: 10px;
  position: sticky;
  top: 0;
  height: 100vh;
}

/* Flat brand text */
.brand{
  font-weight: 900;
  font-size: 14px;
  letter-spacing: .3px;
  padding: 6px 2px;
  background: none;
  border: none;
  color: var(--text);
  text-decoration:none;
}

.nav{
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  text-decoration:none;
  display:flex;
  align-items:center;
  gap:10px;
  color:#111827;
}
.nav:hover{
  background:#f3f6fb;
  border-color:#edf1f7;
}
.nav.active{
  background: linear-gradient(180deg, rgba(19,111,58,.16), rgba(19,111,58,.08));
  border-color: rgba(19,111,58,.22);
  color:#0f3a22;
  font-weight: 900;
}

.main{ min-width:0; }

/* =========================
   TOPBAR
   ========================= */

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

.title{
  font-weight: 900;
  font-size: 15px;
  letter-spacing: .2px;
}

.userbox{
  display:flex;
  align-items:center;
  gap: 18px;
  font-size: 13px;
}

/* Split name + balance */
.pill{ display: contents; }

.userbox .name{
  font-weight: 800;
  color: var(--text);
}

.userbox .bal{
  font-weight: 700;
  color: var(--muted);
}

/* Logout subtle */
.topbar .btn.ghost{
  height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
}
.topbar .btn.ghost:hover{
  background: #f6f8fd;
  border-color: var(--line2);
}

/* =========================
   CONTENT + CARDS
   ========================= */

.content{
  padding: 22px;
  width: 100%;
  max-width: none;
}

.card{
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r20);
  padding: 18px;
  box-shadow: var(--shadow2);
}

/* =========================
   TOOLBAR
   ========================= */

.toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 14px;
  width: 100%;
}

.toolbarActions{
  display:flex;
  align-items:center;
  gap: 10px;
}

/* =========================
   ROW
   ========================= */

.row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  flex-wrap: nowrap;
}

.row.stack{
  flex-direction: column;
  align-items: stretch;
}

form.row{ justify-content:flex-start; }
form.row input{ flex: 1 1 auto; min-width: 280px; }

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

.table{
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r16);
  overflow:hidden;
  background:#fff;
  box-shadow: var(--shadow1);
}

.thead,.trow{
  display:grid;
  grid-template-columns: 190px 1fr 1fr 80px 210px;
  gap: 10px;
  padding: 12px 12px;
  align-items:center;
}

.thead{
  background:#f7f9fd;
  color: var(--muted);
  font-size: 12px;
  border-bottom:1px solid var(--line);
  font-weight: 800;
}

.trow{
  border-bottom:1px solid var(--line);
  text-decoration:none !important;
  color: inherit !important;
}
.trow:visited{ color: inherit !important; }
.trow:hover{ background:#f4f8ff; }
.trow:last-child{ border-bottom:0; }
.trow > :first-child{ font-weight: 950; }

.trow > div{
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================
   GRID + KV
   ========================= */

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

.kv{
  border: 1px solid var(--line);
  border-radius: var(--r16);
  padding: 12px;
  background: linear-gradient(180deg, #fff, #fbfdff);
  box-shadow: var(--shadow1);
}

.k{ color: var(--muted); font-size:12px; letter-spacing:.2px; }
.v{ font-weight: 950; margin-top:6px; }

/* =========================
   IFRAME
   ========================= */

iframe.mlc{
  width:100%;
  height: 720px;
  border: 1px solid var(--line);
  border-radius: var(--r16);
  background:#fff;
  box-shadow: var(--shadow1);
}

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

@media (max-width: 980px){
  body.app .shell{ grid-template-columns: 1fr; }
  .sidebar{ display:none; }

  .content{ padding: 16px; }
  .grid{ grid-template-columns: 1fr; }

  .thead,.trow{
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .thead{ display:none; }

  form.row input{ min-width: 0; }
}

/* Keep Licenses controls horizontal even on small widths */
@media (max-width: 720px){
  .toolbar{ flex-direction: column; align-items: stretch; }
  .toolbarActions{ width: 100%; }

  .row{ flex-direction: row; align-items: center; }
  .row.stack{ flex-direction: column; align-items: stretch; }

  .row .btn{ width: auto; }
  form.row input{ min-width: 0; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce){
  *{ transition:none !important; }
}

/* Add these to your styles.css (or replace your overlay section if you already have one) */

.overlay{
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, .38);
  backdrop-filter: blur(8px);
  z-index: 9999;
}

.overlayCard{
  width: min(520px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r20);
  box-shadow: var(--shadow2);
  padding: 18px;
  display:flex;
  flex-direction:column;
  align-items:center;
  text-align:center;
}

.spinner{
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 3px solid rgba(148,163,184,.55);
  border-top-color: rgba(19,111,58,.85);
  animation: spin .9s linear infinite;
  margin-bottom: 10px;
}

@keyframes spin{
  to{ transform: rotate(360deg); }
}


/* =========================
   ROYALTY PAGE (accordion + nested table)
   ========================= */

.royaltiesHead{
  grid-template-columns: 1fr 220px 140px;
}

.royaltiesRow{
  grid-template-columns: 1fr 220px 140px;
  cursor: pointer;
  user-select: none;
}

.right{ text-align: right; }
.small{ font-size: 12px; }

.monthCell{
  display:flex;
  align-items:center;
  gap:10px;
  min-width: 0;
}

/* little chevron */
.chev{
  width: 10px;
  height: 10px;
  display:inline-block;
  border-right: 2px solid #98a2b3;
  border-bottom: 2px solid #98a2b3;
  transform: rotate(-45deg);
  transition: transform .15s ease;
  flex: 0 0 auto;
}

.royaltiesRow.open .chev{
  transform: rotate(45deg);
}

/* accordion panel */
.accPanel{
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfdff, #ffffff);
}

.nestedWrap{
  padding: 12px;
}

.nestedTitle{
  display:flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.nestedTable{
  margin-top: 0;
  border-radius: 14px;
}

/* nested grid */
.nestedHead,
.nestedRow{
  grid-template-columns: 190px 1fr 160px 110px 160px;
}

/* slightly tighter rows inside */
.nestedHead{ font-size: 12px; }
.nestedRow{ padding: 10px 12px; }
.nestedRow:hover{ background:#f4f8ff; }

/* mobile stacking stays consistent with your responsive rules */
@media (max-width: 980px){
  .royaltiesHead, .royaltiesRow,
  .nestedHead, .nestedRow{
    grid-template-columns: 1fr;
  }
  .right{ text-align: left; }
}

.btn.mini{
  height: 32px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 900;
}

/* NOI PAGE */
.noiHead,
.noiRow{
  grid-template-columns: 220px 1fr 140px;
}