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

/* ── Variables ── */
:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --border: #e2e2de;
  --border-strong: #c4c4bf;
  --text: #1a1a18;
  --text-soft: #5c5c56;
  --text-muted: #9a9892;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --btn-bg: #eeede9;
  --btn-border: #d8d8d4;
  --danger: #dc2626;
}

body.dark {
  --bg: #111110;
  --surface: #1c1c1a;
  --border: #2a2a27;
  --border-strong: #3c3c38;
  --text: #e5e0d8;
  --text-soft: #8a8780;
  --text-muted: #5a5853;
  --accent: #4d8ef8;
  --accent-soft: #1a2540;
  --btn-bg: #252523;
  --btn-border: #333330;
  --danger: #f87171;
}

/* ── Base ── */
body,
button,
input,
select,
textarea {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
}

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  transition: background 0.25s, color 0.25s;
}

/* ── Header ── */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 12px;
}

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

.header-left .page-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.role-label {
  font-size: 11px;
  color: var(--text-muted);
}

.datetime {
  font-size: 11px;
  color: var(--text-muted);
}

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

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-soft);
  line-height: 1;
  transition: background 0.15s;
}

.icon-btn:hover {
  background: var(--border);
}

.logout-link,
.back-link {
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 5px 10px;
  border: 1px solid var(--btn-border);
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.logout-link:hover,
.back-link:hover {
  color: var(--text);
  background: var(--btn-bg);
}

/* ── Main layout ── */
.main-content {
  max-width: 740px;
  margin: 20px auto;
  padding: 0 16px 40px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: 12px;
  padding: 18px 20px 20px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

body.dark .card {
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.card-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.sub-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 18px 0 12px;
}

.danger-title {
  display: none;
}

/* ── Fields ── */
.field {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: 0.03em;
}

.inline-field {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.inline-field label {
  white-space: nowrap;
}

.input-group {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ── Inputs ── */
input[type="text"],
input[type="password"] {
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
  flex: 1;
}

input[type="text"]:focus,
input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.1);
}

body.dark input[type="text"],
body.dark input[type="password"] {
  background: #1a1a17;
  border-color: #252521;
}

body.dark input[type="text"]:focus,
body.dark input[type="password"]:focus {
  box-shadow: 0 0 0 2px rgba(77,142,248,0.15);
}

/* ── Password section ── */
.password-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.password-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: 0.03em;
}

.password-field input {
  width: 100% !important;
  flex: none;
}

/* ── Buttons ── */
button,
.btn-primary,
.btn-danger,
.btn-small {
  cursor: pointer;
  border-radius: 7px;
  border: none;
  font-family: inherit;
  font-weight: 600;
  transition: opacity 0.15s, background 0.15s;
}

.btn-primary,
.password-field button {
  background: var(--accent);
  color: #fff;
  padding: 7px 14px;
  font-size: 12px;
  border: none;
  border-radius: 7px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.btn-primary:hover,
.password-field button:hover {
  opacity: 0.88;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  padding: 7px 14px;
  font-size: 12px;
}

.btn-danger:hover {
  opacity: 0.88;
}

.btn-small {
  background: var(--accent);
  color: #fff;
  padding: 6px 12px;
  font-size: 12px;
}

.btn-small:hover {
  opacity: 0.88;
}

/* ── Stats ── */
.total-clicks {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 10px;
}

.stats-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.stats-list li {
  font-size: 12px;
  color: var(--text-soft);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
}

.stats-list li:last-child {
  border-bottom: none;
}

/* ── Login history ── */
#loginHistoryList {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
}

#loginHistoryList li {
  font-size: 11px;
  color: var(--text-muted);
  padding: 3px 0;
}

/* ── Delete account (hidden) ── */
#deleteAccount {
  display: none !important;
}

/* ── Responsive ── */
@media (max-width: 700px) {
  .main-content {
    grid-template-columns: 1fr;
    padding: 0 12px 32px;
  }

  .header {
    flex-wrap: wrap;
    gap: 8px;
  }
}
