:root {
  color-scheme: light;
  --ink: #16211f;
  --muted: #61706c;
  --line: #d9e5e1;
  --surface: #ffffff;
  --canvas: #f3f8f6;
  --primary: #0f6b5c;
  --primary-hover: #0b584c;
  --primary-soft: #d8f2ec;
  --danger: #a32929;
  --danger-soft: #fde8e8;
  --warning: #815200;
  --warning-soft: #fff1d7;
  --shadow: 0 16px 45px rgba(14, 58, 49, .09);
  font-family: Vazirmatn, Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(60, 191, 164, .14), transparent 30rem),
    var(--canvas);
}

button, input { font: inherit; }

button { cursor: pointer; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1240px;
  margin: 0 auto;
  padding: 2rem 1.25rem 1rem;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .25rem; font-size: clamp(1.6rem, 3vw, 2.3rem); }
h2 { margin-bottom: .35rem; font-size: 1.15rem; }

.eyebrow {
  margin-bottom: .35rem;
  color: var(--primary);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.muted { color: var(--muted); font-size: .9rem; }

.layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  max-width: 1240px;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
}

.card {
  padding: 1.35rem;
  border: 1px solid rgba(15, 107, 92, .12);
  border-radius: 1.25rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.subscriptions-card { grid-column: 1 / -1; }

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr .7fr .6fr auto;
  gap: .8rem;
  align-items: end;
}

.form-grid.compact { grid-template-columns: 1fr .7fr auto; }

label {
  display: block;
  margin-bottom: .4rem;
  color: #42504d;
  font-size: .82rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 2.8rem;
  padding: .65rem .8rem;
  border: 1px solid #bdcdc8;
  border-radius: .75rem;
  outline: none;
  background: #fbfdfc;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 107, 92, .13);
}

.primary-button, .secondary-button, .ghost-button, .danger-button {
  min-height: 2.8rem;
  padding: .62rem 1rem;
  border: 0;
  border-radius: .75rem;
  font-weight: 750;
  transition: background .15s ease, transform .15s ease;
}

.primary-button { color: white; background: var(--primary); }
.primary-button:hover { background: var(--primary-hover); }
.secondary-button { color: var(--primary); background: var(--primary-soft); }
.ghost-button { color: var(--primary); background: transparent; border: 1px solid var(--line); }
.danger-button { min-height: 2.2rem; padding: .35rem .7rem; color: var(--danger); background: var(--danger-soft); }
.small-button { min-height: 2.2rem; padding: .35rem .65rem; }
button:active { transform: translateY(1px); }
button:disabled { cursor: wait; opacity: .55; }
.full-width { width: 100%; margin-top: .35rem; }

.form-result { min-height: 1.25rem; margin: .75rem 0 0; color: var(--primary); font-size: .85rem; }
.form-result.error, .error-message { color: var(--danger); }
.error-message:empty { display: none; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: .85rem .75rem; border-bottom: 1px solid #e6eeeb; text-align: right; }
th { color: var(--muted); font-size: .78rem; font-weight: 750; }
td { font-size: .9rem; }
tbody tr:last-child td { border-bottom: 0; }

.username { direction: ltr; text-align: right; font-weight: 750; }
.device-limit-control { display: flex; align-items: center; gap: .4rem; }
.device-limit-control input { width: 4.2rem; min-height: 2.2rem; padding: .3rem .45rem; }
.status {
  display: inline-flex;
  align-items: center;
  padding: .25rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 750;
}
.status.active { color: var(--primary); background: var(--primary-soft); }
.status.expired { color: var(--warning); background: var(--warning-soft); }
.status.revoked { color: var(--danger); background: var(--danger-soft); }

.login-page {
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.login-card {
  width: min(100%, 410px);
  padding: 2rem;
  border: 1px solid rgba(15, 107, 92, .12);
  border-radius: 1.5rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card label { margin-top: 1rem; }
.login-card input { margin-bottom: .65rem; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 3.2rem;
  height: 3.2rem;
  margin-bottom: 1rem;
  border-radius: 1rem;
  color: white;
  background: var(--primary);
  font: 800 1.5rem/1 Arial, sans-serif;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .subscriptions-card { grid-column: auto; }
  .form-grid, .form-grid.compact { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .form-grid, .form-grid.compact { grid-template-columns: 1fr; }
  .card { padding: 1rem; border-radius: 1rem; }
  .topbar { padding-top: 1.25rem; }
}
